资源简介
自动训练厉害的高分游戏。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
代码片段和文件信息
#!/usr/bin/env python
from __future__ import print_function
import tensorflow as tf
import cv2
import sys
sys.path.append(“game/“)
import wrapped_flappy_bird as game
import random
import numpy as np
from collections import deque
GAME = ‘bird‘ # the name of the game being played for log files
ACTIONS = 2 # number of valid actions
GAMMA = 0.99 # decay rate of past observations
OBSERVE = 100000. # timesteps to observe before training
EXPLORE = 2000000. # frames over which to anneal epsilon
FINAL_EPSILON = 0.0001 # final value of epsilon
INITIAL_EPSILON = 0.0001 # starting value of epsilon
REPLAY_MEMORY = 50000 # number of previous transitions to remember
BATCH = 32 # size of minibatch
frame_PER_ACTION = 1
def weight_variable(shape):
initial = tf.truncated_normal(shape stddev = 0.01)
return tf.Variable(initial)
def bias_variable(shape):
initial = tf.constant(0.01 shape = shape)
return tf.Variable(initial)
def conv2d(x W stride):
return tf.nn.conv2d(x W strides = [1 stride stride 1] padding = “SAME“)
def max_pool_2x2(x):
return tf.nn.max_pool(x ksize = [1 2 2 1] strides = [1 2 2 1] padding = “SAME“)
def createNetwork():
# network weights
W_conv1 = weight_variable([8 8 4 32])
b_conv1 = bias_variable([32])
W_conv2 = weight_variable([4 4 32 64])
b_conv2 = bias_variable([64])
W_conv3 = weight_variable([3 3 64 64])
b_conv3 = bias_variable([64])
W_fc1 = weight_variable([1600 512])
b_fc1 = bias_variable([512])
W_fc2 = weight_variable([512 ACTIONS])
b_fc2 = bias_variable([ACTIONS])
# input layer
s = tf.placeholder(“float“ [None 80 80 4])
# hidden layers
h_conv1 = tf.nn.relu(conv2d(s W_conv1 4) + b_conv1)
h_pool1 = max_pool_2x2(h_conv1)
h_conv2 = tf.nn.relu(conv2d(h_pool1 W_conv2 2) + b_conv2)
#h_pool2 = max_pool_2x2(h_conv2)
h_conv3 = tf.nn.relu(conv2d(h_conv2 W_conv3 1) + b_conv3)
#h_pool3 = max_pool_2x2(h_conv3)
#h_pool3_flat = tf.reshape(h_pool3 [-1 256])
h_conv3_flat = tf.reshape(h_conv3 [-1 1600])
h_fc1 = tf.nn.relu(tf.matmul(h_conv3_flat W_fc1) + b_fc1)
# readout layer
readout = tf.matmul(h_fc1 W_fc2) + b_fc2
return s readout h_fc1
def trainNetwork(s readout h_fc1 sess):
# define the cost function
a = tf.placeholder(“float“ [None ACTIONS])
y = tf.placeholder(“float“ [None])
readout_action = tf.reduce_sum(tf.multiply(readout a) reduction_indices=1)
cost = tf.reduce_mean(tf.square(y - readout_action))
train_step = tf.train.AdamOptimizer(1e-6).minimize(cost)
# open up a game state to communicate with emulator
game_state = game.GameState()
# store the previous observations in replay memory
D = deque()
# printing
a_file = open(“logs_“ + GAME + “/readout.txt“ ‘w‘)
h_file = open(“logs_“ + GAME + “/hidden.txt“ ‘w‘)
# get the first state by doing nothing and preprocess the image to 80x80x4
do_noth
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-02-28 10:19 DeepLearningFlappyBird-master\
文件 31 2017-02-28 10:19 DeepLearningFlappyBird-master\.gitignore
文件 6241 2017-02-28 10:19 DeepLearningFlappyBird-master\README.md
目录 0 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\
目录 0 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\audio\
文件 17483 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\audio\die.ogg
文件 194894 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\audio\die.wav
文件 15670 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\audio\hit.ogg
文件 96590 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\audio\hit.wav
文件 13235 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\audio\point.ogg
文件 177486 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\audio\point.wav
文件 13697 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\audio\swoosh.ogg
文件 354638 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\audio\swoosh.wav
文件 7728 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\audio\wing.ogg
文件 29902 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\audio\wing.wav
目录 0 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\
文件 2879 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\0.png
文件 2868 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\1.png
文件 2888 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\2.png
文件 2877 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\3.png
文件 2898 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\4.png
文件 2888 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\5.png
文件 2885 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\6.png
文件 2896 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\7.png
文件 2878 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\8.png
文件 2892 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\9.png
文件 4030 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\background-black.png
文件 664 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\ba
文件 5042 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\pipe-green.png
文件 2948 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\redbird-downflap.png
文件 2949 2017-02-28 10:19 DeepLearningFlappyBird-master\assets\sprites\redbird-midflap.png
............此处省略26个文件信息
- 上一篇:宠物管理系统宠物医院管理系统免费宠物系统
- 下一篇:2019最新微信大屏幕系统
相关资源
- 6种用于人脸识别的人脸数据库
- 模式识别——人脸识别
- cpp-基于MXNetC框架的CPU实时人脸识别
- AU人脸图像,对做人脸识别的同学们有
- 人脸识别 技术
- point-04 多姿态人脸库
- Dlib 编译好的Lib
- Dlib FaceLandmark Detector 1.2.8.rar
- Dlib FaceLandmark Detector 1.2.5
- 人脸识别系统 开源技术大作业
- 人脸识别含原理、论文和源代码
- 人脸负样本图片
- 人脸识别教程非常全面
- opencv3.2 + contrib3.2完整编译
- 通过SpringMvc和百度AI实现人脸识别
- 虹软人脸识别 SDK+Demo
- 人脸照片数据,提供测试学习
- 百度人脸识别API
- opencv人脸识别demo并保存头像小照片
- 基于ARMLinux的智能门禁系统论文,优秀
- PIE人脸识别数据库jpg版
- OpenCV人脸识别-3.0
- Qt+OpenCV人脸识别
- 人脸识别库包括Yale,ORL,MIT,AT&T人脸
- 毕业设计:基于ARM-Linux的应用OpenCV和
- 人脸识别,基于VS+openCV
- 人脸识别集成包.zip
- MTCNN人脸检测应用代码
- qt+opencv+人脸识别
- 人脸性别识别数据库
评论
共有 条评论