Class: DNN::Models::Sequential
Instance Attribute Summary collapse
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Attributes inherited from Model
#last_log, #loss_func, #optimizer
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, #predict, #predict1, #save, #setup, #test_on_batch, #train, #train_by_iterator, #train_on_batch
Constructor Details
#initialize(stack = []) ⇒ Sequential
Returns a new instance of Sequential.
371 372 373 374 |
# File 'lib/dnn/core/models.rb', line 371 def initialize(stack = []) super() @stack = stack.clone end |
Instance Attribute Details
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
368 369 370 |
# File 'lib/dnn/core/models.rb', line 368 def stack @stack end |
Instance Method Details
#add(layer) ⇒ DNN::Models::Model Also known as: <<
Add layer to the model.
379 380 381 382 383 384 385 |
# File 'lib/dnn/core/models.rb', line 379 def add(layer) unless layer.is_a?(Layers::Layer) || layer.is_a?(Model) raise TypeError, "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
399 400 401 402 403 404 |
# File 'lib/dnn/core/models.rb', line 399 def call(x) @stack.each do |layer| x = layer.(x) end x end |
#remove(layer) ⇒ Boolean
Remove layer to the model.
392 393 394 395 396 397 |
# File 'lib/dnn/core/models.rb', line 392 def remove(layer) unless layer.is_a?(Layers::Layer) || layer.is_a?(Model) raise TypeError, "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 |