ValueError:变量d_h0_conv / w / Adam /不存在,或者未使用tf.get_variable()创建。你的意思是在VarScope中设置reuse = None吗?

时间:2017-07-27 15:42:50

标签: python python-3.x tensorflow

我使用文字到图片代码,有错误。我做了以下但仍有问题。请帮助我。非常感谢你。

with tf.variable_scope(tf.get_variable_scope(), reuse=False):
    d_optim = tf.train.AdamOptimizer(args.learning_rate, beta1 = args.beta1).minimize(loss['d_loss'], var_list=variables['d_vars'])
    g_optim = tf.train.AdamOptimizer(args.learning_rate, beta1 = args.beta1).minimize(loss['g_loss'], var_list=variables['g_vars'])

错误:

Traceback (most recent call last):
      File "train.py", line 243, in <module>
        main()
      File "train.py", line 83, in main
        d_optim = tf.train.AdamOptimizer(args.learning_rate, beta1 = args.beta1).minimize(loss['d_loss'], var_list=variables['d_vars'])
      File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 325, in minimize
        name=name)
      File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 446, in apply_gradients
        self._create_slots([_get_variable_for(v) for v in var_list])
      File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\training\adam.py", line 128, in _create_slots
        self._zeros_slot(v, "m", self._name)
      File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\training\optimizer.py", line 766, in _zeros_slot
        named_slots[_var_key(var)] = slot_creator.create_zeros_slot(var, op_name)
      File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 174, in create_zeros_slot
        colocate_with_primary=colocate_with_primary)
      File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 146, in create_slot_with_initializer
        dtype)
      File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\training\slot_creator.py", line 66, in _create_slot_var
        validate_shape=validate_shape)
      File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 1065, in get_variable
        use_resource=use_resource, custom_getter=custom_getter)
      File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 962, in get_variable
        use_resource=use_resource, custom_getter=custom_getter)
      File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 367, in get_variable
        validate_shape=validate_shape, use_resource=use_resource)
      File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 352, in _true_getter
        use_resource=use_resource)
      File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\ops\variable_scope.py", line 682, in _get_single_variable
        "VarScope?" % name)
    ValueError: Variable d_h0_conv/w/Adam/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?

0 个答案:

没有答案