本文整理汇总了Python中evaluator.Evaluator.eval_multi方法的典型用法代码示例。如果您正苦于以下问题:Python Evaluator.eval_multi方法的具体用法?Python Evaluator.eval_multi怎么用?Python Evaluator.eval_multi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类evaluator.Evaluator
的用法示例。
在下文中一共展示了Evaluator.eval_multi方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TrainManager
# 需要导入模块: from evaluator import Evaluator [as 别名]
# 或者: from evaluator.Evaluator import eval_multi [as 别名]
#.........这里部分代码省略.........
self.preproc_func = preproc_func
def _init_inputs(self):
preproc_func = self.preproc_func
input_shape = self.input_shape
# Define input TF placeholder
with tf.device('/gpu:0'):
x_pre = tf.placeholder(tf.float32, shape=input_shape, name='x')
x = preprocess_batch(x_pre, preproc_func)
y = tf.placeholder(tf.float32, shape=(self.batch_size, 10),
name='y')
self.g0_inputs = {'x_pre': x_pre, 'x': x, 'y': y}
def _init_model(self):
flags = self.hparams.__dict__
# Define TF model graph
model = make_model(input_shape=self.input_shape, **flags)
model.set_device(None)
self.model = model
def _init_eval(self):
logging.info("Init eval")
x_pre, x, y = [self.g0_inputs[k] for k in ['x_pre', 'x', 'y']]
self.model.set_device('/gpu:0')
self.evaluate = Evaluator(self.sess, self.model, self.batch_size,
x_pre, x, y,
self.data,
self.writer,
self.hparams)
def eval(self, **kwargs):
if self.evaluate is not None:
self.report = self.evaluate.eval_multi()
def finish(self):
if self.writer:
self.writer.close()
return self.report
def _update_learning_params(self):
model = self.model
hparams = self.hparams
fd = self.runner.feed_dict
step_num = self.step_num
if hparams.model_type == 'resnet_tf':
if step_num < hparams.lrn_step:
lrn_rate = hparams.mom_lrn
elif step_num < 30000:
lrn_rate = hparams.mom_lrn/10
elif step_num < 35000:
lrn_rate = hparams.mom_lrn/100
else:
lrn_rate = hparams.mom_lrn/1000
fd[model.lrn_rate] = lrn_rate
def _build_train_op(self, predictions, y, predictions_adv):
model = self.model
hparams = self.hparams
if hparams.model_type == 'resnet_tf':
build_train_op = model.build_cost
else:
build_train_op = attack_softmax_cross_entropy