continue rgb = [int(x) for x in entry[1:4]] word = entry[4][:-1] learnerB.learn(word, Expression(["COLOUR", "r_%d" % rgb[0], "g_%d" % rgb[1], "b_%d" % rgb[2] ])) # pick sample of N random colours test_colours = [ (random.randint(0,255), random.randint(0,255), random.randint(0,255)) for i in range(args.num_test_samples)] logger.log_points("langA", test_colours) logger.mean("langA") # generation simulation for generation in range(1,args.generations): learnerA = learnerB learnerB = gauss_colour.GaussianColourSemantics("L_%d" % generation, creative=True) logger.learner = learnerB # train L(i+1) (B) from L(i) (A) for i in range(0, args.num_train_samples): (word, meaning) = learnerA.say_something() learnerB.learn(word, meaning) # output sample from trained L(i+1)
logger = logger.colour_logger.ColourLogger(learnerA) # train A from stdin for line in fileinput.input(): entry = line.split(",") if entry[0] == "lang.name": continue rgb = [int(x) for x in entry[1:4]] word = entry[4][:-1] learnerA.learn(word, pack_expression(rgb)) # pick sample of N random colours (in blue subspace) test_colours = [pick_random_blue() for i in range(NUM_SAMPLES)] # output for learner A logger.log_points("langA", test_colours) logger.learner = learnerB # iteratively train learner B on A's utterances (N iterations) for i in range(0, TRAINING_ITERATIONS): meaning = pack_expression(pick_random_blue()) word = learnerA.word_for(meaning) learnerB.learn(word, meaning) if i % SKIP == 0: logger.log_points("langB_%02d" % i, test_colours)