Open vkgpt11 opened 6 years ago
I don't see anything immediately wrong with the portion of the code you posted.
I came across similar error. My fault was that I created 1-D array instead of scalar
Error code
w = tf.get_variable('w', shape=(1, 1), initializer=tf.constant_initializer(0.0))
which should be
w = tf.get_variable('w', shape=[], initializer=tf.constant_initializer(0.0))
def huber_loss(labels, predictions, delta=1.0): residual = tf.abs(labels - predictions) def f1(): return 0.5 tf.square(residual) def f2(): return delta residual - 0.5 * tf.square(delta) return tf.cond(residual < delta, f1, f2)
Step 4: predict Y (number of theft) from the number of fire
Y_predicted = w X X + X * u + b
Step 5: Profit!
loss = huber_loss(Y, Y_predicted)
optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.001).minimize(loss)
I am getting Error "Shape must be rank 0 but is rank 1 for 'cond_4/Switch' (op: 'Switch') with input shapes: [190], [190]." on step no 5