Python layers.predictions() Examples
The following are 18
code examples of layers.predictions().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
layers
, or try the search function
.
Example #1
Source File: graphs.py From object_detection_kitti with Apache License 2.0 | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False, bidir=True) embedded = [self.layers['embedding'](inp.tokens) for inp in inputs] _, next_states, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) f_inputs, _ = inputs eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), f_inputs.labels, f_inputs.weights) } # Save states on accuracy update saves = [inp.save_state(state) for (inp, state) in zip(inputs, next_states)] with tf.control_dependencies(saves): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #2
Source File: graphs.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False, bidir=True) embedded = [self.layers['embedding'](inp.tokens) for inp in inputs] _, next_states, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) f_inputs, _ = inputs eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), f_inputs.labels, f_inputs.weights) } # Save states on accuracy update saves = [inp.save_state(state) for (inp, state) in zip(inputs, next_states)] with tf.control_dependencies(saves): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #3
Source File: graphs.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False) embedded = self.layers['embedding'](inputs.tokens) _, next_state, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) if FLAGS.single_label: indices = tf.stack([tf.range(FLAGS.batch_size), inputs.length - 1], 1) labels = tf.expand_dims(tf.gather_nd(inputs.labels, indices), 1) weights = tf.expand_dims(tf.gather_nd(inputs.weights, indices), 1) else: labels = inputs.labels weights = inputs.weights eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), labels, weights) } with tf.control_dependencies([inputs.save_state(next_state)]): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #4
Source File: graphs.py From models with Apache License 2.0 | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False, bidir=True) embedded = [self.layers['embedding'](inp.tokens) for inp in inputs] _, next_states, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) f_inputs, _ = inputs eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), f_inputs.labels, f_inputs.weights) } # Save states on accuracy update saves = [inp.save_state(state) for (inp, state) in zip(inputs, next_states)] with tf.control_dependencies(saves): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #5
Source File: graphs.py From models with Apache License 2.0 | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False) embedded = self.layers['embedding'](inputs.tokens) _, next_state, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) if FLAGS.single_label: indices = tf.stack([tf.range(FLAGS.batch_size), inputs.length - 1], 1) labels = tf.expand_dims(tf.gather_nd(inputs.labels, indices), 1) weights = tf.expand_dims(tf.gather_nd(inputs.weights, indices), 1) else: labels = inputs.labels weights = inputs.weights eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), labels, weights) } with tf.control_dependencies([inputs.save_state(next_state)]): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #6
Source File: graphs.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False, bidir=True) embedded = [self.layers['embedding'](inp.tokens) for inp in inputs] _, next_states, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) f_inputs, _ = inputs eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), f_inputs.labels, f_inputs.weights) } # Save states on accuracy update saves = [inp.save_state(state) for (inp, state) in zip(inputs, next_states)] with tf.control_dependencies(saves): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #7
Source File: graphs.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False) embedded = self.layers['embedding'](inputs.tokens) _, next_state, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) if FLAGS.single_label: indices = tf.stack([tf.range(FLAGS.batch_size), inputs.length - 1], 1) labels = tf.expand_dims(tf.gather_nd(inputs.labels, indices), 1) weights = tf.expand_dims(tf.gather_nd(inputs.weights, indices), 1) else: labels = inputs.labels weights = inputs.weights eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), labels, weights) } with tf.control_dependencies([inputs.save_state(next_state)]): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #8
Source File: graphs.py From object_detection_with_tensorflow with MIT License | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False, bidir=True) embedded = [self.layers['embedding'](inp.tokens) for inp in inputs] _, next_states, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) f_inputs, _ = inputs eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), f_inputs.labels, f_inputs.weights) } # Save states on accuracy update saves = [inp.save_state(state) for (inp, state) in zip(inputs, next_states)] with tf.control_dependencies(saves): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #9
Source File: graphs.py From object_detection_with_tensorflow with MIT License | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False) embedded = self.layers['embedding'](inputs.tokens) _, next_state, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), inputs.labels, inputs.weights) } with tf.control_dependencies([inputs.save_state(next_state)]): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #10
Source File: graphs.py From DOTA_models with Apache License 2.0 | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False) embedded = self.layers['embedding'](inputs.tokens) _, next_state, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), inputs.labels, inputs.weights) } with tf.control_dependencies([inputs.save_state(next_state)]): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #11
Source File: graphs.py From object_detection_kitti with Apache License 2.0 | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False) embedded = self.layers['embedding'](inputs.tokens) _, next_state, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), inputs.labels, inputs.weights) } with tf.control_dependencies([inputs.save_state(next_state)]): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #12
Source File: graphs.py From hands-detection with MIT License | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False, bidir=True) embedded = [self.layers['embedding'](inp.tokens) for inp in inputs] _, next_states, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) f_inputs, _ = inputs eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), f_inputs.labels, f_inputs.weights) } # Save states on accuracy update saves = [inp.save_state(state) for (inp, state) in zip(inputs, next_states)] with tf.control_dependencies(saves): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #13
Source File: graphs.py From hands-detection with MIT License | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False) embedded = self.layers['embedding'](inputs.tokens) _, next_state, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), inputs.labels, inputs.weights) } with tf.control_dependencies([inputs.save_state(next_state)]): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #14
Source File: graphs.py From Gun-Detector with Apache License 2.0 | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False, bidir=True) embedded = [self.layers['embedding'](inp.tokens) for inp in inputs] _, next_states, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) f_inputs, _ = inputs eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), f_inputs.labels, f_inputs.weights) } # Save states on accuracy update saves = [inp.save_state(state) for (inp, state) in zip(inputs, next_states)] with tf.control_dependencies(saves): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #15
Source File: graphs.py From Gun-Detector with Apache License 2.0 | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False) embedded = self.layers['embedding'](inputs.tokens) _, next_state, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) if FLAGS.single_label: indices = tf.stack([tf.range(FLAGS.batch_size), inputs.length - 1], 1) labels = tf.expand_dims(tf.gather_nd(inputs.labels, indices), 1) weights = tf.expand_dims(tf.gather_nd(inputs.weights, indices), 1) else: labels = inputs.labels weights = inputs.weights eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), labels, weights) } with tf.control_dependencies([inputs.save_state(next_state)]): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #16
Source File: graphs.py From yolo_v2 with Apache License 2.0 | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False, bidir=True) embedded = [self.layers['embedding'](inp.tokens) for inp in inputs] _, next_states, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) f_inputs, _ = inputs eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), f_inputs.labels, f_inputs.weights) } # Save states on accuracy update saves = [inp.save_state(state) for (inp, state) in zip(inputs, next_states)] with tf.control_dependencies(saves): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #17
Source File: graphs.py From yolo_v2 with Apache License 2.0 | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False) embedded = self.layers['embedding'](inputs.tokens) _, next_state, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), inputs.labels, inputs.weights) } with tf.control_dependencies([inputs.save_state(next_state)]): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict
Example #18
Source File: graphs.py From DOTA_models with Apache License 2.0 | 5 votes |
def eval_graph(self, dataset='test'): """Constructs classifier evaluation graph. Args: dataset: the labeled dataset to evaluate, {'train', 'test', 'valid'}. Returns: eval_ops: dict<metric name, tuple(value, update_op)> var_restore_dict: dict mapping variable restoration names to variables. Trainable variables will be mapped to their moving average names. """ inputs = _inputs(dataset, pretrain=False, bidir=True) embedded = [self.layers['embedding'](inp.tokens) for inp in inputs] _, next_states, logits, _ = self.cl_loss_from_embedding( embedded, inputs=inputs, return_intermediates=True) f_inputs, _ = inputs eval_ops = { 'accuracy': tf.contrib.metrics.streaming_accuracy( layers_lib.predictions(logits), f_inputs.labels, f_inputs.weights) } # Save states on accuracy update saves = [inp.save_state(state) for (inp, state) in zip(inputs, next_states)] with tf.control_dependencies(saves): acc, acc_update = eval_ops['accuracy'] acc_update = tf.identity(acc_update) eval_ops['accuracy'] = (acc, acc_update) var_restore_dict = make_restore_average_vars_dict() return eval_ops, var_restore_dict