当前位置: 首页>>代码示例>>Python>>正文


Python NeuralNetwork.build_from_array方法代码示例

本文整理汇总了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
开发者ID:LucasSimpson,项目名称:2048_Optimized,代码行数:6,代码来源:run.py

示例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)
开发者ID:LucasSimpson,项目名称:2048_Optimized,代码行数:31,代码来源:run.py


注:本文中的NeuralNetwork.NeuralNetwork.build_from_array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。