AI-NeuralNet-Mesh

 view release on metacpan or  search on metacpan

examples/ex_bmp.pl  view on Meta::CPAN

=begin

	File:   examples/ex_bmp.pl
	Author: Josiah Bryan, <jdb@wcoil.com>
	Desc:
	
		This demonstrates simple classification of 6x6 bitmaps.

=cut

	use AI::NeuralNet::Mesh;
	use Benchmark;

	# Set resolution
	my $xres=5;
	my $yres=5;
	
	# Create a new net with 3 layes, $xres*$yres inputs, and 1 output
	my $net = AI::NeuralNet::Mesh->new(1,$xres*$yres,1);
	
	# Enable debugging
	$net->debug(4);
	
	# Create datasets.
	my @data = ( 
		[	0,1,1,0,0,
			0,0,1,0,0,
			0,0,1,0,0,
			0,0,1,0,0,
			0,1,1,1,2	],		[	1	],
		
		[	1,1,1,0,0,
			0,0,0,1,0,
			0,1,1,1,0,
			1,0,0,0,0,
			1,1,1,1,2	],		[	2	],
		
		[	0,1,1,1,0,
			1,0,0,0,0,
			1,1,1,0,0,
			1,0,0,0,0,
			0,1,1,1,2	],		[	3	],
		
		[	1,0,0,1,0,
			1,0,0,1,0,
			1,1,1,1,0,
			0,0,0,1,0,
			0,0,0,1,2	],		[	4	],
		
		
		[	1,1,1,1,0,
			1,0,0,0,0,
			1,1,1,1,0,
			0,0,0,1,0,
			1,1,1,1,2	],		[	5	],
		
	);
    
    
	# If we havnt saved the net already, do the learning
	if(!$net->load('images.mesh')) {
		print "\nLearning started...\n";
		
		# Make it learn the whole dataset $top times
		my @list;
		my $top=3;
		for my $a (0..$top) {



( run in 0.760 second using v1.01-cache-2.11-cpan-39bf76dae61 )