【问题标题】:Tensorflow in Rust, unresolved importRust 中的 TensorFlow,未解决的导入
【发布时间】:2020-08-12 09:25:40
【问题描述】:

我正在尝试在 rust 中使用 tensorflow。我已按照 rust tensorflow 项目的github page 上的说明进行操作。我的Cargo.toml 文件有

[dependencies]
tensorflow = "0.15.0"

在里面。我的处理器是 Intel i7-8700,我运行的是 Ubuntu 18.04,这应该意味着他们根据 github 页面下载了预构建的二进制文件,我不需要担心其他先决条件。

cargo run,cargo下载并构建了很多包。然后我尝试复制他们的xor.rs 示例。它从一堆进口开始。首先很多use std:: 很好。然后我们进入 tensorflow 导入,从

开始
use tensorflow::ops;
use tensorflow::train::AdadeltaOptimizer;
use tensorflow::train::MinimizeOptions;
use tensorflow::train::Optimizer;

我立即遇到了导入问题。这是列表的顶部:

error[E0432]: unresolved import `tensorflow::ops`
 --> src/main.rs:7:5
  |
7 | use tensorflow::ops;
  |     ^^^^^^^^^^^^^^^ no `ops` in the root

error[E0432]: unresolved import `tensorflow::train`
 --> src/main.rs:8:17
  |
8 | use tensorflow::train::AdadeltaOptimizer;
  |                 ^^^^^ could not find `train` in `tensorflow`

error[E0432]: unresolved import `tensorflow::train`
 --> src/main.rs:9:17
  |
9 | use tensorflow::train::MinimizeOptions;
  |                 ^^^^^ could not find `train` in `tensorflow`

error[E0432]: unresolved import `tensorflow::train`
  --> src/main.rs:10:17
   |
10 | use tensorflow::train::Optimizer;
   |                 ^^^^^ could not find `train` in `tensorflow`

但是根据上面链接的 github 存储库中 tensorflow 的 src/lib.rs 文件和 documentation,确实应该有模块 tensorflow::opstensorflow::train 可用。

我的货物怎么找不到?

【问题讨论】:

标签: tensorflow rust importerror


【解决方案1】:

在 cmets 中解决。我必须编辑 Cargo.toml 文件才能阅读

tensorflow = {version = "0.15.0", features = ["experimental_training"]}

experimental training 显然是这些模块的必需功能。

【讨论】:

  • 剩余的错误,其中许多是expected struct "tensorflow::graph::Output", found struct "tensorflow::graph::Operation",都已通过对into()from()的适当调用得到修复。
猜你喜欢
  • 1970-01-01
  • 2021-05-27
  • 2022-11-23
  • 2021-11-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-01
相关资源
最近更新 更多