Ejemplo n.º 1
0
int main()
{
RBM *a = new RBM;

//a->input(stdin);
// for xor
a->build(2,2);  
int x[2],y[2],s[2],sz[2];
x[0] = -1;
x[1] =  1;
y[0] =  1;
y[1] = -1;
s[0] =  1;
s[1] =  1;
sz[0] = -1;
sz[1] = -1;
for( int i=0; i< 100; i++)
	{
a->train((float)1.001,2,x);
a->train((float)1.001,2,y);
printf( "xor %f %f same %f %f\n",a->energy(2,x),a->energy(2,y),a->energy(2,s),a->energy(2,sz));

a->dump(stdout);
	}

s[1] = 0;
a->fillin(2,s);
printf("%d %d\n",s[0],s[1]);
}
int main()
{
RBM *a = new RBM;

//a->input(stdin);
// for xor
a->build(1,4);  
int x[4],y[4],s[4],sz[4];
for( int i=0; i< 4; i++)
{
	x[i] = 1;
	y[i] = -1;
	s[i] = 1;
	sz[i] = -1;
}
for( int i=0; i<4; i+=3)
{
	x[i] = -1;
	y[i] =  1;
}
for( int i=0; i< 100; i++)
	{
a->train((float)1.001,4,x);
a->train((float)1.001,4,y);
printf( "xor %f %f same %f %f\n",a->energy(4,x),a->energy(4,y),a->energy(4,s),a->energy(4,sz));

a->dump(stdout);
	}

}