Пример #1
0
    def __init__(self,
                 model_file="128x10-t60-2-5300.pb.gz",
                 cfg_file="configs/example.yaml"):

        with open(cfg_file, "rb") as f:
            cfg = f.read()

        cfg = yaml.safe_load(cfg)
        print(yaml.dump(cfg, default_flow_style=False))

        tfp = tfprocess.TFProcess(cfg, gpu=True)
        tfp.init_net_v2()
        tfp.replace_weights_v2(model_file)

        self.model = tfp.model
Пример #2
0
    def __init__(self, weights_filename):
        filters, blocks, weights = read_weights_file(weights_filename)
        cfg = yaml.safe_load(YAMLCFG)
        cfg['model']['filters'] = filters
        cfg['model']['residual_blocks'] = blocks
        cfg['name'] = 'online-{}x{}'.format(filters, blocks)
        print(yaml.dump(cfg, default_flow_style=False))

        x = [
            tf.placeholder(tf.float32, [None, 112, 8 * 8]),
            tf.placeholder(tf.float32, [None, 1858]),
            tf.placeholder(tf.float32, [None, 1])
        ]

        self.tfp = tfprocess.TFProcess(cfg)
        self.tfp.init_net(x)
        self.tfp.replace_weights(weights)
Пример #3
0
    help='Net file to be converted to a model checkpoint.')
argparser.add_argument('--start', type=int, default=0,
    help='Offset to set global_step to.')
args = argparser.parse_args()
START_FROM = args.start
net = Net()
net.parse_proto(args.net)

filters, blocks = net.filters(), net.blocks()
cfg['model']['filters'] = filters
cfg['model']['residual_blocks'] = blocks
cfg['name'] = 'online-{}x{}'.format(filters, blocks)
weights = net.get_weights()

print(yaml.dump(cfg, default_flow_style=False))

x = [
    tf.placeholder(tf.float32, [None, 112, 8*8]),
    tf.placeholder(tf.float32, [None, 1858]),
    tf.placeholder(tf.float32, [None, 1])
    ]

tfp = tfprocess.TFProcess(cfg)
tfp.init_net(x)
tfp.replace_weights(weights)
path = os.path.join(os.getcwd(), cfg['name'])
update_global_step = tfp.global_step.assign(START_FROM)
tfp.session.run(update_global_step)
save_path = tfp.saver.save(tfp.session, path, global_step=START_FROM)
print("Writted model to {}".format(path))
Пример #4
0
import tfprocess as tfp
import weights
import numpy as np

m = weights.model()

tfprocess = tfp.TFProcess()
tfprocess.init_net(m[0], m[1], m[2])
planes = np.zeros((1, 18, 19, 19))
#planes[0][15][3][3] =  1
planes[0][17] = np.ones((19, 19))
y_out, z_out = tfprocess.submit(planes)
print "vic %s " % z_out[0]
index = np.argmax(y_out, axis=None)
print "best move (%s,%s)" % (int(index / 19) + 1, (index % 19) + 1)