- Hands-On Reinforcement Learning with Python
- Sudharsan Ravichandiran
- 83字
- 2021-06-18 19:12:08
Variables
Variables are the containers used to store values. Variables will be used as input to several other operations in the computational graph. We can create TensorFlow variables using the tf.Variable() function. In the following example, we define a variable with values from a random normal distribution and name it weights:
weights = tf.Variable(tf.random_normal([3, 2], stddev=0.1), name="weights")
However, after defining a variable, we need to explicitly create an initialization operation using the tf.global_variables_initializer() method which will allocate resources for the variable.