Created
July 28, 2023 12:40
-
-
Save hietalajulius/9e101f3d1715d54e952da5003a6fb82f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Perform forward pass through the ReLU activation function. | |
fn forward(&mut self, x: &Array2<f64>) -> Array2<f64> { | |
// Calculate dy/dx for backpropagation | |
let dy_dx = x.mapv(|val| if val > 0.0 { 1.0 } else { 0.0 }); | |
// Store dy/dx for later use in backward pass | |
self.dy_dx = Some(dy_dx); | |
// Get the output of the ReLU activation function | |
self.get_output(x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment