74 lines
2.4 KiB
C++
74 lines
2.4 KiB
C++
/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
*
|
|
* 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: vertical_data.hpp
|
|
* Revision: 0.1.0
|
|
* Date: 29-07-2026
|
|
* Author: Michelle Bausager
|
|
*
|
|
* Description:
|
|
* Functions to generate dataset for neural networks;
|
|
*
|
|
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
|
|
|
#include <config/types.hpp>
|
|
#include <tensor/vector.hpp>
|
|
#include <tensor/matrix.hpp>
|
|
//---------------------------------------------------------------------------------------------------------------------------
|
|
// INPLEMENTATION
|
|
//---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
namespace panic {
|
|
namespace neural_network {
|
|
|
|
|
|
/**
|
|
* @brief Generates a dataset of vertical values
|
|
*
|
|
* Computes:
|
|
* @code
|
|
* vertical_data(10, 1, X, y)
|
|
* @endcode
|
|
*
|
|
* @tparam T Numeric element type.
|
|
* @param samples Number of samples dataset.
|
|
* @param classes Number of classes in the vertical data.
|
|
* @param X Output X matrix
|
|
* @param y Output y matrix
|
|
*
|
|
* @return true if @p X and @p y was resized and filled successfully.
|
|
* @return false if resizing @p X or @p y failed.
|
|
*
|
|
* @note This funtion writes the result into an existing vector to avoid
|
|
* unnecessary temporary allocations.
|
|
*/
|
|
template <typename T>
|
|
bool vertical_data(const panic::types::uint_t samples, const panic::types::uint_t classes, panic::tensor::matrix<T>& X, panic::tensor::uint_vector& y);
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace neural_network
|
|
} // namespace panic
|