NifTK / NiftyNet

[unmaintained] An open-source convolutional neural networks platform for research in medical image analysis and image-guided therapy
http://niftynet.io
Apache License 2.0
1.36k stars 403 forks source link

custom optimization #426

Open poorneshwaran opened 5 years ago

poorneshwaran commented 5 years ago

I'm using dense_vnet for segment ct data. Its working fine. But , I need to customize optimization, loss function and activation function. I got error like no object takes no parameters for optimization. I used AdaBound optim in engine and call get instance & return without tf.train.[optim].

ericspod commented 5 years ago

We're need more information than this to see where the issue is. Do you have a log output? Is an actual exception being raised somewhere we have a trace for? Do you have the ini file you used?

poorneshwaran commented 5 years ago

And I tried to solve above error, new error as appear.

Traceback (most recent call last): File "net_segment.py", line 13, in sys.exit(main()) File "/home/poornesh/my-projects/new-Nifty/niftynet/init.py", line 147, in main app_driver.run(app_driver.app) File "/home/poornesh/my-projects/new-Nifty/niftynet/engine/application_driver.py", line 188, in run is_training_action=self.is_training_action) File "/home/poornesh/my-projects/new-Nifty/niftynet/engine/application_driver.py", line 269, in create_graph outputs_collector, gradients_collector) File "/home/poornesh/my-projects/new-Nifty/niftynet/application/segmentation_application.py", line 364, in connect_data_and_network loss, var_list=to_optimise, colocate_gradients_with_ops=True) TypeError: compute_gradients() missing 1 required positional argument: 'loss'

training_nifty_log:

INFO:niftynet:2019-08-08 14:11:05,840: starting segmentation application INFO:niftynet:2019-08-08 14:11:05,840: csv_file = not found, writing to "/home/poornesh/my-projects/new-Nifty/models/naso-Gtv-selubound/naso-Gtv.csv" instead. INFO:niftynet:2019-08-08 14:11:05,841: Overwriting existing: "/home/poornesh/my-projects/new-Nifty/models/naso-Gtv-selubound/naso-Gtv.csv". INFO:niftynet:2019-08-08 14:11:05,841: [naso-Gtv] search file folders, writing csv file /home/poornesh/my-projects/new-Nifty/models/naso-Gtv-selubound/naso-Gtv.csv INFO:niftynet:2019-08-08 14:11:05,847: csv_file = not found, writing to "/home/poornesh/my-projects/new-Nifty/models/naso-Gtv-selubound/label.csv" instead. INFO:niftynet:2019-08-08 14:11:05,847: Overwriting existing: "/home/poornesh/my-projects/new-Nifty/models/naso-Gtv-selubound/label.csv". INFO:niftynet:2019-08-08 14:11:05,847: [label] search file folders, writing csv file /home/poornesh/my-projects/new-Nifty/models/naso-Gtv-selubound/label.csv INFO:niftynet:2019-08-08 14:11:05,852:

Number of subjects 50, input section names: ['subject_id', 'naso-Gtv', 'label'] -- using all subjects (without data partitioning).

WARNING:niftynet:2019-08-08 14:11:05,854: From /home/poornesh/my-projects/new-Nifty/niftynet/layer/base_layer.py:26: The name tf.make_template is deprecated. Please use tf.compat.v1.make_template instead.

WARNING:niftynet:2019-08-08 14:11:05,856: From /home/poornesh/my-projects/new-Nifty/niftynet/io/image_loader.py:107: The name tf.logging.debug is deprecated. Please use tf.compat.v1.logging.debug instead.

INFO:niftynet:2019-08-08 14:11:06,020: Image reader: loading 50 subjects from sections ('naso-Gtv',) as input [image] INFO:niftynet:2019-08-08 14:11:06,020: Image reader: loading 50 subjects from sections ('label',) as input [label] INFO:niftynet:2019-08-08 14:11:06,024: reading size of preprocessed images INFO:niftynet:2019-08-08 14:11:06,028: initialised resize sampler {'image': (1, 152, 144, 144, 1, 1), 'image_location': (1, 7), 'label': (1, 152, 144, 144, 1, 1), 'label_location': (1, 7)} INFO:niftynet:2019-08-08 14:11:06,031: using DenseVNet INFO:niftynet:2019-08-08 14:11:06,034: Initialising Dataset from 50 subjects... WARNING:niftynet:2019-08-08 14:11:06,357: niftyreg_image_resampling is not installed; falling back onto niftynet.layer.resampler.ResamplerLayer. To allow fast resampling, please see installation instructions in niftynet/contrib/niftyreg_image_resampling/README.md

WARNING:niftynet:2019-08-08 14:11:08,032: From /home/poornesh/my-projects/new-Nifty/niftynet/layer/linear_resize.py:60: The name tf.image.resize_bilinear is deprecated. Please use tf.compat.v1.image.resize_bilinear instead.

