November 2019
Intermediate to advanced
296 pages
7h 52m
English
Once our model is able to emulate the sine function, we are able to predict the sine value with any given input. The 2-degree polynomial regression model is constructed as follows:
const w0 = tf.scalar(Math.random() - 0.5).variable();const w1 = tf.scalar(Math.random() - 0.5).variable();const w2 = tf.scalar(Math.random() - 0.5).variable();// f(x) = w2*x^2 + w1*x + w0const f_x = x => { return w2.mul(x).mul(x) .add(w1.mul(x)) .add(w0);}
Now, we have defined the 2-degree function that will be adjusted by the optimization process. To specify the trainable variable explicitly, it is necessary to use the variable method in tensor in TensorFlow.js. We have initialized the variables with the random variable that ...
Read now
Unlock full access