#420·rust

是否有范围相关操作的示例

作者: Jzow创建于 2023年12月26日更新于 2023年12月26日

这是我的代码: Rust fn tf_ops_range() { // 创建一个生成 [0, 1, 2, 3, 4, 5] 的范围操作 let mut scope = tensorflow::Scope::new_root_scope(); let start = tensorflow::ops::constant(0_i32, &mut scope); let limit = tensorflow::ops::constant(6_i32, &mut scope); let delta = tensorflow::ops::constant(1_i32, &mut scope);

let range_op = tensorflow::ops::range(start, limit, delta, &mut scope).unwrap();

}

// 测试 tf_ops_range #[test] fn test_tf_ops_range() { tf_ops_range(); }

// 报错: Rust let range_op = tensorflow::ops::range(start, limit, delta, &mut scope).unwrap(); | ---------------------- ^^^^^ the trait From<Result<Operation, Status>> is not implemented for tensorflow::Output | | | required by a bound introduced by this call | = help: the trait From<Operation> is implemented for tensorflow::Output = note: required for Result<Operation, Status> to implement Into<tensorflow::Output> 我查阅了相关文档,包括源代码,但遗憾的是我没有看到如何使用 range 的示例。

内容来源: tensorflow/rust