Class: DNN::Models::Sequential
Instance Attribute Summary collapse
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Attributes inherited from Model
Instance Method Summary collapse
-
#add(layer) ⇒ DNN::Models::Model
(also: #<<)
Add layer to the model.
- #call(x) ⇒ Object
-
#initialize(stack = []) ⇒ Sequential
constructor
A new instance of Sequential.
-
#remove(layer) ⇒ Boolean
Remove layer to the model.
Methods inherited from Model
#accuracy, #add_callback, #built?, #clear_callbacks, #copy, #get_layer, #has_param_layers, #layers, load, #load_hash_params, #load_json_params, #predict, #predict1, #save, #setup, #test_on_batch, #train, #train_on_batch
Constructor Details
#initialize(stack = []) ⇒ Sequential
Returns a new instance of Sequential.
356 357 358 359 |
# File 'lib/dnn/core/models.rb', line 356 def initialize(stack = []) super() @stack = stack.clone end |
Instance Attribute Details
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
353 354 355 |
# File 'lib/dnn/core/models.rb', line 353 def stack @stack end |
Instance Method Details
#add(layer) ⇒ DNN::Models::Model Also known as: <<
Add layer to the model.
364 365 366 367 368 369 370 |
# File 'lib/dnn/core/models.rb', line 364 def add(layer) unless layer.is_a?(Layers::Layer) || layer.is_a?(Model) raise TypeError.new("layer: #{layer.class.name} is not an instance of the DNN::Layers::Layer class or DNN::Models::Model class.") end @stack << layer self end |
#call(x) ⇒ Object
384 385 386 387 388 389 |
# File 'lib/dnn/core/models.rb', line 384 def call(x) @stack.each do |layer| x = layer.(x) end x end |
#remove(layer) ⇒ Boolean
Remove layer to the model.
377 378 379 380 381 382 |
# File 'lib/dnn/core/models.rb', line 377 def remove(layer) unless layer.is_a?(Layers::Layer) || layer.is_a?(Model) raise TypeError.new("layer: #{layer.class.name} is not an instance of the DNN::Layers::Layer class or DNN::Models::Model class.") end @stack.delete(layer) ? true : false end |