Skip to main content

Linear

Struct Linear 

Source
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

Source

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§

Source§

impl Default for Linear

Source§

fn default() -> Self

Creates a new Linear activation function Linear weight initialization factor is set to 1.0.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V