我正在研究Alex Gordan的Attention_ocr项目。 我遵循指南并根据Alex的answer以FSNS格式存储我的数据。
但是,当我运行命令时: python train.py --dataset_name = rctw
发生错误,错误消息显示如下:
Caused by op u'save/Assign_175', defined at:
File "train.py", line 209, in <module>
app.run()
File "/usr/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 44, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "train.py", line 205, in main
train(total_loss, init_fn, hparams)
File "train.py", line 153, in train
init_fn=init_fn)
File "/usr/lib/python2.7/site-packages/tensorflow/contrib/slim/python/slim/learning.py", line 688, in train
saver = saver or tf_saver.Saver()
File "/usr/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1040, in __init__
self.build()
File "/usr/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1070, in build
restore_sequentially=self._restore_sequentially)
File "/usr/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 675, in build
restore_sequentially, reshape)
File "/usr/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 414, in _AddRestoreOps
assign_ops.append(saveable.restore(tensors, shapes))
File "/usr/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 155, in restore
self.op.get_shape().is_fully_defined())
File "/usr/lib/python2.7/site-packages/tensorflow/python/ops/gen_state_ops.py", line 47, in assign
use_locking=use_locking, name=name)
File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op
op_def=op_def)
File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2327, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1226, in __init__
self._traceback = _extract_stack()
InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [3794,3506] rhs shape= [422,134]
[[Node: save/Assign_175 = Assign[T=DT_FLOAT, _class=["loc:@AttentionOcr_v1/sequence_logit_fn/SQLR/LSTM/attention_decoder/weights"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/gpu:0"](AttentionOcr_v1/sequence_logit_fn/SQLR/LSTM/attention_decoder/weights/Momentum, save/RestoreV2_175/_15)]]
[[Node: save/RestoreV2_141/_168 = _Send[T=DT_FLOAT, client_terminated=false, recv_device="/job:localhost/replica:0/task:0/gpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=1, tensor_name="edge_715_save/RestoreV2_141", _device="/job:localhost/replica:0/task:0/cpu:0"](save/RestoreV2_141)]]
由于我使用python / datasets / fsns.py作为示例来创建我的rctw.py,并将其作为fsns包含在datasets / init.py中,为什么会出现此错误?也许你的项目中有一些硬编码,所以他们总是称之为“134 charset”
希望作者或任何其他人的回应。
答案 0 :(得分:0)
代码使用存储在我的tmp路径中的预训练模型,我清理/ tmp来解决它。