Beispiel #1
0
Vector< Matrix<double> > ProbabilisticLayer::calculate_probability_Hessian_form(const Vector<double>&) const
{
    Vector< Matrix<double> > Hessian_form(1);

    Hessian_form[0].set(1, 1, 0.0);

    return(Hessian_form);
}
Beispiel #2
0
Vector< Matrix<double> > ScalingLayer::arrange_Hessian_form(const Vector<double>& second_derivative) const
{
   const size_t scaling_neurons_number = get_scaling_neurons_number();

   Vector< Matrix<double> > Hessian_form(scaling_neurons_number);

   for(size_t i = 0; i < scaling_neurons_number; i++)
   {
      Hessian_form[i].set(scaling_neurons_number, scaling_neurons_number, 0.0);

      Hessian_form[i](i,i) = second_derivative[i];
   }

   return(Hessian_form);
}
Beispiel #3
0
Vector< Matrix<double> > ProbabilisticLayer::calculate_softmax_Hessian_form(const Vector<double>& inputs) const
{
   Vector< Matrix<double> > Hessian_form(probabilistic_neurons_number);

   for(size_t i = 0; i < probabilistic_neurons_number; i++)
   {
       Hessian_form[i].set(probabilistic_neurons_number, probabilistic_neurons_number);
   }

   const Vector<double> outputs = inputs.calculate_softmax();

   for(size_t i = 0; i < probabilistic_neurons_number; i++)
   {
       for(size_t j = 0; j < probabilistic_neurons_number; j++)
       {
           for(size_t k = 0; k < probabilistic_neurons_number; k++)
           {
                if(j == i && j == k && i == k)
                {
                    Hessian_form[i](j, k) = outputs[i]*(1 - outputs[i] - 2*outputs[i]*(1 - outputs[i]));
                }
                else if(j == i && j != k && i != k)
                {
                    Hessian_form[i](j, k) = -outputs[i]*outputs[k]*(1 - 2*outputs[i]);
                }
                else if(j != i && j == k && i != k)
                {
                    Hessian_form[i](j, k) = outputs[i]*outputs[j]*outputs[k] - outputs[i]*outputs[j]*(1 - outputs[j]);
                }
                else if(j != i && i == k && j != k)
                {
                    Hessian_form[i](j, k) = outputs[i]*outputs[j]*outputs[k] - outputs[i]*outputs[j]*(1 - outputs[i]);
                }
                else if(j != i && i != k && j != k)
                {
                    Hessian_form[i](j, k) = 2*outputs[i]*outputs[j]*outputs[k];
                }
           }
       }
   }

   return(Hessian_form);
}