jackm321 / RustNN

A neural network crate
Apache License 2.0
332 stars 32 forks source link

Index out of bounds error with more than three layers #2

Closed guersam closed 9 years ago

guersam commented 9 years ago

Hi,

When I change the layer of xor test NN from &[2,3,1] to &[2,3,3,1] , it panics at this line with the following trace:

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcollections/vec.rs:1338
stack backtrace:
   1:     0x7f238e58c7e9 - sys::backtrace::write::ha14749a03a5342e69AD
   2:     0x7f238e5905e6 - panicking::on_panic::hee4fd6319a5ce222fRJ
   3:     0x7f238e57a3f3 - rt::unwind::begin_unwind_inner::h7cec0e68cf4dd4e9WwJ
   4:     0x7f238e57a7df - rt::unwind::begin_unwind_fmt::h9b999773388b3dfaxvJ
   5:     0x7f238e58ffa7 - rust_begin_unwind
   6:     0x7f238e5bd0a4 - panicking::panic_fmt::h518b890fb69ee41c9qB
   7:     0x7f238e5bec9c - panicking::panic_bounds_check::hfe3fd03998902d4dfqB
   8:     0x7f238e4d8066 - vec::Vec<T>.Index<usize>::index::h10533351574849293586
                        at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcollections/vec.rs:1338
   9:     0x7f238e4aff8e - NN::calculate_weight_updates::h496ec902d44cfbc4AOa
                        at src/lib.rs:538
  10:     0x7f238e4cf655 - NN::train_batch::closure.5782
                        at src/lib.rs:450
  11:     0x7f238e4cf33d - F.FnBox::call_box::h16158016883286431322
                        at /home/guersam/.cargo/registry/src/github.com-1ecc6299db9ec823/threadpool-0.1.2/src/lib.rs:26
  12:     0x7f238e546fee - spawn_scoped_in_pool::closure.3431
                        at /home/guersam/.cargo/registry/src/github.com-1ecc6299db9ec823/threadpool-0.1.2/src/lib.rs:225
  13:     0x7f238e546de6 - thunk::Thunk<'a, (), R>::new::closure.3426
                        at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/thunk.rs:27
  14:     0x7f238e546d41 - thunk::F.Invoke<A, R>::invoke::h3097253234199166430
                        at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/thunk.rs:54
  15:     0x7f238e53d6a7 - thunk::Thunk<'a, A, R>::invoke::h13280486025064970643
                        at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/thunk.rs:41
  16:     0x7f238e53cd63 - thread::Builder::spawn_inner::closure.3133
                        at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/thread/mod.rs:354
  17:     0x7f238e53ccee - rt::unwind::try::try_fn::__rust_abi::h7868465900712247904
                        at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/rt/unwind.rs:139
  18:     0x7f238e53cc89 - rt::unwind::try::try_fn::h7868465900712247904
  19:     0x7f238e594818 - rust_try_inner
  20:     0x7f238e594805 - rust_try
  21:     0x7f238e53c07a - rt::unwind::try::h18352464926673870406
                        at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/rt/unwind.rs:125
  22:     0x7f238e53bcb7 - thread::Builder::spawn_inner::closure.3000
                        at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/thread/mod.rs:354
  23:     0x7f238e53dca4 - thunk::Thunk<'a, (), R>::new::closure.3155
                        at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/thunk.rs:27
  24:     0x7f238e53dbdc - thunk::F.Invoke<A, R>::invoke::h13792676425105660100
                        at /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/thunk.rs:54
  25:     0x7f238e58f2c1 - sys::thread::create::thread_start::h5bfe55b0d48e24ddIqI
  26:     0x7f238d5580a4 - start_thread
  27:     0x7f238dd71cfc - __clone
  28:                0x0 - <unknown>
jackm321 commented 9 years ago

Thanks for finding this, it should be fixed now.