0

i am making agent for cart pole using Q-network i am watching online lecture but he is using tensorflow v1 (it has record before tf_v2)

he is using placeholder api and placeholder is removed in tensorflow-v2

i want a find alternative solution for tensorflow-v2

this is my code

x = tf.placeholder([1,input_size],dtype=tf.float32)
w = tf.Variable(tf.random.uniform([input_size,output_size],0,0.01))

qpred = tf.matmul(x,w)
  • Try this, https://www.tensorflow.org/api_docs/python/tf/compat/v1/placeholder. – B200011011 Apr 20 '21 at 02:42
  • i know a method using tf.compat.v2.placeholder() but what i want a know is a alternative method using tensorflow v2 – Jeongjin Shin Apr 20 '21 at 02:46
  • 1
    This may help, https://www.tensorflow.org/guide/migrate#converting_models. – B200011011 Apr 20 '21 at 03:28
  • You can use `tf.keras.Input` to replace `tf.placeholder` in TF 2.x. Please check [this](https://www.tensorflow.org/api_docs/python/tf/compat/v1/placeholder#migrate-to-tf2) reference for more details. –  May 25 '22 at 07:38

0 Answers0