0
スローします。Tensorflowのapply_gradientsは、私はエラーを取得エラー
def x1_x2_diff_net_v0():
x = tf.placeholder(tf.float32, [None, 4])
lb = tf.placeholder(tf.float32, [None, 2])
#First fc layer
with tf.variable_scope('fc1') as scope:
w = tfu.get_weights([4,100], name='fc1_w')
b = tfu.get_bias([1,100], name='fc1_b')
fc1 = tf.nn.relu(tf.matmul(x, w) + b)
#Prediction layer
with tf.variable_scope('pred') as scope:
w = tfu.get_weights([100,2], name='pred_w')
b = tfu.get_bias([1, 2], name='pred_b')
pred = tf.nn.relu(tf.matmul(fc1, w) + b)
#Define the loss
loss = tf.nn.l2_loss(pred - lb, name='loss')
return loss
def train(stepNum, initLr=0.01):
g = tf.Graph()
with g.as_default():
loss = x1_x2_diff_net_v0()
lr = tf.train.exponential_decay(initLr, stepNum, 100,
0.1, staircase=True)
for tv in tf.trainable_variables():
print (tv.name)
# Compute gradients.
opt = tf.train.GradientDescentOptimizer(lr)
grads = opt.compute_gradients(loss)
# Apply gradients.
apply_gradient_op = opt.apply_gradients(grads, global_step=stepNum)
何か問題が発生している可能性がありますか?私はコードcifar10.py
の例のコードからの抜粋を取った。