没有会话工厂为给定的会话选项注册:{target:“master”config:}?

时间:2017-09-29 13:40:42

标签: tensorflow

看看我的代码:

def SessionManager_restore_test():
    '''
        In the model_ckpt/slim_train_init_fn_test.ckpt,
        {'x/y': 1.0, 'x/z': 2.0, 'y/z': 3.0}
    '''
    x_y = slim.variable('x/y', initializer=4.0)
    x_z = slim.variable('x/z', initializer=5.0)
    y_z = slim.variable('y/z', initializer=6.0)
    sm = tf.train.SessionManager()
    sess = sm.prepare_session(master='',
                              checkpoint_filename_with_path='model_ckpt/slim_train_init_fn_test.ckpt',
                              saver=tf.train.Saver())
    _x_y, _x_z, _y_z = sess.run([x_y, x_z, y_z])
    print(_x_y, _x_z, _y_z)

如果我将master从''更改为'master',则会引发错误:

tensorflow.python.framework.errors_impl.NotFoundError: No session factory regist
ered for the given session options: {target: "master" config: } Registered facto
ries are {DIRECT_SESSION, GRPC_SESSION}.

缺少哪一步?如何解决?

1 个答案:

答案 0 :(得分:0)

如果要手动指定主服务器,可以通过指定其地址来执行此操作,例如:

config = tf.contrib.learn.RunConfig(master='grpc://localhost:2222',...)