728x90
반응형
#include <stdio.h>

void dnn_test();
void backward_WE(double* WE, double* X, double* YE, int M, int N);
void print(const char* s, double* W, int M, int N);

const int M = 2;
const int N = 2;

double X[N] = { 2, 3 };
double YE[M] = { -8, 60 };
double WE[M][N] = { 0, };

int main(void)
{
	dnn_test();
	
	return 0;
}

void dnn_test()
{
	backward_WE((double*)WE, X, YE, M, N);
	print("WE = ", (double*)WE, M, N);
}

void backward_WE(double* WE, double* X, double* YE, int M, int N)
{
	for (int m = 0; m < M; m++)
	{
		for (int n = 0; n < N; n++)
			WE[m * N + n] = X[m] * YE[n];
	}
}

void print(const char* s, double* W, int M, int N)
{
	printf("%s [\n", s);
	for (int m = 0; m < M; m++)
	{
		printf("[%s", s);
		for (int n = 0; n < N - 1; n++)
		{
			printf("%.3f", W[m * N + n]);
		}
		printf("%.3f]\n", W[m * N + N - 1]);
	}
	printf("]\n");
}

가중치 역전파

728x90
반응형

+ Recent posts