ValueError: Variable generator/Conv/weights/Adam/ does not exist, or was not created with...

錯誤:

多GPU設置時出現如下錯誤:ValueError: Variable E_conv0/w/Adam/ does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?

原因:

代碼中有tf.get_variable_scope().reuse_variables(),但卻缺少上下文管理的APItf.varibale_scope().

解決方法:

在設置GPU的位置添加如下命令:with tf.variable_scope(tf.get_variable_scope()) as scope:

with tf.variable_scope(tf.get_variable_scope()) as scope:
    for i in range(args.num_gpus):
        with tf.device('gpu:%d' % i):
            with tf.name_scope("%s_%d" % ('Tower', i)):
            ...
            tf.get_variable_scope().reuse_variables()

參考:https://blog.csdn.net/u012436149/article/details/73555017

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章