Exemple #1
0
                  train_ratio=model_config.train_ratio,
                  device=device)

log_dir = os.path.join('saves', config.model)
# Initialize Logger class
logger = Logger(log_dir)
model_config.save(os.path.join(logger.log_dir, 'config.json'))
# Get the position and target of the evaluated item
eval_pos, eval_target = dataset.eval_data()
# Get the popularity item
item_popularity = dataset.item_popularity
# Initialize Evaluator class
evaluator = Evaluator(eval_pos, eval_target, item_popularity,
                      model_config.top_k)
# Build the model
model = build_model(config.model, model_config, dataset.num_users,
                    dataset.num_items, device)
# Get the model info and data info
logger.info(model_config)
logger.info(dataset)

# Initialize Trainer class
trainer = Trainer(dataset=dataset,
                  model=model,
                  evaluator=evaluator,
                  logger=logger,
                  conf=model_config)
# Train the model and get results
trainer.train(experiment)

# Dictionary to store model hyper-parameters
hyper_params = {
import tensorflow as tf
from Environment import *
from ModelBuilder import build_model
import os

tf.reset_default_graph()

layers = [729, 729, 729]
inputs, Q_out, predict = build_model(9, layers, 9)

sess = tf.Session()
env = Environment()

saver = tf.train.Saver()

init = tf.global_variables_initializer()
sess.run(init)

checkpoint = tf.train.get_checkpoint_state("model")
if checkpoint and checkpoint.model_checkpoint_path:
    s = saver.restore(sess, checkpoint.model_checkpoint_path)
    print("Successfully loaded the model:", checkpoint.model_checkpoint_path)
    step = int(
        os.path.basename(checkpoint.model_checkpoint_path).split('-')[1])
else:
    print("Could not find old network weights")

player = env.O
turn = get_first_turn()
done = False
state = get_new_board()