Machine Learning - What Is TensorFlow
Machine Learning - What Is TensorFlow
Using TensorFlow
To use TensorFlow.js, add the following script tag to your HTML file(s):
Example
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
If you always want to use the latest version, drop the version number:
Example 2
<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.
Tensorflow.js was designed to provide the same features as the original TensorFlow library written in
Python.
Tensors
Property Description
Sometimes in machine learning, the term "dimension" is used interchangeably with "rank.
In addition the term "dimensionality" can refer to the size of a one dimension.
Example: In the 2-dimensional tensor [10, 5], the dimensionality of the first dimension is 10.
ADVERTISEMENT
Creating a Tensor
A Tensor is created from any N-dimensional array with the tf.tensor() method:
Example 1
Example 2
Try it Yourself »
Example 3
Try it Yourself »
Tensor Shape
Example1
Try it Yourself »
Example2
Try it Yourself »
Example3
Try it Yourself »
Example
function display(data) {
document.getElementById("demo").innerHTML = data;
}
Try it Yourself »
Example
function display(data) {
document.getElementById("demo").innerHTML = data;
}
Try it Yourself »
function display(data) {
document.getElementById("demo").innerHTML = data;
}
Try it Yourself »
Example
document.getElementById("demo").innerHTML = tensorA.rank;
Try it Yourself »
Example
document.getElementById("demo").innerHTML = tensorA.shape;
Try it Yourself »
You can get the datatype of a tensor using tensor.dtype:
Example
document.getElementById("demo").innerHTML = tensorA.dtype;
Try it Yourself »
• bool
• int32
• float32 (default)
• complex64
• string
When you create a tensor, you can specify the data type as the third parameter:
Example
Try it Yourself »