当我尝试在Jupyter Notebook中运行NiftyNet Promise12演示的推理部分时,我收到以下错误。
AttributeError Traceback (most recent call last)
<ipython-input-3-f9444ce4ad73> in <module>()
3 import niftynet
4 sys.argv=['', 'inference','-a','net_segment','--conf',os.path.join('demos','PROMISE12','promise12_demo_inference_config.ini')]
----> 5 niftynet.main()
~/BI/NN/NiftyNet/niftynet/__init__.py in main()
118 app_driver = ApplicationDriver()
119 app_driver.initialise_application(system_param, input_data_param)
--> 120 app_driver.run_application()
121 return 0
~/BI/NN/NiftyNet/niftynet/engine/application_driver.py in run_application(self)
254 # start samplers' threads
255 self._run_sampler_threads(session=session)
--> 256 self.graph = self._create_graph(self.graph)
257
258 # check app variables initialised and ready for starts
~/BI/NN/NiftyNet/niftynet/engine/application_driver.py in _create_graph(self, graph)
330 self.app.connect_data_and_network(
331 self.outputs_collector,
--> 332 self.gradients_collector)
333 if self.is_training:
334 # batch norm statistics from the last device
~/BI/NN/NiftyNet/niftynet/application/segmentation_application.py in connect_data_and_network(self, outputs_collector, gradients_collector)
288 grads = self.optimiser.compute_gradients(loss)
289 # collecting gradients variables
--> 290 gradients_collector.add_to_collection([grads])
291 # collecting output variables
292 outputs_collector.add_to_collection(
AttributeError: 'NoneType' object has no attribute 'add_to_collection'
我目前正在使用Python 3.4和Tensorflow 1.4.1。我该如何解决这个问题?
答案 0 :(得分:0)
在笔记本中调用niftynet.main()
后,应用程序状态未正确清除。在每个niftynet.main()
之后重新启动内核可以避免此问题。它也在最新版本的NiftyNet中修复。谢谢!