Optimazation is done
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
*
|
||||
* PANIC
|
||||
* Portable Algorithms and Numerics In C++
|
||||
*
|
||||
* Scientific computing from scratch, with feeling.
|
||||
*
|
||||
* Copyright (c) 2026 Michelle Bausager
|
||||
*
|
||||
* This file is part of PANIC.
|
||||
*
|
||||
* PANIC is free software licensed under the GNU General Public License v3.0 or later.
|
||||
* You may redistribute and/or modify it under the terms of the GPL.
|
||||
*
|
||||
* PANIC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the LICENSE file for the full license text.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
*
|
||||
* Project Name: PANIC
|
||||
* Module Name: neural_network
|
||||
* File Name: optimizer_rmsprop.hpp
|
||||
* Revision: 0.1.0
|
||||
* Date: 04-08-2026
|
||||
* Author: Michelle Bausager
|
||||
*
|
||||
* Description:
|
||||
* Defines the optimizer_adam struct used in neural network
|
||||
*
|
||||
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
#pragma once
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// INCLUDE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
#include <config/types.hpp>
|
||||
#include <neural_network/optimizers/optimizer.hpp>
|
||||
|
||||
|
||||
namespace panic{
|
||||
namespace neural_network{
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief optimizer_adam for the rest of the neural network library to use
|
||||
*
|
||||
*/
|
||||
struct optimizer_adam: optimizer{
|
||||
|
||||
panic::types::real_t learning_rate;
|
||||
|
||||
panic::types::real_t decay;
|
||||
|
||||
panic::types::real_t epsilon;
|
||||
|
||||
panic::types::real_t beta_1;
|
||||
panic::types::real_t beta_2;
|
||||
|
||||
panic::types::real_t beta_1_power;
|
||||
panic::types::real_t beta_2_power;
|
||||
|
||||
panic::types::uint_t iterations;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param learning_rate The learning rate for the optimization.
|
||||
* @param decay The decay for the learning rate over the interations.
|
||||
*
|
||||
*/
|
||||
optimizer_adam(const panic::types::real_t learning_rate = static_cast<panic::types::real_t>(0.001),
|
||||
const panic::types::real_t decay = static_cast<panic::types::real_t>(0),
|
||||
const panic::types::real_t epsilon = static_cast<panic::types::real_t>(1e-7),
|
||||
const panic::types::real_t beta_1 = static_cast<panic::types::real_t>(0.9),
|
||||
const panic::types::real_t beta_2 = static_cast<panic::types::real_t>(0.999));
|
||||
|
||||
|
||||
/**
|
||||
* @brief Default de-constructor
|
||||
*
|
||||
*/
|
||||
~optimizer_adam() = default;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Updates weights and biases in trainable layers
|
||||
*
|
||||
* @param layer Trianable layer to update.
|
||||
*
|
||||
*/
|
||||
bool update_params(trainable_layer& layer) override;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief function to update internal parameters before update_params()
|
||||
*
|
||||
* @param layer Trianable layer to update.
|
||||
*
|
||||
*/
|
||||
bool pre_update_params() override;
|
||||
|
||||
/**
|
||||
* @brief function to update internal parameters after update_params()
|
||||
*
|
||||
*/
|
||||
bool post_update_params() override;
|
||||
|
||||
};
|
||||
|
||||
} // namespace tensor
|
||||
} // namespace panic
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user