Search code examples
tensorflowtensorflow.js

How to import specific version of Tensorflow.js?


I am trying to integrate the TensorFlow library into my IDE so I can train with it.

I went to this site: https://www.tensorflow.org/js/tutorials/setup and it looks like I got the latest and greatest version:

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>

However, that version is not working for because of how it outputs the tf object in my code editor.

I am looking for something close to this version:

enter image description here

But as you can see, it's confusing to me, which one of these is it exactly? When I pull up the versions property in my console I just see 1.0.0 across the board, so I am not sure what version I am looking for, but it's whatever outputs what you see above or close to it.

The important thing is I write out in my IDE:

const data = tf.tensor([1,2,3]);
const otherData = tf.tensor([4,5,6]);

data.add(otherData);

I should see this: [5, 7, 9] outputted, instead I see this:

{"isDisposedInternal":false,"shape":[3],"dtype":"float32","size":3,"strides":[],"dataId":{},"id":267,"rankType":"1"}

Solution

  • You are looking for tensor.print().

    If you really need to change the version, just change it in the src attribute of the script tag.