class MXNet::Gluon::ParameterDict

Overview

A dictionary managing a set of Parameters.

Included Modules

Defined in:

mxnet/gluon/parameter.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(prefix = "", shared = nil) #

Creates a new instance.

Parameters

  • prefix (String, default "") The prefix to be prepended to all Parameters' names created by this dict.
  • shared (ParameterDict, optional) If not nil, when this dict's #get method creates a new parameter, it will first try to retrieve it from shared dict. Usually used for sharing parameters with another Block.

[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


[View source]
def each(&) #
Description copied from module Enumerable({String, MXNet::Gluon::Parameter})

Must yield this collection's elements to the block.


[View source]
def get(name, **kwargs) #

Retrieves a Parameter with name "<prefix><name>". If not found, #get will first try to retrieve it from shared dict. If still not found, #get will create a new Parameter with key-word arguments and both store and return it.

Parameters

  • name (String) Name of the desired Parameter. It will be prepended with this dict's prefix.

[View source]
def has_key?(key) #

[View source]
def has_value?(value) #

[View source]
def init(init = nil, ctx = nil, force_reinit = false) #

Initializes all Parameters managed by this dict for use with NDArray API. It has no effect when using Symbol API.

Parameters

  • init (Initializer, optional) The initializer to use.
  • ctx (Context | Array(Context), optional) Desired contexts. Initializes Parameter on given contexts.
  • force_reinit (Boolean, default = false) Whether to force re-initialization if parameters are already initialized.

[View source]
def keys #

[View source]
def load(fname, ctx = nil, allow_missing = false, ignore_extra = false, restore_prefix = "") #

Loads parameters from a file.

Parameters

  • fname (String) Path to parameter file.
  • ctx (Context | Array(Context), default = nil) Context(s) to initialize loaded parameters on.
  • allow_missing (Bool, default = false) Whether to silently skip loading parameters not present in the file.
  • ignore_extra (Bool, default = false) Whether to silently ignore parameters from the file that are not present in this dict.
  • restore_prefix (String, default = "") Prefix to prepend to names of stored parameters before loading.

[View source]
def prefix : String #

Prefix of this dict. It will be prepended to a Parameter's name created with #get.


[View source]
def save(fname, strip_prefix = "") #

Saves parameters to a file.

Parameters

  • fname (String) Path to parameter file.
  • strip_prefix (String, default = "") Prefix to strip from parameter names before saving.

[View source]
def to_s(io) #

Writes this object to an IO.


[View source]
def update(other : Enumerable(Tuple(String, Parameter))) #

Copies all Parameters in other into this dict.

Parameters

  • other (Enumerable({String, Parameter})) Dict to copy from.

[View source]
def values #

[View source]