TensorFlow.js Tutorial
Tensorflow.js is popular JavaScript library for machine learning.
It lets us train and deploy machine learning in the browser, and lets us add machine learning functions to any Web application.
Using TensorFlow.js
To use TensorFlow.js, add the following script tag to your HTML file(s):
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@3.6.0/dist/tf.min.js">
</script>
|
If you always want to use the latest version, drop the version number:
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs">
</script>
|
TensorFlow was developed by the Google Brain Team for internal Google use, but was released as open software in 2015.
In January 2019, Google developers released TensorFlow.js, the JavaScript implementation of TensorFlow.
Tensorflow.js was designed to provide the same features as the original TensorFlow library written in Python.
Tensors
TensorFlow.js is a JavaScript library to define and operate on tensors.
The main data type in TensorFlow.js is the tensor.
A tensor is much the same as a multidimensional array.
It contains values in one or more dimensions.
A tensor has the following main properties:
Property |
Description |
dtype |
The data type |
rank |
The number of dimensions |
shape |
The size of each dimension |
|
|
|
Sometimes in machine learning, the term “dimension” is used interchangeably with rank.
[10, 5] is a 2-dimensional tensor or a 2-rank tensor.
In addition the term “dimensionality” can refer to the size of a one dimension.
For example, in the 2-dimensional tensor [10, 5], the dimensionality of the first dimension is 10.
It is a symbolic math library that uses dataflow and differentiable programming to perform various tasks.