Skip to content

Commit

Permalink
Fix a regression on beta Rust
Browse files Browse the repository at this point in the history
This bit of code relies on behavior that will no longer work in Rust 1.79,
which is currently in beta. Since this crate was the only regression, the
behavior change was considered acceptable, but does mean that this crate has a
minor breakage in tests. 

Add a concrete type to the vector to correct for this behavior change. 

See the context here:
rust-lang/rust#125198
  • Loading branch information
tgross35 authored Jun 5, 2024
1 parent 5ddd081 commit f17baab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,22 +216,22 @@ mod test {

#[test]
fn softmax_test() {
let items = vec![1.0, 2.0, 3.0];
let items = vec![1.0f64, 2.0, 3.0];
let res = Activation::softmax(items[0], items);
assert!((res - 0.09003057).abs() < 0.001)
// close eneough.
}

#[test]
fn softmax_derivative_test() {
let classes = vec![3.0, 4.0, 5.0];
let classes = vec![3.0f64, 4.0, 5.0];
let res = Activation::softmax_derivative(0, classes);
assert!((res[0] - 0.08192506).abs() < 0.001);
}

#[test]
fn softmax_derivative_vector_test() {
let classes = vec![1.0, 2.0, 3.0];
let classes = vec![1.0f64, 2.0, 3.0];
let res = Activation::softmax_derivative(0, classes);
println!("{res:?}");

Expand Down

0 comments on commit f17baab

Please sign in to comment.