Tensorflow.js tf.variable() Function
The tf.variable() function is used to create a new variable with the provided initial value.
tf.variable(initialValue, trainable, name, dtype)
- initialValue: The initial value of the tensor from which the new variable will be initialized.
- trainable: It is an optional parameter. It is of boolean type if true optimizers are allowed to update the variable and if false optimizers are not allowed to update it.
- name: It is also an optional parameter. It is of string type. It is used for the name of the variable used as a unique ID.
- dtype: It is also an optional parameter. If it is passed as the argument the intialValue will be changed to the specified dtype.
Return Value: This function returns tf.variable.
Tensor [[8, 2], [5, 6]]
Tensor [1, 2, 5, 6]
Tensor [1 + 0j, 2 + 0j, 3 + 0j]