1 Star 0 Fork 0

gmachine1729 / MineSweeperNeuralNet

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
trainModelBackground.py 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
from MineSweeperLearner import MineSweeperLearner
import imp
import sys, getopt
from keras.models import load_model
#called like this:
#python trainModelBackground.py -o [option] -m [model] -b [batches] -g [gamesPerBatch]
def main(argv):
option = ''
modelChoice = ''
nBatches = 1000
nSamples = 1000
epochsPerBatch = 1
try:
opts, args = getopt.getopt(argv, "ho:m:b:s:e:", ["option=", "model=", "batches=", "nSamples=", "epochsPerBatch="])
except getopt.GetoptError:
print('trainModelBackground.py -o <option> -m <model>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('trainModelBackground.py -o <option> -m <model>')
sys.exit()
elif opt in ("-o", "--option"):
option = arg
elif opt in ("-m", "--model"):
modelChoice = arg
elif opt in ("-b", "--batches"):
nBatches = int(arg)
elif opt in ("-s", "--nSamples"):
nSamples = int(arg)
elif opt in ("-e", "--epochsPerBatch"):
epochsPerBatch = int(arg)
if option == "trainNew":
modelSource = imp.load_source(modelChoice, "modelCode/" + modelChoice + ".py")
model = modelSource.model
elif option == "continueTraining":
model = load_model("trainedModels/" + modelChoice + ".h5")
learner = MineSweeperLearner(modelChoice, model)
learner.learnMineSweeper(nSamples, nBatches, epochsPerBatch, verbose=True)
learner.model.save("trainedModels/" + modelChoice + ".h5")
if __name__ == "__main__":
main(sys.argv[1:])
Python
1
https://gitee.com/gmachine1729/MineSweeperNeuralNet.git
git@gitee.com:gmachine1729/MineSweeperNeuralNet.git
gmachine1729
MineSweeperNeuralNet
MineSweeperNeuralNet
master

搜索帮助