def run_clean(self, times = None): """Runs a generator so that output is clean, as if it came from corpus.""" if times is None: times = cf['eval_len'] for out in self.run_times(self.gen_input(self.input_size), times): # import pdb; pdb.set_trace() yield helpers.extremify(out)
def crosstrain(generator, classifier, learnrate, refdata, times): success = [None for i in xrange(times)] outs = [None for i in xrange(times)] states = [None for i in xrange(times)] classchanges = np.zeros_like(classifier.outnet) for i in xrange(times): (outs[i],states[i]) = generator.update_step() (success[i], classchange) = classifier.trainstep(helpers.extremify(outs[i]), -1) classchanges += learnrate/times * classchange smoothify_success(success) genchanges = np.zeros_like(generator.outnet) for (out, state, suc) in zip(outs, states, success): genchanges += learnrate/times * weightchange(out, helpers.extremify(suc * out), state) for (i,ref) in zip(xrange(times), refdata): (suc, classchange) = classifier.trainstep(ref, 1) classchanges += learnrate/times * classchange return (genchanges, classchanges)
def extremeRI(input_size): for i in randomInput(input_size): yield helpers.extremify(i)
def run_clean(self, times = None): """Runs a generator so that output is clean, as if it came from corpus.""" if times is None: times = cf['eval_len'] for out in run_times(self, self.gen_input, times): yield helpers.extremify(out)
def update_step(self, step_input): out = HistMatRNN.update_step(self, step_input) self.hist = np.vstack((self.hist[self.histentry_size:],helpers.extremify(out))) return out