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 use more than 255 output neurons on the CPU backend #38

Closed
bittere opened this issue Oct 13, 2023 · 3 comments · Fixed by #51
Closed

Unable to use more than 255 output neurons on the CPU backend #38

bittere opened this issue Oct 13, 2023 · 3 comments · Fixed by #51

Comments

@bittere
Copy link

bittere commented Oct 13, 2023

Hi.

Here is a simple neural network with an output of 2 neurons:

import { Cost, CPU, DenseLayer, Sequential, setupBackend, SigmoidLayer, tensor1D, tensor2D, } from "https://deno.land/x/netsaur/mod.ts";

await setupBackend(CPU);

const net = new Sequential({
    size: [4, 2],
    layers: [
      DenseLayer({ size: [3] }),
      SigmoidLayer(),
      DenseLayer({ size: [2] }),
      SigmoidLayer(),
    ],
    cost: Cost.MSE,
  });

const outputs = await net.predict(tensor1D([1, 0]));
console.log(outputs);
$ deno run -A --unstable test.ts

Tensor {                                                                                                                  
    shape: [ 2 ],
    data: Float32Array(2) [ 0.3955751657485962, 0.6075010895729065 ]
}

However, if I update the last layer to 256 (or more) neurons, this happens:

$ deno run -A --unstable test.ts

thread '<unnamed>' panicked at 'source slice length (256) does not match destination slice length (0)', rust\src\ffi.rs:74:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: Rust cannot catch foreign exceptions

With 255 neurons or less, this error does not happen.

It also looks like this only happens when using the CPU backend, not the WASM backend. There is no error if I use the WASM backend.

I am running deno 1.37.1 on Windows 10.

Thanks in advance!

@bittere bittere changed the title Unable to use more than 255 output neurons Unable to use more than 255 output neurons on the CPU backend Oct 13, 2023
@load1n9
Copy link
Member

load1n9 commented Oct 13, 2023

Will look into it ASAP

@retraigo
Copy link
Contributor

retraigo commented Feb 3, 2024

Can we close this now that #51 is merged?

@bittere
Copy link
Author

bittere commented Feb 4, 2024

Yes, it appears to be working now. Thanks!

@bittere bittere closed this as completed Feb 4, 2024
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

Successfully merging a pull request may close this issue.

3 participants