Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- maxGENS=200
- allfits = []
- allrates = []
- parent = ANN()
- parentfit = -9999.0 # We don't know this yet.
- for generation in range(maxGENS) :
- children = []
- mrate = 0.05
- for repc in range(12) :
- gchild = ANNDuplicate(parent)
- if( (generation==0) and (repc==0) ) :
- gchild = gchild # Smuggle the parent.
- else :
- gchild.Mutate(mrate)
- children.append(gchild)
- mrate = mrate + 0.01 # use a spectrum of rates.
- time_start = time.time()
- fitpool = FitnessGlobal_Get( children ) # pass the whole list for testing.
- time_end = time.time()
- elapsed = time_end - time_start
- if( elapsed > 0.01 ) :
- ratepermin = 60.0 / elapsed
- else :
- ratepermin = 5455.0
- allrates.append(12.0 * ratepermin)
- if( generation == 0 ) :
- parentfit = fitpool[0]
- allfits.append(parentfit)
- # Consider the child with the highest fitness amongst the children.
- childfit = max( fitpool )
- hi = fitpool.index( childfit )
- child = children[hi]
- # print fitpool # debug
- verbosim = "gen={} , {} , {} , {}".format(generation , childfit , parentfit, elapsed)
- print(verbosim)
- if(childfit>parentfit) :
- parentfit=childfit
- parent = ANNDuplicate(child)
- bestWFN = "bestweights_{}.dat".format(generation)
- parent.Send_Synapse_Weights_ToFile(bestWFN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement