Class: MachineLearningWorkbench::NeuralNetwork::FeedForward

Inherits:
Base
  • Object
show all
Defined in:
lib/machine_learning_workbench/neural_network/feed_forward.rb

Overview

Feed Forward Neural Network

Instance Attribute Summary

Attributes inherited from Base

#act_fn, #act_fn_name, #layers, #state, #struct

Instance Method Summary collapse

Methods inherited from Base

#activate, #deep_reset, #init_random, #initialize, #interface_methods, #layer_col_sizes, #layer_shapes, #lecun_hyperbolic, #load_weights, #nlayers, #nneurs, #nweights, #nweights_per_layer, #out, #relu, #reset_state, #sigmoid, #weights

Constructor Details

This class inherits a constructor from MachineLearningWorkbench::NeuralNetwork::Base

Instance Method Details

#activate_layer(i) ⇒ Object

Activates a layer of the network

Parameters:

  • i (Integer)

    the layer to activate, zero-indexed



16
17
18
# File 'lib/machine_learning_workbench/neural_network/feed_forward.rb', line 16

def activate_layer i
  act_fn.call(state[i].dot layers[i])
end

#layer_row_sizesArray<Integer>

Calculate the size of each row in a layer’s weight matrix. Includes inputs (or previous-layer activations) and bias.

Returns:

  • (Array<Integer>)

    per-layer row sizes



10
11
12
# File 'lib/machine_learning_workbench/neural_network/feed_forward.rb', line 10

def layer_row_sizes
  @layer_row_sizes ||= struct.each_cons(2).collect {|prev, _curr| prev+1}
end