我正在尝试使用 NiftyNet 和我自己的数据(CT 图像及其相应的标签)来训练网络。在使用类似的样本数据、我能找到的所有 NiftyNet 文档以及调整我自己的数据的参数之后不久,我设计了 Net 类。但我不断收到此错误:
“TypeError:init()得到了一个意外的关键字参数'w_initializer'”。
我已经尝试了我在 config.ini、Net 类等中能想到的所有更改。但我无法使其工作,也无法找到原因。任何人都可以帮助解决这个错误吗?或者,也许可以分享一些指导方针,从一开始就训练我自己的网络,这样我至少可以尝试从零开始一个替代方案,看看我是否找到了出路?
训练命令:
! net_segment train -c /home/niftynet/extensions/dense_vnet_TC/config.ini --name dense_vnet_TC.net_TC.MyNet
config.ini 中的一些值:
[NETWORK]
name = dense_vnet
batch_size = 6
volume_padding_size = 0
window_sampling = resize
[TRAINING]
sample_per_volume = 1
lr = 0.001
loss_type = dense_vnet_TC.dice_hinge.dice
starting_iter = 0
save_every_n = 1000
max_iter = 3001
[INFERENCE]
border = (0, 0, 0)
inference_iter = 3000
output_interp_order = 0
spatial_window_size = (512, 512, 40)
save_seg_dir = ./segmentation_output/
############################ Custom configuration
[SEGMENTATION]
image = ct
label = label
label_normalisation = False
output_prob = False
num_classes = 2
网课基础:
from niftynet.network.base_net import BaseNet
class MyNet(BaseNet):
def __init__(self, num_classes, name='MyNet'):
super(MyNet, self).__init__(num_classes=num_classes, acti_func=acti_func, name=name)
# network specific property
self.hidden_features = 10
def layer_op(self, images, is_training):
# create layer instances
conv_1 = ConvolutionalLayer(self.hidden_features, kernel_size=3, name='conv_input')
conv_2 = ConvolutionalLayer(self.num_classes, kernel_size=1, acti_func=None, name='conv_output')
# apply layer instances
flow = conv_1(images, is_training)
flow = conv_2(flow, is_training)
return flow
输出结束,按预期进行一些处理后:
回溯(最后一次调用):文件
“/home/niftynet/bin/net_segment”,第 10 行,在
sys.exit(main()) 文件“/home/niftynet/lib/python3.6/site-packages/niftynet / init .py”,
第 142 行,在主
app_driver.run(app_driver.app) 文件“/home/niftynet/lib/python3.6/site-packages/niftynet/engine/application_driver.py”,
第 189 行,运行中
is_training_action=self.is_training_action) 文件“/home/niftynet/lib/python3.6/site-packages/niftynet/engine/application_driver.py”,
第 258 行,在 create_graph
application.initialise_network() 文件“/home/niftynet/lib /python3.6/site-packages/niftynet/application/segmentation_application.py",
第 280 行,在 initialise_network
acti_func=self.net_param.activation_function) TypeError: init () got an unexpected keyword argument 'w_initializer'