【发布时间】:2018-07-09 18:21:50
【问题描述】:
我正在尝试在演示部分运行示例./quick_scripts/celebA_superres.sh "./images/182659.jpg"。我是 python 新手并收到以下错误:
AttributeError: 'AdamOptimizer' 对象没有属性 '_beta1_power'
据我所知,一个名为“AdamOptimizer”的对象的实例不知道如何处理这种类型的变量。代码如下:
def get_opt_reinit_op(opt, var_list, global_step):
opt_slots = [opt.get_slot(var, name) for name in opt.get_slot_names() for var in var_list]
if isinstance(opt, tf.train.AdamOptimizer):
opt_slots.extend([opt._beta1_power, opt._beta2_power]) #pylint: disable = W0212
all_opt_variables = opt_slots + var_list + [global_step]
opt_reinit_op = tf.variables_initializer(all_opt_variables)
return opt_reinit_op
opt_slots.extend([opt._beta1_power, opt._beta2_power]) #pylint: disable = W0212 行产生错误的位置。
我没有看到“AdamOptimizer”。我猜它隐藏在opt?我该如何调试这样的事情?这种调试有没有好的做法?
我应该提到我使用 2to3 将代码转换为 python3。这有什么重要的吗?
附加完整的回溯:
Traceback(最近一次调用最后一次): 文件“./src/compressed_sensing.py”,第 177 行,在 主要(HPARAMS) 文件“./src/compressed_sensing.py”,第 21 行,在 main 估计器 = utils.get_estimators(hparams) 文件“/home/erezsh/Projects/CSGM/csgm3/src/utils.py”,第 98 行,在 get_estimators estimators = {model_type: get_estimator(hparams, model_type) for model_type in hparams.model_types} 文件“/home/erezsh/Projects/CSGM/csgm3/src/utils.py”,第 98 行,在 estimators = {model_type: get_estimator(hparams, model_type) for model_type in hparams.model_types} 文件“/home/erezsh/Projects/CSGM/csgm3/src/utils.py”,第 91 行,在 get_estimator 中 估计器 = celebA_estimators.dcgan_estimator(hparams) 文件“/home/erezsh/Projects/CSGM/csgm3/src/celebA_estimators.py”,第 185 行,位于 >dcgan_estimator opt_reinit_op = utils.get_opt_reinit_op(opt, var_list, global_step) 文件“/home/erezsh/Projects/CSGM/csgm3/src/utils.py”,第 545 行,在 >get_opt_reinit_op opt_slots.extend([opt._beta1_power, opt._beta2_power]) #pylint: disable = >W0212 AttributeError:“AdamOptimizer”对象没有属性“_beta1_power”
【问题讨论】:
-
你能把所有的traceback都放上去吗?
-
如果较新的版本不让它们公开可用,那么它将无法工作。
标签: python debugging tensorflow