0

我想为分段任务训练 VNet。对于一个简单的“入门”示例,我有一个 CT 及其对应的分割图像。

ValueError运行train命令时我得到一个:

$ net_segment -c ~/git/vesseg/learning/config.ini train                                               
WARNING:tensorflow:From /Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Use the retry module or similar alternatives.
NiftyNet version 0.2.2
INFO:niftynet: Import [SegmentationApplication] from /Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/application/segmentation_application.py.
INFO:niftynet: Optional Python module yaml not found, please install yaml and retry if the application fails.
INFO:niftynet: Optional Python module yaml not found, please install yaml and retry if the application fails.
INFO:niftynet: Optional Python module yaml not found, please install yaml and retry if the application fails.
INFO:niftynet: Optional Python module yaml not found, please install yaml and retry if the application fails.
INFO:niftynet: Optional Python module yaml not found, please install yaml and retry if the application fails.
INFO:niftynet: Optional Python module yaml not found, please install yaml and retry if the application fails.
INFO:niftynet: Optional Python module yaml not found, please install yaml and retry if the application fails.
[CUSTOM]
-- num_classes: -1
-- output_prob: False
-- label_normalisation: False
-- min_sampling_ratio: 0
-- compulsory_labels: (0, 1)
-- rand_samples: 0
-- min_numb_labels: 1
-- proba_connect: True
-- weight: ()
-- label: ('LABEL',)
-- sampler: ()
-- image: ('DSA',)
-- name: net_segment
[CONFIG_FILE]
-- path: /Users/fernando/git/vesseg/learning/config.ini
[DSA]
-- csv_file:
-- path_to_search: /Users/fernando/mres_project/learning/vnet
-- filename_contains: None
-- filename_not_contains: ('label',)
-- interp_order: 3
-- pixdim: ()
-- axcodes: ()
-- spatial_window_size: (32, 32, 32)
[LABEL]
-- csv_file:
-- path_to_search: /Users/fernando/mres_project/learning/vnet
-- filename_contains: ('_label',)
-- filename_not_contains: ()
-- interp_order: 0
-- pixdim: ()
-- axcodes: ()
-- spatial_window_size: (32, 32, 32)
[SYSTEM]
-- cuda_devices:
-- num_threads: 2
-- num_gpus: 1
-- model_dir: /Users/fernando/mres_project/model_dir
-- dataset_split_file: ./dataset_split.csv
-- action: train
[NETWORK]
-- name: vnet
-- activation_function: relu
-- batch_size: 2
-- decay: 0
-- reg_type: L2
-- volume_padding_size: (0, 0, 0)
-- window_sampling: uniform
-- queue_length: 5
-- multimod_foreground_type: and
-- histogram_ref_file:
-- norm_type: percentile
-- cutoff: (0.01, 0.99)
-- foreground_type: otsu_plus
-- normalisation: False
-- whitening: True
-- normalise_foreground_only: False
-- weight_initializer: he_normal
-- bias_initializer: zeros
[TRAINING]
-- optimiser: adam
-- sample_per_volume: 1
-- rotation_angle: (-10.0, 10.0)
-- rotation_angle_x: ()
-- rotation_angle_y: ()
-- rotation_angle_z: ()
-- scaling_percentage: (0.8, 1.2)
-- random_flipping_axes: (0, 1, 2)
-- lr: 0.01
-- loss_type: Dice
-- starting_iter: 0
-- save_every_n: 500
-- tensorboard_every_n: 20
-- max_iter: 10000
-- max_checkpoints: 100
-- validation_every_n: -1
-- validation_max_iter: 1
-- exclude_fraction_for_validation: 0.0
-- exclude_fraction_for_inference: 0.0
INFO:niftynet: Import [SegmentationApplication] from /Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/application/segmentation_application.py.
INFO:niftynet: starting segmentation application
INFO:niftynet: [DSA] search file folders, writing csv file /Users/fernando/mres_project/model_dir/DSA.csv
INFO:niftynet: [LABEL] search file folders, writing csv file /Users/fernando/mres_project/model_dir/LABEL.csv
INFO:niftynet:

Number of subjects 1, input section names: ['subject_id', 'DSA', 'LABEL']
-- using all subjects (without data partitioning).

