class MXNet::Gluon::Parameter
- MXNet::Gluon::Parameter
 - Reference
 - Object
 
Overview
A Container holding parameters (weights) of Blocks.
Parameter holds a copy of the parameter on each Context
after it is initialized with #init. If grad_req is not
:null, it also holds a gradient array on each Context.
Direct Known Subclasses
Defined in:
mxnet/gluon/parameter.crConstructors
- 
        .new(name, shape = nil, dtype = nil, init = nil, allow_deferred_init = false, grad_req = :write)
        
          
Creates a new instance.
 
Instance Method Summary
- 
        #==(other : self)
        
          
Returns
trueif this reference is the same as other. - 
        #data(ctx = nil)
        
          
Returns a copy of this parameter on one context.
 - #dtype : Symbol?
 - #dtype=(dtype)
 - 
        #grad(ctx = nil)
        
          
Returns a gradient buffer for this parameter on one context.
 - 
        #init(init = nil, ctx = nil, default_init = :uniform, force_reinit = false)
        
          
Initializes parameter and gradient arrays.
 - 
        #list_ctx
        
          
Returns a list of contexts this parameter is initialized on.
 - 
        #list_data
        
          
Returns copies of this parameter on all contexts, in the same order as creation.
 - 
        #list_grad
        
          
Returns gradient buffers on all contexts, in the same order as creation.
 - #name : String
 - 
        #set_data(data)
        
          
Sets this parameter's value on all contexts.
 - #shape : Array(Int32)?
 - #shape=(shape)
 - 
        #to_s(io)
        
          
Writes this object to an
IO. - #trainer : MXNet::Gluon::Trainer?
 - #trainer=(trainer)
 - 
        #var
        
          
Returns a symbol representing this parameter.
 - 
        #zero_grad
        
          
Sets gradient buffer to zero on all contexts.
 
Constructor Detail
Creates a new instance.
Parameters
- name (
String) Name of this parameter. - shape (
Int|Array(Int), optional) Shape of this parameter. By default, shape is inferred. - dtype (
Symbol, default:float32) Data type of this parameter. - init (
Initializer, optional) The initializer to use. - allow_deferred_init (
Bool, default =false) Is deferred initialization allowed. - grad_req (
Symbol, default:write) :write: updated is written to the gradient:add: update is added to the existing gradient.:null: gradient is not supported on this parameter
Instance Method Detail
Returns true if this reference is the same as other. Invokes same?.
Returns a copy of this parameter on one context. Must have been initialized on this context before.
Parameters
- ctx (
Context, optional) Desired context. 
Returns a gradient buffer for this parameter on one context. Must have been initialized on this context before.
Parameters
- ctx (
Context, optional) Desired context. 
Initializes parameter and gradient arrays. Only used with
NDArray API.
Parameters
- init (
Initializer, default =nil) The initializer to use. Overrides both init, set when this instance was created, and default_init in this call. - ctx (
Context|Array(Context), default =nil) InitializeParameteron givenContexts. A copy will be created for each context. Note: copies are independent arrays. The programmer is responsible for keeping values consistent when updating. NormallyTrainerdoes this for you. - default_init (
Initializer, default =:uniform) Default initializer. - force_reinit (
Bool, default =false) Whether to force re-initialization if parameter is already initialized. 
weight = MXNet::Gluon::Parameter.new('weight', shape: [2, 2])
weight.init(ctx: MXNet.cpu)
weight.data # => [[0.0068339, 0.0129982],...
weight.grad # => [[0, 0],...