def __init__(self, config): self.cfg = config self.target = [] self.inp = tf.placeholder(tf.float32, self.cfg.test_param_dims) self.initialized = False with tf.device('/gpu:0'): with tf.variable_scope("model", reuse=tf.AUTO_REUSE) as scope: self.model = cnn_model_struct() self.model.build(self.inp, self.cfg.test_param_dims[1:], self.cfg.output_hist_dims[1:], train_mode=False, verbose=False) self.gpuconfig = tf.ConfigProto() self.gpuconfig.gpu_options.allow_growth = True self.gpuconfig.allow_soft_placement = True self.saver = tf.train.Saver()
def __init__(self, config, max_iters=100, tol=1e-7, nsamples=1e5): self.max_iters = max_iters self.tol = tol self.N = nsamples self.cfg = config self.target = [] self.inf_batch_size = 50000 # placeholder for forward model self.forward_model_inpdims = [self.inf_batch_size] + self.cfg.param_dims[1:] self.forward_input = tf.placeholder(tf.float32, self.forward_model_inpdims) self.forward_initialized = False with tf.device('/gpu:0'): with tf.variable_scope("model", reuse=tf.AUTO_REUSE) as scope: # build the forward model self.forward_model = cnn_model_struct() self.forward_model.build(self.forward_input, self.cfg.param_dims[1:], self.cfg.output_hist_dims[1:], train_mode=False, verbose=False) self.gpuconfig = tf.ConfigProto() self.gpuconfig.gpu_options.allow_growth = True self.gpuconfig.allow_soft_placement = True self.saver = tf.train.Saver() self.forward_sess = tf.Session(config=self.gpuconfig) ckpts = tf.train.latest_checkpoint(self.cfg.model_output) self.saver.restore(self.forward_sess, ckpts) # placeholder for inverse model self.inv_model_inpdims = [1] + self.cfg.output_hist_dims[1:] self.inv_input = tf.placeholder(tf.float32, self.inv_model_inpdims) with tf.device('/gpu:1'): with tf.variable_scope("reversemodel", reuse=tf.AUTO_REUSE) as scope: # build the inverse model self.inv_model = cnn_reverse_model() self.inv_model.build(self.inv_input, self.cfg.output_hist_dims[1:], self.cfg.param_dims[1:], train_mode=False, verbose=False) self.gpuconfig1 = tf.ConfigProto() self.gpuconfig1.gpu_options.allow_growth = True self.gpuconfig1.allow_soft_placement = True self.saver1 = tf.train.Saver(var_list=tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope='reversemodel')) self.inv_sess = tf.Session(config=self.gpuconfig1) ckpts = tf.train.latest_checkpoint(os.path.join(self.cfg.base_dir, 'models', 'rev_'+self.cfg.model_name+'_training_data_binned_{}_nbins_{}_n_{}'.format(int(self.cfg.isBinned),self.cfg.nBins,self.cfg.nDatapoints)) ) self.saver1.restore(self.inv_sess, ckpts)
def __init__(self, config, max_iters=100, tol=1e-7, nsamples=1e5, tdist=False): if tdist: self.generateFromProposal = self.generateFromProposalTDist self.evalProposalByComponent = self.evalProposalByComponentTDist else: self.generateFromProposal = self.generateFromProposalNormal self.evalProposalByComponent = self.evalProposalByComponentNormal self.max_iters = max_iters self.tol = tol self.N = nsamples self.cfg = config self.target = [] self.inf_batch_size = 50000 # placeholder for forward model #self.forward_model_inpdims = [self.inf_batch_size] + self.cfg.param_dims[1:] self.forward_model_inpdims = [None] + self.cfg.param_dims[1:] self.forward_input = tf.placeholder(tf.float32, self.forward_model_inpdims) self.forward_initialized = False with tf.device('/gpu:0'): with tf.variable_scope("model", reuse=tf.AUTO_REUSE) as scope: # build the forward model self.forward_model = cnn_model_struct() self.forward_model.build(self.forward_input, self.cfg.param_dims[1:], self.cfg.output_hist_dims[1:], train_mode=False, verbose=False) self.gpuconfig = tf.ConfigProto() self.gpuconfig.gpu_options.allow_growth = True self.gpuconfig.allow_soft_placement = True self.saver = tf.train.Saver() self.forward_sess = tf.Session(config=self.gpuconfig) ckpts = tf.train.latest_checkpoint(self.cfg.model_output) self.saver.restore(self.forward_sess, ckpts) '''
def __init__(self,config): self.config = config self.input = tf.placeholder(tf.float32, [None,config.image_target_size[0],config.image_target_size[1],config.image_target_size[2]], name='ip_placeholder') self.initialized = False with tf.device('/gpu:0'): with tf.variable_scope("model") as scope: self.model = cnn_model_struct() self.model.build(self.input, config.num_classes, train_mode=False) self.gpuconfig = tf.ConfigProto() self.gpuconfig.gpu_options.allow_growth = True self.gpuconfig.allow_soft_placement = True self.saver = tf.train.Saver()