Struct primitiv::Parameter
[−]
[src]
pub struct Parameter { /* fields omitted */ }
Struct to manage a trainable tensor parameter.
Methods
impl Parameter
[src]
pub fn new() -> Self
[src]
Creates an invalid parameter object.
pub fn from_values<S: Into<Shape>>(shape: S, value: &[f32]) -> Self
[src]
Creates a new Parameter object.
pub fn from_values_on<S: Into<Shape>, D: Device>(
shape: S,
value: &[f32],
device: Option<&mut D>
) -> Self
[src]
shape: S,
value: &[f32],
device: Option<&mut D>
) -> Self
Creates a new Parameter object.
pub fn from_initializer<S: Into<Shape>, I: Initializer>(
shape: S,
initializer: &I
) -> Self
[src]
shape: S,
initializer: &I
) -> Self
Creates a new Parameter object.
pub fn from_initializer_on<S: Into<Shape>, D: Device, I: Initializer>(
shape: S,
initializer: &I,
device: Option<&mut D>
) -> Self
[src]
shape: S,
initializer: &I,
device: Option<&mut D>
) -> Self
Creates a new Parameter object.
pub fn init_by_values<S: Into<Shape>>(&mut self, shape: S, value: &[f32])
[src]
Initializes the Parameter object.
pub fn init_by_values_on<S: Into<Shape>, D: Device>(
&mut self,
shape: S,
value: &[f32],
device: Option<&mut D>
)
[src]
&mut self,
shape: S,
value: &[f32],
device: Option<&mut D>
)
Initializes the Parameter object.
pub fn init_by_initializer<S: Into<Shape>, I: Initializer>(
&mut self,
shape: S,
initializer: &I
)
[src]
&mut self,
shape: S,
initializer: &I
)
Initializes the Parameter object.
pub fn init_by_initializer_on<S: Into<Shape>, D: Device, I: Initializer>(
&mut self,
shape: S,
initializer: &I,
device: Option<&mut D>
)
[src]
&mut self,
shape: S,
initializer: &I,
device: Option<&mut D>
)
Initializes the Parameter object.
pub fn load<P: AsRef<Path>>(&mut self, path: P, with_stats: bool) -> Result<()>
[src]
Loads parameters from specified file.
pub fn load_on<P: AsRef<Path>, D: Device>(
&mut self,
path: P,
with_stats: bool,
device: Option<&mut D>
) -> Result<()>
[src]
&mut self,
path: P,
with_stats: bool,
device: Option<&mut D>
) -> Result<()>
Loads parameters from specified file.
pub fn save<P: AsRef<Path>>(&self, path: P, with_stats: bool) -> Result<()>
[src]
Saves current parameters into specified file.
pub fn valid(&self) -> bool
[src]
Returns whether the parameter is valid or not.
pub fn reset_gradient(&mut self)
[src]
Set all gradients to 0.
pub fn add_stats<S: Into<Shape>>(&mut self, name: &str, shape: S)
[src]
Adds a new optional statistics tensor.
pub fn has_stats(&self, name: &str) -> bool
[src]
Checks whether the statistics with name name
exists or not.
pub fn shape(&self) -> Shape
[src]
Returns the shape of the parameter.
pub fn device(&self) -> AnyDevice
[src]
Returns the Device object to manage the internal memory.
pub fn value(&self) -> Tensor
[src]
Returns the values of the parameter.
pub fn gradient(&self) -> Tensor
[src]
Returns the current gradient of the parameter.
pub fn stats(&self, name: &str) -> Tensor
[src]
Returns the current opotional statistics tensor specified by given name.
Trait Implementations
impl Debug for Parameter
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more