INNER CODE UNIT · Python
fill_var
nfmcclure/tensorflow_cookbook · 01_Introduction/02_Creating_and_Using_Tensors/02_tensors.py:41
fill_var = tf.Variable(tf.fill([row_dim, col_dim], -1))
# Create a variable from a constant
const_var = tf.Variable(tf.constant([8, 6, 7, 5, 3, 0, 9]))
# This can also be used to fill an array:
const_fill_var = tf.Variable(tf.constant(-1, shape=[row_dim, col_dim]))
# Sequence generation
linear_var = tf.Variable(tf.linspace(start=0.0, stop=1.0, num=3)) # Generates [0.0, 0.5, 1.0] includes the end
sequence_var = tf.Variable(tf.range(start=6, limit=15, delta=3)) # Generates [6, 9, 12] doesn't include the end
# Random Numbers
# Random Normal
rnorm_var = tf.random_normal([row_dim, col_dim], mean=0.0, stddev=1.0)
# Add summaries to tensorboard