赞
踩
Ubuntu 18.04.2 LTS
Nvidia GeForce RTX2080super CUDA Version 10.0
tensorflow-gpu 1.13.1
keras 2.2.4-tf
诸如此类:
- TypeError: _init_subclassed_network() got an unexpected keyword argument 'input'
-
- TypeError: forward() got an unexpected keyword argument 'input'
-
- TypeError: Decoder() got an unexpected keyword argument 'input'
-
- TypeError: xxxxxx() got an unexpected keyword argument 'input'
本人是在运行Unet时出现的此问题:
- Traceback (most recent call last):
- File "unet.py", line 185, in <module>
- myunet.train()
- File "unet.py", line 164, in train
- model = self.get_unet()
- File "unet.py", line 154, in get_unet
- model = Model(input = inputs, output = conv10)
- File "/home/xxx/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 121, in __init__
- super(Model, self).__init__(*args, **kwargs)
- File "/home/xxx/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py", line 84, in __init__
- self._init_subclassed_network(**kwargs)
- File "/home/xxx/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/checkpointable/base.py", line 442, in _method_wrapper
- method(self, *args, **kwargs)
- TypeError: _init_subclassed_network() got an unexpected keyword argument 'input'
查看自己环境中keras对应版本的函数调用方法,得知是版本不同造成的。
- #旧版本中代码:
- from keras.models import Model
- model = Model(input = inputs, output = conv10)
-
- #新版本中代码:
- from tensorflow.python.keras.models import Model
- model = Model(inputs = inputs, outputs = conv10)
-
- #出现UserWarning不用理会
同理, Decoder(inputs=out_sents_, encoder_hidden=en_hidden, encoder_outputs=en_output)函数报错也是一样的原因。
- results = Decoder(inputs=out_sents_, encoder_hidden=en_hidden, encoder_outputs=en_output)
- #修改如下
- results = Decoder(out_sents_, en_hidden)
方案一:"input"修改为"inputs","output"修改为"outputs"。
- model = Model(input = inputs, output = conv10)
- #修改如下,参数根据自己的需要调整
- model = Model(inputs = inputs, outputs = conv10)
方案二:删除"input"/"output"参数名即可。
- model = Model(input = inputs, output = conv10)
- #修改如下,参数根据自己的需要调整
- model = Model(inputs, conv10)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。