Files
jube-fork/Accord.Core/MachineLearning/ITransform.cs
richard-churchman cc0a2bee21 Extensive modifications to the serialisation of Neural Network models to support Newtonsoft Json.net rather than Binary Serializer.
Included open-source Accord.net library code natively to the solution given the deprecated state of that project.  Accord.net will be supported inside Jube for own needs (such as upgrading to .Net 7+).

Accord.net libraries modified to compile to .Net 6.

Modified Accord.net libraries to better support Newtonsoft Json.net serialisation.

Included annotations in the Accord.net libraries to house important dependency statistics. Serialised json can be used independently of Jube to recall a Neural Network.

Removal of Binary Serializer totally as a precursor to the projects support of .Net 7+.

Extensive bug fixing in crucial functions of Neural Network training and recall.  While this part of the system remains in Alpha, it is substantially more fit for purpose.
2023-12-24 10:22:22 +01:00

158 lines
6.3 KiB
C#

// Accord Statistics Library
// The Accord.NET Framework
// http://accord-framework.net
//
// Copyright © César Souza, 2009-2017
// cesarsouza at gmail.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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 GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
namespace Accord.MachineLearning
{
/// <summary>
/// Common interface for data transformation algorithms. Examples of transformations include
/// <see cref="IClassifier{TInput, TClasses}">classifiers</see>, <see cref="IRegression{TInput, TOutputs}">
/// regressions</see> and other machine learning techniques.
/// </summary>
///
public interface ITransform
{
/// <summary>
/// Gets or sets the number of inputs accepted by the model.
/// </summary>
///
int NumberOfInputs
{
get;
set;
}
/// <summary>
/// Gets or sets the number of outputs generated by the model.
/// </summary>
///
int NumberOfOutputs
{
get;
set;
}
}
/// <summary>
/// Common interface for data transformation algorithms. Examples of transformations include
/// <see cref="IClassifier{TInput, TClasses}">classifiers</see>, <see cref="IRegression{TInput, TOutputs}">regressions</see>
/// and other machine learning techniques.
/// </summary>
///
/// <typeparam name="TInput">The type for the output data that enters in the model. Default is double[].</typeparam>
/// <typeparam name="TOutput">The type for the input data that exits from the model. Default is double[].</typeparam>
///
public interface ICovariantTransform<in TInput, out TOutput> : ITransform
{
/// <summary>
/// Applies the transformation to an input, producing an associated output.
/// </summary>
///
/// <param name="input">The input data to which the transformation should be applied.</param>
///
/// <returns>The output generated by applying this transformation to the given input.</returns>
///
TOutput Transform(TInput input);
/// <summary>
/// Applies the transformation to a set of input vectors,
/// producing an associated set of output vectors.
/// </summary>
///
/// <param name="input">The input data to which
/// the transformation should be applied.</param>
///
/// <returns>The output generated by applying this
/// transformation to the given input.</returns>
///
TOutput[] Transform(TInput[] input);
}
/// <summary>
/// Common interface for data transformation algorithms. Examples of transformations include
/// <see cref="IClassifier{TInput, TClasses}">classifiers</see>, <see cref="IRegression{TInput, TOutputs}">regressions</see>
/// and other machine learning techniques.
/// </summary>
///
/// <typeparam name="TInput">The type for the output data that enters in the model. Default is double[].</typeparam>
/// <typeparam name="TOutput">The type for the input data that exits from the model. Default is double[].</typeparam>
///
public interface ITransform<in TInput, TOutput> : ICovariantTransform<TInput, TOutput>
{
/// <summary>
/// Applies the transformation to a set of input vectors,
/// producing an associated set of output vectors.
/// </summary>
///
/// <param name="input">The input data to which
/// the transformation should be applied.</param>
/// <param name="result">The location to where to store the
/// result of this transformation.</param>
///
/// <returns>The output generated by applying this
/// transformation to the given input.</returns>
///
TOutput[] Transform(TInput[] input, TOutput[] result);
}
/// <summary>
/// Common interface for data transformation algorithms. Examples of transformations include
/// <see cref="IClassifier{TInput, TClasses}">classifiers</see>, <see cref="IRegression{TInput, TOutputs}">regressions</see>
/// and other machine learning techniques.
/// </summary>
///
/// <typeparam name="TInput">The type for the output data that enters in the model. Default is double[].</typeparam>
/// <typeparam name="TOutput">The type for the input data that exits from the model. Default is double[].</typeparam>
///
public interface IMultipleTransform<in TInput, TOutput> : ITransform<TInput, TOutput>
{
/// <summary>
/// Applies the transformation to a set of input vectors,
/// producing an associated set of output vectors.
/// </summary>
///
/// <param name="input">The input data to which
/// the transformation should be applied.</param>
/// <param name="result">The location to where to store the
/// result of this transformation.</param>
///
/// <returns>The output generated by applying this
/// transformation to the given input.</returns>
///
TOutput[] Transform(TInput[] input, TOutput result);
}
/// <summary>
/// Common interface for data transformation algorithms. Examples of transformations include
/// <see cref="IClassifier{TInput, TClasses}">classifiers</see>, <see cref="IRegression{TInput, TOutput}">regressions</see>
/// and other machine learning techniques.
/// </summary>
///
/// <typeparam name="TInput">The type for the output data that enters in the model.</typeparam>
///
public interface ITransform<TInput> : ITransform<TInput, double[]>
{
}
}