代码拉取完成,页面将自动刷新
import os
from prototpye.dynamic_network import DynamicNetwork
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
''' Normalization in TensorFlow '''
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
import numpy as np
import scipy.ndimage as ndimage
import lib.config as C
from sklearn import preprocessing
def cut_file(record_path):
f = open(record_path, "r")
lines = f.readlines()
last_line = lines[-1]
print(last_line)
f.close()
f = open(record_path + ".change", "w")
for line in lines:
if line != last_line:
f.write(line)
f.close()
def train(record_path, is_restore=False, is_norm=False):
# train model
config = tf.ConfigProto(
allow_soft_placement=True, log_device_placement=False,
)
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)
model_path = "./model/" + "20190218-182616" + "_dynamic/"
dynamic_net = DynamicNetwork(name='train', sess=sess, load_path=model_path)
dynamic_net.initialize()
if is_restore:
dynamic_net.restore_tech()
model_data = np.loadtxt(record_path)
sample_num = model_data.shape[0]
print('sample_num:', sample_num)
print('sample_data:', model_data[0])
print('sample_data:', model_data[-1])
observations = model_data[:, :C._SIZE_SIMPLE_INPUT]
tech_actions = model_data[:, C._SIZE_SIMPLE_INPUT:C._SIZE_SIMPLE_INPUT + 1]
next_observations = model_data[:, C._SIZE_SIMPLE_INPUT + 1:]
tech_actions = np.squeeze(tech_actions, axis=1)
dynamic_net.SL_train_tech_net(observations, tech_actions, next_observations, batch_size=5000, iter_num=10000, lr=1e-3)
if __name__ == "__main__":
# simple_test()
record_path = "../shared_data/record.txt"
# cut_file(record_path)
train(record_path + ".change", False)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。