为什么我收到错误 "tf.fromPixels is not a function"?

Why am I getting the error "tf.fromPixels is not a function"?

我有一些基本的 tensorflow.js 代码 from an example on the documentation:

const image = new ImageData(1, 1);
image.data[0] = 100;
image.data[1] = 150;
image.data[2] = 200;
image.data[3] = 255;
const xs = tf.fromPixels(image);
xs.print();
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js"></script>

使用此版本(网站告诉您使用的版本):

https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js

并收到错误:Uncaught TypeError: tf.fromPixels is not a function 可能是什么原因造成的?当您 运行 代码段时,其他人是否收到此错误?

您正在查看版本 0.12.0 的文档。

tf.fromPixels 在 1.0.0 版本中被弃用,使用:tf.browser.fromPixels()