RaggedTensor
Represents a ragged tensor.
tf.compat.v1.RaggedTensor
tf.compat.v2.RaggedTensor
A RaggedTensor
is a tensor with one or more ragged dimensions, which are
dimensions whose slices may have different lengths. For example, the inner
(column) dimension of rt=[[3, 1, 4, 1], [], [5, 9, 2], [6], []]
is ragged,
since the column slices (rt[0, :]
, ..., rt[4, :]
) have different lengths.
Dimensions whose slices all have the same length are called uniform
dimensions. The outermost dimension of a RaggedTensor
is always uniform,
since it consists of a single slice (and so there is no possibility for
differing slice lengths).
The total number of dimensions in a RaggedTensor
is called its rank,
and the number of ragged dimensions in a RaggedTensor
is called its
ragged-rank. A RaggedTensor
's ragged-rank is fixed at graph creation
time: it can't depend on the runtime values of Tensor
s, and can't vary
dynamically for different session runs.
```
Many ops support both Tensor
s and RaggedTensor
s. The term "potentially
ragged tensor" may be used to refer to a tensor that might be either a
Tensor
or a RaggedTensor
. The ragged-rank of a Tensor
is zero.
When documenting the shape of a RaggedTensor, ragged dimensions can be
indicated by enclosing them in parentheses. For example, the shape of
a 3-D RaggedTensor
that stores the fixed-size word embedding for each
word in a sentence, for each sentence in a batch, could be written as
[num_sentences, (num_words), embedding_size]
. The parentheses around
(num_words)
indicate that dimension is ragged, and that the length
of each element list in that dimension may vary for each item.
Internally, a RaggedTensor
consists of a concatenated list of values that
are partitioned into variable-length rows. In particular, each RaggedTensor
consists of:
A values
tensor, which concatenates the variable-length rows into a
flattened list. For example, the values
tensor for
[[3, 1, 4, 1], [], [5, 9, 2], [6], []]
is [3, 1, 4, 1, 5, 9, 2, 6]
.
A row_splits
vector, which indicates how those flattened values are
divided into rows. In particular, the values for row rt[i]
are stored
in the slice rt.values[rt.row_splits[i]:rt.row_splits[i+1]]
.
>>> print(tf.RaggedTensor.from_row_splits( ... values=[3, 1, 4, 1, 5, 9, 2, 6], ... row_splits=[0, 4, 4, 7, 8, 8])) <tf.RaggedTensor [[3, 1, 4, 1], [], [5, 9, 2], [6], []]>
In addition to row_splits
, ragged tensors provide support for four other
row-partitioning schemes:
row_lengths
: a vector with shape [nrows]
, which specifies the length
of each row.
value_rowids
and nrows
: value_rowids
is a vector with shape
[nvals]
, corresponding one-to-one with values
, which specifies
each value's row index. In particular, the row rt[row]
consists of the
values rt.values[j]
where value_rowids[j]==row
. nrows
is an
integer scalar that specifies the number of rows in the
RaggedTensor
. (nrows
is used to indicate trailing empty rows.)
row_starts
: a vector with shape [nrows]
, which specifies the start
offset of each row. Equivalent to row_splits[:-1]
.
row_limits
: a vector with shape [nrows]
, which specifies the stop
offset of each row. Equivalent to row_splits[1:]
.
Example: The following ragged tensors are equivalent, and all represent the
nested list [[3, 1, 4, 1], [], [5, 9, 2], [6], []]
.
>>> values = [3, 1, 4, 1, 5, 9, 2, 6] >>> rt1 = RaggedTensor.from_row_splits(values, row_splits=[0, 4, 4, 7, 8, 8]) >>> rt2 = RaggedTensor.from_row_lengths(values, row_lengths=[4, 0, 3, 1, 0]) >>> rt3 = RaggedTensor.from_value_rowids( ... values, value_rowids=[0, 0, 0, 0, 2, 2, 2, 3], nrows=5) >>> rt4 = RaggedTensor.from_row_starts(values, row_starts=[0, 4, 4, 7, 8]) >>> rt5 = RaggedTensor.from_row_limits(values, row_limits=[4, 4, 7, 8, 8])
RaggedTensor
s with multiple ragged dimensions can be defined by using
a nested RaggedTensor
for the values
tensor. Each nested RaggedTensor
adds a single ragged dimension.
>>> inner_rt = RaggedTensor.from_row_splits( # =rt1 from above ... values=[3, 1, 4, 1, 5, 9, 2, 6], row_splits=[0, 4, 4, 7, 8, 8]) >>> outer_rt = RaggedTensor.from_row_splits( ... values=inner_rt, row_splits=[0, 3, 3, 5]) >>> print outer_rt.to_list() [[[3, 1, 4, 1], [], [5, 9, 2]], [], [[6], []]] >>> print outer_rt.ragged_rank 2
The factory function RaggedTensor.from_nested_row_splits
may be used to
construct a RaggedTensor
with multiple ragged dimensions directly, by
providing a list of row_splits
tensors:
>>> RaggedTensor.from_nested_row_splits( ... flat_values=[3, 1, 4, 1, 5, 9, 2, 6], ... nested_row_splits=([0, 3, 3, 5], [0, 4, 4, 7, 8, 8])).to_list() [[[3, 1, 4, 1], [], [5, 9, 2]], [], [[6], []]]
RaggedTensor
s with uniform inner dimensions can be defined
by using a multidimensional Tensor
for values
.
>>> rt = RaggedTensor.from_row_splits(values=tf.ones([5, 3]), .. row_splits=[0, 2, 5]) >>> print rt.to_list() [[[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1], [1, 1, 1]]] >>> print rt.shape (2, ?, 3)
```
The shape of a RaggedTensor is currently restricted to have the following form:
This restriction follows from the fact that each nested RaggedTensor
replaces the uniform outermost dimension of its values
with a uniform
dimension followed by a ragged dimension.
__init__
__init__( values, row_splits, cached_row_lengths=None, cached_value_rowids=None, cached_nrows=None, internal=False )
Creates a RaggedTensor
with a specified partitioning for values
.
This constructor is private -- please use one of the following ops to
build RaggedTensor
s:
tf.RaggedTensor.from_row_lengths
tf.RaggedTensor.from_value_rowids
tf.RaggedTensor.from_row_splits
tf.RaggedTensor.from_row_starts
tf.RaggedTensor.from_row_limits
tf.RaggedTensor.from_nested_row_splits
tf.RaggedTensor.from_nested_row_lengths
tf.RaggedTensor.from_nested_value_rowids
values
: A potentially ragged tensor of any dtype and shape [nvals, ...]
.row_splits
: A 1-D integer tensor with shape [nrows+1]
.cached_row_lengths
: A 1-D integer tensor with shape [nrows]
cached_value_rowids
: A 1-D integer tensor with shape [nvals]
.cached_nrows
: A 1-D integer scalar tensor.internal
: True if the constructor is being called by one of the factory
methods. If false, an exception will be raised.TypeError
: If a row partitioning tensor has an inappropriate dtype.TypeError
: If exactly one row partitioning argument was not specified.ValueError
: If a row partitioning tensor has an inappropriate shape.ValueError
: If multiple partitioning arguments are specified.ValueError
: If nrows is specified but value_rowids is not None.dtype
The DType
of values in this tensor.
flat_values
The innermost values
tensor for this ragged tensor.
Concretely, if rt.values
is a Tensor
, then rt.flat_values
is
rt.values
; otherwise, rt.flat_values
is rt.values.flat_values
.
Conceptually, flat_values
is the tensor formed by flattening the
outermost dimension and all of the ragged dimensions into a single
dimension.
rt.flat_values.shape = [nvals] + rt.shape[rt.ragged_rank + 1:]
(where nvals
is the number of items in the flattened dimensions).
A Tensor
.
```python
rt = ragged.constant([[[3, 1, 4, 1], [], [5, 9, 2]], [], [[6], []]]) print rt.flat_values() tf.Tensor([3, 1, 4, 1, 5, 9, 2, 6]) ```
nested_row_splits
A tuple containing the row_splits for all ragged dimensions.
rt.nested_row_splits
is a tuple containing the row_splits
tensors for
all ragged dimensions in rt
, ordered from outermost to innermost. In
particular, rt.nested_row_splits = (rt.row_splits,) + value_splits
where:
* `value_splits = ()` if `rt.values` is a `Tensor`. * `value_splits = rt.values.nested_row_splits` otherwise.
A tuple
of 1-D integer Tensor
s.
```python
rt = ragged.constant([[[[3, 1, 4, 1], [], [5, 9, 2]], [], [[6], []]]]) for i, splits in enumerate(rt.nested_row_splits()): ... print('Splits for dimension %d: %s' % (i+1, splits)) Splits for dimension 1: [0, 1] Splits for dimension 2: [0, 3, 3, 5] Splits for dimension 3: [0, 4, 4, 7, 8, 8] ```
ragged_rank
The number of ragged dimensions in this ragged tensor.
A Python int
indicating the number of ragged dimensions in this ragged
tensor. The outermost dimension is not considered ragged.
row_splits
The row-split indices for this ragged tensor's values
.
rt.row_splits
specifies where the values for each row begin and end in
rt.values
. In particular, the values for row rt[i]
are stored in
the slice rt.values[rt.row_splits[i]:rt.row_splits[i+1]]
.
A 1-D integer Tensor
with shape [self.nrows+1]
.
The returned tensor is non-empty, and is sorted in ascending order.
self.row_splits[0]
is zero, and self.row_splits[-1]
is equal to
self.values.shape[0]
.
```python
rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) print rt.row_splits # indices of row splits in rt.values tf.Tensor([0, 4, 4, 7, 8, 8]) ```
shape
The statically known shape of this ragged tensor.
A TensorShape
containing the statically known shape of this ragged
tensor. Ragged dimensions have a size of None
.
>>> ragged.constant([[0], [1, 2]]).shape TensorShape([Dimension(2), Dimension(None)]) >>> ragged.constant([[[0, 1]], [[1, 2], [3, 4]]], ragged_rank=1).shape TensorShape([Dimension(2), Dimension(None), Dimension(2)
values
The concatenated rows for this ragged tensor.
rt.values
is a potentially ragged tensor formed by flattening the two
outermost dimensions of rt
into a single dimension.
rt.values.shape = [nvals] + rt.shape[2:]
(where nvals
is the
number of items in the outer two dimensions of rt
).
rt.ragged_rank = self.ragged_rank - 1
A potentially ragged tensor.
```python
rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) print rt.values tf.Tensor([3, 1, 4, 1, 5, 9, 2, 6]) ```
__abs__
__abs__( x, name=None )
Computes the absolute value of a tensor.
Given a tensor of integer or floating-point values, this operation returns a tensor of the same type, where each element contains the absolute value of the corresponding element in the input.
Given a tensor x
of complex numbers, this operation returns a tensor of type
float32
or float64
that is the absolute value of each element in x
. All
elements in x
must be complex numbers of the form \(a + bj\). The
absolute value is computed as \( \sqrt{a^2 + b^2}\). For example:
x = tf.constant([[-2.25 + 4.75j], [-3.25 + 5.75j]]) tf.abs(x) # [5.25594902, 6.60492229]
x
: A Tensor
or SparseTensor
of type float16
, float32
, float64
,
int32
, int64
, complex64
or complex128
.name
: A name for the operation (optional).A Tensor
or SparseTensor
the same size, type, and sparsity as x
with
absolute values.
Note, for complex64
or complex128
input, the returned Tensor
will be
of type float32
or float64
, respectively.
If x
is a SparseTensor
, returns
SparseTensor(x.indices, tf.math.abs(x.values, ...), x.dense_shape)
__add__
Defined in generated file: python/ops/gen_math_ops.py
__add__( x, y, name=None )
Returns x + y element-wise.
NOTE: math.add
supports broadcasting. AddN
does not. More about broadcasting
here
x
: A Tensor
. Must be one of the following types: bfloat16
, half
, float32
, float64
, uint8
, int8
, int16
, int32
, int64
, complex64
, complex128
, string
.y
: A Tensor
. Must have the same type as x
.name
: A name for the operation (optional).A Tensor
. Has the same type as x
.
__and__
Defined in generated file: python/ops/gen_math_ops.py
__and__( x, y, name=None )
Returns the truth value of x AND y element-wise.
NOTE: math.logical_and
supports broadcasting.  It will be removed in a future version. Instructions for updating: Deprecated in favor of operator or tf.math.divide.
NOTE: Prefer using the Tensor division operator or tf.divide which obey Python 3 division operator semantics.
This function divides x
and y
, forcing Python 2 semantics. That is, if x
and y
are both integers then the result will be an integer. This is in
contrast to Python 3, where division with /
is always a float while division
with //
is always an integer.
x
: Tensor
numerator of real numeric type.y
: Tensor
denominator of real numeric type.name
: A name for the operation (optional).x / y
returns the quotient of x and y.
__floordiv__
__floordiv__( x, y, name=None )
Divides x / y
elementwise, rounding toward the most negative integer.
The same as tf.compat.v1.div(x,y)
for integers, but uses
tf.floor(tf.compat.v1.div(x,y))
for
floating point arguments so that the result is always an integer (though
possibly an integer represented as floating point). This op is generated by
x // y
floor division in Python 3 and in Python 2.7 with
from __future__ import division
.
x
and y
must have the same type, and the result will have the same type
as well.
x
: Tensor
numerator of real numeric type.y
: Tensor
denominator of real numeric type.name
: A name for the operation (optional).x / y
rounded down.
TypeError
: If the inputs are complex.__ge__
Defined in generated file: python/ops/gen_math_ops.py
__ge__( x, y, name=None )
Returns the truth value of (x >= y) element-wise.
NOTE: math.greater_equal
supports broadcasting. More about broadcasting
here
x
: A Tensor
. Must be one of the following types: float32
, float64
, int32
, uint8
, int16
, int8
, int64
, bfloat16
, uint16
, half
, uint32
, uint64
.y
: A Tensor
. Must have the same type as x
.name
: A name for the operation (optional).A Tensor
of type bool
.
__getitem__
__getitem__(key)
Returns the specified piece of this RaggedTensor.
Supports multidimensional indexing and slicing, with one restriction: indexing into a ragged inner dimension is not allowed. This case is problematic because the indicated value may exist in some rows but not others. In such cases, it's not obvious whether we should (1) report an IndexError; (2) use a default value; or (3) skip that value and return a tensor with fewer rows than we started with. Following the guiding principles of Python ("In the face of ambiguity, refuse the temptation to guess"), we simply disallow this operation.
Any dimensions added by array_ops.newaxis
will be ragged if the following
dimension is ragged.
self
: The RaggedTensor to slice.key
: Indicates which piece of the RaggedTensor to return, using standard
Python semantics (e.g., negative values index from the end). key
may have any of the following types:
int
constant
Tensor
slice
containing integer constants and/or scalar integer
Tensor
sEllipsis
tf.newaxis
tuple
containing any of the above (for multidimentional indexing)A Tensor
or RaggedTensor
object. Values that include at least one
ragged dimension are returned as RaggedTensor
. Values that include no
ragged dimensions are returned as Tensor
. See above for examples of
expressions that return Tensor
s vs RaggedTensor
s.
ValueError
: If key
is out of bounds.ValueError
: If key
is not supported.TypeError
: If the indices in key
have an unsupported type.>>> # A 2-D ragged tensor with 1 ragged dimension. >>> rt = ragged.constant([['a', 'b', 'c'], ['d', 'e'], ['f'], ['g']]) >>> rt[0].eval().tolist() # First row (1-D `Tensor`) ['a', 'b', 'c'] >>> rt[:3].eval().tolist() # First three rows (2-D RaggedTensor) [['a', 'b', 'c'], ['d', 'e'], '[f'], [g']] >>> rt[3, 0].eval().tolist() # 1st element of 4th row (scalar) 'g' >>> # A 3-D ragged tensor with 2 ragged dimensions. >>> rt = ragged.constant([[[1, 2, 3], [4]], ... [[5], [], [6]], ... [[7]], ... [[8, 9], [10]]]) >>> rt[1].eval().tolist() # Second row (2-D RaggedTensor) [[5], [], [6]] >>> rt[3, 0].eval().tolist() # First element of fourth row (1-D Tensor) [8, 9] >>> rt[:, 1:3].eval().tolist() # Items 1-3 of each row (3-D RaggedTensor) [[[4]], [[], [6]], [], [[10]]] >>> rt[:, -1:].eval().tolist() # Last item of each row (3-D RaggedTensor) [[[4]], [[6]], [[7]], [[10]]]
__gt__
Defined in generated file: python/ops/gen_math_ops.py
__gt__( x, y, name=None )
Returns the truth value of (x > y) element-wise.
NOTE: math.greater
supports broadcasting. More about broadcasting
here
x
: A Tensor
. Must be one of the following types: float32
, float64
, int32
, uint8
, int16
, int8
, int64
, bfloat16
, uint16
, half
, uint32
, uint64
.y
: A Tensor
. Must have the same type as x
.name
: A name for the operation (optional).A Tensor
of type bool
.
__invert__
Defined in generated file: python/ops/gen_math_ops.py
__invert__( x, name=None )
Returns the truth value of NOT x element-wise.
x
: A Tensor
of type bool
.name
: A name for the operation (optional).A Tensor
of type bool
.
__le__
Defined in generated file: python/ops/gen_math_ops.py
__le__( x, y, name=None )
Returns the truth value of (x <= y) element-wise.
NOTE: math.less_equal
supports broadcasting. More about broadcasting
here
x
: A Tensor
. Must be one of the following types: float32
, float64
, int32
, uint8
, int16
, int8
, int64
, bfloat16
, uint16
, half
, uint32
, uint64
.y
: A Tensor
. Must have the same type as x
.name
: A name for the operation (optional).A Tensor
of type bool
.
__lt__
Defined in generated file: python/ops/gen_math_ops.py
__lt__( x, y, name=None )
Returns the truth value of (x < y) element-wise.
NOTE: math.less
supports broadcasting. More about broadcasting
here
x
: A Tensor
. Must be one of the following types: float32
, float64
, int32
, uint8
, int16
, int8
, int64
, bfloat16
, uint16
, half
, uint32
, uint64
.y
: A Tensor
. Must have the same type as x
.name
: A name for the operation (optional).A Tensor
of type bool
.
__mod__
Defined in generated file: python/ops/gen_math_ops.py
__mod__( x, y, name=None )
Returns element-wise remainder of division. When x < 0
xor y < 0
is
true, this follows Python semantics in that the result here is consistent
with a flooring divide. E.g. floor(x / y) * y + mod(x, y) = x
.
NOTE: math.floormod
supports broadcasting. More about broadcasting
here
x
: A Tensor
. Must be one of the following types: int32
, int64
, bfloat16
, half
, float32
, float64
.y
: A Tensor
. Must have the same type as x
.name
: A name for the operation (optional).A Tensor
. Has the same type as x
.
__mul__
__mul__( x, y, name=None )
Returns x * y element-wise.
NOTE: tf.multiply
supports broadcasting. More about broadcasting
here
x
: A Tensor
. Must be one of the following types: bfloat16
, half
, float32
, float64
, uint8
, int8
, uint16
, int16
, int32
, int64
, complex64
, complex128
.y
: A Tensor
. Must have the same type as x
.name
: A name for the operation (optional).A Tensor
. Has the same type as x
.
__neg__
Defined in generated file: python/ops/gen_math_ops.py
__neg__( x, name=None )
Computes numerical negative value element-wise.
I.e., \(y = -x\).
x
: A Tensor
. Must be one of the following types: bfloat16
, half
, float32
, float64
, int32
, int64
, complex64
, complex128
.name
: A name for the operation (optional).A Tensor
. Has the same type as x
.
If x
is a SparseTensor
, returns
SparseTensor(x.indices, tf.math.negative(x.values, ...), x.dense_shape)
__nonzero__
__nonzero__(_)
Dummy method to prevent a RaggedTensor from being used as a Python bool.
__or__
Defined in generated file: python/ops/gen_math_ops.py
__or__( x, y, name=None )
Returns the truth value of x OR y element-wise.
NOTE: math.logical_or
supports broadcasting. More about broadcasting
here
x
: A Tensor
of type bool
.y
: A Tensor
of type bool
.name
: A name for the operation (optional).A Tensor
of type bool
.
__pow__
__pow__( x, y, name=None )
Computes the power of one value to another.
Given a tensor x
and a tensor y
, this operation computes \(x^y\) for
corresponding elements in x
and y
. For example:
x = tf.constant([[2, 2], [3, 3]]) y = tf.constant([[8, 16], [2, 3]]) tf.pow(x, y) # [[256, 65536], [9, 27]]
x
: A Tensor
of type float16
, float32
, float64
, int32
, int64
,
complex64
, or complex128
.y
: A Tensor
of type float16
, float32
, float64
, int32
, int64
,
complex64
, or complex128
.name
: A name for the operation (optional).A Tensor
.
__radd__
Defined in generated file: python/ops/gen_math_ops.py
__radd__( x, y, name=None )
Returns x + y element-wise.
NOTE: math.add
supports broadcasting. AddN
does not. More about broadcasting
here
x
: A Tensor
. Must be one of the following types: bfloat16
, half
, float32
, float64
, uint8
, int8
, int16
, int32
, int64
, complex64
, complex128
, string
.y
: A Tensor
. Must have the same type as x
.name
: A name for the operation (optional).A Tensor
. Has the same type as x
.
__rand__
Defined in generated file: python/ops/gen_math_ops.py
__rand__( x, y, name=None )
Returns the truth value of x AND y element-wise.
NOTE: math.logical_and
supports broadcasting.  It will be removed in a future version. Instructions for updating: Deprecated in favor of operator or tf.math.divide.
NOTE: Prefer using the Tensor division operator or tf.divide which obey Python 3 division operator semantics.
This function divides x
and y
, forcing Python 2 semantics. That is, if x
and y
are both integers then the result will be an integer. This is in
contrast to Python 3, where division with /
is always a float while division
with //
is always an integer.
x
: Tensor
numerator of real numeric type.y
: Tensor
denominator of real numeric type.name
: A name for the operation (optional).x / y
returns the quotient of x and y.
__rfloordiv__
__rfloordiv__( x, y, name=None )
Divides x / y
elementwise, rounding toward the most negative integer.
The same as tf.compat.v1.div(x,y)
for integers, but uses
tf.floor(tf.compat.v1.div(x,y))
for
floating point arguments so that the result is always an integer (though
possibly an integer represented as floating point). This op is generated by
x // y
floor division in Python 3 and in Python 2.7 with
from __future__ import division
.
x
and y
must have the same type, and the result will have the same type
as well.
x
: Tensor
numerator of real numeric type.y
: Tensor
denominator of real numeric type.name
: A name for the operation (optional).x / y
rounded down.
TypeError
: If the inputs are complex.__rmod__
Defined in generated file: python/ops/gen_math_ops.py
__rmod__( x, y, name=None )
Returns element-wise remainder of division. When x < 0
xor y < 0
is
true, this follows Python semantics in that the result here is consistent
with a flooring divide. E.g. floor(x / y) * y + mod(x, y) = x
.
NOTE: math.floormod
supports broadcasting. More about broadcasting
here
x
: A Tensor
. Must be one of the following types: int32
, int64
, bfloat16
, half
, float32
, float64
.y
: A Tensor
. Must have the same type as x
.name
: A name for the operation (optional).A Tensor
. Has the same type as x
.
__rmul__
__rmul__( x, y, name=None )
Returns x * y element-wise.
NOTE: tf.multiply
supports broadcasting. More about broadcasting
here
x
: A Tensor
. Must be one of the following types: bfloat16
, half
, float32
, float64
, uint8
, int8
, uint16
, int16
, int32
, int64
, complex64
, complex128
.y
: A Tensor
. Must have the same type as x
.name
: A name for the operation (optional).A Tensor
. Has the same type as x
.
__ror__
Defined in generated file: python/ops/gen_math_ops.py
__ror__( x, y, name=None )
Returns the truth value of x OR y element-wise.
NOTE: math.logical_or
supports broadcasting. More about broadcasting
here
x
: A Tensor
of type bool
.y
: A Tensor
of type bool
.name
: A name for the operation (optional).A Tensor
of type bool
.
__rpow__
__rpow__( x, y, name=None )
Computes the power of one value to another.
Given a tensor x
and a tensor y
, this operation computes \(x^y\) for
corresponding elements in x
and y
. For example:
x = tf.constant([[2, 2], [3, 3]]) y = tf.constant([[8, 16], [2, 3]]) tf.pow(x, y) # [[256, 65536], [9, 27]]
x
: A Tensor
of type float16
, float32
, float64
, int32
, int64
,
complex64
, or complex128
.y
: A Tensor
of type float16
, float32
, float64
, int32
, int64
,
complex64
, or complex128
.name
: A name for the operation (optional).A Tensor
.
__rsub__
__rsub__( x, y, name=None )
Returns x - y element-wise.
NOTE: Subtract
supports broadcasting. More about broadcasting
here
x
: A Tensor
. Must be one of the following types: bfloat16
, half
, float32
, float64
, uint8
, int8
, uint16
, int16
, int32
, int64
, complex64
, complex128
.y
: A Tensor
. Must have the same type as x
.name
: A name for the operation (optional).A Tensor
. Has the same type as x
.
__rtruediv__
__rtruediv__( x, y, name=None )
Divides x / y elementwise (using Python 3 division operator semantics).
NOTE: Prefer using the Tensor operator or tf.divide which obey Python division operator semantics.
This function forces Python 3 division operator semantics where all integer
arguments are cast to floating types first. This op is generated by normal
x / y
division in Python 3 and in Python 2.7 with
from __future__ import division
. If you want integer division that rounds
down, use x // y
or tf.math.floordiv
.
x
and y
must have the same numeric type. If the inputs are floating
point, the output will have the same type. If the inputs are integral, the
inputs are cast to float32
for int8
and int16
and float64
for int32
and int64
(matching the behavior of Numpy).
x
: Tensor
numerator of numeric type.y
: Tensor
denominator of numeric type.name
: A name for the operation (optional).x / y
evaluated in floating point.
TypeError
: If x
and y
have different dtypes.__rxor__
__rxor__( x, y, name='LogicalXor' )
Logical XOR function.
x ^ y = (x | y) & ~(x & y)
Inputs are tensor and if the tensors contains more than one element, an element-wise logical XOR is computed.
x = tf.constant([False, False, True, True], dtype = tf.bool) y = tf.constant([False, True, False, True], dtype = tf.bool) z = tf.logical_xor(x, y, name="LogicalXor") # here z = [False True True False]
x
: A Tensor
type bool.y
: A Tensor
of type bool.A Tensor
of type bool with the same size as that of x or y.
__sub__
__sub__( x, y, name=None )
Returns x - y element-wise.
NOTE: Subtract
supports broadcasting. More about broadcasting
here
x
: A Tensor
. Must be one of the following types: bfloat16
, half
, float32
, float64
, uint8
, int8
, uint16
, int16
, int32
, int64
, complex64
, complex128
.y
: A Tensor
. Must have the same type as x
.name
: A name for the operation (optional).A Tensor
. Has the same type as x
.
__truediv__
__truediv__( x, y, name=None )
Divides x / y elementwise (using Python 3 division operator semantics).
NOTE: Prefer using the Tensor operator or tf.divide which obey Python division operator semantics.
This function forces Python 3 division operator semantics where all integer
arguments are cast to floating types first. This op is generated by normal
x / y
division in Python 3 and in Python 2.7 with
from __future__ import division
. If you want integer division that rounds
down, use x // y
or tf.math.floordiv
.
x
and y
must have the same numeric type. If the inputs are floating
point, the output will have the same type. If the inputs are integral, the
inputs are cast to float32
for int8
and int16
and float64
for int32
and int64
(matching the behavior of Numpy).
x
: Tensor
numerator of numeric type.y
: Tensor
denominator of numeric type.name
: A name for the operation (optional).x / y
evaluated in floating point.
TypeError
: If x
and y
have different dtypes.__xor__
__xor__( x, y, name='LogicalXor' )
Logical XOR function.
x ^ y = (x | y) & ~(x & y)
Inputs are tensor and if the tensors contains more than one element, an element-wise logical XOR is computed.
x = tf.constant([False, False, True, True], dtype = tf.bool) y = tf.constant([False, True, False, True], dtype = tf.bool) z = tf.logical_xor(x, y, name="LogicalXor") # here z = [False True True False]
x
: A Tensor
type bool.y
: A Tensor
of type bool.A Tensor
of type bool with the same size as that of x or y.
bounding_shape
bounding_shape( axis=None, name=None, out_type=None )
Returns the tight bounding box shape for this RaggedTensor
.
axis
: An integer scalar or vector indicating which axes to return the
bounding box for. If not specified, then the full bounding box is
returned.name
: A name prefix for the returned tensor (optional).out_type
: dtype
for the returned tensor. Defaults to
self.row_splits.dtype
.An integer Tensor
(dtype=self.row_splits.dtype
). If axis
is not
specified, then output
is a vector with
output.shape=[self.shape.ndims]
. If axis
is a scalar, then the
output
is a scalar. If axis
is a vector, then output
is a vector,
where output[i]
is the bounding size for dimension axis[i]
.
```python
rt = ragged.constant([[1, 2, 3, 4], [5], [], [6, 7, 8, 9], [10]]) rt.bounding_shape() [5, 4] ```
consumers
consumers()
from_nested_row_lengths
@classmethod from_nested_row_lengths( cls, flat_values, nested_row_lengths, name=None, validate=True )
Creates a RaggedTensor
from a nested list of row_lengths
tensors.
result = flat_values for row_lengths in reversed(nested_row_lengths): result = from_row_lengths(result, row_lengths)
flat_values
: A potentially ragged tensor.nested_row_lengths
: A list of 1-D integer tensors. The i
th tensor is
used as the row_lengths
for the i
th ragged dimension.name
: A name prefix for the RaggedTensor (optional).validate
: If true, then use assertions to check that the arguments form
a valid RaggedTensor
.A RaggedTensor
(or flat_values
if nested_row_lengths
is empty).
from_nested_row_splits
@classmethod from_nested_row_splits( cls, flat_values, nested_row_splits, name=None, validate=True )
Creates a RaggedTensor
from a nested list of row_splits
tensors.
result = flat_values for row_splits in reversed(nested_row_splits): result = from_row_splits(result, row_splits)
flat_values
: A potentially ragged tensor.nested_row_splits
: A list of 1-D integer tensors. The i
th tensor is
used as the row_splits
for the i
th ragged dimension.name
: A name prefix for the RaggedTensor (optional).validate
: If true, then use assertions to check that the arguments form a
valid RaggedTensor
.A RaggedTensor
(or flat_values
if nested_row_splits
is empty).
from_nested_value_rowids
@classmethod from_nested_value_rowids( cls, flat_values, nested_value_rowids, nested_nrows=None, name=None, validate=True )
Creates a RaggedTensor
from a nested list of value_rowids
tensors.
result = flat_values for (rowids, nrows) in reversed(zip(nested_value_rowids, nested_nrows)): result = from_value_rowids(result, rowids, nrows)
flat_values
: A potentially ragged tensor.nested_value_rowids
: A list of 1-D integer tensors. The i
th tensor is
used as the value_rowids
for the i
th ragged dimension.nested_nrows
: A list of integer scalars. The i
th scalar is used as the
nrows
for the i
th ragged dimension.name
: A name prefix for the RaggedTensor (optional).validate
: If true, then use assertions to check that the arguments form
a valid RaggedTensor
.A RaggedTensor
(or flat_values
if nested_value_rowids
is empty).
ValueError
: If len(nested_values_rowids) != len(nested_nrows)
.from_row_lengths
@classmethod from_row_lengths( cls, values, row_lengths, name=None, validate=True )
Creates a RaggedTensor
with rows partitioned by row_lengths
.
The returned RaggedTensor
corresponds with the python list defined by:
result = [[values.pop(0) for i in range(length)] for length in row_lengths]
values
: A potentially ragged tensor with shape [nvals, ...]
.row_lengths
: A 1-D integer tensor with shape [nrows]
. Must be
nonnegative. sum(row_lengths)
must be nvals
.name
: A name prefix for the RaggedTensor (optional).validate
: If true, then use assertions to check that the arguments form
a valid RaggedTensor
.A RaggedTensor
. result.rank = values.rank + 1
.
result.ragged_rank = values.ragged_rank + 1
.
```python
print(tf.RaggedTensor.from_row_lengths( ... values=[3, 1, 4, 1, 5, 9, 2, 6], ... row_lengths=[4, 0, 3, 1, 0]))
```
from_row_limits
@classmethod from_row_limits( cls, values, row_limits, name=None, validate=True )
Creates a RaggedTensor
with rows partitioned by row_limits
.
Equivalent to: from_row_splits(values, concat([0, row_limits]))
.
values
: A potentially ragged tensor with shape [nvals, ...]
.row_limits
: A 1-D integer tensor with shape [nrows]
. Must be sorted in
ascending order. If nrows>0
, then row_limits[-1]
must be nvals
.name
: A name prefix for the RaggedTensor (optional).validate
: If true, then use assertions to check that the arguments form
a valid RaggedTensor
.A RaggedTensor
. result.rank = values.rank + 1
.
result.ragged_rank = values.ragged_rank + 1
.
```python
print(tf.RaggedTensor.from_row_limits( ... values=[3, 1, 4, 1, 5, 9, 2, 6], ... row_limits=[4, 4, 7, 8, 8]))
```
from_row_splits
@classmethod from_row_splits( cls, values, row_splits, name=None, validate=True )
Creates a RaggedTensor
with rows partitioned by row_splits
.
The returned RaggedTensor
corresponds with the python list defined by:
result = [values[row_splits[i]:row_splits[i + 1]] for i in range(len(row_splits) - 1)]
values
: A potentially ragged tensor with shape [nvals, ...]
.row_splits
: A 1-D integer tensor with shape [nrows+1]
. Must not be
empty, and must be sorted in ascending order. row_splits[0]
must be
zero and row_splits[-1]
must be nvals
.name
: A name prefix for the RaggedTensor (optional).validate
: If true, then use assertions to check that the arguments form
a valid RaggedTensor
.A RaggedTensor
. result.rank = values.rank + 1
.
result.ragged_rank = values.ragged_rank + 1
.
ValueError
: If row_splits
is an empty list.```python
print(tf.RaggedTensor.from_row_splits( ... values=[3, 1, 4, 1, 5, 9, 2, 6], ... row_splits=[0, 4, 4, 7, 8, 8]))
```
from_row_starts
@classmethod from_row_starts( cls, values, row_starts, name=None, validate=True )
Creates a RaggedTensor
with rows partitioned by row_starts
.
Equivalent to: from_row_splits(values, concat([row_starts, nvals]))
.
values
: A potentially ragged tensor with shape [nvals, ...]
.row_starts
: A 1-D integer tensor with shape [nrows]
. Must be
nonnegative and sorted in ascending order. If nrows>0
, then
row_starts[0]
must be zero.name
: A name prefix for the RaggedTensor (optional).validate
: If true, then use assertions to check that the arguments form
a valid RaggedTensor
.A RaggedTensor
. result.rank = values.rank + 1
.
result.ragged_rank = values.ragged_rank + 1
.
```python
print(tf.RaggedTensor.from_row_starts( ... values=[3, 1, 4, 1, 5, 9, 2, 6], ... row_starts=[0, 4, 4, 7, 8]))
```
from_sparse
@classmethod from_sparse( cls, st_input, name=None, row_splits_dtype=tf.dtypes.int64 )
Converts a 2D tf.SparseTensor
to a RaggedTensor
.
Each row of the output
RaggedTensor
will contain the explicit values
from the same row in st_input
. st_input
must be ragged-right. If not
it is not ragged-right, then an error will be generated.
>>> st = SparseTensor(indices=[[0, 1], [0, 2], [0, 3], [1, 0], [3, 0]], ... values=[1, 2, 3, 4, 5], ... dense_shape=[4, 3]) >>> rt.RaggedTensor.from_sparse(st).eval().tolist() [[1, 2, 3], [4], [], [5]]
Currently, only two-dimensional SparseTensors
are supported.
st_input
: The sparse tensor to convert. Must have rank 2.name
: A name prefix for the returned tensors (optional).row_splits_dtype
: dtype
for the returned RaggedTensor
's row_splits
tensor. One of tf.int32
or tf.int64
.A RaggedTensor
with the same values as st_input
.
output.ragged_rank = rank(st_input) - 1
.
output.shape = [st_input.dense_shape[0], None]
.
ValueError
: If the number of dimensions in st_input
is not known
statically, or is not two.from_tensor
@classmethod from_tensor( cls, tensor, lengths=None, padding=None, ragged_rank=1, name=None, row_splits_dtype=tf.dtypes.int64 )
Converts a tf.Tensor
into a RaggedTensor
.
The set of absent/default values may be specified using a vector of lengths
or a padding value (but not both). If lengths
is specified, then the
output tensor will satisfy output[row] = tensor[row][:lengths[row]]
. If
'lengths' is a list of lists or tuple of lists, those lists will be used
as nested row lengths. If padding
is specified, then any row suffix
consisting entirely of padding
will be excluded from the returned
RaggedTensor
. If neither lengths
nor padding
is specified, then the
returned RaggedTensor
will have no absent/default values.
>>> dt = tf.constant([[5, 7, 0], [0, 3, 0], [6, 0, 0]]) >>> tf.RaggedTensor.from_tensor(dt) <tf.RaggedTensor [[5, 7, 0], [0, 3, 0], [6, 0, 0]]> >>> tf.RaggedTensor.from_tensor(dt, lengths=[1, 0, 3]) <tf.RaggedTensor [[5], [], [6, 0, 0]]>
tf.RaggedTensor.from_tensor(dt, padding=0)
dt = tf.constant([[[5, 0], [7, 0], [0, 0]], [[0, 0], [3, 0], [0, 0]], [[6, 0], [0, 0], [0, 0]]]) tf.RaggedTensor.from_tensor(dt, lengths=([2, 0, 3], [1, 1, 2, 0, 1]))
tensor
: The Tensor
to convert. Must have rank ragged_rank + 1
or
higher.lengths
: An optional set of row lengths, specified using a 1-D integer
Tensor
whose length is equal to tensor.shape[0]
(the number of rows
in tensor
). If specified, then output[row]
will contain
tensor[row][:lengths[row]]
. Negative lengths are treated as zero. You
may optionally pass a list or tuple of lengths to this argument, which
will be used as nested row lengths to construct a ragged tensor with
multiple ragged dimensions.padding
: An optional padding value. If specified, then any row suffix
consisting entirely of padding
will be excluded from the returned
RaggedTensor. padding
is a Tensor
with the same dtype as tensor
and with shape=tensor.shape[ragged_rank + 1:]
.ragged_rank
: Integer specifying the ragged rank for the returned
RaggedTensor
. Must be greater than zero.name
: A name prefix for the returned tensors (optional).row_splits_dtype
: dtype
for the returned RaggedTensor
's row_splits
tensor. One of tf.int32
or tf.int64
.A RaggedTensor
with the specified ragged_rank
. The shape of the
returned ragged tensor is compatible with the shape of tensor
.
ValueError
: If both lengths
and padding
are specified.from_value_rowids
@classmethod from_value_rowids( cls, values, value_rowids, nrows=None, name=None, validate=True )
Creates a RaggedTensor
with rows partitioned by value_rowids
.
The returned RaggedTensor
corresponds with the python list defined by:
result = [[values[i] for i in range(len(values)) if value_rowids[i] == row] for row in range(nrows)]
values
: A potentially ragged tensor with shape [nvals, ...]
.value_rowids
: A 1-D integer tensor with shape [nvals]
, which corresponds
one-to-one with values
, and specifies each value's row index. Must be
nonnegative, and must be sorted in ascending order.nrows
: An integer scalar specifying the number of rows. This should be
specified if the RaggedTensor
may containing empty training rows. Must
be greater than value_rowids[-1]
(or zero if value_rowids
is empty).
Defaults to value_rowids[-1]
(or zero if value_rowids
is empty).name
: A name prefix for the RaggedTensor (optional).validate
: If true, then use assertions to check that the arguments form
a valid RaggedTensor
.A RaggedTensor
. result.rank = values.rank + 1
.
result.ragged_rank = values.ragged_rank + 1
.
ValueError
: If nrows
is incompatible with value_rowids
.```python
print(tf.RaggedTensor.from_value_rowids( ... values=[3, 1, 4, 1, 5, 9, 2, 6], ... value_rowids=[0, 0, 0, 0, 2, 2, 2, 3], ... nrows=5))
```
nested_row_lengths
nested_row_lengths(name=None)
Returns a tuple containing the row_lengths for all ragged dimensions.
rt.nested_row_lengths()
is a tuple containing the row_lengths
tensors
for all ragged dimensions in rt
, ordered from outermost to innermost.
name
: A name prefix for the returned tensors (optional).A tuple
of 1-D integer Tensors
. The length of the tuple is equal to
self.ragged_rank
.
nested_value_rowids
nested_value_rowids(name=None)
Returns a tuple containing the value_rowids for all ragged dimensions.
rt.nested_value_rowids
is a tuple containing the value_rowids
tensors
for
all ragged dimensions in rt
, ordered from outermost to innermost. In
particular, rt.nested_value_rowids = (rt.value_rowids(),) + value_ids
where:
* `value_ids = ()` if `rt.values` is a `Tensor`. * `value_ids = rt.values.nested_value_rowids` otherwise.
name
: A name prefix for the returned tensors (optional).A tuple
of 1-D integer Tensor
s.
```python
rt = ragged.constant([[[[3, 1, 4, 1], [], [5, 9, 2]], [], [[6], []]]]) for i, ids in enumerate(rt.nested_value_rowids()): ... print('row ids for dimension %d: %s' % (i+1, ids)) row ids for dimension 1: [0] row ids for dimension 2: [0, 0, 0, 2, 2] row ids for dimension 3: [0, 0, 0, 0, 2, 2, 2, 3] ```
nrows
nrows( out_type=None, name=None )
Returns the number of rows in this ragged tensor.
I.e., the size of the outermost dimension of the tensor.
out_type
: dtype
for the returned tensor. Defaults to
self.row_splits.dtype
.name
: A name prefix for the returned tensor (optional).A scalar Tensor
with dtype out_type
.
```python
rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) rt.nrows() # rt has 5 rows. 5 ```
row_lengths
row_lengths( axis=1, name=None )
Returns the lengths of the rows in this ragged tensor.
rt.row_lengths()[i]
indicates the number of values in the
i
th row of rt
.
axis
: An integer constant indicating the axis whose row lengths should be
returned.name
: A name prefix for the returned tensor (optional).A potentially ragged integer Tensor with shape self.shape[:axis]
.
ValueError
: If axis
is out of bounds.```python
rt = ragged.constant([[[3, 1, 4], [1]], [], [[5, 9], [2]], [[6]], []]) rt.row_lengths(rt) # lengths of rows in rt tf.Tensor([2, 0, 2, 1, 0]) rt.row_lengths(axis=2) # lengths of axis=2 rows.
```
row_limits
row_limits(name=None)
Returns the limit indices for rows in this ragged tensor.
These indices specify where the values for each row end in
self.values
. rt.row_limits(self)
is equal to rt.row_splits[:-1]
.
name
: A name prefix for the returned tensor (optional).A 1-D integer Tensor with shape [nrows]
.
The returned tensor is nonnegative, and is sorted in ascending order.
```python
rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) rt.values tf.Tensor([3, 1, 4, 1, 5, 9, 2, 6]) rt.row_limits() # indices of row limits in rt.values tf.Tensor([4, 4, 7, 8, 8]) ```
row_starts
row_starts(name=None)
Returns the start indices for rows in this ragged tensor.
These indices specify where the values for each row begin in
self.values
. rt.row_starts()
is equal to rt.row_splits[:-1]
.
name
: A name prefix for the returned tensor (optional).A 1-D integer Tensor with shape [nrows]
.
The returned tensor is nonnegative, and is sorted in ascending order.
```python
rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) rt.values tf.Tensor([3, 1, 4, 1, 5, 9, 2, 6]) rt.row_starts() # indices of row starts in rt.values tf.Tensor([0, 4, 4, 7, 8]) ```
to_list
to_list()
Returns a nested Python list
with the values for this RaggedTensor
.
Requires that rt
was constructed in eager execution mode.
A nested Python list
.
to_sparse
to_sparse(name=None)
Converts this RaggedTensor
into a tf.SparseTensor
.
>>> rt = ragged.constant([[1, 2, 3], [4], [], [5, 6]]) >>> rt.to_sparse().eval() SparseTensorValue(indices=[[0, 0], [0, 1], [0, 2], [1, 0], [3, 0], [3, 1]], values=[1, 2, 3, 4, 5, 6], dense_shape=[4, 3])
name
: A name prefix for the returned tensors (optional).A SparseTensor with the same values as self
.
to_tensor
to_tensor( default_value=None, name=None )
Converts this RaggedTensor
into a tf.Tensor
.
>>> rt = ragged.constant([[9, 8, 7], [], [6, 5], [4]]) >>> print rt.to_tensor() [[9 8 7] [0 0 0] [6 5 0] [4 0 0]]
default_value
: Value to set for indices not specified in self
. Defaults
to zero. default_value
must be broadcastable to
self.shape[self.ragged_rank + 1:]
.name
: A name prefix for the returned tensors (optional).A Tensor
with shape ragged.bounding_shape(self)
and the
values specified by the non-empty values in self
. Empty values are
assigned default_value
.
value_rowids
value_rowids(name=None)
Returns the row indices for the values
in this ragged tensor.
rt.value_rowids()
corresponds one-to-one with the outermost dimension of
rt.values
, and specifies the row containing each value. In particular,
the row rt[row]
consists of the values rt.values[j]
where
rt.value_rowids()[j] == row
.
name
: A name prefix for the returned tensor (optional).A 1-D integer Tensor
with shape self.values.shape[:1]
.
The returned tensor is nonnegative, and is sorted in ascending order.
```python
rt = ragged.constant([[3, 1, 4, 1], [], [5, 9, 2], [6], []]) rt.values tf.Tensor([3, 1, 4, 1, 5, 9, 2, 6]) rt.value_rowids() tf.Tensor([0, 0, 0, 0, 2, 2, 2, 3]) # corresponds 1:1 with rt.values ```
with_flat_values
with_flat_values(new_values)
Returns a copy of self
with flat_values
replaced by new_value
.
Preserves cached row-partitioning tensors such as self.cached_nrows
and
self.cached_value_rowids
if they have values.
new_values
: Potentially ragged tensor that should replace
self.flat_values
. Must have rank > 0
, and must have the same
number of rows as self.flat_values
.A RaggedTensor
.
result.rank = self.ragged_rank + new_values.rank
.
result.ragged_rank = self.ragged_rank + new_values.ragged_rank
.
with_row_splits_dtype
with_row_splits_dtype(dtype)
Returns a copy of this RaggedTensor with the given row_splits
dtype.
For RaggedTensors with multiple ragged dimensions, the row_splits
for all
nested RaggedTensor
objects are cast to the given dtype.
A copy of this RaggedTensor, with the row_splits
cast to the given
type.
with_values
with_values(new_values)
Returns a copy of self
with values
replaced by new_value
.
Preserves cached row-partitioning tensors such as self.cached_nrows
and
self.cached_value_rowids
if they have values.
new_values
: Potentially ragged tensor to use as the values
for the
returned RaggedTensor
. Must have rank > 0
, and must have the same
number of rows as self.values
.A RaggedTensor
. result.rank = 1 + new_values.rank
.
result.ragged_rank = 1 + new_values.ragged_rank


Before Change
def __sub__(self, other):
if isinstance(other, collections.Iterable):
return TinyVector(map(lambda x,y: x - y ,self,other))
else:
return TinyVector(map(lambda x: x - other ,self))
def __rsub__(self, other):
if isinstance(other, collections.Iterable):
After Change
self = TinyVector(x+other for x in self)
return self
def __sub__(self, other):
if isinstance(other, collections.Iterable):
return TinyVector(x-y for x,y in zip(self,other))
else:
return TinyVector(x-other for x in self)
def __rsub__(self, other):
if isinstance(other, collections.Iterable):


Shakib Khan fined Tk 1m for breach of building design
by bdnews24.comThe capital development authority, or Rajuk, has fined actor Shakib Khan Tk 1 million for failing to adhere to the approved design of his building in Niketan residential area in Dhaka.
A mobile court led by Rajuk Executive Magistrate Ashraf Hossain launched a drive on the building on Monday, said Rajuk official Mohammad Hossain.
Shakib’s brother-in-law and a caretaker were present on the site during the mobile court’s drive. Shakib was not at home.
“The porch was extended by an inch,” Shakib told bdnews24.com by phone.
“However, Rajuk should have served a notice prior to the drive. We would have demolished it.”
Shakib said he would pay the fine as per Rajuk’s decision.


Well, it’s about that time you made the decision to reach us. The solution to your vehicle’s worries is just one click away.
We get feedback here!!!
Your email was recieved. We will get back shortly


Dylan Ashley
Reinforcement Learning ◇ Machine Learning ◇ Artificial Intelligence
Hi! I’m a Ph.D. student with Professor Jürgen Schmidhuber at the Swiss AI Lab IDSIA. I completed my M.Sc. in 2020 under the supervision of Professor Richard Sutton of the Alberta Machine Intelligence Institute. During my M.Sc., I served for a year as the Vice-President Academic of the Graduate Students’ Association. Before all of this, I was a B.Sc. student in Computing Science at the University of Alberta, and before that, I was a High School student in South Africa.
Most of my research focuses on various topics related to a particular branch of Artificial Intelligence called Reinforcement Learning, though I’m interested in Machine Learning more broadly. You can find a list of my publications here.
When my research gives me a free moment, you can often find me working to become a better amateur photographer. You can check out my portfolio here.


The X-Bolt Max Long Range May Be The World's Best Long-Range Gun
Here are the details.
by Gun News DailyKey point: Distance won't save you.
Browning has recently introduced a new rifle in their lineup: the X-Bolt Max Long Range.
The X-Bolt Max Long Range, as the name clearly suggests, is designed for long range shooting and is built appropriately for the task.
The rifle comes installed with a stainless steel fluted heavy sporter barrel, and features a threaded muzzle brake at the end to help reduce recoil. It also features a ⅝”-24 TPI suppressor thread, making it suppressor ready right out of the box.
The end of the Composite Max stock features spaces that allow you to adjust your length of pull, and the bolt handle has also been extended in contrast to other bolt action rifles so that ejecting spent shell cases and chambering new ones can be done much faster.
This rifle is also ready to be installed with a sling and bipod thanks to three swivel studs that are present on the rifle. The stock has a nice gray and black finish that you will be sure to notice as well.
Overall, if you’re looking for a brand new long range competition or hunting bolt action rifle, the X-Bolt Max Long Range could be worth a look.
This article by Will Ellis originally appeared at Gun News Daily in 2019.
This article first appeared last spring.
Image: Creative Commons.


|
JANA2
|
Public Member Functions | |
| JCsvWriter (std::string tag="") | |
| void | Init (void) override |
| JEventProcessor::Init, Process, and Finish are meant to be written by the user. More... | |
| void | Process (const std::shared_ptr< const JEvent > &event) override |
| Process i. | |
| void | Finish (void) override |
| string | GetType () const override |
| Public Member Functions inherited from JEventProcessor | |
| JEventProcessor (JApplication *app=nullptr) | |
| Status | GetStatus () const |
| std::string | GetPluginName () const |
| std::string | GetTypeName () const |
| std::string | GetResourceName () const |
| uint64_t | GetEventCount () const |
| JApplication * | GetApplication () const |
| bool | AreEventsOrdered () const |
| virtual void | DoInitialize () |
| virtual void | DoMap (const std::shared_ptr< const JEvent > &e) |
| virtual void | DoReduce (const std::shared_ptr< const JEvent > &e) |
| virtual void | DoFinalize () |
Additional Inherited Members | |
| Public Types inherited from JEventProcessor | |
| enum | Status { Unopened, Opened, Finished } |
| Protected Member Functions inherited from JEventProcessor | |
| void | SetTypeName (std::string type_name) |
| SetTypeName is intended as a replacement to GetType(), which should be less confusing for the user. More... | |
| void | SetResourceName (std::string resource_name) |
| Resource name lets the user tell the parallelization engine to synchronize different EventProcessors which write to the same shared resource; e.g. More... | |
| void | SetEventsOrdered (bool receive_events_in_order) |
| SetEventsOrdered allows the user to tell the parallelization engine that it needs to see the event stream ordered by increasing event IDs. More... | |
| Protected Attributes inherited from JEventProcessor | |
| JApplication * | mApplication = nullptr |
|
inlineoverridevirtual |
JEventProcessor::Init, Process, and Finish are meant to be written by the user.
Each JEventProcessor is intended to generate one distinct output,
Reimplemented from JEventProcessor.


Enter Product ID
Or search for product by name
{{product.title}}
{{$storage.productToMakeDeal.name}}
{{$storage.productToMakeDeal.price/100 | currency}}
Assigned to beacon {{$storage.selectedBeacon}} ?


|
ovs all
|
Public Member Functions | |
| def | __init__ (self, reconnect, rpc) |
| def | close (self) |
| def | run (self) |
| def | wait (self, poller) |
| def | get_backlog (self) |
| def | get_name (self) |
| def | send (self, msg) |
| def | recv (self) |
| def | recv_wait (self, poller) |
| def | is_alive (self) |
| def | is_connected (self) |
| def | get_seqno (self) |
| def | force_reconnect (self) |
Static Public Member Functions | |
| def | open (name) |
| def | open_unreliably (jsonrpc) |
Data Fields | |
| reconnect | |
| rpc | |
| stream | |
| pstream | |
| seqno | |
A JSON-RPC session with reconnection.
| def ovs.jsonrpc.Session.__init__ | ( | self, | |
| reconnect, | |||
| rpc | |||
| ) |
| def ovs.jsonrpc.Session.close | ( | self | ) |
| def ovs.jsonrpc.Session.force_reconnect | ( | self | ) |
| def ovs.jsonrpc.Session.get_backlog | ( | self | ) |
| def ovs.jsonrpc.Session.get_name | ( | self | ) |
| def ovs.jsonrpc.Session.is_alive | ( | self | ) |
| def ovs.jsonrpc.Session.is_connected | ( | self | ) |
|
static |
Creates and returns a Session that maintains a JSON-RPC session to 'name', which should be a string acceptable to ovs.stream.Stream or ovs.stream.PassiveStream's initializer. If 'name' is an active connection method, e.g. "tcp:<IP_ADDRESS>", the new session connects and reconnects, with back-off, to 'name'. If 'name' is a passive connection method, e.g. "ptcp:", the new session listens for connections to 'name'. It maintains at most one connection at any given time. Any new connection causes the previous one (if any) to be dropped.
|
static |
| def ovs.jsonrpc.Session.recv | ( | self | ) |
| def ovs.jsonrpc.Session.recv_wait | ( | self, | |
| poller | |||
| ) |
| def ovs.jsonrpc.Session.run | ( | self | ) |
| def ovs.jsonrpc.Session.send | ( | self, | |
| msg | |||
| ) |
| def ovs.jsonrpc.Session.wait | ( | self, | |
| poller | |||
| ) |
| ovs.jsonrpc.Session.pstream |
| ovs.jsonrpc.Session.reconnect |
| ovs.jsonrpc.Session.rpc |
| ovs.jsonrpc.Session.seqno |
| ovs.jsonrpc.Session.stream |


Handler for notifications sent by. More...
#include <Log.h>
Public Member Functions | |
| Log (int verbosityLevel=LOG_WARNING) | |
| Log (const Log &m) | |
| void | setVerbosity (int level) |
| int | getVerbosity () |
| void | start (int level, const std::string &sender) |
| Echoes the message, and halts on error. More... | |
| template<class T > | |
| void | handle (int level, const T &message, const std::string &sender) |
| void | flush () |
| void | flush (int level, const std::string &prefix, const std::stringstream &sstr) |
| long | getRelativeMilliseconds () |
| long | getMilliseconds () |
| void | resetTime () |
Public Attributes | |
| bool | VT100 |
| int | verbosityLevel |
Protected Attributes | |
| std::stringstream | sstr |
| int | msgLevel |
| const void * | currentSender |
| timeval | _time |
| long | _millisecondsStart |
Handler for notifications sent by.
TODO: add direct feed, perhaps Log::error() could instantiate a source?
|
inline |
|
inline |
Start new message, if new sender or new level
| void start | ( | int | level, |
| const std::string & | sender | ||
| ) |
Echoes the message, and halts on error.
Flush current buffer (Should be done already, but if not...)


Museum of Contemporary Art raises $6 million with auction
by The Associated PressChicago’s Museum of Contemporary Art has announced it raised $6 million with a benefit art auction, making it one of the most successful fundraisers in the institution’s history.
Museum director Madeleine Grynsztejn says the highest winning bid at the Nov. 16 auction was $1,150,000 for the 2018 painting “Untitled” by American artist Richard Prince, who donated the art.
Grynsztejn says the event featured work by some of the world’s most influential contemporary artists currently working, including fabric sculptor Nick Cave, feminist Judy Chicago and conceptual artist Rashid Johnson. Also auctioned were works of art from U.S. and European galleries.
According to Grynsztejn, the auction is an essential part of realizing the MCA’s commitment to advancing contemporary art.
The auction was led by Oliver Barker, the senior director and chairman of Sotheby’s Europe.
The Associated Press


Thong Guan may trend higher, says RHB Retail Research
by theedgemarkets.comKUALA LUMPUR (Nov 8): RHB Retail Research said Thong Guan Industries Bhd may trend higher after it formed a long white candle and hit its new 52-week high.
In a trading stocks note today, the research house said this could be viewed as a continuation of the bulls extending the rebound from the Oct 23’s “Hammer” pattern.
“A positive bias may emerge above the RM2.95 level, with an exit set below the RM2.72 threshold.
“Towards the upside, the immediate resistance is at RM3.20. This is followed by the RM3.37 level,” it said.


This little letter was written by my niece, Ruva when she was over for the holiday last year. She’s 7 years old and learns at Phoenix Primary School in Malawi. After bugging me to write something to her parents, I decided to let her write a letter I promised to post on my blog.
Copied below is what she had to say:
My name is Ruva Dawn Mukwenha.
Hi mum and dad. I’ve spent a long time in Zimbabwe. I came in June. I also want to tell the world to recycle waste material. My life in Zimbabwe is fun. On 14 July we went to watch rugby. On 15 July we went to green woodpark. My parents went back to Malawi, only spent five days in Zim.
So I stay with my grandmother and also my aunt. We go shopping we watch many stuff together like Idols and you know, girly stuff.
If you agree with the message about recycling, text on this exact same blog and tell other people that you know this very same message.
I love you all.


Toggle navigation
Farmers
Home
Blog
About Farmbase
Post Message
<EMAIL_ADDRESS>Edit Profile
Sign Out
Consultant Posts
Make your posts messages below
Manage your previous posts
Here...
Name of Post
Description(body)....
Cartegory
Select Cartegory...
Feeds, Suppliments and Seeds
Farm Machinery and Tools
Livestock, Poultry and Fish
Farm Produce
Product Img.


I am a fresh college graduate. Actually, in my thesis proposal, we propose a game that can help Grade 1 student to improve their Vocabulary and Pronunciation. To be honest, it is all self-study so it can be less messy. About Me
My research project is all about a game that help Grade 1 to their vocabulary. In this development I use C# Language.
In my free time I usually go to YouTube to learn some new techniques using Adobe Photoshop, Adobe After Effects and Premiere Pro.
It's still quite new to me. I'm still learning this language, but I`m confident that I can learn in a short time.
I am a fast-learner, team player and flexible.


Welcome to the Overlord RTGov (Runtime Governance) dashboard. This page serves as a jumping off point, providing quick access to frequently used functionality in the Runtime Governance UI.
Here you will find an analytics dashboard to help you analyse your system's activity.


Email<EMAIL_ADDRESS>Telephone +41 (0)76 515 88 77 (You’ll be talking to Kaspar)
Address
Technology Astronauts GmbH
Morgenstrasse 129
CH – 3018 Bern
Switzerland
Depending on our current mission, there will be a communications delay. Please leave a message and we’ll get back to you.


Home
Data
Data by State
Demography
Ranking
Analysis
Shows the collected Data
Update status
Total Confirmed
Total Recovered
Total Death
Daily Data:
No
Yes
Download


A linear congruential pseudorandom number generator (lcg).
$ npm install compute-lcg
For use in the browser, use browserify.
To use the module,
var lcg = require( 'compute-lcg' );
Returns a pseudorandom number generator.
var rand = lcg();
To seed the generator, provide a numeric
seed
var rand = lcg( 1234 );
Returns a pseudorandom floating-point number
between 0
and 1
.
var val = rand();
If provided a length n
, the method returns an array
of pseudorandom numbers.
var arr = rand( 10 );
// returns [...]
For a general lcg reference, see Wikipedia. Linear congruential generators use the following recurrence relation:
X_{n+1} = ( a*X_n + c ) mod m
In this implementation, the constants a
, c
, and m
have the following values:
a = 16807 c = 0 m = 2^31 - 1 =><PHONE_NUMBER>
The values for a
, c
, and m
are taken from Park and Miller, "Random Number Generators: Good Ones Are Hard To Find". Park's and Miller's article is also the basis for a recipe in the second edition of Numerical Recipes in C. For the most part, this implementation follows Numerical Recipes.
The generator has a period of approximately 2.1e9 [4].
Lcg is fast and uses little memory. On the other hand, because it is a simple linear congruential generator it has recognized shortcomings. By today's PRNG standards, its period, on the order of 2e9, is relatively short. More importantly, the "randomness quality" of its output is not of the best quality. These defects rule it out, for example, in Monte Carlo simulations and in cryptographic applications. For more on the advantages and disadvantages of LCGs see [5].
var lcg = require( 'compute-lcg' );
// Create a new (unseeded) generator:
var rand = lcg();
// Generate some pseudorandom numbers...
for ( var i = 0; i < 10; i++ ) {
console.log( rand() );
}
// Create a new (seeded) generator:
rand = lcg( 1 );
for ( var j = 0; j < 10; j++ ) {
console.log( rand() );
}
// Create a new generator seeded with the same seed as the previous generator:
rand = lcg( 1 );
console.log( rand( 10 ).join( '\n' ) );
To run the example code from the top-level application directory,
$ node ./examples/index.js
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
Test data generated from the C code published in Numerical Recipes.
1. Wikipedia. Linear Congruential Generator
2. S.K. Park and K.W. Miller (1988). "Random Number Generators: Good Ones Are Hard To Find". Communications of the ACM 31 (10): 1192-1201.
3. William H. Press, et. al., Numerical Recipes in C: The Art of Scientific Computing, Section 7.1 "Uniform Deviates" (2d ed. 1992) (hereinafter Numerical Recipes).
5. Wikipedia. Linear Congruential Generator.
Copyright © 2014. rgizz.


Release Notes
Release History
| Version | Date | Description |
|---|---|---|
| 3.1-SNAPSHOT | Nightly build | |
| 3.0 | 26.03.2018 | Earl Grey Release |
| 2.1 | 22.02.2016 | Darjeeling Release |
| 2.0 | 30.09.2015 | Camellia Release |
| 1.1.2 | 12.05.2015 | Minor bugfixes for 1.1 |
| 1.1.1 | 06.05.2015 | Minor bugfixes for 1.1 |
| 1.1 | 30.04.2015 | Black release |
| 1.0 | 19.12.2014 | Assam release |
Release 3.1-SNAPSHOT
No changes in this release.
Release 3.0 – 26.03.2018
| Type | Changes | By |
|---|---|---|
| Added support for arbitrary scheduling concepts. Fixes 318. | chw | |
| Added another scheduling concept: thread pool with task queues. Fixes 210. | chw | |
| Introduction of a configuration builder. Fixes 325. Thanks to Sören Henning. | ||
| AbstractStage.terminate() renamed to terminateStage(). Fixes 270. | ntd | |
| Switched to Java 1.8. Fixes 311. | chw | |
| Removed NotEnoughInputException and returnNoElement(). Fixes 313. | chw |
Release 2.1 – 22.02.2016
| Type | Changes | By |
|---|---|---|
| Introduced error codes. Fixes 163. | ntd | |
| Configuration can now be executed from command line. Fixes 247. | ntd | |
| Port connections can be validated before the execution of a configuration. Fixes 11. | ntd | |
| New Concept: Task farm enables an automatic stage duplication. Fixes 178. Thanks to Christian Claus Wiechmann. | ||
| Enable monitoring of pipe instances. Fixes 162. Thanks to Christian Claus Wiechmann. | ||
| Renamed AbstractCompositeStage to CompositeStage and made it non-abstract. | ntd | |
| Renamed TextLine to TextLineContainer. | ntd | |
| Renamed Distributor strategies. Fixes 245. | ntd | |
| Method declareActive() was moved to the class Stage. Fixes 222. | ntd | |
| Pipe classes were renamed. Fixes 209. | ntd | |
| Reduced the visibility of AbstractStage.onSignal() to package private. Fixes 260. | ntd | |
| Reduced the visibility of the class NotEnoughInputException to package private. Fixes 240. | ntd | |
| Various code quality improvements. | ||
| Removed IPipeFactory Fixes 232. | ntd |
Release 2.0 – 30.09.2015
| Type | Changes | By |
|---|---|---|
| New concept: composite stages. Fixes 93. | ntd | |
| New concept: TeeTime automatically chooses the correct type of pipe for all connections. Fixes 33. | ntd | |
| Added capacity to IPipe. Fixes 207. | chw | |
| Added the ability to add ports to a merger at runtime. Fixes 197. | chw | |
| Added the ability to add ports to a distributor at runtime. Fixes 172. | chw | |
| Threads can be added at runtime. Fixes 183. | chw | |
| Configurations can only be executed once. Fixes 195. | ntd | |
| Ports can be named for better debugging. Fixes 165. | ntd | |
| Stages without any input port are automatically executed in a dedicated thread. | ntd | |
| Configurations are now built within the Configuration class. This removes any constraints on CompositeStages and enables therefore multiple connections and multithreading in such stages. Fixes 171. | ntd | |
| All stages will be initialized before starting the analysis. Fixes 154. | ntd | |
| Threads can be named for better debugging. Fixes 122. | ntd | |
| Exceptions within the initialization will now terminate the execution. Fixes 170. | ntd | |
| Added Services. Any Execution can now be aborted. Fixes 211. | ntd | |
| Merged Stage into AbstractStage. Fixes 224. | ntd | |
| Merger and Distributor strategies are moved to a separate package. Fixes 189. | chw | |
| TerminatingExceptionListener is now the default listener. Fixes 185. | ntd | |
| Removed addThreadableStage and replaced it by AbstractStage.declareActive(). Fixes 174. | ntd | |
| Renamed Analysis to Execution. | ntd | |
| Removed InitializingSignal. Fixes 217. | ntd | |
| Removed pair class. | ntd |
Release 1.1.2 – 12.05.2015
| Type | Changes | By |
|---|---|---|
| Solved a bug in the merger stage. Fixes 151. Thanks to Nils C. Ehmke. | chw |
Release 1.1.1 – 06.05.2015
| Type | Changes | By |
|---|---|---|
| Solved a bug which led to a NullPointerExceptions. Fixes 151. Thanks to Nils C. Ehmke. | ntd | |
| Removed deprecated methods. Fixes 102. | ntd |
Release 1.1 – 30.04.2015
| Type | Changes | By |
|---|---|---|
| New concept: exception handling incl. Wiki tutorial. Fixes 32. | ntd | |
| New concept: unit test framework for testing a single stage. Fixes 107. Thanks to Nils C. Ehmke. | ||
| New class: AbstractTransformation; Represents a stage with a single input and a single output port. | chw | |
| New class: AbstractFilter; Represents a stage with a single input and a single output port of the same type. | chw | |
| Analysis.start() is now deprecated. Use Analysis.execute() instead. Fixes 92. | ntd | |
| Renamed Stage.executeWithPorts() to Stage.executeStage(). Fixes 120. Thanks to Arne J. Salveter. | ||
| Removed IterableProducer. Use InitialElementProducer instead. Fixes 112. | ntd | |
| Updated dependencies. Fixes 141. | chw | |
| Jar is not only published via the Central Maven Repository, but also via our CI server Jenkins. Fixes 72. | ntd | |
| #143 Null values can block the analysis. Fixes 143. | chw | |
| #109 Minor bug in ObjectProducer stage. Fixes 109. | ntd | |
| #75 Signal passing is incorrect. Fixes 75. | ntd |


--- layout: home --- {% assign filtered_posts = site.posts | where_exp: 'post', "post.most_read == true" %}


Interaction between C++ and Python¶
Users employ API in Python to describe their own network, however, the network construction actually happens in C++. so Protobuf is introduced to send the message between Python and C++.
The Interaction between Python and C++ can be simplified as two steps:
- C++ tells Python how many Ops there are, and what parameter do users need to offer to initialize a new Op. Python then builds API for each Op at compile time.
- Users invoke APIs built by Python and provide necessary parameters. These parameters will be sent to C++ fo finish Op construction task.
Message form C++ to Python¶
We define a Protobuf message class OpProto
to hold message needed in the first step. What should an OpProto
contain? This question is equivalent to “What message do we need to offer, to build a Python API which is legal and user oriented and can use to describe a whole Op.”
Following message are necessary:
- Op’s name, and its simple comment.
- Input and output variable number; each variable’s name, type, and comment.
- Op’s attributes; each attribute includes name, type, comment, default value and value range.
So OpProto
can be defined as follows:
enum AttrType {
INT = 1;
FLOAT = 2;
STRING = 3;
INTS = 4;
FLOATS = 5;
STRINGS = 6;
};
message AttrValue {
AttrType type = 1;
optional int iv = 2;
optional float fv = 3;
optional string sv = 4;
repeated int ivs = 5;
repeated float fvs = 6;
repeated string svs = 7;
};
message AttrProto {
required string name = 1;
required string comment = 2;
required AttrType type = 3;
};
message VarProto {
required string name = 1;
required string comment = 2;
};
message OpProto {
repeated VarProto inputs = 1;
repeated VarProto outputs = 2;
repeated AttrProto attrs = 3;
required string type = 4;
required string comment = 5;
};
To generate Python code automatically:
def create_python_ops_creatation_functions():
op_protos = paddle.framework.OpRegistry.get_all_op_proto()
for type_name in op_protos:
op_proto = op_protos[type_name]
def __impl__(**kwargs): # User must use key word args in Paddle API
inputs = [kwargs.get(ipt.name, "") for ipt in op_proto.inputs]
outputs = [kwargs.get(opt.name, "") for opt in op_proto.outputs]
attrs = [cast_to_op_attr(attr, kwargs.get(attr.name, None)) for attr in op_proto.attrs]
opdesc = （input, outputs, type_name, attrs）
return paddle.framework.OpRegistry.CreateOp(opdesc)
__impl__.__doc__ = create_doc_string(op_proto)
globals()[type_name] = __impl__
create_python_ops_creatation_functions()
Message from Python to C++¶
To hold message needed in the above second step, we define Protobuf message class OpDesc
. It is used to hold user-specified parameters in Op describing.
message OpDesc {
required string type = 1;
repeated string inputs = 2;
repeated string outputs = 3;
map<string, AttrValue> attrs = 4;
};
OpProto Register¶
Every Op has its own OpProto
. For using convenience, we need to register them and record all their messages. For each Op
class, we define a corresponding OpMaker
class, in whose constructor we implement the OpProto
‘s building process. OpMaker
‘s constructor will be invoked by another function OpRegistry::RegisterOp()
.
class OpProtoMaker {
public:
OpProtoMaker(OpProto* proto): proto_(proto) {}
protected:
OpProto* proto_;
void AddInput(const std::string& name, const std::string& desc) {...}
void AddAttr(const std::string& name, const std::string& desc, TypeId type) {...}
void AddComment(const std::string& comment) { ... }
};
class OpRegistry {
public:
using OpCreator = std::function<OperatorBase* (OpDesc& desc)>;
template <typename OpType, typename OpMaker>
static void RegisterOp(const std::string& name) {
gCreators_[name] = [](const OpDesc& desc) {
return new OpType(desc);
};
OpProto& opProto = gProtos_[name];
OpMaker()(&opProto);
}
static map<string, OpCreator> gCreators_;
static map<string, OpProto> gProtos_;
};
template <typename OpType, typename OpMaker>
class OpRegister {
public:
OpRegister(std::string type) {
OpRegistry::RegisterOp<OpType, OpMaker>(type);
}
};
#define REGISTER_OP(op_class, op_maker_class, type_name) \
class op_class##Register { \
private: \
const static OpRegister<#op_class, #op_maker_class> reg; \
}; \
const Register op_class##Register::reg(#type_name);
class CosineOp {
// ...
}
struct CosineOpProtoMaker : public OpProtoMaker {
CosineOpProtoMaker(OpProto* proto) : OpProtoMaker(proto) {
AddInput("input", "input of cosine op");
AddAttr("scale", "scale of cosine op", float).Default(1.0).LargerThan(0.0);
AddType("cos");
AddComment("This is cos op");
}
}
REGISTER_OP(CosineOp, CosineOpProtoMaker, cos);
In REGISTER_OP(CosineOp, CosineOpProtoMaker, cos)
, we register not only CosineOp
but also CosineOpProto
. As fields of CosineOpProto
, the default value and value range of scale
are also registered here.
Python API¶
Python APIs are divided into two types, high-level API and low-level API.
High-Level API¶
High-level API is called by users directly, so it should keep its style consistent with existing V2 APIs.
Here is a sample about how a define a fc layer:
hd = fc_layer(input=data, size=56, with_bias=True, activation="sigmoid");
hd
is the output of fc_layer
and it’s a variable
. It can be further sent into other layers as input.
The definition of fc_layer()
:
def fc_layer(input, size, with_bias, activation):
attr_map = {"size":size}
check_attrs(attr_map)
w = make_variable('w')
if with_bias:
b = make_variable('b')
else:
b = None
fc_output = make_variable('fc_output');
fc_op(input, w, b, fc_output, attr_map)
act_output = make_variable('sigmod_output');
if activation == "sigmod":
sigmod_op(fc_output, act_output);
elif:
# ...
return act_output;
Low Leval API¶
In above sample, fc_op
and sigmod_op
are low-level API. They build OpDesc
and invoke corresponding C++ code.
TODO


Seven Labs
Create an account
Already have an account? Login
By clicking "Register" you create account and agree to our Terms and Conditions and Privacy Policy.


Welcome new board members Brian Kesler and Kyle Kirchhoefer as well as returning board members Greg Sopa and Tim Yardley.
Thank you for your service Rachel Shekar!
It's time to cast your vote for the four open positions on the board for 2017/18! Voting will close November 30th, 2016.
You can access the electronic ballot here.
To opt for a paper ballot, please drop a note in the HOA dropbox.
One vote per household. Homeowners must be a member in good standing to vote in the election, and not owe the association more than $10. You can access the past due list by clicking here.
It's time to cast your vote for the four open positions on the board for 2017/18! Voting will close November 30th, 2016.
You can access the electronic ballot here.
To opt for a paper ballot, please drop a note in the HOA dropbox.
One vote per household. Homeowners must be a member in good standing to vote in the election, and not owe the association more than $10. You can access the past due list by clicking here.
If you are interested in running for a seat on the PF HOA Board of Directors, you can download an application form or contact the HOA via email.
The day to day operations of the PF HOA are run by an all-volunteer Board of Directors, along with help from many other committee volunteers. The Board establishes the annual dues assessment and is responsible for using the money assessed to maintain and improve HOA property and offer programs which are of value to Prairie Fields residents, thereby increasing the value of the neighborhood. If you have 1-2 hours a month to donate to the neighborhood, you are encouraged to run one of the 3 upcoming vacancies on the Board for a term which begins January 1, 2017 and runs through December 31, 2017. Applications must be submitted by October 21.
This year, voting will be conducted electronically. You can opt for paper ballots by dropping a note in the HOA dropbox. Homeowners must be a member in good standing to vote in the election, and not owe the association more than $10. You can access the past due list by clicking here.
For more information, please email<EMAIL_ADDRESS>The parade route will leave the park and go west on Gentian St., north on Tickseed Ave., east on Dropseed Dr., and south at Prairie Rose Lane where they will return to the Park. Residents are also encouraged to line the parade route and cheer the participants along.
Construction has now begun on Phase 14 of Prairie Fields. The layout for the new the new housing phase being constructed on the west of the PF subdivision is available here.
As with previous phases, phase will not be part of the HOA until it is completed. Until then, it is under the control of Signature Homes.
School has started and there are children walking to Carrie Busey and to the neighborhood bus stops. Please drive carefully!
You can help by slowing down, being sure to come to a complete stop and avoiding distractions. If possible, avoid the roads by Carrie Busey before and after school. Children should walk on the sidewalks as much as possible, and only cross on a crosswalk or when a guard is present
If you see speeding in our neighborhood contact the Sheriff's Department patrol commander, Lt. Brian Mennenga with your observations including specific information that may better engage in enforcement (eg. more specific times, directions, days of week that are worse, particular vehicle, etc.).
Meet at Prairie Fields park shortly before 9am with your bikes/strollers/wagons/children and pets decorated for the festivities! We will depart the park at 9am and return around 9:15am.
The route will be the usual "Prairie Fields Parade Route" starting on Gentian, heading North on Tickseed, and East on Dropseed back to the park. As we did last year, the Savoy Fire Department will be on hand to celebrate with us as well.
Please join your neighbors in celebrating!
Food vouchers for first 100 PF visitors!
The Prairie Fields Neighborhood Watch is up and running! If you would like to be added to the Neighborhood Watch email list, please add your contact information here.
Remember, if you see anything suspicious or out of the ordinary, call 911 first before spreading the word through the Neighborhood Watch email list or on Nextdoor.
With collective effort, Prairie Fields will remain a safe place to live, work, play, or attend school!
Deputy Oliger will be discussing how we can keep Prairie Fields a safe place to live.
Friday, January 22 7:30-8:30
Carrie Busey
The HOA Annual Meeting will be held on Thursday. January 21st at 7pm in the Carrie Busey library.
This is your chance to meet the Board Members, see the HOA budget, discuss neighborhood issues, learn about HOA committees that need your help, and suggest neighborhood events. All residents of Prairie Fields are encouraged to attend.
Annual Meeting Agenda (subject to change)
7:00 Call to Order
7:01 Welcome, Agenda, & Meeting Ground Rules
7:05 What is an HOA?
7:10 Board of Directors
7:12 What are covenants?
7:20 How your dues are spent
7:30 HOA committees
7:40 Current HOA Issues and Updates
8:00 Open Questions & Answers
Welcome new board members MariAnne Schmidt and Dan Harmon as well as returning board member PJ Trautman.
Thank you for your service Tyler Kuntz and Eric Ray!
For a list of announcement archives please email board@prairiefieldshoa.com.


Controlling Sound: Musical Torture from the Shoah to Guantánamo
“Purely physical torture is losing importance,” observed the psychologist Gustav Keller in 1981. “Psychological and psychiatric findings and methods are taking its place, planned and sometimes administered by white-collar torturers.” This statement, though prescient, is debatable: plenty of purely physical torture has been reported by former prisoners of Guantánamo and Bagram. The implication, however, is one of progress: that torture has been civilized, professionalized, in some way stripped of its teeth.
After the news broke that American soldiers were torturing detainees in secret prisons like Guantánamo, the idea spread that so-called “no touch” torture is more humane than more conventional methods involving violence to the body. No-touch torture utilizes methods like sleep deprivation, temperature regulation, violation of cultural and religious taboos, the playing of loud music, and psychological manipulation while interrogating prisoners. These methods, though often brutal, frequently don’t leave physical marks, thus nebulizing the concept of torture and leaving the act more open to interpretation.
Music torture at Guantánamo is a prime example of this mindset. Endless news cycles discussed whether waterboarding, hooding, and playing loud music could even be considered torture. Musicians, when asked for comment about “music torture”, sometimes responded dismissively: Metallica’s James Hetfield replied to the news with the comment, “We’ve been punishing our parents, our wives, our loved ones with this music for ever. Why should the Iraqis be any different?” Bob Singleton, who composed the often-used Barney the Purple Dinosaur theme song, wrote in the Los Angeles Times, “Would it annoy them? Perhaps … But could it ‘break’ the mental state of an adult? If so, that would say more about their mental state than about the music.”
The implication that these torture methods are somehow softer or easier to withstand than traditional methods is an interesting but dangerous fallacy. In no-touch torture, the torture weapon is the prisoner’s own body, which aches in stress positions, shivers, sweats, and demands sleep. The body itself becomes the enemy, psychologically destroying the prisoner from the inside out.
During war-crime trials, the torture weapon is often used as a synecdoche for the torture itself: a hammer, thumbscrew, or bathtub presented as evidence manifest the experience of that torture in an object. But with no-touch torture, where the weapon is the prisoner’s body, no such object exists to display as a remnant of the event. In the absence of a clearly identifiable torture weapon, the torture practiced on a prisoner becomes nearly invisible to outsiders, and the room itself becomes toxic for the victim.
As a physical torture, music is rarely used by itself; instead, it’s a component of the toxic environment. By blasting music, blaring lights, and keeping a cell ice cold, a prisoner is prevented from sleeping, and this deprivation is the ostensible goal. After enough of this treatment, prisoners are apparently easier to interrogate. As Sergeant Mark Hadsell of the 361st PsyOps Company in Iraq explained in 2003,
These people haven’t heard heavy metal. They can’t take it.  That’s when we come in and talk to them.
Beyond its psychological power, music’s physical properties also mean that it can be used as a weapon by itself. The US has used LRADs and infrasonic weapons, causing reports of blown out eardrums, dizziness, ringing, and temporary deafness. ‘Safe’ levels of sound are articulated in scientific language.
In Guantánamo, music’s physical and psychological properties interrelate. Not only does the music cause headaches and sound like loud, painful banging, its aesthetic qualities demand an innate human reaction. When we listen to music repeatedly, it inscribes itself in our brains (think of ‘getting a tune stuck in your head’ or a German ‘Ohrwurm’).
Musicologist Christian Grüny writes about a former prisoner of Guantanamo who was tortured with David Grey’s “Babylon,” a soft rock ballad seemingly chosen for the geographical coincidence (Babylon as a location in the Middle East). Years after his torture, when Grüny played a part of the song for him, he immediately burst into sobs. Suzanne Cusick describes how music’s cultural connotations come to symbolize the military power of the torturer. Because of music’s ability to get inside its listener, musical torture represents “the overwhelmingly diffuse Power that is outside one, but also is inside, and that operates by forcing one to comply against one’s will, against one’s interests, because there is no way, not even a retreat into interiority—to escape the pain.”
How do interrogators choose the soundtracks of musical torture? During the siege of Fallujah in November 2004, the 361st PsyOps company bombed the city with Metallica. As PsyOps spokesman Ben Abel explained at the time:
It’s not the music so much as the sound. It’s like throwing a smoke bomb. The aim is to disorient and confuse the enemy to gain a tactical advantage … our guys have been getting really creative in finding sounds they think would make the enemy upset …These guys have their own mini-disc players, with their own music, plus hundreds of downloaded sounds. It’s kind of personal preference how they choose the songs. We’ve got very young guys making these decisions.
During the siege of Fallujah, mullahs responded to American rap with “loudspeakers hooked to generators, trying to drown out Eminem with prayers, chants of Allahu Akbar, and Arabic music.”
In the course of my doctoral research, I’ve had the chance to reflect on the parallels between these news stories and the long history of musical torture. The other half of my project involves mapping some of the music heard in the infamous Nazi concentration camp Auschwitz. In some ways, the projects are so different as to seem unconnected: music played at Auschwitz was part of an overall culture of terror and control, but not a torture in itself. However, the same idea, that musical space is a metaphor for control, can be seen all over the camp. A particularly clear example can be heard in the hospital barracks at Auschwitz-Birkenau.
Szymon Laks, a survivor who was forced to play in the camp orchestra, describes how his ensemble was sent to the barracks on Christmas of 1943 to console the sick with carols, specifically “Stille Nacht” (“Silent Night”):
After a few bars quiet weeping began to be heard from all sides, which became louder as we played and finally burst out in general uncontrolled sobbing. I didn’t know what to do. To play on? Louder? From all sides, spasmodic cries began to roll in on me. ‘Enough of this! Stop! Clear out!
Laks, though a prisoner himself, appears here as a representative of Nazi power, simply because he’s playing Christmas carols to dying (largely Jewish) inmates.
 This music, to which they are forced to listen, disturbs them not only because it disrupts that space, but because it invades their bodies. A piece played inside a brick barrack would be audible on the path outside, and the march played next to the path would be audible to anyone within. Moreover, there is a limited distinction between sounds heard by guards and sounds heard by prisoners—a difference in psychological affect, certainly, but not in the music itself.
In other words, the sounds heard by guards and prisoners were often the same and, in this strange sense, prisoners and guards were and are united in their experience. In the case of musical torture during the war on terror, this sharing was, at least in one instance, more radical. Jonathan Pieslak records the following quote from U.S. soldier C.J. Grisham, who used music during interrogations in Iraq:
As long as they were listening to babies crying, I had to listen to babies crying …You are not allowed to do anything to the enemy, by law, that you wouldn’t do yourself. So if I’m getting eight hours of sleep, the people I’m interrogating have to get eight hours of sleep, if I’m only getting two hours of sleep, then my prisoners are only required to get two hours of sleep. We can’t treat them any worse than we treat ourselves.
This inference of shared experience through music is reminiscent of the musical warfare at the Siege of Fallujah, where opposing soundtracks competed for control of the city in a sonic analogue to the battle. It also articulates the sonic hegemony I’m investigating: how sound equalizes all ears, while still demonstrating an unequal power relation.
Grisham’s description of this army guideline, requiring a certain equality between prisoners and guards, provides an interesting inversion of a traditional understanding of torture. For Scarry, torture’s premise is the utter gulf between a person being tortured, who experiences the pain as world-destroying, and a person not being tortured, who doubts the existence of that pain because of its utter unsharability. The boundaries between torturer and victim blur—not in their power relations, but in the similarity of their experienced environment.
That shared environment is part of what I find so interesting about music in Auschwitz, and it is a feature of the camps that I have tried to visualize in my work. My partner Jake Melrose and I mapped forced music (which prisoners were required to play) in red, and voluntary music in blue. Performance allowed for a modicum of creative expression, an outlet not readily available for manual laborers. For example, after a rehearsal in Block 24 of Auschwitz I (the Main Camp), a Hungarian pianist played Chopin’s Funeral March (Piano Sonata #2 in B-flat minor), saying it was the only appropriate music considering the circumstances. This same Block 24, however, transformed into a perverse jazz club when SS officers came to unwind after a long day. They would ask musicians to play prohibited American jazz and ragtime songs like “Dinah,” “Sweet Sue,” “I Can’t Give You Anything but Love,” and “Alexander’s Ragtime Band.”
Alexander’s Ragtime Band
Directly outside Block 24 was the area through which work gangs marched into and out of the gates, accompanied by various marches like Fucik’s “Florentiner Marsch,” Liebling’s “Wenn Ich Traurig Bin,” and the “Horst Wessel Lied.” Obviously, this area could become a very different musical environment at different times of the day. By having the freedom to choose the music they wanted to hear, the guards made their authority clear and their control absolute. Moments of musical mourning, like the pianist playing Chopin, had to be squeezed in when no one was listening.
Chopin’s Piano Sonata #2 In B Flat Minor, Op. 35, “Funeral March”
Julius Fucik’s Florentiner Marsch
Music played in Guantánamo is similarly varied. The most confusing category to me is emotional, nostalgic music: Fleetwood Mac, Matchbox 20, Chris Christopherson, David Grey’s “Babylon” as well as children’s songs—notably the themes from Sesame Street and Barney the Purple Dinosaur. To me, this bespeaks a strange nostalgia for a specifically American childhood, even as those American children have grown up to inherit a world that is nothing like what they anticipated while watching Sesame Street.
“American Pie,” another song in this category, similarly invokes nostalgia for a lost past, in addition to carrying a religious implication—one verse reads, “the three men I admired most, the father, son, and holy ghost, they caught the last train to the coast, the day the music died”—in a kind of requiem for a nation that’s strayed from its God. The emotional thrust of this piece would hit American soldiers much harder than prisoners less familiar with Americana. This is a particularly American kind of abuse: aggressive exertion of cultural hegemony mixed with physical force, ostensible compliance with the “good guy” rules, and nostalgia for the lost American dream.
My project began as an attempt to think about music in space. How does music work to control space, and how can it affect bodies inhabiting that space? What does an environment that has been saturated with an enemy culture’s music sound like, and is the music functioning as anything beyond cultural aggression?
But one of the most interesting aspects for me, beyond those initial questions, has been the responses. The first comment from almost everyone who hears about my project is either a joke or a respectful “hmm,” depending on which case I begin with. If I start to describe music torture in Guantánamo, the comment will usually be a quip about what musical genre or artist they would consider torturous: country music, Yoko Ono, Justin Bieber, insert-hated-group-here. If I begin by describing the Auschwitz maps, the comment is something quiet, curious and respectful. It seems like firsthand evidence of the way we differentiate history from current events, and American behavior from everyone else’s.
And this American exceptionalism can prevent us from hearing crucial voices coming out of Guantánamo now. An op-ed in The New York Times on Sunday, April 14, 2013 by Samir Naji al Hasan Moqbel reported on a hunger strike in Guantánamo. It ended with the plea, “I just hope that because of the pain we are suffering, the eyes of the world will once again look to Guantánamo before it is too late.”


> spawning terminal... Add nodes to the scene and link them up to perform operations Keys: space - use chisel to perform actions


PlaidTab is designed specifically for you. It's a CMU-specific new tab extension that offers you a pick-me-up and a burst of motivation when you need it most. PlaidTab is the dashboard for every CMU student, highly customizable, and made to fit...you.


Hack 14 Get the Most Out of grep
You may not know where its odd name originated,
but you can't argue the usefulness of
grep.
Have
you ever needed to find a particular
file and thought, "I don't recall
the filename, but I remember some of its contents"?
The oddly named grep command does just that,
searching inside files and reporting on those that contain a given
piece of text.
2.3.1 Finding Text
Suppose
you
wish to search your shell scripts for the text
$USER. Try this:
% grep -s '$USER' *
add-user:if [ "$USER" != "root" ]; then
bu-user: echo " [-u user] - override $USER as the user to backup"
bu-user:if [ "$user" = "" ]; then user="$USER"; fi
del-user:if [ "$USER" != "root" ]; then
mount-host:mounted=$(df | grep "$ALM_AFP_MOUNT/$USER")
.....
mount-user: echo " [-u user] - override $USER as the user to backup"
mount-user:if [ "$user" = "" ]; then user="$USER"; fi
In this example, grep has searched through all
files in the current directory, displaying each line that contained
the text $USER. Use single quotes around the text
to prevent the shell from interpreting special characters. The
-s option suppresses error messages when
grep encounters a directory.
Perhaps you only want to know the name of each file containing the
text $USER. Use the -l option
to create that list for you:
% grep -ls '$USER' *
add-user
bu-user
del-user
mount-host
mount-user
2.3.2 Searching by Relevance
What if you're more concerned about how many times a
particular string occurs within a file? That's known
as a relevance
search
. Use a
command similar to:
% grep -sc '$USER' * | grep -v ':0' | sort -k 2 -t : -r
mount-host:6
mount-user:2
bu-user:2
del-user:1
add-user:1
How does this magic work? The -c flag lists each
file with a count of matching lines, but it unfortunately includes
files with zero matches. To counter this, I piped the output from
grep into a second grep, this
time searching for ':0' and using a second option,
-v, to reverse the sense of the search by
displaying lines that don't
match. The second grep reads from the pipe instead
of a file, searching the output of the first grep.
For a little extra flair, I sorted the subsequent output by the
second field of each line with sort -k 2, assuming
a field separator of colon (-t :) and using
-r to reverse the sort into descending order.
2.3.3 Document Extracts
Suppose
you wish to search a
set of documents and extract a few lines of text centered on each
occurrence of a keyword. This time we are interested in the matching
lines and their surrounding context, but not in the filenames. Use a
command something like this:
% grep -rhiw -A4 -B4 'preferences' *.txt > research.txt
% more research.txt
This grep command searches all files with the
.txt extension for the word
preferences. It performs a recursive search
(-r) to include all subdirectories, hides
(-h) the filename in the output, matches in a
case-insensitive (-i) manner, and matches
preferences as a complete word but not as part of
another word (-w). The -A4 and
-B4 options display the four lines immediately
after and before the matched
line, to give the desired context. Finally, I've
redirected the output to the file research.txt.
You could also send the output straight to the vim
text editor with:
% grep -rhiw -A4 -B4 'preferences' *.txt | vim -
Vim: Reading from stdin...
|
vim can be installed from
/usr/ports/editors/vim.
|
|
Specifying vim - tells vim to
read stdin (in this case the piped output from
grep) instead of a file. Type
:q! to exit vim.
To search files for several alternatives, use the
-e option to introduce extra search patterns:
% grep -e 'text1' -e 'text2' *
|
Q. How did grep get its odd name?
A. grep was written as a standalone program to
simulate a commonly performed command available in the ancient Unix
editor ex. The command in question searched an
entire file for lines containing a regular expression and displayed
those lines. The command was g/re/p:
globally search for a regular
expression and print the line.
|
|
2.3.4 Using Regular Expressions
To
search
for text that is more vaguely specified, use a regular expression.
grep understands both basic and extended regular
expressions, though it must be invoked as either
egrep or grep -E when given an
extended regular expression. The text or regular expression to be
matched is usually called the pattern.
Suppose you need to search for lines that end in a space or tab
character. Try this command (to insert a tab, press Ctrl-V and then
Ctrl-I, shown as <tab> in the example):
% grep -n '[ <tab>]$' test-file
2:ends in space
3:ends in tab
I used the [...] construct to form a regular
expression listing the characters to match: space and tab. The
expression matches exactly one space or one tab
character. $ anchors the match to the end of a
line. The -n flag tells grep to
include the line number in its output.
Alternatively, use:
% grep -n '[[:blank:]]$' test-file
2:ends is space
3:ends in tab
Regular expressions provide many preformed character groups of the
form [[:description:]].
Example groups include all control characters, all digits, or all
alphanumeric characters. See man
re_format for
details.
We can modify a previous example to search for either
"preferences" or
"preference" as a complete word,
using an extended regular expression such as this:
% egrep -rhiw -A4 -B4 'preferences?' *.txt > research.txt
The ? symbol specifies zero or one of the
preceding character, making the s of
preferences optional. Note that I use
egrep
because ? is
available only in extended regular expressions. If you wish to search
for the ? character itself, escape it with a
backslash, as in \?.
An alternative method uses an expression of the form
(string1|string2),
which matches either one string or the other:
% egrep -rhiw -A4 -B4 'preference(s|)' *.txt > research.txt
As a final example, use this to seek out all bash,
tcsh, or sh shell scripts:
% egrep '^#\!/bin/(ba|tc|)sh[[:blank:]]*$' *
The caret (^) character at the start of a regular
expression anchors it to the start of the line (much as
$ at the end anchors it to the end).
(ba|tc|) matches ba, tc, or nothing. The
* character specifies zero or more of
[[:blank:]], allowing trailing whitespace but
nothing else. Note that the ! character must be
escaped as \! to avoid shell interpretation in
tcsh (but not in bash).
|
Here's a handy tip for debugging
regular expressions: if you
don't pass a filename to grep, it
will read standard input, allowing you to enter lines of text to see
which match. grep will echo back only matching
lines.
|
|
2.3.5 Combining grep with Other Commands
grep works well with other
commands. For example, to
display all tcsh processes:
% ps axww | grep -w 'tcsh'
saruman 10329 0.0 0.2 6416 1196 p1 Ss Sat01PM 0:00.68 -tcsh (tcsh)
saruman 11351 0.0 0.2 6416 1300 std Ss Sat07PM 0:02.54 -tcsh (tcsh)
saruman 13360 0.0 0.0 1116 4 std R+ 10:57PM 0:00.00 grep -w tcsh
%
Notice that the grep command itself appears in the
output. To prevent this, use:
% ps axww | grep -w '[t]csh'
saruman 10329 0.0 0.2 6416 1196 p1 Ss Sat01PM 0:00.68 -tcsh (tcsh)
saruman 11351 0.0 0.2 6416 1300 std Ss Sat07PM 0:02.54 -tcsh (tcsh)
%
I'll let you figure out how this
works.
2.3.6 See Also
|