本文整理汇总了Python中NeuralNetwork.NeuralNetwork.build_from_array方法的典型用法代码示例。如果您正苦于以下问题:Python NeuralNetwork.build_from_array方法的具体用法?Python NeuralNetwork.build_from_array怎么用?Python NeuralNetwork.build_from_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NeuralNetwork.NeuralNetwork
的用法示例。
在下文中一共展示了NeuralNetwork.build_from_array方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_fitness_score
# 需要导入模块: from NeuralNetwork import NeuralNetwork [as 别名]
# 或者: from NeuralNetwork.NeuralNetwork import build_from_array [as 别名]
def get_fitness_score (self, genotype):
nn = NeuralNetwork (LAYERS)
nn.build_from_array (genotype)
return 1.0 * sum ([play_game (nn) for a in range (self.games)]) / self.games
示例2: random_gene
# 需要导入模块: from NeuralNetwork import NeuralNetwork [as 别名]
# 或者: from NeuralNetwork.NeuralNetwork import build_from_array [as 别名]
def random_gene (self):
return random.random () * 2 - 1
class GeneticAlgorithm2048Threaded (ThreadedBaseGeneticAlgorithm):
percent_pop_kept = 0.08
def create_genotype (self):
return Genotype2048 ()
class GeneticAlgorithm2048 (BaseGeneticAlgorithm):
percent_pop_kept = 0.08
def create_genotype (self):
return Genotype2048 ()
ga = GeneticAlgorithm2048Threaded (200)
while (True):
ga.epoch ()
genotype = ga.alpha ()
nn = NeuralNetwork (LAYERS)
nn.build_from_array (genotype)
while (raw_input ('play game? (y/n) ') == 'y'):
play_game (nn, visual=True)