Class: DNN::Layers::GRU
- Inherits:
-
RNN
- Object
- Layer
- TrainableLayer
- Connection
- RNN
- DNN::Layers::GRU
- Defined in:
- lib/dnn/core/layers/rnn_layers.rb
Instance Attribute Summary
Attributes inherited from RNN
#hidden, #num_units, #recurrent_weight, #recurrent_weight_initializer, #recurrent_weight_regularizer, #return_sequences, #stateful
Attributes inherited from Connection
#bias, #bias_initializer, #bias_regularizer, #weight, #weight_initializer, #weight_regularizer
Attributes inherited from TrainableLayer
Attributes inherited from Layer
Instance Method Summary collapse
- #build(input_shape) ⇒ Object
- #create_hidden_layer ⇒ Object
-
#initialize(num_units, stateful: false, return_sequences: true, weight_initializer: Initializers::RandomNormal.new, recurrent_weight_initializer: Initializers::RandomNormal.new, bias_initializer: Initializers::Zeros.new, weight_regularizer: nil, recurrent_weight_regularizer: nil, bias_regularizer: nil, use_bias: true) ⇒ GRU
constructor
A new instance of GRU.
Methods inherited from RNN
#backward_node, #compute_output_shape, #forward_node, #get_params, #load_hash, #regularizers, #reset_state, #to_hash
Methods included from LayerNode
#backward_node, #forward, #forward_node
Methods inherited from Connection
#get_params, #regularizers, #to_hash, #use_bias
Methods inherited from TrainableLayer
Methods inherited from Layer
#<<, #built?, #call, call, #clean, #compute_output_shape, #forward, from_hash, #load_hash, #to_hash
Constructor Details
#initialize(num_units, stateful: false, return_sequences: true, weight_initializer: Initializers::RandomNormal.new, recurrent_weight_initializer: Initializers::RandomNormal.new, bias_initializer: Initializers::Zeros.new, weight_regularizer: nil, recurrent_weight_regularizer: nil, bias_regularizer: nil, use_bias: true) ⇒ GRU
Returns a new instance of GRU.
433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/dnn/core/layers/rnn_layers.rb', line 433 def initialize(num_units, stateful: false, return_sequences: true, weight_initializer: Initializers::RandomNormal.new, recurrent_weight_initializer: Initializers::RandomNormal.new, bias_initializer: Initializers::Zeros.new, weight_regularizer: nil, recurrent_weight_regularizer: nil, bias_regularizer: nil, use_bias: true) super end |
Instance Method Details
#build(input_shape) ⇒ Object
446 447 448 449 450 451 452 453 |
# File 'lib/dnn/core/layers/rnn_layers.rb', line 446 def build(input_shape) super num_prev_units = input_shape[1] @weight.data = Xumo::SFloat.new(num_prev_units, @num_units * 3) @recurrent_weight.data = Xumo::SFloat.new(@num_units, @num_units * 3) @bias.data = Xumo::SFloat.new(@num_units * 3) if @bias init_weight_and_bias end |