简体   繁体   English

Keras: TypeError: __call__() 得到了一个意外的关键字参数“name”

[英]Keras: TypeError: __call__() got an unexpected keyword argument 'name'

I am attempting to get DeepCell to work with keras.我试图让 DeepCell 与 keras 一起工作。 I'm running keras 2, but I added in the UID code from keras 1 to let DeepCell run.我正在运行 keras 2,但我添加了来自 keras 1 的 UID 代码以让 DeepCell 运行。 other than that I just downloaded the dependencies and software files, and I'm getting the following error.除此之外,我刚刚下载了依赖项和软件文件,但出现以下错误。

Traceback:追溯:

  Traceback (most recent call last):
  File "/home/birtwistlelab/DeepCell/keras_version/running_template.py",line 65, in <module>
cytoplasm_predictions = run_models_on_directory(data_location,cyto_channel_names, cyto_location, model_fn = cyto_fn,list_of_weights = list_of_cyto_weights, image_size_x = image_size_x, image_size_y = image_size_y,win_x = win_cyto, win_y = win_cyto, std = False, split = False)
 File "/home/birtwistlelab/DeepCell/keras_version/cnn_functions.py", line 1491, in run_models_on_directory
model = model_fn(batch_input_shape = batch_input_shape, n_features = n_features, weights_path = list_of_weights[0])
File "/home/birtwistlelab/DeepCell/keras_version/model_zoo.py", line 528, in sparse_bn_feature_net_61x61
model.add(sparse_Convolution2D(64, 3, 3, d = d, init = init,  batch_input_shape = batch_input_shape, border_mode='valid', W_regularizer = l2(reg)))
File "/home/birtwistlelab/miniconda2/lib/python2.7/site-packages/keras/models.py", line 436, in add
layer(x)
File "/home/birtwistlelab/miniconda2/lib/python2.7/site-packages/keras/engine/topology.py", line 569, in __call__
self.build(input_shapes[0])
File "/home/birtwistlelab/DeepCell/keras_version/cnn_functions.py", line 1012, in build
self.W = self.init(self.W_shape, name='{}_W'.format(self.name))
TypeError: __call__() got an unexpected keyword argument 'name'

Code I am trying to run:我正在尝试运行的代码:

"""
Load data
"""
direc_name = "/home/birtwistlelab/DeepCell/validation_data/HeLa/"
data_location = os.path.join(direc_name, 'RawImages')
cyto_location = os.path.join(direc_name, 'Cytoplasm')
nuclear_location = os.path.join(direc_name, 'Nuclear')
mask_location = os.path.join(direc_name, 'Masks')

cyto_channel_names = ['phase','farred']
nuclear_channel_names = ['farred']

trained_network_cyto_directory = "/home/birtwistlelab/DeepCell/trained_networks/HeLa/"
trained_network_nuclear_directory = "/home/birtwistlelab/DeepCell/trained_networks/Nuclear/"

cyto_prefix = "2017-06-21_HeLa_all_61x61_bn_feature_net_61x61_"
nuclear_prefix = "2016-07-12_nuclei_all_61x61_bn_feature_net_61x61_"

win_cyto = 30
win_nuclear = 30

image_size_x, image_size_y = get_image_sizes(data_location, nuclear_channel_names)
image_size_x /= 2
image_size_y /= 2

"""
Define model
"""

list_of_cyto_weights = []
for j in xrange(5):
    cyto_weights = os.path.join(trained_network_cyto_directory,  cyto_prefix + str(j) + ".h5")
    list_of_cyto_weights += [cyto_weights]

list_of_nuclear_weights = []
for j in xrange(5):
    nuclear_weights = os.path.join(trained_network_nuclear_directory,  nuclear_prefix + str(j) + ".h5")
    list_of_nuclear_weights += [nuclear_weights]

 print list_of_nuclear_weights

 """
 Run model on directory
 """

 cytoplasm_predictions = run_models_on_directory(data_location, cyto_channel_names, cyto_location, model_fn = cyto_fn,list_of_weights = list_of_cyto_weights, image_size_x = image_size_x, image_size_y = image_size_y,win_x = win_cyto, win_y = win_cyto, std = False, split = False)

nuclear_predictions = run_models_on_directory(data_location, nuclear_channel_names, nuclear_location, model_fn = nuclear_fn,list_of_weights = list_of_nuclear_weights, image_size_x = image_size_x, image_size_y = image_size_y,win_x = win_nuclear, win_y = win_nuclear, std = False, split = False)



"""
Refine segmentation with active contours
"""

    nuclear_masks = segment_nuclei(nuclear_predictions, mask_location = mask_location, threshold = 0.75, area_threshold = 100, solidity_threshold = 0.75, eccentricity_threshold = 0.95)
cytoplasm_masks = segment_cytoplasm(cytoplasm_predictions, nuclear_masks = nuclear_masks, mask_location = mask_location, smoothing = 1, num_iters = 120)


"""
Compute validation metrics (optional)
"""
direc_val = os.path.join(direc_name, 'Validation')
imglist_val = nikon_getfiles(direc_val, 'validation_interior')
val_name = os.path.join(direc_val, imglist_val[0]) 
print val_name
val = get_image(val_name)
val = val[win_cyto:-win_cyto,win_cyto:-win_cyto]
cyto = cytoplasm_masks[0,win_cyto:-win_cyto,win_cyto:-win_cyto]
nuc = nuclear_masks[0,win_cyto:-win_cyto,win_cyto:-win_cyto]
print val.shape, cyto.shape, nuc.shape
dice_jaccard_indices(cyto, val, nuc)

I'm using the https://covertlab.github.io/DeepCell/starting/ guide.我正在使用https://covertlab.github.io/DeepCell/starting/指南。 I've think it probably has something to due with the versions of the dependencies, as most of the other problems I was having were, but I'm not entirely sure.我认为这可能与依赖项的版本有关,因为我遇到的大多数其他问题都是,但我不完全确定。 Any help would be greatly appreciated, is any other information is needed to help, let me know.任何帮助将不胜感激,是否需要任何其他信息来帮助,让我知道。

DeepCell (at least this version,) is not fully compatible with Keras 2 . DeepCell (至少这个版本)与Keras 2不完全兼容

So, in Keras 2 the initializers headers were (drastically) changed, and DeepCell code doesn't reflect that.因此,在Keras 2 中,初始值设定项标头已(彻底)更改,而DeepCell代码并未反映这一点。 In order to fix your error, either:为了修复您的错误,请执行以下任一操作:

  • Switch to Keras 1切换到Keras 1
  • Modify DeepCell code to be Keras 2 compatible.修改DeepCell代码以兼容Keras 2 But I seriously doubt that cnn_functions.py:1012 would be the only place to modify但我严重怀疑cnn_functions.py:1012将是唯一需要修改的地方

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:__call__() 为参数“名称”获取了多个值 - TypeError: __call__() got multiple values for argument 'name' 类型错误:Planet() 有一个意外的关键字参数“名称” - TypeError: Planet() got an unexpected keyword argument 'name' Python TypeError: got an unexpected keyword argument 'name' - Python TypeError: got an unexpected keyword argument 'name' TypeError:得到了意外的关键字参数“ name” - TypeError: got an unexpected keyword argument “name” / Accept() 处的 TypeError 得到了意外的关键字参数“名称” - TypeError at / Accept() got an unexpected keyword argument 'name' Keras TypeError:valuate_generator()得到了意外的关键字参数“ steps” - Keras TypeError: evaluate_generator() got an unexpected keyword argument 'steps' TypeError:得到一个意外的关键字参数 - TypeError: got an unexpected keyword argument TypeError:call()获得了意外的关键字参数“ input_shape” - TypeError: call() got an unexpected keyword argument 'input_shape' TypeError:url()得到一个意外的关键字参数&#39;name_space&#39; - TypeError: url() got an unexpected keyword argument 'name_space' 类型错误:__init__() 得到了意外的关键字参数“名称”-CONVOKIT - TypeError: __init__() got an unexpected keyword argument 'name' - CONVOKIT
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM