Done with activation softmax backwards
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
*
|
||||
*
|
||||
* 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: tensor
|
||||
* File Name: eye.hpp
|
||||
* Revision: 0.1.0
|
||||
* Date: 31-07-2026
|
||||
* Author: Michelle Bausager
|
||||
*
|
||||
* Description:
|
||||
* Functions to generate eye matrices
|
||||
*
|
||||
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
#pragma once
|
||||
|
||||
#include <tensor/matrix.hpp> // for panic::vector
|
||||
#include <config/types.hpp>
|
||||
|
||||
namespace panic{
|
||||
namespace tensor{
|
||||
|
||||
/**
|
||||
* @brief Outputs an eye matrix
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param size Number or rows and columns.
|
||||
* @param A Output matrix
|
||||
*
|
||||
* @return true if @p A was resized and filled successfully.
|
||||
* @return false if resizing @p A failed.
|
||||
*
|
||||
* @note This overload writes the result into an existing vector to avoid
|
||||
* unnecessary temporary allocations.
|
||||
*/
|
||||
template <typename T>
|
||||
bool eye(const panic::types::uint_t size, panic::tensor::matrix<T> A);
|
||||
|
||||
/**
|
||||
* @brief Returns a eye matrix
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* @endcode
|
||||
*
|
||||
* @param T Numeric element type.
|
||||
* @param size Number of rows and columns.
|
||||
*
|
||||
* @return A new vector containing the result.
|
||||
* @return An empty vector if the operation fails.
|
||||
*
|
||||
* @note This overload is convenient, but may allocate a new vector.
|
||||
*/
|
||||
//template <typename T>
|
||||
//panic::tensor::matrix<T> eye(const T size);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace tensor
|
||||
} // namespace panic
|
||||
@@ -0,0 +1,91 @@
|
||||
/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
*
|
||||
*
|
||||
* 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: tensor
|
||||
* File Name: one_hot.hpp
|
||||
* Revision: 0.1.0
|
||||
* Date: 31-07-2026
|
||||
* Author: Michelle Bausager
|
||||
*
|
||||
* Description:
|
||||
* Functions to one_hot matrices
|
||||
*
|
||||
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
#pragma once
|
||||
|
||||
#include <tensor/vector.hpp>
|
||||
#include <tensor/matrix.hpp> // for panic::vector
|
||||
#include <config/types.hpp>
|
||||
|
||||
namespace panic{
|
||||
namespace tensor{
|
||||
|
||||
/**
|
||||
* @brief Outputs an one_hot matrix
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
|
||||
* @endcode
|
||||
*
|
||||
* @tparam T Numeric element type.
|
||||
* @param size Number of columns.
|
||||
* @param a Input vector that contains here 1 should be
|
||||
* @param B Output matrix
|
||||
*
|
||||
* @return true if @p B was resized and filled successfully.
|
||||
* @return false if resizing @p B failed.
|
||||
*
|
||||
* @note This overload writes the result into an existing vector to avoid
|
||||
* unnecessary temporary allocations.
|
||||
*/
|
||||
template <typename T>
|
||||
bool one_hot(const panic::types::uint_t size, const panic::tensor::uint_vector& a, panic::tensor::matrix<T>& B);
|
||||
|
||||
/**
|
||||
* @brief Returns a one_hot matrix
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* @endcode
|
||||
*
|
||||
* @param T Numeric element type.
|
||||
* @param size Number of columns.
|
||||
* @param a Input vector that contains here 1 should be
|
||||
*
|
||||
* @return A new vector containing the result.
|
||||
* @return An empty vector if the operation fails.
|
||||
*
|
||||
* @note This overload is convenient, but may allocate a new vector.
|
||||
*/
|
||||
//template <typename T>
|
||||
//panic::tensor::matrix<T> one_hot(const panic::types::uint_t size, const panic::tensor::vector<T>& a);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace tensor
|
||||
} // namespace panic
|
||||
Reference in New Issue
Block a user