def weight_variable(shape,o):
initial = tf.truncated_normal(shape,stddev=0.1)
u = tf.Variable(initial)
tf.add_to_collection("losses", tf.contrib.layers.l2_regularizer(o)(u))
return u
def bias_variable(shape,o):
initial = tf.constant(0.1,shape=shape)
v = tf.Variable(initial)
tf.add_to_collection("losses", tf.contrib.layers.l2_regularizer(o)(v))
return v
tf.add_to_collection("losses",cross_entropy)
loss = tf.add_n(tf.get_collection("losses"))
train_step = tf.train.AdamOptimizer(1e-4).minimize(loss)
这会发生错误以及add_n()形状错误的原因