WARNING:niftynet:2019-08-08 14:11:08,595: niftyreg_image_resampling is not installed; falling back onto niftynet.layer.resampler.ResamplerLayer. To allow fast resampling, please see installation instructions in niftynet/contrib/niftyreg_image_resampling/README.md

WARNING:niftynet:2019-08-08 14:11:08,741: From /home/poornesh/my-projects/new-Nifty/niftynet/engine/AdaBound.py:10: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.

CRITICAL:niftynet:2019-08-08 14:11:08,741: ModuleNotFoundError("No module named 'dense_vnet_abdominal_ct'",) CRITICAL:niftynet:2019-08-08 14:11:08,741: segmentation loss: Could not import object"dice" from "dense_vnet_abdominal_ct.dice_hinge" INFO:niftynet:2019-08-08 14:12:25,742: starting segmentation application INFO:niftynet:2019-08-08 14:12:25,743: csv_file = not found, writing to "/home/poornesh/my-projects/new-Nifty/models/naso-Gtv-selubound/naso-Gtv.csv" instead. INFO:niftynet:2019-08-08 14:12:25,743: Overwriting existing: "/home/poornesh/my-projects/new-Nifty/models/naso-Gtv-selubound/naso-Gtv.csv". INFO:niftynet:2019-08-08 14:12:25,743: [naso-Gtv] search file folders, writing csv file /home/poornesh/my-projects/new-Nifty/models/naso-Gtv-selubound/naso-Gtv.csv INFO:niftynet:2019-08-08 14:12:25,749: csv_file = not found, writing to "/home/poornesh/my-projects/new-Nifty/models/naso-Gtv-selubound/label.csv" instead. INFO:niftynet:2019-08-08 14:12:25,749: Overwriting existing: "/home/poornesh/my-projects/new-Nifty/models/naso-Gtv-selubound/label.csv". INFO:niftynet:2019-08-08 14:12:25,749: [label] search file folders, writing csv file /home/poornesh/my-projects/new-Nifty/models/naso-Gtv-selubound/label.csv INFO:niftynet:2019-08-08 14:12:25,755:

Number of subjects 50, input section names: ['subject_id', 'naso-Gtv', 'label'] -- using all subjects (without data partitioning).

WARNING:niftynet:2019-08-08 14:12:25,757: From /home/poornesh/my-projects/new-Nifty/niftynet/layer/base_layer.py:26: The name tf.make_template is deprecated. Please use tf.compat.v1.make_template instead.

WARNING:niftynet:2019-08-08 14:12:25,760: From /home/poornesh/my-projects/new-Nifty/niftynet/io/image_loader.py:107: The name tf.logging.debug is deprecated. Please use tf.compat.v1.logging.debug instead.

INFO:niftynet:2019-08-08 14:12:25,923: Image reader: loading 50 subjects from sections ('naso-Gtv',) as input [image] INFO:niftynet:2019-08-08 14:12:25,923: Image reader: loading 50 subjects from sections ('label',) as input [label] INFO:niftynet:2019-08-08 14:12:25,927: reading size of preprocessed images INFO:niftynet:2019-08-08 14:12:25,931: initialised resize sampler {'image': (1, 152, 144, 144, 1, 1), 'image_location': (1, 7), 'label': (1, 152, 144, 144, 1, 1), 'label_location': (1, 7)} INFO:niftynet:2019-08-08 14:12:25,934: using DenseVNet INFO:niftynet:2019-08-08 14:12:25,937: Initialising Dataset from 50 subjects... WARNING:niftynet:2019-08-08 14:12:26,260: niftyreg_image_resampling is not installed; falling back onto niftynet.layer.resampler.ResamplerLayer. To allow fast resampling, please see installation instructions in niftynet/contrib/niftyreg_image_resampling/README.md

WARNING:niftynet:2019-08-08 14:12:27,937: From /home/poornesh/my-projects/new-Nifty/niftynet/layer/linear_resize.py:60: The name tf.image.resize_bilinear is deprecated. Please use tf.compat.v1.image.resize_bilinear instead.

WARNING:niftynet:2019-08-08 14:12:28,506: niftyreg_image_resampling is not installed; falling back onto niftynet.layer.resampler.ResamplerLayer. To allow fast resampling, please see installation instructions in niftynet/contrib/niftyreg_image_resampling/README.md

WARNING:niftynet:2019-08-08 14:12:28,651: From /home/poornesh/my-projects/new-Nifty/niftynet/engine/AdaBound.py:10: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.

INFO:niftynet:2019-08-08 14:12:28,652: Import [dice] from /home/poornesh/niftynet/extensions/dense_vnet_abdominal_ct/dice_hinge.py.