Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example / quickstart fails to compile #88

Closed
clemej opened this issue Feb 6, 2022 · 2 comments
Closed

Example / quickstart fails to compile #88

clemej opened this issue Feb 6, 2022 · 2 comments

Comments

@clemej
Copy link

clemej commented Feb 6, 2022

rustup 1.24.3 (ce5817a94 2021-05-31)
rustc 1.58.1 (db9d1b20b 2022-01-20)
cargo 1.58.0 (f01b232bc 2022-01-19)

Two issues: first, cargo build --examples doesn't work because the label in Cargo.toml is [[example]] instead of [[examples]] as it should be. Fixing that manually leads to the following errors:

$ cargo build --examples
warning: unused manifest key: examples
   Compiling neuronika v0.2.0 (/home/john/umbc/git/neuronika)
warning: unused import: `self`
 --> examples/quickstart.rs:4:10
  |
4 |     nn::{self, loss, Learnable, Linear, ModelStatus},
  |          ^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0277]: the trait bound `NeuralNetwork: serde::de::Deserialize<'_>` is not satisfied
    --> examples/quickstart.rs:56:9
     |
56   |     } = serde_json::from_str(
     |         ^^^^^^^^^^^^^^^^^^^^ the trait `serde::de::Deserialize<'_>` is not implemented for `NeuralNetwork`
     |
note: required by a bound in `serde_json::from_str`
    --> /home/john/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.78/src/de.rs:2611:8
     |
2611 |     T: de::Deserialize<'a>,
     |        ^^^^^^^^^^^^^^^^^^^ required by this bound in `serde_json::from_str`

For more information about this error, try `rustc --explain E0277`.
warning: `neuronika` (example "quickstart") generated 1 warning
error: could not compile `neuronika` due to previous error; 1 warning emitted

I'm super excited for this library and it's chance to build portable, cross-platform binaries that can train RNNs, CNNs, and feed-forward networks.

@frjnn
Copy link
Member

frjnn commented Feb 6, 2022

Hi, thanks for showing interest in the project. As for the latest commit on main (0717d4b), I can run the example with:

cargo run --package neuronika --example quickstart --features serialize

which gives

Loss for epoch 0 : 2.2159102 
Loss for epoch 1 : 2.0667396 
Loss for epoch 2 : 1.5102402 
Loss for epoch 3 : 1.4285513 
Loss for epoch 4 : 1.3589511 

On the other hand, cargo build --examples, gives:

warning: Target filter `examples` specified, but no targets matched. This is a no-op
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s

@clemej
Copy link
Author

clemej commented Feb 6, 2022

Huh. I can confirm your way works. Must be my rust/cargo inexperience, so I guess there is no bug here. will close as notabug.

@clemej clemej closed this as completed Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants