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

Unable to compile example in stand-alone repository using main due to Serde error #103

Open
quietlychris opened this issue Apr 29, 2022 · 14 comments

Comments

@quietlychris
Copy link

Hello,

I tried building the quickstart example in a stand-alone project today, and was unable to do so. I've tested that cloning neuronika off the main branch builds (and the example runs), but when pulling it in as a dependency, I am consistently running into the error

error[E0277]: the trait bound `NeuralNetwork: serde::de::Deserialize<'_>` is not satisfied
    --> src/main.rs:53:9
     |
53   |     } = 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/chrism/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.79/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`.
error: could not compile `neuronika_example` due to previous error

Running this code with 0.2 doesn't seem feasible due to what I'm assuming are updated trait bounds around Overwrite.

My Cargo.toml file has the following configuration, based on neuronika main's:

[dependencies]
neuronika = {git = "https://github.com/neuronika/neuronika.git", branch = "main", features = ["serialize"]}
ndarray = {version = "0.15.4", features = ["rayon"]}
serde_json = "1.0.72"
serde = {version = "1.0.130", features = ["derive"]}

I am compiling with rustc 1.60.0-stable on an x86 platform using Pop!_OS 21.04.

I'm very interested in this library, and would love to experiment with starting to solve basic classification problem like MNIST or CIFAR-10 with it. Any advice on how I might be able to resolve these issues would be greatly appreciated. Thanks for your time!

@frjnn
Copy link
Member

frjnn commented Apr 29, 2022

Hi, thanks for the interest in the project,

I strongly recommend to pull neuronika as follows:

[dependencies]

neuronika = { git = "https://github.com/neuronika/neuronika" }

Currently the whole codebase is going through a rework, with many improvement and the addition of CUDA support.

When it's ready I'll probably yank the 0.2.0 version.

Apologies.

@quietlychris
Copy link
Author

I'm afraid it doesn't look like this fixes the issue. Thanks for your consideration, but since it sounds like you're doing a lot of re-factoring at the moment (really looking forward to the features you mentioned landing!), I'll probably just wait until the next release to really start digging in.

@frjnn
Copy link
Member

frjnn commented Apr 30, 2022

How are you running the example? You should be using cargo run --example quickstart --features="serialize"

@quietlychris
Copy link
Author

I think we've had a miscommunication. When I clone the neuronika repository and run cargo run --example quickstart --features="serialize", everything compiles fine.

However, when I create a new repository cargo new --bin neurnika_test, copy-paste in the quickstart example code, and try to run it while having the following Cargo.toml file

[dependencies]
neuronika = {git = "https://github.com/neuronika/neuronika.git", branch = "main", features = ["serialize"]}
ndarray = {version = "0.15.4", features = ["rayon"]}
serde_json = "1.0.72"
serde = {version = "1.0.130", features = ["derive"]}

which should import the neuronika main branch with the serialize feature enabled, I get a compilation error regarding serde trait bounds as seen in my first example. In essence, it seems like in-project development builds are fine, but I am having issues using neuronika main as a dependency in other projects.

@frjnn
Copy link
Member

frjnn commented May 1, 2022

Got it. Yes, that's a problem. Would you be able to look into it? Unfortunately, I'll be quite busy for the next couple of weeks.

@quietlychris
Copy link
Author

Apologies for the delay! Yes, I'll try to take a look at this over the next few days

@phatware
Copy link

phatware commented Jul 5, 2022

Just ran into the same error too. Was it resolved? Thanks.

@frjnn
Copy link
Member

frjnn commented Jul 5, 2022

@phatware does the following work? cargo run --example quickstart --features="serialize"

@phatware
Copy link

phatware commented Jul 5, 2022

yes, this command works, however creating a new project and using code similar to
fn load_model() -> NeuralNetwork {
let NeuralNetwork {
lin1,
lin2,
lin3,
mut status,
} = serde_json::from_str(
r#"
{
"lin1":{
"weight":{
......

fails with the same error as described before.
Thanks.

@frjnn
Copy link
Member

frjnn commented Jul 5, 2022

got it. What does your cargo.toml look like?

@phatware
Copy link

phatware commented Jul 5, 2022

it looks the same as posted by @quietlychris above, + a few other unrelated dependencies

@frjnn
Copy link
Member

frjnn commented Jul 5, 2022

@phatware try this for_pathware.zip, it works for me. Also, forgive me for not taking care of the project in the last few months but I have been very very busy with other stuff. If you are interested in the library do note that soon (around or before October) a big rework of the project with GPU support will land on main. You can check it out at the variable-rework branch.

Also forgive me for misspelling your nickname!

@phatware
Copy link

phatware commented Jul 5, 2022

This worked, thank you. Appreciate quick response. Cheers.

@dbsxdbsx
Copy link

@phatware try this for_pathware.zip, it works for me. Also, forgive me for not taking care of the project in the last few months but I have been very very busy with other stuff. If you are interested in the library do note that soon (around or before October) a big rework of the project with GPU support will land on main. You can check it out at the variable-rework branch.

Also forgive me for misspelling your nickname!

I got the same issue, and it is solved by your zip, thanks.

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

4 participants