tensorflow - TensorFlow.js 收集字符串张量
问题描述
我是 TensorFlow.js 的新手并且有一个问题.. 通过索引从列表中收集元素时
const x = tf.tensor1d([32, 43, 25, 65])
const indices = tf.tensor1d([1, 3, 3], 'int32');
x.gather(indices).print();
// Tensor
// [43, 65, 65]
但是当 x 是字符串张量时,它不起作用。
const x = tf.tensor1d(["a1", "a2", "a3", "a4"]);
const indices = tf.tensor1d([1, 3, 3], 'int32');
x.gather(indices).print();
// Uncaught Error: Argument 'x' passed to 'gather' must be numeric tensor, but got string tensor
我错过了什么吗?
解决方案
推荐阅读
- git - git push 未在 github 上显示,仍然出现 lfs 错误
- c++ - 如何在 Visual Studio 2017 中为 Windows XP 编译代码
- azure-active-directory - 为 AAD 更改通知创建订阅会不一致地引发“订阅验证超时异常”
- sql - 使用所有参数选项时,如何让 SSRS 显示正确的平均工作时间?
- c - 如何在 C 中以二进制和文本模式使用 FILE
- ios - 快速,有没有办法从第二个领域包中添加新数据,而不覆盖当前默认领域中的任何现有数据?
- accord.net - Accord.net Codification can't handle non-strings
- c++ - 获取对 const 规范重载的成员函数的引用
- c# - 如何使用 ASP.NET MVC 和 SQL Server 将表字段值从一个表传递或复制到另一个表
- python - 如何将列表中的数据动态添加到数据库(PostgreSQL)