我的职责是:
elif loss == 'rmse,gl':
weightss=tf.trainable_variables()
reg=tf.contrib.layers.apply_regularization(groupl1,weightss)
loss = tf.sqrt(tf.reduce_mean(tf.square(tf.subtract(x_, decoded)))
)+reg*0.0001
当我把它放在我的代码中时:
Traceback (most recent call last):
File "L1_02.py", line 45, in <module>
train_X_=model.fit_transform(train_X)
File "/home/hjson/tmp/BRCA/libsdae/stacked_autoencoder.py", line 93, in fit_transform
self.fit(x)
File "/home/hjson/tmp/BRCA/libsdae/stacked_autoencoder.py", line 70, in fit
print_step=self.print_step, lambda_=self.lambda_)
File "/home/hjson/tmp/BRCA/libsdae/stacked_autoencoder.py", line 138, in run
reg=tf.contrib.layers.apply_regularization(groupl1,weightss)
NameError: global name 'groupl1' is not defined
它不能处理错误:
{{1}}
我很困惑,因为我在代码中清楚地说明了groupl1功能。 我的问题在这里是什么?
答案 0 :(得分:0)
猜猜你在调用之前定义你的功能?
def groupl1(x):
return ...
.
.
.
groupl1(example_input)