Tensorflow.js: tf.pad results in TypeError: t.map is not a function
Tensorflow.js: tf.pad results in TypeError: t.map is not a function
此代码来自 TF API 文档:
let t = tf.tensor([[1, 2, 3], [4, 5, 6]])
let padding = tf.tensor([[1, 1,], [2, 2]])
当我执行它时:
tf.pad(t, padding, "CONSTANT")
我得到:
TypeError: t.map is not a function
我使用的是最新版本的 tfjs。
padding 是普通的 js 元组数组(数组的数组)而不是张量。
目前1.3.1版本只支持CONSTANT模式。这是要走的路:
let t = tf.tensor([[1, 2, 3], [4, 5, 6]])
let padding = [[2, 2,], [1, 1]]
tf.pad(t, padding).print()
// [[0, 0, 0, 0, 0],
// [0, 0, 0, 0, 0],
// [0, 1, 2, 3, 0],
// [0, 4, 5, 6, 0],
// [0, 0, 0, 0, 0],
// [0, 0, 0, 0, 0]]
此代码来自 TF API 文档:
let t = tf.tensor([[1, 2, 3], [4, 5, 6]])
let padding = tf.tensor([[1, 1,], [2, 2]])
当我执行它时:
tf.pad(t, padding, "CONSTANT")
我得到:
TypeError: t.map is not a function
我使用的是最新版本的 tfjs。
padding 是普通的 js 元组数组(数组的数组)而不是张量。
目前1.3.1版本只支持CONSTANT模式。这是要走的路:
let t = tf.tensor([[1, 2, 3], [4, 5, 6]])
let padding = [[2, 2,], [1, 1]]
tf.pad(t, padding).print()
// [[0, 0, 0, 0, 0],
// [0, 0, 0, 0, 0],
// [0, 1, 2, 3, 0],
// [0, 4, 5, 6, 0],
// [0, 0, 0, 0, 0],
// [0, 0, 0, 0, 0]]