tensorflow-gradient

Tensorflow - No gradients provided for any variable

混江龙づ霸主 提交于 2019-12-11 14:23:45
问题 I am experimenting some code on Jupyter and keep getting stuck here. Things work actually fine if I remove the line starting with "optimizer = ..." and all references to this line. But if I put this line in the code, it gives an error. I am not pasting all other functions here to keep the size of the code at a readable level. I hope someone more experienced can see it at once what is the problem here. Note that there are 5, 4, 3, and 2 units in input layer, in 2 hidden layers, and in output

Updating a tensor in tensorflow

情到浓时终转凉″ 提交于 2019-12-11 08:39:49
问题 I have defined an unsupervised problem in tensorflow, I need to update my B and my tfZ with every iteration, but I don't know how to update my tfZ using the tensorflow session. tfY = tf.placeholder(shape=(15, 15), dtype=tf.float32) with tf.variable_scope('test'): B = tf.Variable(tf.zeros([])) tfZ = tf.convert_to_tensor(Z, dtype=tf.float32) def loss(tfY): r = tf.reduce_sum(tfZ*tfZ, 1) r = tf.reshape(r, [-1, 1]) D = tf.sqrt(r - 2*tf.matmul(tfZ, tf.transpose(tfZ)) + tf.transpose(r) + 1e-9)