Markov: let backwards chainer go randomly longer
the code, in a kind of trial state, would very quickly stop trying to work backwards. (part of this was for performance reasons, i believe.) since that seems to have proven stable, let's mess with it --- the backwards chainer can now go backwards a random distance, rather than just what almost always turned out to be 2
This commit is contained in:
parent
60ac4d25bd
commit
232eeccbcb
|
@ -383,10 +383,16 @@ class Markov(Module):
|
||||||
self.log.debug("working_backwards: {0:s}".format(" ".join(working_backwards)))
|
self.log.debug("working_backwards: {0:s}".format(" ".join(working_backwards)))
|
||||||
|
|
||||||
# now work backwards until we randomly bump into a start
|
# now work backwards until we randomly bump into a start
|
||||||
|
# to steer the chainer away from spending too much time on
|
||||||
|
# the weaker-context reverse chaining, we make max_size
|
||||||
|
# a non-linear distribution, making it more likely that
|
||||||
|
# some time is spent on better forward chains
|
||||||
|
max_back = random.randint(1, max_size/2) + random.randint(1, max_size/2)
|
||||||
|
self.log.debug("max_back: {0:d}".format(max_back))
|
||||||
while True:
|
while True:
|
||||||
key_hits = self._retrieve_k2_for_value(working_backwards[0], context_id)
|
key_hits = self._retrieve_k2_for_value(working_backwards[0], context_id)
|
||||||
if self.start2 in key_hits and len(working_backwards) > 2:
|
if self.start2 in key_hits and len(working_backwards) > max_back:
|
||||||
self.log.debug("working backwards forced start, finishing")
|
self.log.debug("max_back exceeded, cleanly finishing")
|
||||||
gen_words += working_backwards
|
gen_words += working_backwards
|
||||||
self.log.debug("gen_words: {0:s}".format(" ".join(gen_words)))
|
self.log.debug("gen_words: {0:s}".format(" ".join(gen_words)))
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue