concision_linear/impls/model/
impl_linear.rs1use crate::{Config, Linear, ParamMode, ParamsBase};
6use core::borrow::{Borrow, BorrowMut};
7use nd::{DataOwned, Ix2, RawData, RemoveAxis};
8
9impl<A, K, S> Linear<A, K, Ix2, S>
10where
11 K: ParamMode,
12 S: RawData<Elem = A>,
13{
14 pub fn from_features(inputs: usize, outputs: usize) -> Self
15 where
16 A: Clone + Default,
17 S: DataOwned,
18 {
19 let config = Config::std(inputs, outputs);
20 let params = ParamsBase::new(config.dim());
21 Self { config, params }
22 }
23}
24
25impl<A, S, D, K> Borrow<Config<K, D>> for Linear<A, K, D, S>
26where
27 D: RemoveAxis,
28 S: RawData<Elem = A>,
29{
30 fn borrow(&self) -> &Config<K, D> {
31 &self.config
32 }
33}
34
35impl<A, S, D, K> Borrow<ParamsBase<S, D, K>> for Linear<A, K, D, S>
36where
37 D: RemoveAxis,
38 S: RawData<Elem = A>,
39{
40 fn borrow(&self) -> &ParamsBase<S, D, K> {
41 &self.params
42 }
43}
44
45impl<A, S, D, K> BorrowMut<ParamsBase<S, D, K>> for Linear<A, K, D, S>
46where
47 D: RemoveAxis,
48 S: RawData<Elem = A>,
49{
50 fn borrow_mut(&mut self) -> &mut ParamsBase<S, D, K> {
51 &mut self.params
52 }
53}