Python tensorflow.python.framework.ops.Tensor() Examples
The following are 30
code examples of tensorflow.python.framework.ops.Tensor().
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
tensorflow.python.framework.ops
, or try the search function
.
Example #1
Source File: utils.py From tensornets with MIT License | 6 votes |
def get_tensor_aliases(tensor): """Get a list with the aliases of the input tensor. If the tensor does not have any alias, it would default to its its op.name or its name. Args: tensor: A `Tensor`. Returns: A list of strings with the aliases of the tensor. """ if hasattr(tensor, 'aliases'): aliases = tensor.aliases else: if tensor.name[-2:] == ':0': # Use op.name for tensor ending in :0 aliases = [tensor.op.name] else: aliases = [tensor.name] return aliases
Example #2
Source File: array_ops.py From lambda-packs with MIT License | 6 votes |
def shape(input, name=None, out_type=dtypes.int32): # pylint: disable=redefined-builtin """Returns the shape of a tensor. This operation returns a 1-D integer tensor representing the shape of `input`. For example: ```python # 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]] shape(t) ==> [2, 2, 3] ``` Args: input: A `Tensor` or `SparseTensor`. name: A name for the operation (optional). out_type: (Optional) The specified output type of the operation (`int32` or `int64`). Defaults to `tf.int32`. Returns: A `Tensor` of type `out_type`. """ return shape_internal(input, name, optimize=True, out_type=out_type)
Example #3
Source File: array_ops.py From lambda-packs with MIT License | 6 votes |
def shape_internal(input, name=None, optimize=True, out_type=dtypes.int32): # pylint: disable=redefined-builtin """Returns the shape of a tensor. Args: input: A `Tensor` or `SparseTensor`. name: A name for the operation (optional). optimize: if true, encode the shape as a constant when possible. out_type: (Optional) The specified output type of the operation (`int32` or `int64`). Defaults to tf.int32. Returns: A `Tensor` of type `out_type`. """ with ops.name_scope(name, "Shape", [input]) as name: if isinstance( input, (sparse_tensor.SparseTensor, sparse_tensor.SparseTensorValue)): return gen_math_ops.cast(input.dense_shape, out_type) else: input_tensor = ops.convert_to_tensor(input) input_shape = input_tensor.get_shape() if optimize and input_shape.is_fully_defined(): return constant(input_shape.as_list(), out_type, name=name) return gen_array_ops.shape(input, name=name, out_type=out_type)
Example #4
Source File: array_ops.py From lambda-packs with MIT License | 6 votes |
def size(input, name=None, out_type=dtypes.int32): # pylint: disable=redefined-builtin """Returns the size of a tensor. This operation returns an integer representing the number of elements in `input`. For example: ```python # 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]]] size(t) ==> 12 ``` Args: input: A `Tensor` or `SparseTensor`. name: A name for the operation (optional). out_type: (Optional) The specified output type of the operation (`int32` or `int64`). Defaults to tf.int32. Returns: A `Tensor` of type `out_type`. Defaults to tf.int32. """ return size_internal(input, name, optimize=True, out_type=out_type)
Example #5
Source File: array_ops.py From lambda-packs with MIT License | 6 votes |
def size_internal(input, name=None, optimize=True, out_type=dtypes.int32): # pylint: disable=redefined-builtin,protected-access """Returns the size of a tensor. Args: input: A `Tensor` or `SparseTensor`. name: A name for the operation (optional). optimize: if true, encode the size as a constant when possible. out_type: (Optional) The specified output type of the operation (`int32` or `int64`). Defaults to tf.int32. Returns: A `Tensor` of type `out_type`. """ with ops.name_scope(name, "Size", [input]) as name: if isinstance( input, (sparse_tensor.SparseTensor, sparse_tensor.SparseTensorValue)): return gen_math_ops._prod( gen_math_ops.cast(input.dense_shape, out_type), 0, name=name) else: input_tensor = ops.convert_to_tensor(input) input_shape = input_tensor.get_shape() if optimize and input_shape.is_fully_defined(): return constant(input_shape.num_elements(), out_type, name=name) return gen_array_ops.size(input, name=name, out_type=out_type)
Example #6
Source File: stepper.py From lambda-packs with MIT License | 6 votes |
def is_placeholder(self, graph_element_name): """Check whether a graph element is a Placeholder, by name. Args: graph_element_name: (str) Name of the tensor or op to be tested. Returns: (bool) Whether the graph element of the specified name is a Placeholder op or the output Tensor of a Placeholder op. Raises: ValueError: If graph_element_name is not in the transitive closure of the stepper instance. """ node_name = self._get_node_name(graph_element_name) if node_name not in self.sorted_nodes(): raise ValueError( "%s is not in the transitive closure of this NodeStepper " "instance" % graph_element_name) graph_element = self._sess.graph.as_graph_element(graph_element_name) if not isinstance(graph_element, ops.Operation): graph_element = graph_element.op return graph_element.type == "Placeholder"
Example #7
Source File: beam_search_decoder_from_tensorflow.py From tensorflow_end2end_speech_recognition with MIT License | 6 votes |
def _maybe_merge_batch_beams(self, t, s): """Splits the tensor from a batch by beams into a batch of beams. More exactly, t is a tensor of dimension [batch_size*beam_width, s]. We reshape this into [batch_size, beam_width, s] Args: t: Tensor of dimension [batch_size*beam_width, s] s: Tensor, Python int, or TensorShape. Returns: A reshaped version of t with dimension [batch_size, beam_width, s]. Raises: TypeError: If t is an instance of TensorArray. ValueError: If the rank of t is not statically known. """ _check_maybe(t) if t.shape.ndims >= 2: return self._merge_batch_beams(t, s) else: return t
Example #8
Source File: array_ops.py From lambda-packs with MIT License | 6 votes |
def _autopacking_conversion_function(v, dtype=None, name=None, as_ref=False): """Tensor conversion function that automatically packs arguments.""" if as_ref: return NotImplemented inferred_dtype = _get_dtype_from_nested_lists(v) if inferred_dtype is None: # We did not find any tensor-like objects in the nested lists, so defer to # other conversion functions. return NotImplemented if dtype is not None and dtype != inferred_dtype: return NotImplemented return _autopacking_helper(v, inferred_dtype, name or "packed") # pylint: enable=invalid-name # NOTE: Register this conversion function to run *before* one that # assumes every element is a value.
Example #9
Source File: beam_search_decoder_from_tensorflow.py From tensorflow_end2end_speech_recognition with MIT License | 6 votes |
def _merge_batch_beams(self, t, s=None): """Merges the tensor from a batch of beams into a batch by beams. More exactly, t is a tensor of dimension [batch_size, beam_width, s]. We reshape this into [batch_size*beam_width, s] Args: t: Tensor of dimension [batch_size, beam_width, s] s: (Possibly known) depth shape. Returns: A reshaped version of t with dimension [batch_size * beam_width, s]. """ if isinstance(s, ops.Tensor): s = tensor_shape.as_shape(tensor_util.constant_value(s)) else: s = tensor_shape.TensorShape(s) t_shape = tf.shape(t) static_batch_size = tensor_util.constant_value(self._batch_size) batch_size_beam_width = ( None if static_batch_size is None else static_batch_size * self._beam_width) reshaped_t = tf.reshape( t, tf.concat( ([self._batch_size * self._beam_width], t_shape[2:]), 0)) reshaped_t.set_shape( (tensor_shape.TensorShape([batch_size_beam_width]).concatenate(s))) return reshaped_t
Example #10
Source File: beam_search_decoder_from_tensorflow.py From tensorflow_end2end_speech_recognition with MIT License | 6 votes |
def tile_batch(t, multiplier, name=None): """Tile the batch dimension of a (possibly nested structure of) tensor(s) t. For each tensor t in a (possibly nested structure) of tensors, this function takes a tensor t shaped `[batch_size, s0, s1, ...]` composed of minibatch entries `t[0], ..., t[batch_size - 1]` and tiles it to have a shape `[batch_size * multiplier, s0, s1, ...]` composed of minibatch entries `t[0], t[0], ..., t[1], t[1], ...` where each minibatch entry is repeated `multiplier` times. Args: t: `Tensor` shaped `[batch_size, ...]`. multiplier: Python int. name: Name scope for any created operations. Returns: A (possibly nested structure of) `Tensor` shaped `[batch_size * multiplier, ...]`. Raises: ValueError: if tensor(s) `t` do not have a statically known rank or the rank is < 1. """ flat_t = nest.flatten(t) with tf.name_scope(name, "tile_batch", flat_t + [multiplier]): return nest.map_structure(lambda t_: _tile_batch(t_, multiplier), t)
Example #11
Source File: dynamic_decoder.py From tensorflow_end2end_speech_recognition with MIT License | 6 votes |
def _transpose_batch_time(x): """Transpose the batch and time dimensions of a Tensor. Retains as much of the static shape information as possible. Args: x: A tensor of rank 2 or higher. Returns: x transposed along the first two dimensions. Raises: ValueError: if `x` is rank 1 or lower. """ x_static_shape = x.get_shape() if x_static_shape.ndims is not None and x_static_shape.ndims < 2: raise ValueError( "Expected input tensor %s to have rank at least 2, but saw shape: %s" % (x, x_static_shape)) x_rank = array_ops.rank(x) x_t = array_ops.transpose( x, array_ops.concat( ([1, 0], math_ops.range(2, x_rank)), axis=0)) x_t.set_shape( tensor_shape.TensorShape([ x_static_shape[1].value, x_static_shape[0].value ]).concatenate(x_static_shape[2:])) return x_t
Example #12
Source File: cli_shared.py From lambda-packs with MIT License | 6 votes |
def _get_fetch_names(fetches): """Get a flattened list of the names in run() call fetches. Args: fetches: Fetches of the `Session.run()` call. It maybe a Tensor, an Operation or a Variable. It may also be nested lists, tuples or dicts. See doc of `Session.run()` for more details. Returns: (list of str) A flattened list of fetch names from `fetches`. """ lines = [] if isinstance(fetches, (list, tuple)): for fetch in fetches: lines.extend(_get_fetch_names(fetch)) elif isinstance(fetches, dict): for key in fetches: lines.extend(_get_fetch_names(fetches[key])) else: # This ought to be a Tensor, an Operation or a Variable, for which the name # attribute should be available. (Bottom-out condition of the recursion.) lines.append(_get_fetch_name(fetches)) return lines
Example #13
Source File: utils.py From tensornets with MIT License | 6 votes |
def append_tensor_alias(tensor, alias): """Append an alias to the list of aliases of the tensor. Args: tensor: A `Tensor`. alias: String, to add to the list of aliases of the tensor. Returns: The tensor with a new alias appended to its list of aliases. """ # Remove ending '/' if present. if alias[-1] == '/': alias = alias[:-1] if hasattr(tensor, 'aliases'): tensor.aliases.append(alias) else: tensor.aliases = [alias] return tensor
Example #14
Source File: builder_impl.py From lambda-packs with MIT License | 6 votes |
def _asset_path_from_tensor(path_tensor): """Returns the filepath value stored in constant `path_tensor`. Args: path_tensor: Tensor of a file-path. Returns: The string value i.e. path of the tensor, if valid. Raises: TypeError if tensor does not match expected op type, dtype or value. """ if not isinstance(path_tensor, ops.Tensor): raise TypeError("Asset path tensor must be a Tensor.") if path_tensor.op.type != "Const": raise TypeError("Asset path tensor must be of type constant.") if path_tensor.dtype != dtypes.string: raise TypeError("Asset path tensor must be of dtype string.") str_values = path_tensor.op.get_attr("value").string_val if len(str_values) != 1: raise TypeError("Asset path tensor must be a scalar.") return str_values[0]
Example #15
Source File: rev_block_lib.py From tensornets with MIT License | 6 votes |
def _underlying_variable_ref(t): """Find the underlying variable ref. Traverses through Identity, ReadVariableOp, and Enter ops. Stops when op type has Variable or VarHandle in name. Args: t: a Tensor Returns: a Tensor that is a variable ref, or None on error. """ while t.op.type in ["Identity", "ReadVariableOp", "Enter"]: t = t.op.inputs[0] op_type = t.op.type if "Variable" in op_type or "VarHandle" in op_type: return t else: return None
Example #16
Source File: stepper.py From lambda-packs with MIT License | 6 votes |
def _flatten_fetches(fetches): """Flatten list, tuple of fetches, or a single fetch into a list of fetches. Args: fetches: The fetches to flatten: Can be a single Tensor, Op, or a potentially nested list, tuple or dict of such individual fetches. Returns: The fetches flattened to a list. """ flattened = [] if isinstance(fetches, (list, tuple)): for fetch in fetches: flattened.extend(_flatten_fetches(fetch)) elif isinstance(fetches, dict): for key in fetches: flattened.extend(_flatten_fetches(fetches[key])) else: flattened.append(fetches) return flattened
Example #17
Source File: tf_image.py From seglink with GNU General Public License v3.0 | 6 votes |
def _ImageDimensions(image): """Returns the dimensions of an image tensor. Args: image: A 3-D Tensor of shape `[height, width, channels]`. Returns: A list of `[height, width, channels]` corresponding to the dimensions of the input image. Dimensions that are statically known are python integers, otherwise they are integer scalar tensors. """ if image.get_shape().is_fully_defined(): return image.get_shape().as_list() else: static_shape = image.get_shape().with_rank(3).as_list() dynamic_shape = array_ops.unstack(array_ops.shape(image), 3) return [s if s is not None else d for s, d in zip(static_shape, dynamic_shape)]
Example #18
Source File: io_ops.py From lambda-packs with MIT License | 6 votes |
def num_records_produced(self, name=None): """Returns the number of records this reader has produced. This is the same as the number of Read executions that have succeeded. Args: name: A name for the operation (optional). Returns: An int64 Tensor. """ if self._reader_ref.dtype == dtypes.resource: return gen_io_ops._reader_num_records_produced_v2(self._reader_ref, name=name) else: return gen_io_ops._reader_num_records_produced(self._reader_ref, name=name)
Example #19
Source File: tf_helpers.py From Counterfactual-StoryRW with MIT License | 6 votes |
def __init__(self, sample_fn, sample_shape, sample_dtype, start_inputs, end_fn, next_inputs_fn=None): """Initializer. Args: sample_fn: A callable that takes `outputs` and emits tensor `sample_ids`. sample_shape: Either a list of integers, or a 1-D Tensor of type `int32`, the shape of the each sample in the batch returned by `sample_fn`. sample_dtype: the dtype of the sample returned by `sample_fn`. start_inputs: The initial batch of inputs. end_fn: A callable that takes `sample_ids` and emits a `bool` vector shaped `[batch_size]` indicating whether each sample is an end token. next_inputs_fn: (Optional) A callable that takes `sample_ids` and returns the next batch of inputs. If not provided, `sample_ids` is used as the next batch of inputs. """ self._sample_fn = sample_fn self._end_fn = end_fn self._sample_shape = tensor_shape.TensorShape(sample_shape) self._sample_dtype = sample_dtype self._next_inputs_fn = next_inputs_fn self._batch_size = array_ops.shape(start_inputs)[0] self._start_inputs = ops.convert_to_tensor( start_inputs, name="start_inputs")
Example #20
Source File: tf_helpers.py From Counterfactual-StoryRW with MIT License | 6 votes |
def sample(self, time, outputs, state, name=None): """Gets a sample for one step.""" del time, state # unused by sample_fn # Outputs are logits, we sample instead of argmax (greedy). if not isinstance(outputs, ops.Tensor): raise TypeError("Expected outputs to be a single Tensor, got: %s" % type(outputs)) if self._softmax_temperature is None: logits = outputs else: logits = outputs / self._softmax_temperature sample_id_sampler = categorical.Categorical(logits=logits) sample_ids = sample_id_sampler.sample(seed=self._seed) return sample_ids
Example #21
Source File: tf_helpers.py From Counterfactual-StoryRW with MIT License | 6 votes |
def __init__(self, initialize_fn, sample_fn, next_inputs_fn, sample_ids_shape=None, sample_ids_dtype=None): """Initializer. Args: initialize_fn: callable that returns `(finished, next_inputs)` for the first iteration. sample_fn: callable that takes `(time, outputs, state)` and emits tensor `sample_ids`. next_inputs_fn: callable that takes `(time, outputs, state, sample_ids)` and emits `(finished, next_inputs, next_state)`. sample_ids_shape: Either a list of integers, or a 1-D Tensor of type `int32`, the shape of each value in the `sample_ids` batch. Defaults to a scalar. sample_ids_dtype: The dtype of the `sample_ids` tensor. Defaults to int32. """ self._initialize_fn = initialize_fn self._sample_fn = sample_fn self._next_inputs_fn = next_inputs_fn self._batch_size = None self._sample_ids_shape = tensor_shape.TensorShape(sample_ids_shape or []) self._sample_ids_dtype = sample_ids_dtype or dtypes.int32
Example #22
Source File: io_ops.py From lambda-packs with MIT License | 5 votes |
def read(self, queue, name=None): """Returns the next record (key, value pair) produced by a reader. Will dequeue a work unit from queue if necessary (e.g. when the Reader needs to start reading from a new file since it has finished with the previous file). Args: queue: A Queue or a mutable string Tensor representing a handle to a Queue, with string work items. name: A name for the operation (optional). Returns: A tuple of Tensors (key, value). key: A string scalar Tensor. value: A string scalar Tensor. """ if isinstance(queue, ops.Tensor): queue_ref = queue else: queue_ref = queue.queue_ref if self._reader_ref.dtype == dtypes.resource: return gen_io_ops._reader_read_v2(self._reader_ref, queue_ref, name=name) else: # For compatibility with pre-resource queues, create a ref(string) tensor # which can be looked up as the same queue by a resource manager. old_queue_op = gen_data_flow_ops._fake_queue(queue_ref) return gen_io_ops._reader_read(self._reader_ref, old_queue_op, name=name)
Example #23
Source File: control_flow_grad.py From lambda-packs with MIT License | 5 votes |
def _ExitGrad(op, grad): """Gradients for an exit op are calculated using an Enter op.""" graph = ops.get_default_graph() # pylint: disable=protected-access grad_ctxt = graph._get_control_flow_context() # pylint: enable=protected-access if not grad_ctxt.back_prop: # The flag `back_prop` is set by users to suppress gradient # computation for this loop. If the attribute `back_prop` is false, # no gradient computation. return None # pylint: disable=protected-access if op._get_control_flow_context().grad_state: raise TypeError("Second-order gradient for while loops not supported.") # pylint: enable=protected-access if isinstance(grad, ops.Tensor): grad_ctxt.AddName(grad.name) else: if not isinstance(grad, (ops.IndexedSlices, sparse_tensor.SparseTensor)): raise TypeError("Type %s not supported" % type(grad)) grad_ctxt.AddName(grad.values.name) grad_ctxt.AddName(grad.indices.name) dense_shape = grad.dense_shape if dense_shape is not None: grad_ctxt.AddName(dense_shape.name) grad_ctxt.Enter() # pylint: disable=protected-access result = control_flow_ops._Enter( grad, grad_ctxt.name, is_constant=False, parallel_iterations=grad_ctxt.parallel_iterations, name="b_exit") # pylint: enable=protected-access grad_ctxt.loop_enters.append(result) grad_ctxt.Exit() return result
Example #24
Source File: control_flow_grad.py From lambda-packs with MIT License | 5 votes |
def _EnterGrad(op, grad): """Gradients for an Enter are calculated using an Exit op. For loop variables, grad is the gradient so just add an exit. For loop invariants, we need to add an accumulator loop. """ graph = ops.get_default_graph() # pylint: disable=protected-access grad_ctxt = graph._get_control_flow_context() # pylint: enable=protected-access if not grad_ctxt.back_prop: # Skip gradient computation, if the attribute `back_prop` is false. return grad if grad_ctxt.grad_state is None: # Pass the gradient through if we are not in a gradient while context. return grad if op.get_attr("is_constant"): # Add a gradient accumulator for each loop invariant. if isinstance(grad, ops.Tensor): result = grad_ctxt.AddBackPropAccumulator(op, grad) elif isinstance(grad, ops.IndexedSlices): result = grad_ctxt.AddBackPropIndexedSlicesAccumulator(op, grad) else: # TODO(yuanbyu, lukasr): Add support for SparseTensor. raise TypeError("Type %s not supported" % type(grad)) else: result = exit(grad) grad_ctxt.loop_exits.append(result) grad_ctxt.ExitResult([result]) return result
Example #25
Source File: array_ops.py From lambda-packs with MIT License | 5 votes |
def rank(input, name=None): # pylint: disable=redefined-builtin """Returns the rank of a tensor. This operation returns an integer representing the rank of `input`. For example: ```python # 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]] # shape of tensor 't' is [2, 2, 3] rank(t) ==> 3 ``` **Note**: The rank of a tensor is not the same as the rank of a matrix. The rank of a tensor is the number of indices required to uniquely select each element of the tensor. Rank is also known as "order", "degree", or "ndims." Args: input: A `Tensor` or `SparseTensor`. name: A name for the operation (optional). Returns: A `Tensor` of type `int32`. @compatibility(numpy) Equivalent to np.ndim @end_compatibility """ return rank_internal(input, name, optimize=True)
Example #26
Source File: rnn_cell_impl.py From lambda-packs with MIT License | 5 votes |
def zero_state(self, batch_size, dtype): """Return zero-filled state tensor(s). Args: batch_size: int, float, or unit Tensor representing the batch size. dtype: the data type to use for the state. Returns: If `state_size` is an int or TensorShape, then the return value is a `N-D` tensor of shape `[batch_size x state_size]` filled with zeros. If `state_size` is a nested list or tuple, then the return value is a nested list or tuple (of the same structure) of `2-D` tensors with the shapes `[batch_size x s]` for each s in `state_size`. """ with ops.name_scope(type(self).__name__ + "ZeroState", values=[batch_size]): state_size = self.state_size return _zero_state_tensors(state_size, batch_size, dtype)
Example #27
Source File: rnn_cell_impl.py From lambda-packs with MIT License | 5 votes |
def __call__(self, inputs, state, scope=None): """Run this RNN cell on inputs, starting from the given state. Args: inputs: `2-D` tensor with shape `[batch_size x input_size]`. state: if `self.state_size` is an integer, this should be a `2-D Tensor` with shape `[batch_size x self.state_size]`. Otherwise, if `self.state_size` is a tuple of integers, this should be a tuple with shapes `[batch_size x s] for s in self.state_size`. scope: VariableScope for the created subgraph; defaults to class name. Returns: A pair containing: - Output: A `2-D` tensor with shape `[batch_size x self.output_size]`. - New state: Either a single `2-D` tensor, or a tuple of tensors matching the arity and shapes of `state`. """ if scope is not None: with vs.variable_scope(scope, custom_getter=self._rnn_get_variable) as scope: return super(RNNCell, self).__call__(inputs, state, scope=scope) else: with vs.variable_scope(vs.get_variable_scope(), custom_getter=self._rnn_get_variable): return super(RNNCell, self).__call__(inputs, state)
Example #28
Source File: export_output.py From lambda-packs with MIT License | 5 votes |
def as_signature_def(self, receiver_tensors): if len(receiver_tensors) != 1: raise ValueError('Regression input must be a single string Tensor; ' 'got {}'.format(receiver_tensors)) (_, examples), = receiver_tensors.items() if dtypes.as_dtype(examples.dtype) != dtypes.string: raise ValueError('Regression input must be a single string Tensor; ' 'got {}'.format(receiver_tensors)) return signature_def_utils.regression_signature_def(examples, self.value)
Example #29
Source File: export_output.py From lambda-packs with MIT License | 5 votes |
def __init__(self, value): """Constructor for `RegressionOutput`. Args: value: a float `Tensor` giving the predicted values. Required. Raises: ValueError: if the value is not a `Tensor` with dtype tf.float32. """ if not (isinstance(value, ops.Tensor) and value.dtype.is_floating): raise ValueError('Regression output value must be a float32 Tensor; ' 'got {}'.format(value)) self._value = value
Example #30
Source File: export_output.py From lambda-packs with MIT License | 5 votes |
def as_signature_def(self, receiver_tensors): if len(receiver_tensors) != 1: raise ValueError('Classification input must be a single string Tensor; ' 'got {}'.format(receiver_tensors)) (_, examples), = receiver_tensors.items() if dtypes.as_dtype(examples.dtype) != dtypes.string: raise ValueError('Classification input must be a single string Tensor; ' 'got {}'.format(receiver_tensors)) return signature_def_utils.classification_signature_def( examples, self.classes, self.scores)