Tensor Flow Variables and Functions
Overview
A variable is a number or some other mathematical object that can during the course of processing. A particular
example of using a variable to is
optimize
a function that depends on the value of the variable by changing the variable.
Variables
A variable represents a value (typically a number) which can be changed, during an
optimization.
That is, a function is defined (see below) which is to optimized by changing a variable.
Variables can be created using the variable function in tensor-flow.
The following code creates a variable initially set to the value of 2.
let w = tf.variable(tf.scalar(2));
Functions
New functions can be defined over tensor flow variables using the standard javascript notation for
creating a
function,
but then using pre-defined tensor-flow operations on the function's variables.
let f = function(x){
return x.add(tf.scalar(2)).pow(tf.scalar(2, 'int32'))
}
let x = tf.variable(tf.scalar(2));
let test = f(x);
$console.log(test.dataSync());
Try it!
Pre-defined Functions