./deepspeech.py
tf.convert_to_tensor()
operation. Variable()
constructor.Variable()
constructor expects an initial value for the variable, which can be any kind or shape of Tensor. The type and form of the variable are defined by its initial value. The shape and the variables are fixed once they are created. let’s look at a few examples of how to create variables in TensorFlow.tf.Variable(initial_value=None, trainable=None, validate_shape=True,
caching_device=None, name=None, variable_def=None, dtype=None, import_scope=None,
constraint=None,synchronization=tf.VariableSynchronization.AUTO,
aggregation=tf.compat.v1.VariableAggregation.NONE, shape=None)â€‹
convert_to_tensor
will decide.initial_value
will be used. if any shape is specified, the variable will be assigned with that particular shape.tf.Variable()
constructor is used to create a variable in TensorFlow.tensor = tf.Variable([3,4])
<tf.Variable ‘Variable:0’ shape=(2,) dtype=int32, numpy=array([3, 4], dtype=int32)>
# import packages
import tensorflow as tf
# create variable
tensor1 = tf.Variable([3, 4])
# The shape of the variable
print("The shape of the variable: ",
tensor1.shape)
# The number of dimensions in the variable
print("The number of dimensions in the variable:",
tf.rank(tensor1).numpy())
# The size of the variable
print("The size of the tensorflow variable:",
tf.size(tensor1).numpy())
# checking the datatype of the variable
print("The datatype of the tensorflow variable is:",
tensor1.dtype)
The shape of the variable: (2,)
The number of dimensions in the variable: 1
The size of the tensorflow variable: 2
The datatype of the tensorflow variable is: <dtype: 'int32'>
assign()
method to modify the variable. It is more like indexing and then using the assign()
method. There are more methods to assign or modify the variable such as Variable.assign_add()
and Variable.assign_sub()
.assign()
: It’s used to update or add a new value.assign(value, use_locking=False, name=None, read_value=True)
import tensorflow as tf
tensor1 = tf.Variable([3, 4])
tensor1[1].assign(5)
tensor1
<tf.Variable ‘Variable:0’ shape=(2,) dtype=int32, numpy=array([3, 5], dtype=int32)>
Example :
Syntax : assign_add(delta, use_locking=False, name=None, read_value=True)
parameters :
* delta : The value to be added to the variable(Tensor).
* use_locking : During the operation, if True, utilise locking.
* name : name of the operation.
* read_value : If True, anything that evaluates to the modified value of the variable will be returned; if False, the assign op will be returned.
# import packages
import tensorflow as tf
# create variable
tensor1 = tf.Variable([3, 4])
# using assign_add() function
tensor1.assign_add([1, 1])
tensor1
Output :
<tf.Variable ‘Variable:0’ shape=(2,) dtype=int32, numpy=array([4, 5], dtype=int32)>
Example :
Syntax : assign_sub( delta, use_locking=False, name=None, read_value=True)
parameters :
* delta : The value to be subtracted from the variable
* use_locking : During the operation, if True, utilise locking.
* name : name of the operation.
* read_value : If True, anything that evaluates to the modified value of the variable will be returned; if False, the assign op will be returned.
# import packages
import tensorflow as tf
# create variable
tensor1 = tf.Variable([3, 4])
# using assign_sub() function
tensor1.assign_sub([1, 1])
tensor1
Output :
<tf.Variable ‘Variable:0’ shape=(2,) dtype=int32, numpy=array([2, 3], dtype=int32)>
tf.variable
and tf.placeholder both are almost similar to each other, but there are some differences as following:tf.variable  tf.placeholder 





tf.summary.histogram
. Each chart displays the temporal "slices" of data, where each slice is a histogram of the tensor at a given step. It is arranged with the oldest timestep in the back, and the most recent timestep in front.tf.summary.audio
is used for the storage of these files, and the tagging system is used to embed the latest audio based on the storage policies.