INFO:niftynet: Image reader: loading [label] from ('LABEL',) (1)
INFO:niftynet: Image reader: loading [image] from ('DSA',) (1)
INFO:niftynet: reading size of preprocessed images
INFO:niftynet: initialised window instance
INFO:niftynet: buffering with 5 windows
INFO:niftynet: initialised sampler output {'label': (32, 32, 32, 1, 1), 'image': (32, 32, 32, 1, 1)}
2018-04-30 14:23:40.717301: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
INFO:niftynet: Starting preprocessing threads...
INFO:niftynet: New thread: 0
INFO:niftynet: New thread: 1
INFO:niftynet: Filling queues (this can take a few minutes)
INFO:niftynet: Import [VNet] from /Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/network/vnet.py.
INFO:niftynet: Import [HeNormal] from /Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/engine/application_initializer.py.
INFO:niftynet: Import [Zeros] from /Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/engine/application_initializer.py.
INFO:niftynet: using VNet
[Layer] VNet/L1 (input undecided) [Trainable] conv_0/w, downsample/w, downsample/b (6128)
[Layer] VNet/L2 (input undecided) [Trainable] conv_0/w, conv_1/w, downsample/w, downsample/b (272448)
[Layer] VNet/L3 (input undecided) [Trainable] conv_0/w, conv_1/w, conv_2/w, downsample/w, downsample/b (1601664)
[Layer] VNet/L4 (input undecided) [Trainable] conv_0/w, conv_1/w, conv_2/w, downsample/w, downsample/b (6406400)
[Layer] VNet/V_ (input undecided) [Trainable] conv_0/w, conv_1/w, conv_2/w, upsample/w, upsample/b (25100544)
[Layer] VNet/R4 (input undecided) [Trainable] conv_0/w, conv_1/w, conv_2/w, upsample/w, upsample/b (28934272)
[Layer] VNet/R3 (input undecided) [Trainable] conv_0/w, conv_1/w, conv_2/w, upsample/w, upsample/b (7233600)
[Layer] VNet/R2 (input undecided) [Trainable] conv_0/w, conv_1/w, upsample/w, upsample/b (1296416)
Traceback (most recent call last):
  File "/Users/fernando/anaconda/envs/nn/bin/net_segment", line 11, in <module>
    sys.exit(main())
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/__init__.py", line 115, in main
    app_driver.run_application()
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/engine/application_driver.py", line 241, in run_application
    self.graph = self._create_graph(self.graph)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/engine/application_driver.py", line 309, in _create_graph
    self.gradients_collector)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/application/segmentation_application.py", line 266, in connect_data_and_network
    net_out = self.net(image, is_training=self.is_training)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/layer/base_layer.py", line 34, in __call__
    return self._op(*args, **kwargs)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/template.py", line 455, in __call__
    result = self._call_func(args, kwargs)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/template.py", line 406, in _call_func
    result = self._func(*args, **kwargs)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/network/vnet.py", line 121, in layer_op
    name='R1')(concat_r1, up_1)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/layer/base_layer.py", line 34, in __call__
    return self._op(*args, **kwargs)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/template.py", line 455, in __call__
    result = self._call_func(args, kwargs)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/template.py", line 406, in _call_func
    result = self._func(*args, **kwargs)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/network/vnet.py", line 186, in layer_op
    kernel_size=1, with_bias=True)(res_flow)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/layer/base_layer.py", line 34, in __call__
    return self._op(*args, **kwargs)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/template.py", line 455, in __call__
    result = self._call_func(args, kwargs)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/template.py", line 406, in _call_func
    result = self._func(*args, **kwargs)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/layer/convolution.py", line 83, in layer_op
    regularizer=self.regularizers['w'])
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 1297, in get_variable
    constraint=constraint)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 1093, in get_variable
    constraint=constraint)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 439, in get_variable
    constraint=constraint)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 408, in _true_getter
    use_resource=use_resource, constraint=constraint)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 735, in _get_single_variable
    shape = tensor_shape.as_shape(shape)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/framework/tensor_shape.py", line 860, in as_shape
    return TensorShape(shape)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/framework/tensor_shape.py", line 458, in __init__
    self._dims = [as_dimension(d) for d in dims_iter]
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/framework/tensor_shape.py", line 458, in <listcomp>
    self._dims = [as_dimension(d) for d in dims_iter]
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/framework/tensor_shape.py", line 399, in as_dimension
    return Dimension(value)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/framework/tensor_shape.py", line 39, in __init__
    raise ValueError("Dimension %d must be >= 0" % self._value)
ValueError: Dimension -1 must be >= 0

originally defined at:
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/layer/convolution.py", line 50, in __init__
    super(ConvLayer, self).__init__(name=name)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/layer/base_layer.py", line 58, in __init__
    super(TrainableLayer, self).__init__(name=name)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/layer/base_layer.py", line 26, in __init__
    self._op = tf.make_template(name, self.layer_op, create_scope_now_=True)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/template.py", line 153, in make_template
    **kwargs)


originally defined at:
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/network/vnet.py", line 141, in __init__
    super(VNetBlock, self).__init__(name=name)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/layer/base_layer.py", line 58, in __init__
    super(TrainableLayer, self).__init__(name=name)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/layer/base_layer.py", line 26, in __init__
    self._op = tf.make_template(name, self.layer_op, create_scope_now_=True)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/template.py", line 153, in make_template
    **kwargs)


originally defined at:
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/engine/application_driver.py", line 295, in _create_graph
    self.app.initialise_network()
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/application/segmentation_application.py", line 235, in initialise_network
    acti_func=self.net_param.activation_function)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/network/vnet.py", line 39, in __init__
    name=name)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/network/base_net.py", line 21, in __init__
    super(BaseNet, self).__init__(name=name)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/layer/base_layer.py", line 58, in __init__
    super(TrainableLayer, self).__init__(name=name)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/niftynet/layer/base_layer.py", line 26, in __init__
    self._op = tf.make_template(name, self.layer_op, create_scope_now_=True)
  File "/Users/fernando/anaconda/envs/nn/lib/python3.6/site-packages/tensorflow/python/ops/template.py", line 153, in make_template
    **kwargs)

这是我的config.ini

[DSA]
path_to_search = /Users/fernando/mres_project/learning/vnet
filename_not_contains = label
spatial_window_size = (32, 32, 32)
interp_order = 3

[LABEL]
path_to_search = /Users/fernando/mres_project/learning/vnet
filename_contains = _label
spatial_window_size = (32, 32, 32)
interp_order = 0

[SYSTEM]
model_dir = /Users/fernando/mres_project/model_dir

[NETWORK]
name = vnet
whitening = True

[TRAINING]
loss_type = Dice
rotation_angle = -10.0,10.0
scaling_percentage = 0.8,1.2
random_flipping_axes = 0,1,2

[SEGMENTATION]
image = DSA
label = LABEL
4

1 回答 1

0

我添加num_classes = 2到我的[SEGMENTATION]部分,config.ini错误现在消失了。

于 2018-04-30T16:56:24.400 回答