pub struct Linear;Expand description
Linear is a builder for Linear Activation Function
Linear (or Identity) activation function does not transform the input at all. It is typically used in the output layer of a regression model, where we want to predict a numeric value.
Range: (-∞, +∞) Best for: Output layers where prediction of continuous values is required.
Implementations§
Source§impl Linear
impl Linear
Sourcepub fn build() -> Result<Box<dyn ActivationFunction>, NetworkError>
pub fn build() -> Result<Box<dyn ActivationFunction>, NetworkError>
Examples found in repository?
examples/energy_efficiency/energy_efficiency.rs (line 117)
113fn energy_efficiency_network(inp_size: usize, targ_size: usize) -> Network {
114 let network = NetworkBuilder::new(inp_size, targ_size)
115 .layer(Dense::default().size(18).activation(ReLU::build()).build())
116 .layer(Dense::default().size(14).activation(ReLU::build()).build())
117 .layer(Dense::default().size(targ_size).activation(Linear::build()).build())
118 .optimizer(Adam::default().beta1(0.99).beta2(0.999).learning_rate(0.0030).build())
119 .loss_function(MeanSquared.build())
120 .early_stopper(
121 Flexible::default()
122 .monitor_metric(MonitorMetric::Loss)
123 .patience(500)
124 .min_delta(0.1)
125 .smoothing_factor(0.5)
126 .build(),
127 )
128 .batch_size(7)
129 .batch_group_size(2)
130 .parallelize(2)
131 .normalize_input(MinMax::default())
132 .epochs(500)
133 .seed(55)
134 .build();
135
136 match network {
137 Ok(net) => net,
138 Err(e) => {
139 eprintln!("Failed to build network: {}", e);
140 std::process::exit(1);
141 }
142 }
143}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Linear
impl RefUnwindSafe for Linear
impl Send for Linear
impl Sync for Linear
impl Unpin for Linear
impl UnsafeUnpin for Linear
impl UnwindSafe for Linear
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.