Get started with tensorflow CDN

Apache-2.0 licensed

TensorFlow is an open-source machine learning platform for building and training models.

Tags:
  • WebGL
  • Machine Learning
  • Training

Stable version

Copied!

How to start using tensorflow CDN


// Include TensorFlow library from the CDN
const tf = document.createElement('script');
tf.src = 'https://cdn.cdnhub.io/tensorflow/4.17.0/tf.min.js';
document.head.appendChild(tf);

// Wait for TensorFlow to load
window.onTensorFlowLoad = () => {
  // Create a Tensor from an array
  const tensor1d = tf.tensor1d([1, 2, 3, 4]);

  // Perform element-wise addition with another Tensor
  const tensor2d = tf.tensor2d([[1, 2], [3, 4]]);
  const result = tf.add(tensor1d, tensor2d);

  // Print the result
  result.print();

  // Dispose of the tensors to free memory
  tensor1d.dispose();
  tensor2d.dispose();
  result.dispose();
};
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions