test_class.file: deepnetts-core/src/test/java/deepnetts/net/layers/OutputLayerTest.java
test_class.identifier: OutputLayerTest
test_case.body: @Test
      public void testApplyWeightChanges() {
          OutputLayer instance = new OutputLayer(10);
          FullyConnectedLayer prevLayer = new FullyConnectedLayer(5);
          instance.setPrevLayer(prevLayer);
          instance.init();
          Tensor weights = new Tensor(5, 10);
  
          WeightsInit.initSeed(123);
          WeightsInit.uniform(weights.getValues(), 5);    
          Tensor biases = new Tensor(10); // 
          WeightsInit.randomize(weights.getValues()); //  [-0.2885946, -0.023120344, 0.114212096, -0.35789996, -0.46654212, -0.060512245, 0.18889612, -0.38798183, 0.18411279, 0.34890008, -0.4247411, -0.3433265, 0.44680566, -0.09958029, -0.063123405, 0.43927592, 0.19381553, -0.083636045, 0.17639846, 0.32855767, 0.12878358, 0.1629799, 0.07470411, -0.46918643, -0.11202836, 0.2753712, -0.31087178, -0.08334535, -0.47327846, -0.3146028, -0.46844327, 0.112583816, 0.33040798, -0.10281438, 0.24008608, 0.32558167, 0.44147235, 0.32505035, 0.32593954, -0.17731398, 0.014207661, 0.28614485, 0.09407586, 0.123054445, -0.27172554, -0.14735949, -0.19683117, -0.33119786, 0.19504476, 0.23377019]
          WeightsInit.randomize(biases.getValues()); //   [-0.07173675, -0.06975782, 0.46547735, -0.06449604, 0.22543085, -0.25612664, -0.16484225, -0.21565866, 0.45828927, -0.13396758]
          instance.setWeights(weights);
          instance.setBiases(biases.getValues());        
          instance.setDeltas(new Tensor(10));
          instance.deltaWeights = new Tensor(5, 10);
          WeightsInit.randomize(instance.deltaWeights.getValues()); // [-0.014675736, -0.20824462, -0.2544266, -0.29433697, 0.19522274, -0.042135, -0.2805665, 0.44587213, -0.38881636, 0.2882418, 0.06629634, 0.011203349, 0.014710844, 0.23828048, -0.34540945, -0.16317445, 0.052065372, 0.35782564, -0.2368347, 0.16372514, -0.21912044, 0.32790893, -0.08429372, -0.347282, -0.33204705, -0.25469518, 0.33288032, -0.22248, -0.19762617, -0.30643207, -0.05354631, -0.46328926, 0.23842907, 0.25631714, -0.4825107, 0.0952881, -0.32452244, -0.014563918, 0.48131067, -0.3766222, 0.44226605, -0.12013543, 0.35074377, -0.29712552, 0.259381, 0.49666756, -0.43016553, -0.40166676, -0.012900829, 0.3826325]
          WeightsInit.randomize(instance.deltaBiases); // [-0.32544816, -0.42210114, 0.46139675, 0.44991916, 0.11481196, 0.48068362, 0.2159949, 0.23206848, -0.41850775, 0.28163642]
                  
          instance.applyWeightChanges();        
          Tensor expectedWeights = new Tensor(-0.30327034f, -0.23136496f, -0.1402145f, -0.65223693f, -0.27131938f, -0.10264724f, -0.09167038f,  0.0578903f,  -0.20470357f,  0.63714188f, -0.35844476f, -0.33212315f, 0.4615165f,   0.13870019f, -0.40853286f,  0.27610147f,  0.2458809f,   0.2741896f, -0.06043624f,  0.49228281f, -0.09033686f,  0.49088883f, -0.00958961f, -0.81646843f, -0.44407541f,  0.02067602f,  0.02200854f, -0.30582535f, -0.67090463f, -0.62103487f, -0.52198958f, -0.35070544f,  0.56883705f,  0.15350276f, -0.24242462f,  0.42086977f, 0.11694991f,  0.31048643f,  0.80725021f, -0.55393618f,  0.45647371f,  0.16600942f, 0.44481963f, -0.17407107f, -0.01234454f,  0.34930807f, -0.6269967f,  -0.73286462f, 0.18214393f,  0.61640269f);        
          Tensor expectedBiases = new Tensor(-0.39718491f, -0.49185896f, 0.9268741f, 0.38542312f, 0.34024281f, 0.22455698f, 0.05115265f, 0.01640982f, 0.03978152f, 0.14766884f);
                  
          assertArrayEquals(weights.getValues(), expectedWeights.getValues(), 1e-7f);
          assertArrayEquals(biases.getValues(), expectedBiases.getValues(), 1e-7f);  
      }
test_case.class_method_signature: OutputLayerTest.testApplyWeightChanges()
test_case.full_signature: @Test public void testApplyWeightChanges()
test_case.identifier: testApplyWeightChanges
test_case.invocations: setPrevLayer init initSeed uniform getValues randomize getValues randomize getValues setWeights setBiases getValues setDeltas randomize getValues randomize applyWeightChanges assertArrayEquals getValues getValues assertArrayEquals getValues getValues
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testApplyWeightChanges()
focal_class.declarator: outputErrors
focal_class.modifier: protected
focal_class.original_string: protected float[] outputErrors;
focal_class.type: float[]
focal_class.var_name: outputErrors
focal_class.declarator: labels
focal_class.modifier: protected final
focal_class.original_string: protected final String[] labels;
focal_class.type: String[]
focal_class.var_name: labels
focal_class.declarator: lossType
focal_class.modifier: protected
focal_class.original_string: protected LossType lossType;
focal_class.type: LossType
focal_class.var_name: lossType
focal_class.declarator: targetClassIdx
focal_class.original_string: int targetClassIdx;
focal_class.type: int
focal_class.var_name: targetClassIdx
focal_class.file: deepnetts-core/src/main/java/deepnetts/net/layers/OutputLayer.java
focal_class.identifier: OutputLayer
focal_class.class_method_signature: OutputLayer.OutputLayer(int width)
focal_class.full_signature: public  OutputLayer(int width)
focal_class.identifier: OutputLayer
focal_class.modifiers: public
focal_class.parameters: (int width)
focal_class.signature:  OutputLayer(int width)
focal_class.class_method_signature: OutputLayer.OutputLayer(int width, ActivationType activationFunction)
focal_class.full_signature: public  OutputLayer(int width, ActivationType activationFunction)
focal_class.identifier: OutputLayer
focal_class.modifiers: public
focal_class.parameters: (int width, ActivationType activationFunction)
focal_class.signature:  OutputLayer(int width, ActivationType activationFunction)
focal_class.class_method_signature: OutputLayer.OutputLayer(String[] labels)
focal_class.full_signature: public  OutputLayer(String[] labels)
focal_class.identifier: OutputLayer
focal_class.modifiers: public
focal_class.parameters: (String[] labels)
focal_class.signature:  OutputLayer(String[] labels)
focal_class.class_method_signature: OutputLayer.OutputLayer(String[] labels, ActivationType activationFunction)
focal_class.full_signature: public  OutputLayer(String[] labels, ActivationType activationFunction)
focal_class.identifier: OutputLayer
focal_class.modifiers: public
focal_class.parameters: (String[] labels, ActivationType activationFunction)
focal_class.signature:  OutputLayer(String[] labels, ActivationType activationFunction)
focal_class.class_method_signature: OutputLayer.setOutputErrors(final float[] outputErrors)
focal_class.full_signature: public final void setOutputErrors(final float[] outputErrors)
focal_class.identifier: setOutputErrors
focal_class.modifiers: public final
focal_class.parameters: (final float[] outputErrors)
focal_class.return: void
focal_class.signature: void setOutputErrors(final float[] outputErrors)
focal_class.class_method_signature: OutputLayer.getOutputErrors()
focal_class.full_signature: public final float[] getOutputErrors()
focal_class.identifier: getOutputErrors
focal_class.modifiers: public final
focal_class.parameters: ()
focal_class.return: float[]
focal_class.signature: float[] getOutputErrors()
focal_class.class_method_signature: OutputLayer.getLossType()
focal_class.full_signature: public final LossType getLossType()
focal_class.identifier: getLossType
focal_class.modifiers: public final
focal_class.parameters: ()
focal_class.return: LossType
focal_class.signature: LossType getLossType()
focal_class.class_method_signature: OutputLayer.setLossType(LossType lossType)
focal_class.full_signature: public void setLossType(LossType lossType)
focal_class.identifier: setLossType
focal_class.modifiers: public
focal_class.parameters: (LossType lossType)
focal_class.return: void
focal_class.signature: void setLossType(LossType lossType)
focal_class.class_method_signature: OutputLayer.init()
focal_class.full_signature: @Override public void init()
focal_class.identifier: init
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void init()
focal_class.class_method_signature: OutputLayer.forward()
focal_class.full_signature: @Override public void forward()
focal_class.identifier: forward
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void forward()
focal_class.class_method_signature: OutputLayer.backward()
focal_class.full_signature: @Override public void backward()
focal_class.identifier: backward
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void backward()
focal_class.class_method_signature: OutputLayer.applyWeightChanges()
focal_class.full_signature: @Override public void applyWeightChanges()
focal_class.identifier: applyWeightChanges
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void applyWeightChanges()
focal_class.superclass: extends AbstractLayer
focal_method.body: @Override
      public void applyWeightChanges() {
          if (batchMode) { // if batch mode calculate average delta weights using batch samples (mini batch)
              deltaWeights.div(batchSize);
              Tensor.div(deltaBiases, batchSize);
          }
  
          // save current as prev delta weights (required for momentum)
          Tensor.copy(deltaWeights, prevDeltaWeights); 
          // apply(add) delta weights
          weights.add(deltaWeights);
  
          // save current as prev delta biases
          Tensor.copy(deltaBiases, prevDeltaBiases); 
          // apply(add) delta bias
          Tensor.add(biases, deltaBiases);
  
          if (batchMode) {    // for batch mode set all delta weights and biases to zero after applying changes. For online mode they are reseted in backward pass
              deltaWeights.fill(0);
              Tensor.fill(deltaBiases, 0);
          }
      }
focal_method.class_method_signature: OutputLayer.applyWeightChanges()
focal_method.full_signature: @Override public void applyWeightChanges()
focal_method.identifier: applyWeightChanges
focal_method.invocations: div div copy add copy add fill fill
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void applyWeightChanges()