November 2019
Intermediate to advanced
296 pages
7h 52m
English
First, we are going to prepare the dataset. The dataset is two numerical sequences representing x and y values in a two-dimensional space. The target value to be predicted by the model is a sine curve in each point. To make the situation as close to the real world as possible, we have added Gaussian random noise to the target value.
tf.randomNormal is a function that samples values from the normal distribution so that we can create noisy data just by adding it to the original sine values:
import * as tf from '@tensorflow/tfjs';const doublePi = tf.scalar(2.0 * Math.PI);// Sequence of xconst xs = tf.mul(doublePi, tf.range(-0.5, 0.5, 0.01));// y is a sine curve with gaussian noiseconst noise = tf.randomNormal([xs.size]).mul(0.05); ...
Read now
Unlock full access