Beispiel #1
0
def test2():

    print "test 2: train from file, codes init. from data"
    print "----------------------------------------------"
    data = csom.open_entries(in_data_file)
    if (data == "NULL"):
        print "\ndata file " + in_data_file + " could not be opened"
        return 1
    codes = csom.randinit_codes(data, csom.TOPOL_HEXA, csom.NEIGH_BUBBLE, 12,
                                8)
    params = csom.construct_teach_params(codes, csom.LINEAR, csom.LINEAR)
    csom.init_training_session(params, alpha, radius, rlen, ewin)
    csom.timing_start(params)
    csom.train_fromdataset(params, data, csom.CYCLIC)
    csom.timing_stop(params)
    time = csom.get_training_time(params)
    print "training session completed in", time, "seconds"
    error = csom.write_entries(codes, out_code_file2)
    if (error):
        print "\nfile " + out_code_file2 + " could not be written"
        return 1
    print "output written to " + out_code_file2

    # cleanup
    csom.close_entries(data)
    csom.close_entries(codes)
    csom.free_teach_params(params)  # WKV 2003-07-28

    print "test 2 succesfully completed"
    return 0
Beispiel #2
0
def test2():
	
	print "test 2: train from file, codes init. from data"
	print "----------------------------------------------"
	data = csom.open_entries(in_data_file)
	if (data == "NULL"):
		print "\ndata file " + in_data_file + " could not be opened"
		return 1
	codes = csom.randinit_codes(data,csom.TOPOL_HEXA,csom.NEIGH_BUBBLE,12,8)
	params = csom.construct_teach_params(codes, csom.LINEAR, csom.LINEAR)
	csom.init_training_session(params, alpha, radius, rlen, ewin)
	csom.timing_start(params)
	csom.train_fromdataset(params, data, csom.CYCLIC)
	csom.timing_stop(params)
	time = csom.get_training_time(params)
	print "training session completed in", time, "seconds"
	error = csom.write_entries(codes, out_code_file2)
	if (error):
		print "\nfile " + out_code_file2 + " could not be written"
		return 1
	print "output written to " + out_code_file2

	# cleanup
	csom.close_entries(data)
	csom.close_entries(codes)
	csom.free_teach_params(params) # WKV 2003-07-28
	
	print "test 2 succesfully completed"
	return 0
Beispiel #3
0
def test1():
    # test 1:
    # SOM's model vectors are read in from ex.cod.  SOM is then trained using
    # a dataset created from ex.dat.  After training, model vectors are saved to
    # test1.cod.

    print "test 1: codes from file, train from file"
    print "----------------------------------------"
    data = csom.open_entries(in_data_file)
    if (data == "NULL"):
        print "\ndata file " + in_data_file + " could not be opened"
        return 1
    codes = csom.open_entries(in_code_file)
    if (codes == "NULL"):
        print "\ncode file " + in_code_file + " could not be opened"
        return 1
    params = csom.construct_teach_params(codes, csom.LINEAR, csom.LINEAR)
    csom.init_training_session(params, alpha, radius, rlen, ewin)
    csom.timing_start(params)
    csom.train_fromdataset(params, data, csom.CYCLIC)
    csom.timing_stop(params)
    time = csom.get_training_time(params)
    print "training session completed in", time, "seconds"
    error = csom.write_entries(codes, out_code_file1)
    if (error):
        print "\nfile " + out_code_file1 + " could not be written"
        return 1
    print "output written to " + out_code_file1
    print "for verification, see test_devrobs.c output"

    # cleanup
    csom.close_entries(data)
    csom.close_entries(codes)
    csom.free_teach_params(params)  # WKV 2003-07-28

    print "test 1 succesfully completed"
    return 0
Beispiel #4
0
def test1():
	# test 1:
	# SOM's model vectors are read in from ex.cod.  SOM is then trained using
	# a dataset created from ex.dat.  After training, model vectors are saved to
	# test1.cod.
	
	print "test 1: codes from file, train from file"
	print "----------------------------------------"
	data = csom.open_entries(in_data_file)
	if (data == "NULL"):
		print "\ndata file " + in_data_file + " could not be opened"
		return 1
	codes = csom.open_entries(in_code_file)
	if (codes == "NULL"):
		print "\ncode file " + in_code_file + " could not be opened"
		return 1
	params = csom.construct_teach_params(codes, csom.LINEAR, csom.LINEAR)
	csom.init_training_session(params, alpha, radius, rlen, ewin)
	csom.timing_start(params)
	csom.train_fromdataset(params, data, csom.CYCLIC)
	csom.timing_stop(params)
	time = csom.get_training_time(params)
	print "training session completed in", time, "seconds"
	error = csom.write_entries(codes, out_code_file1)
	if (error):
		print "\nfile " + out_code_file1 + " could not be written"
		return 1
	print "output written to " + out_code_file1
	print "for verification, see test_devrobs.c output"

	# cleanup
	csom.close_entries(data)
	csom.close_entries(codes)
	csom.free_teach_params(params) # WKV 2003-07-28
	
	print "test 1 succesfully completed"
	return 0