layer_1 = tf.nn.relu(tf.add(tf.matmul(x, w_1), b_1))
layer_1_b = tf.layers.batch_normalization(layer_1)
layer_2 = tf.nn.relu(tf.add(tf.matmul(layer_1_b, w_2), b_2))
layer_2_b = tf.layers.batch_normalization(layer_2)
layer_3 = tf.nn.relu(tf.add(tf.matmul(layer_2_b, w_3), b_3))
layer_3_b = tf.layers.batch_normalization(layer_3)
y = tf.nn.relu(tf.add(tf.matmul(layer_3, w_4), b_4))
g_q_action = tf.argmax(y, axis=1)
# compute loss
g_target_q_t = tf.placeholder(tf.float32, None, name="target_value")
g_action = tf.placeholder(tf.int32, None, name='g_action')
action_one_hot = tf.one_hot(g_action, n_output, 1.0, 0.0, name='action_one_hot')
q_acted = tf.reduce_sum(y * action_one_hot, reduction_indices=1, name='q_acted')
g_loss = tf.reduce_mean(tf.square(g_target_q_t - q_acted), name='g_loss')
optim = tf.train.RMSPropOptimizer(learning_rate=0.001, momentum=0.95, epsilon=0.01).minimize(g_loss)
Error statement:
Traceback (most recent call last):
File “C:UsersTPycharmProjectsProject1.venvmain_test.py”, line 139, in
layer_1 = tf.compat.v1.nn.relu(tf.add(tf.matmul(x, w_1), b_1))
^^^^^^^^^^^^^^^^^
File “C:UsersTAppDataLocalProgramsPythonPython312Libsite-packagestensorflowpythonopsweak_tensor_ops.py”, line 142, in wrapper
return op(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File “C:UsersTAppDataLocalProgramsPythonPython312Libsite-packagestensorflowpythonutiltraceback_utils.py”, line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File “C:UsersTAppDataLocalProgramsPythonPython312Libsite-packagestensorflowpythonframeworkops.py”, line 1037, in _create_c_op
raise ValueError(e.message)
To change 1.x to 2.x tensorflow
Md.Shohel Rana is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.