tensorflowJS Cheatsheet
tensorflowJS Cheatsheet
JS Cheat Sheet
Tensors
Dimensions are given as height, width, and
depth, OR number of channels. This format is
used in many TFJS methods. These values are an
example of the dimensions of a common desktop
image size
Create a tensor filled with a given value Introspection. Prints values of tensor in proper
shape
tf.fill(dims, value)
myTensor.print()
Example - creates a 2-high, 4-wide tensor filled
with 5s (but what about Rex?!) Output the shape of a tensor (height, width,
channels).
tf.fill([2, 4], 5)
myTensor.shape // => [ 3, 3, 1 ] (for
Create a tensor where each value is randomly example)
assigned from a uniform distribution over the
interval [ minValue, maxValue ]
tf.randomUniform(dims, minValue,
maxValue)
1
TensorFlow.JS Cheat Sheet