Sets the parameters which connect the given layer `layer` with the next layer.
(&self, layer: usize, params: Matrix<f64>)
| 54 | /// Sets the parameters which connect the given layer `layer` with the next |
| 55 | /// layer. |
| 56 | pub fn set_params(&self, layer: usize, params: Matrix<f64>) -> NeuralNetwork { |
| 57 | |
| 58 | let mut m = self.params.clone(); |
| 59 | |
| 60 | match m.get_mut(layer) { |
| 61 | None => { panic!("Layer does not exist."); } |
| 62 | Some(mx) => { |
| 63 | assert!(mx.rows() == params.rows() && |
| 64 | mx.cols() == params.cols(), "Parameter configuration is incompatible."); |
| 65 | *mx = params; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | NeuralNetwork { |
| 70 | layers: self.layers.clone(), |
| 71 | params: m |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /// Returns the number of input units. |
| 76 | pub fn input_size(&self) -> usize { |