Created
July 6, 2022 21:11
-
-
Save Steboss89/91d038379f30727f41640f9f16133918 to your computer and use it in GitHub Desktop.
Constant method to initialize weights and biases
This file contains hidden or 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
| Init::Const(cst) => { | |
| // Optimize the case for which a single C++ code can be done. | |
| if cst == 0. { | |
| Tensor::f_zeros(dims, (Kind::Float, device)) | |
| } else if (cst - 1.).abs() <= std::f64::EPSILON { | |
| Tensor::f_ones(dims, (Kind::Float, device)) | |
| } else { | |
| Tensor::f_ones(dims, (Kind::Float, device)).map(|t| t * cst) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment