Programa para el testeo de las funciones.
Programa para el testeo de las funciones.Para compilar o código example_matrix_dsp.cpp:
g++ -static -o example_matrix_dsp example_matrix_dsp.cpp -lpdsramm
Para executar o programa:
Retornando por consola:
Kernel:
-2 -1 2
-1 2 -1
1 0 1
A:
-1 1 -1 -1
1 1 1 -1
1 -1 1 -1
1 -1 -1 -1
A.Conv2D(Kernel,{1,2},Pds::Ra::Full):
2 -1 -1
-1 3 2
-4 -1 -1
-2 3 -3
0 0 0
1 0 -1
Size: 6 3
A.Conv2D(Kernel,{1,2},Pds::Ra::Same):
-6 1
3 1
5 5
2 -2
Size: 4 2
A.Conv2D(Kernel,{1,2},Pds::Ra::Valid):
-1
3
Size: 2 1
Pds::Conv2DCh({A},{Kernel},{1,1},Pds::Ra::Valid):
-12 6 2 4
6 -2 2 -2
10 6 10 -6
4 0 -4 0
B:
0.53763086114909 0.36954202465847 0.56382463392773 -0.87250749271152 -0.22063468437125 -1.3938059648353 -0.7925277058445
2.1272209970701 -1.045855489402 0.86048864346136 0.74207001785205 1.1751184865889 0.56014623106965 0.32903772889095
0.70173766075107 -1.905261897823 -0.63665096203108 -0.79135165245963 -2.6824486717837 -0.45348322290476 -1.690088387007
-1.7069725340978 -0.1937252221851 0.79550396470808 2.2114365148602 -0.41858441148824 0.52398376859938 0.71464299753309
0.18499950771201 -0.34836253335879 0.19542993985296 1.594179139615 -0.13021434273628 -1.1966067981612 -1.4798431234144
-0.27753533109805 -2.1420249333082 1.4491131309758 -0.35020896503828 -0.59603183320483 -0.22929450773775 -1.9154266347738
0.42747694791413 0.27879006000266 -0.89826698130826 1.2833339393308 -1.0881298971793 -2.1083453076835 -1.474986100036
B.MaxPooling(3,3):
2.1272209970701 1.1751184865889 0.32903772889095
1.4491131309758 2.2114365148602 0.71464299753309
0.42747694791413 1.2833339393308 -1.474986100036
Block[0]:
2.1272209970701 1.1751184865889 0.32903772889095
1.4491131309758 2.2114365148602 0.71464299753309
0.42747694791413 1.2833339393308 -1.474986100036
Block[1]:
2.1272209970701 1.1751184865889 0.32903772889095
1.4491131309758 2.2114365148602 0.71464299753309
0.42747694791413 1.2833339393308 -1.474986100036
Código example_matrix_dsp.cpp:
#include <Pds/Ra>
int main(void)
{
"-1 2 -1\n"
" 1 0 1");
Kernel.
Print(
"Kernel:\n");
" 1 1 1 -1\n"
" 1 -1 1 -1\n"
" 1 -1 -1 -1");
Ans.
Print(
"\nA.Conv2D(Kernel,{1,2},Pds::Ra::Full):\n");
Ans.
Print(
"\nA.Conv2D(Kernel,{1,2},Pds::Ra::Same):\n");
Ans.
Print(
"\nA.Conv2D(Kernel,{1,2},Pds::Ra::Valid):\n");
Ans.
Print(
"\nPds::Conv2DCh({A},{Kernel},{1,1},Pds::Ra::Valid):\n");
Block[0].Print("Block[0]:\n");
Block[1].Print("Block[1]:\n");
return 0;
}
La clase tipo Pds::Matrix . Esta clase genera una matriz de Nlin lineas y Ncol columnas....
Pds::Matrix RandN(unsigned int N)
Crea una matriz con datos aleatórios con distribución Normal de media cero 0.0 y desvío padrón 1....
Pds::Matrix Conv2DCh(const std::vector< Pds::Matrix > &A, const std::vector< Pds::Matrix > &Kernel, const std::vector< unsigned int > &Strides={1, 1}, Pds::Ra::Padding Padding=Pds::Ra::Valid)
Calcula la convolución de todos los canales entre A y Kernel.
Pds::Matrix MaxPooling(unsigned int LinPool, unsigned int ColPool) const
Aplica max pooling de la matriz de lineas y columnas.
Pds::Matrix Conv2D(const Pds::Matrix &B, const std::vector< unsigned int > &Strides={1, 1}, Pds::Ra::Padding Padding=Pds::Ra::Full) const
Calcula la convolución entre A y B.
static std::vector< Pds::Matrix > MaxPoolingSampleBlock(const std::vector< Pds::Matrix > &A, unsigned int LinPool, unsigned int ColPool)
Aplica max pooling a cada matriz de lineas y columnas.
static Pds::Size Conv2DOutputSize(const Pds::Size &A, const Pds::Size &B, const std::vector< unsigned int > &Strides, Pds::Ra::Padding Padding)
Calcula el tamaño de la matriz resultado de la convolucion de A y B.
Pds::Size Size(void) const
Retorna un objeto de tipo Pds::Size con el número de lineas y columans.
std::vector< Pds::Matrix > SampleBlock
Definición de un tipo de dato Pds::SampleBlock.
void Print(const std::string &str, unsigned int precision) const
Imprime en pantalla el contenido de la matriz después del texto indicado en str.