tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [64] rhs shape= [32]

问题

INFO:tensorflow:Restoring parameters from /tmp/mnist_convnet_model\model.ckpt-1619
2018-04-10 16:02:17.996575: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key conv___1/bias not found in checkpoint
2018-04-10 16:02:17.999870: W c:\l\tensorflow_1501918863922\work\tensorflow-1.2.1\tensorflow\core\framework\op_kernel.cc:1158] Not found: Key conv___1/kernel not found in checkpoint
Traceback (most recent call last):
  File "E:\anaconda\envs\py36\lib\site-packages\tensorflow\python\client\session.py", line 1139, in _do_call
    return fn(*args)
  File "E:\anaconda\envs\py36\lib\site-packages\tensorflow\python\client\session.py", line 1121, in _run_fn
    status, run_metadata)
  File "E:\anaconda\envs\py36\lib\contextlib.py", line 88, in __exit__
    next(self.gen)
  File "E:\anaconda\envs\py36\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
    pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [64] rhs shape= [32]
         [[Node: save/Assign = Assign[T=DT_FLOAT, _class=["loc:@conv2d/bias"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/cpu:0"](conv2d/bias, save/RestoreV2)]]

解决过程

  1. google和百度,查看到INVALIDARGUMENTERROR (SEE ABOVE FOR TRACEBACK): ASSIGN REQUIRES SHAPES OF BOTH TENSORS TO MATCH. LHS SHAPE= [2048,38] RHS SHAPE= [2048,2]
    中提到

    做tensorflow object detection 中,清空下checkpoint就可以啦

  2. 于是我看到自己的报错信息中有一句Restoring parameters from /tmp/mnist_convnet_model\model.ckpt-1619,说明程序是在读取参数时出错的。尝试删除这些.ckpt-1619后缀的文件,并且不要设置model_dir之类的变量即可。

你可能感兴趣的:(tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [64] rhs shape= [32])