Softmax + Categorical Crossentropy
I fixed the activation+loss function, you can't select it directly, it automaticly uses it if it can. I also fixed one-hot generator. Still haven't tested the activation + loss nor any other backward function. I'll do that when I get to the optimizers which is next.
This commit is contained in:
@@ -53,10 +53,17 @@ namespace panic{
|
||||
*
|
||||
* The struct is used for PANIC neural_network library.
|
||||
*/
|
||||
struct loss_categorical_crossentropy: loss{
|
||||
|
||||
|
||||
struct loss_categorical_crossentropy: public loss{
|
||||
|
||||
/**
|
||||
* @brief get_type function for loss
|
||||
*
|
||||
* @returns the loss type
|
||||
*
|
||||
*/
|
||||
loss_type get_type() const override {
|
||||
return loss_type::categorical_crossentropy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief forward function to calculate losses
|
||||
@@ -65,9 +72,7 @@ struct loss_categorical_crossentropy: loss{
|
||||
* @param y_true Vector of true label of data.
|
||||
*
|
||||
*/
|
||||
bool forward(
|
||||
const panic::tensor::real_matrix& y_pred,
|
||||
const panic::tensor::uint_vector& y_true)override;
|
||||
bool forward(const panic::tensor::real_matrix& y_pred, const panic::tensor::uint_vector& y_true) override;
|
||||
|
||||
/**
|
||||
* @brief forward function to calculate losses
|
||||
@@ -78,9 +83,7 @@ struct loss_categorical_crossentropy: loss{
|
||||
* @Note Overloaded if one-shot endcoded
|
||||
* is used.
|
||||
*/
|
||||
bool forward(
|
||||
const panic::tensor::real_matrix& y_pred,
|
||||
const panic::tensor::real_matrix& y_true)override;
|
||||
bool forward(const panic::tensor::real_matrix& y_pred, const panic::tensor::real_matrix& y_true) override;
|
||||
|
||||
|
||||
/**
|
||||
@@ -90,9 +93,7 @@ struct loss_categorical_crossentropy: loss{
|
||||
* @param y_true Vector of true label of data.
|
||||
*
|
||||
*/
|
||||
bool backward(
|
||||
const panic::tensor::real_matrix& dvalues,
|
||||
const panic::tensor::uint_vector& y_true) override;
|
||||
bool backward(const panic::tensor::real_matrix& dvalues, const panic::tensor::uint_vector& y_true) override;
|
||||
|
||||
/**
|
||||
* @brief backward function to calculate from losses
|
||||
@@ -103,9 +104,7 @@ struct loss_categorical_crossentropy: loss{
|
||||
* @Note Overloaded if one-shot endcoded
|
||||
* is used.
|
||||
*/
|
||||
bool backward(
|
||||
const panic::tensor::real_matrix& dvalues,
|
||||
const panic::tensor::real_matrix& y_true) override;
|
||||
bool backward(const panic::tensor::real_matrix& dvalues, const panic::tensor::real_matrix& y_true) override;
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user