Beispiel #1
0
autoCollection FFNet_createIrisExample (long numberOfHidden1, long numberOfHidden2) {
	try {
		autoCollection c = Collection_create (classDaata, 3);
		autoCategories uniq = Categories_sequentialNumbers (3);
		autoFFNet me = FFNet_create (4, numberOfHidden1, numberOfHidden2, 3, 0);
		FFNet_setOutputCategories (me.peek(), uniq.peek());
		autostring32 name = FFNet_createNameFromTopology (me.peek());
		Thing_setName (me.peek(), name.peek());
		Collection_addItem_move (c.peek(), me.move());
		autoTableOfReal iris = TableOfReal_createIrisDataset ();

		/*
		 * Scale data to interval [0-1]
		 */
		for (long i = 1; i <= 150; i++) {
			for (long j = 1; j <= 4; j++) {
				iris -> data[i][j] /= 10.0;
			}
		}

		autoPattern ap;
		autoCategories ac;
		TableOfReal_to_Pattern_and_Categories (iris.peek(), 0, 0, 0, 0, & ap, & ac);
		Thing_setName (ap.peek(), U"iris");
		Thing_setName (ac.peek(), U"iris");
		Collection_addItem_move (c.peek(), ap.move());
		Collection_addItem_move (c.peek(), ac.move());
		return c;
	} catch (MelderError) {
		Melder_throw (U"Iris example not created.");
	}
}
Beispiel #2
0
Collection FFNet_createIrisExample (long numberOfHidden1, long numberOfHidden2)
{
	TableOfReal iris = NULL;
	Collection c = NULL;
	FFNet me = NULL;
	Pattern thee = NULL;
	Categories him = NULL, uniq = NULL;
	long i, j;
	MelderString ffnetname = { 0 };
	
	if (! (c = Collection_create (classData, 3)) ||
		! (uniq = Categories_sequentialNumbers (3)) ||
		! (me = FFNet_create (4, numberOfHidden1, numberOfHidden2, 3, 0)) ||
		! FFNet_setOutputCategories (me, uniq) ||
		! Collection_addItem (c, me) ||
		! (iris = TableOfReal_createIrisDataset ()) ||
		! TableOfReal_to_Pattern_and_Categories (iris, 0, 0, 0, 0, &thee, &him) ||
		! Collection_addItem (c, thee) ||
		! Collection_addItem (c, him)) goto end;
		
	/*
		Scale data to interval [0-1]
	*/
	for (i = 1; i <= 150; i++)
	{
		for (j = 1; j <= 4; j++) thy z[i][j] /= 10.0;
	}
	FFNet_createNameFromTopology (me, &ffnetname);
	Thing_setName (me, ffnetname.string);
	Thing_setName (thee, L"iris");
	Thing_setName (him, L"iris");
	MelderString_free (&ffnetname);
end:
	forget (uniq); forget (iris);
	if (! Melder_hasError()) return c;
	forget (c);
	return NULL;
}