Class: DNN::Layers::GRU

Inherits:
RNN show all
Defined in:
lib/dnn/core/rnn_layers.rb

Instance Attribute Summary

Attributes inherited from RNN

#h, #num_nodes, #stateful

Attributes inherited from Connection

#l1_lambda, #l2_lambda

Attributes inherited from HasParamLayer

#grads, #params, #trainable

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RNN

#backward, #dlasso, #dlasso2, #dridge, #dridge2, #forward, #lasso, #reset_state, #ridge, #shape, #to_hash

Methods inherited from Connection

#dlasso, #dridge, #lasso, #ridge, #to_hash

Methods inherited from HasParamLayer

#build, #update

Methods inherited from Layer

#backward, #build, #built?, #forward, #prev_layer, #shape, #to_hash

Constructor Details

#initialize(num_nodes, stateful: false, return_sequences: true, weight_initializer: nil, bias_initializer: nil, l1_lambda: 0, l2_lambda: 0) ⇒ GRU

Returns a new instance of GRU.



435
436
437
438
439
440
441
442
443
# File 'lib/dnn/core/rnn_layers.rb', line 435

def initialize(num_nodes,
               stateful: false,
               return_sequences: true,
               weight_initializer: nil,
               bias_initializer: nil,
               l1_lambda: 0,
               l2_lambda: 0)
  super
end

Class Method Details

.load_hash(hash) ⇒ Object



423
424
425
426
427
428
429
430
431
432
433
# File 'lib/dnn/core/rnn_layers.rb', line 423

def self.load_hash(hash)
  gru = self.new(hash[:num_nodes],
                 stateful: hash[:stateful],
                 return_sequences: hash[:return_sequences],
                 weight_initializer: Util.load_hash(hash[:weight_initializer]),
                 bias_initializer: Util.load_hash(hash[:bias_initializer]),
                 l1_lambda: hash[:l1_lambda],
                 l2_lambda: hash[:l2_lambda])
  gru.h = Xumo::SFloat.cast(hash[:h])
  gru
end