elektronn2.neuromancer.graphutils module¶
-
class
elektronn2.neuromancer.graphutils.
TaggedShape
(shape, tags, strides=None, mfp_offsets=None, fov=None)[source]¶ Bases:
object
Object to manage shape and associated tags uniformly. The
[]
-operator can be used get shape values by either index (int
) or tag (str
)Parameters: - shape (list/tuple of int) – shape of array, unspecified shapes are
None
- tags (list/tuple of strings or comma-separated string) – tags indicate which purpose the dimensions of the tensor serve. They are sometimes used to decide about reshapes. The maximal tensor has tags: “r, b, s, f, z, y, x, s” which denote: * r: perform recurrence along this axis * b: batch size * s: samples of the same instance (over which expectations are calculated) * f: features, filters, channels * z: convolution no. 3 (slower than 1,2) * y: convolution no. 1 * x: convolution no. 2
- strides – list of strides, only for spatial dimensions, so it is 1-3 long
- mfp_offsets –
-
addaxis
(axis, size, tag)[source]¶ Create new TaggedShape with new axis inserted at
axis
of sizesize
taggedtag
. If axis is a tag, the new axis is right of that tag
-
delaxis
(axis)[source]¶ Create new TaggedShape with new axis inserted at
axis
of sizesize
taggedtag
. If axis is a tag, the new axis is right of that tag
-
ext_repr
¶
-
fov
¶
-
fov_all_centered
¶
-
mfp_offsets
¶
-
ndim
¶
-
offsets
¶
-
shape
¶
-
spatial_axes
¶
-
spatial_shape
¶
-
spatial_size
¶
-
strides
¶
-
stripbatch_prod
¶ Calculate product excluding batch dimension
-
stripnone
¶ Return the shape but with all None elements removed (e.g. if batch size is unspecified)
-
stripnone_prod
¶ Return the product of the shape but with all None elements removed (e.g. if batch size is unspecified)
-
updatefov
(axis, new_fov)[source]¶ Create new TaggedShape with
new_fov
onaxis
. Axis is given as index of the spatial axes (not matching the absolute index of sh).
- shape (list/tuple of int) – shape of array, unspecified shapes are
-
class
elektronn2.neuromancer.graphutils.
make_func
(tt_input, tt_output, updates=None, name='Unnamed Function', borrow_inp=False, borrow_out=False, profile_execution=False)[source]¶ Bases:
object
Wrapper for compiled theano functions. Features:
- The function is compiled on demand (i.e. no wait at initialisation)
- Singleton return values are returned directly, multiple values as list
- The last execution time can inspected in the attribute
last_exec_time
- Functions can be timed:
profile_execution
is anint
that specifies the number of runs to average. The average time is printed then. - In/Out values can have a
borrow
flag which might overwrite the numpy arrays but might speed up execution (see theano doc)