Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ask an question- ''NoneType' object has no attribute 'pred'' #1

Open
zwvivid opened this issue Mar 9, 2018 · 0 comments
Open

ask an question- ''NoneType' object has no attribute 'pred'' #1

zwvivid opened this issue Mar 9, 2018 · 0 comments

Comments

@zwvivid
Copy link

zwvivid commented Mar 9, 2018

Hi, when I implament the idea "Input Gradient Regularization" , I meet a problem that ''NoneType' object has no attribute 'pred'' . I think it is because of double backpropagation. Do you konw how to solve this problem? Thank you very much!

my code is simplified as follows:
.......
image_batch = tf.placeholder(tf.float32, (None, IMG_W, IMG_H,IMG_D), name='image_batch')
label_batch = tf.placeholder(tf.int32, (None,), name='label_batch')
y_conv = model(image_batch)
cross = loss(y_conv ,label_batch)
grads = tf.gradients(cross,image_batch )
input_loss = tf.nn.l2_loss(grads[0])
optimizer = tf.train.MomentumOptimizer(learning_rate = learning_rate,momentum=0.9)
train_op = optimizer.minimize(loss)
....
_ = sess.run(train_op,feed_dict={image_batch:train_batch1,label_batch:train_label_batch1})

ERROR:
train_op = optimizer.minimize(loss)
File "/share/apps/python/lib/python2.7/site-packages/tensorflow/python/training/optimizer.py", line 315, in minimize
grad_loss=grad_loss)
File "/share/apps/python/lib/python2.7/site-packages/tensorflow/python/training/optimizer.py", line 386, in compute_gradients
colocate_gradients_with_ops=colocate_gradients_with_ops)
File "/share/apps/python/lib/python2.7/site-packages/tensorflow/python/ops/gradients_impl.py", line 551, in gradients
out_grads[i] = control_flow_ops.ZerosLikeOutsideLoop(op, i)
File "/share/apps/python/lib/python2.7/site-packages/tensorflow/python/ops/control_flow_ops.py", line 1305, in ZerosLikeOutsideLoop
pred = op_ctxt.pred
AttributeError: 'NoneType' object has no attribute 'pred'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant