partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | affine_respective_zoom_matrix | Get affine transform matrix for zooming/scaling that height and width are changed independently.
OpenCV format, x is width.
Parameters
-----------
w_range : float or tuple of 2 floats
The zooming/scaling ratio of width, greater than 1 means larger.
- float, a fixed ratio.
... | tensorlayer/prepro.py | def affine_respective_zoom_matrix(w_range=0.8, h_range=1.1):
"""Get affine transform matrix for zooming/scaling that height and width are changed independently.
OpenCV format, x is width.
Parameters
-----------
w_range : float or tuple of 2 floats
The zooming/scaling ratio of width, greater... | def affine_respective_zoom_matrix(w_range=0.8, h_range=1.1):
"""Get affine transform matrix for zooming/scaling that height and width are changed independently.
OpenCV format, x is width.
Parameters
-----------
w_range : float or tuple of 2 floats
The zooming/scaling ratio of width, greater... | [
"Get",
"affine",
"transform",
"matrix",
"for",
"zooming",
"/",
"scaling",
"that",
"height",
"and",
"width",
"are",
"changed",
"independently",
".",
"OpenCV",
"format",
"x",
"is",
"width",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L425-L464 | [
"def",
"affine_respective_zoom_matrix",
"(",
"w_range",
"=",
"0.8",
",",
"h_range",
"=",
"1.1",
")",
":",
"if",
"isinstance",
"(",
"h_range",
",",
"(",
"float",
",",
"int",
")",
")",
":",
"zy",
"=",
"h_range",
"elif",
"isinstance",
"(",
"h_range",
",",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | transform_matrix_offset_center | Convert the matrix from Cartesian coordinates (the origin in the middle of image) to Image coordinates (the origin on the top-left of image).
Parameters
----------
matrix : numpy.array
Transform matrix.
x and y : 2 int
Size of image.
Returns
-------
numpy.array
The ... | tensorlayer/prepro.py | def transform_matrix_offset_center(matrix, y, x):
"""Convert the matrix from Cartesian coordinates (the origin in the middle of image) to Image coordinates (the origin on the top-left of image).
Parameters
----------
matrix : numpy.array
Transform matrix.
x and y : 2 int
Size of ima... | def transform_matrix_offset_center(matrix, y, x):
"""Convert the matrix from Cartesian coordinates (the origin in the middle of image) to Image coordinates (the origin on the top-left of image).
Parameters
----------
matrix : numpy.array
Transform matrix.
x and y : 2 int
Size of ima... | [
"Convert",
"the",
"matrix",
"from",
"Cartesian",
"coordinates",
"(",
"the",
"origin",
"in",
"the",
"middle",
"of",
"image",
")",
"to",
"Image",
"coordinates",
"(",
"the",
"origin",
"on",
"the",
"top",
"-",
"left",
"of",
"image",
")",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L468-L492 | [
"def",
"transform_matrix_offset_center",
"(",
"matrix",
",",
"y",
",",
"x",
")",
":",
"o_x",
"=",
"(",
"x",
"-",
"1",
")",
"/",
"2.0",
"o_y",
"=",
"(",
"y",
"-",
"1",
")",
"/",
"2.0",
"offset_matrix",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"1"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | affine_transform | Return transformed images by given an affine matrix in Scipy format (x is height).
Parameters
----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
transform_matrix : numpy.array
Transform matrix (offset center), can be generated by ``transform_matrix_offs... | tensorlayer/prepro.py | def affine_transform(x, transform_matrix, channel_index=2, fill_mode='nearest', cval=0., order=1):
"""Return transformed images by given an affine matrix in Scipy format (x is height).
Parameters
----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
transform_... | def affine_transform(x, transform_matrix, channel_index=2, fill_mode='nearest', cval=0., order=1):
"""Return transformed images by given an affine matrix in Scipy format (x is height).
Parameters
----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
transform_... | [
"Return",
"transformed",
"images",
"by",
"given",
"an",
"affine",
"matrix",
"in",
"Scipy",
"format",
"(",
"x",
"is",
"height",
")",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L495-L548 | [
"def",
"affine_transform",
"(",
"x",
",",
"transform_matrix",
",",
"channel_index",
"=",
"2",
",",
"fill_mode",
"=",
"'nearest'",
",",
"cval",
"=",
"0.",
",",
"order",
"=",
"1",
")",
":",
"# transform_matrix = transform_matrix_offset_center()",
"# asdihasid",
"# a... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | affine_transform_cv2 | Return transformed images by given an affine matrix in OpenCV format (x is width). (Powered by OpenCV2, faster than ``tl.prepro.affine_transform``)
Parameters
----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
transform_matrix : numpy.array
A transform ... | tensorlayer/prepro.py | def affine_transform_cv2(x, transform_matrix, flags=None, border_mode='constant'):
"""Return transformed images by given an affine matrix in OpenCV format (x is width). (Powered by OpenCV2, faster than ``tl.prepro.affine_transform``)
Parameters
----------
x : numpy.array
An image with dimension... | def affine_transform_cv2(x, transform_matrix, flags=None, border_mode='constant'):
"""Return transformed images by given an affine matrix in OpenCV format (x is width). (Powered by OpenCV2, faster than ``tl.prepro.affine_transform``)
Parameters
----------
x : numpy.array
An image with dimension... | [
"Return",
"transformed",
"images",
"by",
"given",
"an",
"affine",
"matrix",
"in",
"OpenCV",
"format",
"(",
"x",
"is",
"width",
")",
".",
"(",
"Powered",
"by",
"OpenCV2",
"faster",
"than",
"tl",
".",
"prepro",
".",
"affine_transform",
")"
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L554-L584 | [
"def",
"affine_transform_cv2",
"(",
"x",
",",
"transform_matrix",
",",
"flags",
"=",
"None",
",",
"border_mode",
"=",
"'constant'",
")",
":",
"rows",
",",
"cols",
"=",
"x",
".",
"shape",
"[",
"0",
"]",
",",
"x",
".",
"shape",
"[",
"1",
"]",
"if",
"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | affine_transform_keypoints | Transform keypoint coordinates according to a given affine transform matrix.
OpenCV format, x is width.
Note that, for pose estimation task, flipping requires maintaining the left and right body information.
We should not flip the left and right body, so please use ``tl.prepro.keypoint_random_flip``.
... | tensorlayer/prepro.py | def affine_transform_keypoints(coords_list, transform_matrix):
"""Transform keypoint coordinates according to a given affine transform matrix.
OpenCV format, x is width.
Note that, for pose estimation task, flipping requires maintaining the left and right body information.
We should not flip the left a... | def affine_transform_keypoints(coords_list, transform_matrix):
"""Transform keypoint coordinates according to a given affine transform matrix.
OpenCV format, x is width.
Note that, for pose estimation task, flipping requires maintaining the left and right body information.
We should not flip the left a... | [
"Transform",
"keypoint",
"coordinates",
"according",
"to",
"a",
"given",
"affine",
"transform",
"matrix",
".",
"OpenCV",
"format",
"x",
"is",
"width",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L587-L628 | [
"def",
"affine_transform_keypoints",
"(",
"coords_list",
",",
"transform_matrix",
")",
":",
"coords_result_list",
"=",
"[",
"]",
"for",
"coords",
"in",
"coords_list",
":",
"coords",
"=",
"np",
".",
"asarray",
"(",
"coords",
")",
"coords",
"=",
"coords",
".",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | projective_transform_by_points | Projective transform by given coordinates, usually 4 coordinates.
see `scikit-image <http://scikit-image.org/docs/dev/auto_examples/applications/plot_geometric.html>`__.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
src : list or numpy
... | tensorlayer/prepro.py | def projective_transform_by_points(
x, src, dst, map_args=None, output_shape=None, order=1, mode='constant', cval=0.0, clip=True,
preserve_range=False
):
"""Projective transform by given coordinates, usually 4 coordinates.
see `scikit-image <http://scikit-image.org/docs/dev/auto_examples/applic... | def projective_transform_by_points(
x, src, dst, map_args=None, output_shape=None, order=1, mode='constant', cval=0.0, clip=True,
preserve_range=False
):
"""Projective transform by given coordinates, usually 4 coordinates.
see `scikit-image <http://scikit-image.org/docs/dev/auto_examples/applic... | [
"Projective",
"transform",
"by",
"given",
"coordinates",
"usually",
"4",
"coordinates",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L631-L705 | [
"def",
"projective_transform_by_points",
"(",
"x",
",",
"src",
",",
"dst",
",",
"map_args",
"=",
"None",
",",
"output_shape",
"=",
"None",
",",
"order",
"=",
"1",
",",
"mode",
"=",
"'constant'",
",",
"cval",
"=",
"0.0",
",",
"clip",
"=",
"True",
",",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | rotation | Rotate an image randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
rg : int or float
Degree to rotate, usually 0 ~ 180.
is_random : boolean
If True, randomly rotate. Default is False
row_index col_in... | tensorlayer/prepro.py | def rotation(
x, rg=20, is_random=False, row_index=0, col_index=1, channel_index=2, fill_mode='nearest', cval=0., order=1
):
"""Rotate an image randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
rg : int or floa... | def rotation(
x, rg=20, is_random=False, row_index=0, col_index=1, channel_index=2, fill_mode='nearest', cval=0., order=1
):
"""Rotate an image randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
rg : int or floa... | [
"Rotate",
"an",
"image",
"randomly",
"or",
"non",
"-",
"randomly",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L709-L752 | [
"def",
"rotation",
"(",
"x",
",",
"rg",
"=",
"20",
",",
"is_random",
"=",
"False",
",",
"row_index",
"=",
"0",
",",
"col_index",
"=",
"1",
",",
"channel_index",
"=",
"2",
",",
"fill_mode",
"=",
"'nearest'",
",",
"cval",
"=",
"0.",
",",
"order",
"="... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | crop | Randomly or centrally crop an image.
Parameters
----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
wrg : int
Size of width.
hrg : int
Size of height.
is_random : boolean,
If True, randomly crop, else central crop. Default is Fals... | tensorlayer/prepro.py | def crop(x, wrg, hrg, is_random=False, row_index=0, col_index=1):
"""Randomly or centrally crop an image.
Parameters
----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
wrg : int
Size of width.
hrg : int
Size of height.
is_random : bo... | def crop(x, wrg, hrg, is_random=False, row_index=0, col_index=1):
"""Randomly or centrally crop an image.
Parameters
----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
wrg : int
Size of width.
hrg : int
Size of height.
is_random : bo... | [
"Randomly",
"or",
"centrally",
"crop",
"an",
"image",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L794-L833 | [
"def",
"crop",
"(",
"x",
",",
"wrg",
",",
"hrg",
",",
"is_random",
"=",
"False",
",",
"row_index",
"=",
"0",
",",
"col_index",
"=",
"1",
")",
":",
"h",
",",
"w",
"=",
"x",
".",
"shape",
"[",
"row_index",
"]",
",",
"x",
".",
"shape",
"[",
"col... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | crop_multi | Randomly or centrally crop multiple images.
Parameters
----------
x : list of numpy.array
List of images with dimension of [n_images, row, col, channel] (default).
others : args
See ``tl.prepro.crop``.
Returns
-------
numpy.array
A list of processed images. | tensorlayer/prepro.py | def crop_multi(x, wrg, hrg, is_random=False, row_index=0, col_index=1):
"""Randomly or centrally crop multiple images.
Parameters
----------
x : list of numpy.array
List of images with dimension of [n_images, row, col, channel] (default).
others : args
See ``tl.prepro.crop``.
R... | def crop_multi(x, wrg, hrg, is_random=False, row_index=0, col_index=1):
"""Randomly or centrally crop multiple images.
Parameters
----------
x : list of numpy.array
List of images with dimension of [n_images, row, col, channel] (default).
others : args
See ``tl.prepro.crop``.
R... | [
"Randomly",
"or",
"centrally",
"crop",
"multiple",
"images",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L842-L877 | [
"def",
"crop_multi",
"(",
"x",
",",
"wrg",
",",
"hrg",
",",
"is_random",
"=",
"False",
",",
"row_index",
"=",
"0",
",",
"col_index",
"=",
"1",
")",
":",
"h",
",",
"w",
"=",
"x",
"[",
"0",
"]",
".",
"shape",
"[",
"row_index",
"]",
",",
"x",
"[... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | flip_axis | Flip the axis of an image, such as flip left and right, up and down, randomly or non-randomly,
Parameters
----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
axis : int
Which axis to flip.
- 0, flip up and down
- 1, flip left and ... | tensorlayer/prepro.py | def flip_axis(x, axis=1, is_random=False):
"""Flip the axis of an image, such as flip left and right, up and down, randomly or non-randomly,
Parameters
----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
axis : int
Which axis to flip.
- 0... | def flip_axis(x, axis=1, is_random=False):
"""Flip the axis of an image, such as flip left and right, up and down, randomly or non-randomly,
Parameters
----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
axis : int
Which axis to flip.
- 0... | [
"Flip",
"the",
"axis",
"of",
"an",
"image",
"such",
"as",
"flip",
"left",
"and",
"right",
"up",
"and",
"down",
"randomly",
"or",
"non",
"-",
"randomly"
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L881-L915 | [
"def",
"flip_axis",
"(",
"x",
",",
"axis",
"=",
"1",
",",
"is_random",
"=",
"False",
")",
":",
"if",
"is_random",
":",
"factor",
"=",
"np",
".",
"random",
".",
"uniform",
"(",
"-",
"1",
",",
"1",
")",
"if",
"factor",
">",
"0",
":",
"x",
"=",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | flip_axis_multi | Flip the axises of multiple images together, such as flip left and right, up and down, randomly or non-randomly,
Parameters
-----------
x : list of numpy.array
List of images with dimension of [n_images, row, col, channel] (default).
others : args
See ``tl.prepro.flip_axis``.
Retur... | tensorlayer/prepro.py | def flip_axis_multi(x, axis, is_random=False):
"""Flip the axises of multiple images together, such as flip left and right, up and down, randomly or non-randomly,
Parameters
-----------
x : list of numpy.array
List of images with dimension of [n_images, row, col, channel] (default).
others ... | def flip_axis_multi(x, axis, is_random=False):
"""Flip the axises of multiple images together, such as flip left and right, up and down, randomly or non-randomly,
Parameters
-----------
x : list of numpy.array
List of images with dimension of [n_images, row, col, channel] (default).
others ... | [
"Flip",
"the",
"axises",
"of",
"multiple",
"images",
"together",
"such",
"as",
"flip",
"left",
"and",
"right",
"up",
"and",
"down",
"randomly",
"or",
"non",
"-",
"randomly"
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L918-L961 | [
"def",
"flip_axis_multi",
"(",
"x",
",",
"axis",
",",
"is_random",
"=",
"False",
")",
":",
"if",
"is_random",
":",
"factor",
"=",
"np",
".",
"random",
".",
"uniform",
"(",
"-",
"1",
",",
"1",
")",
"if",
"factor",
">",
"0",
":",
"# x = np.asarray(x).s... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | shift | Shift an image randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
wrg : float
Percentage of shift in axis x, usually -0.25 ~ 0.25.
hrg : float
Percentage of shift in axis y, usually -0.25 ~ 0.25.
is_... | tensorlayer/prepro.py | def shift(
x, wrg=0.1, hrg=0.1, is_random=False, row_index=0, col_index=1, channel_index=2, fill_mode='nearest', cval=0.,
order=1
):
"""Shift an image randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
w... | def shift(
x, wrg=0.1, hrg=0.1, is_random=False, row_index=0, col_index=1, channel_index=2, fill_mode='nearest', cval=0.,
order=1
):
"""Shift an image randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
w... | [
"Shift",
"an",
"image",
"randomly",
"or",
"non",
"-",
"randomly",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L965-L1006 | [
"def",
"shift",
"(",
"x",
",",
"wrg",
"=",
"0.1",
",",
"hrg",
"=",
"0.1",
",",
"is_random",
"=",
"False",
",",
"row_index",
"=",
"0",
",",
"col_index",
"=",
"1",
",",
"channel_index",
"=",
"2",
",",
"fill_mode",
"=",
"'nearest'",
",",
"cval",
"=",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | shift_multi | Shift images with the same arguments, randomly or non-randomly.
Usually be used for image segmentation which x=[X, Y], X and Y should be matched.
Parameters
-----------
x : list of numpy.array
List of images with dimension of [n_images, row, col, channel] (default).
others : args
Se... | tensorlayer/prepro.py | def shift_multi(
x, wrg=0.1, hrg=0.1, is_random=False, row_index=0, col_index=1, channel_index=2, fill_mode='nearest', cval=0.,
order=1
):
"""Shift images with the same arguments, randomly or non-randomly.
Usually be used for image segmentation which x=[X, Y], X and Y should be matched.
Par... | def shift_multi(
x, wrg=0.1, hrg=0.1, is_random=False, row_index=0, col_index=1, channel_index=2, fill_mode='nearest', cval=0.,
order=1
):
"""Shift images with the same arguments, randomly or non-randomly.
Usually be used for image segmentation which x=[X, Y], X and Y should be matched.
Par... | [
"Shift",
"images",
"with",
"the",
"same",
"arguments",
"randomly",
"or",
"non",
"-",
"randomly",
".",
"Usually",
"be",
"used",
"for",
"image",
"segmentation",
"which",
"x",
"=",
"[",
"X",
"Y",
"]",
"X",
"and",
"Y",
"should",
"be",
"matched",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1009-L1041 | [
"def",
"shift_multi",
"(",
"x",
",",
"wrg",
"=",
"0.1",
",",
"hrg",
"=",
"0.1",
",",
"is_random",
"=",
"False",
",",
"row_index",
"=",
"0",
",",
"col_index",
"=",
"1",
",",
"channel_index",
"=",
"2",
",",
"fill_mode",
"=",
"'nearest'",
",",
"cval",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | shear | Shear an image randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
intensity : float
Percentage of shear, usually -0.5 ~ 0.5 (is_random==True), 0 ~ 0.5 (is_random==False),
you can have a quick try by shear(X,... | tensorlayer/prepro.py | def shear(
x, intensity=0.1, is_random=False, row_index=0, col_index=1, channel_index=2, fill_mode='nearest', cval=0.,
order=1
):
"""Shear an image randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
inte... | def shear(
x, intensity=0.1, is_random=False, row_index=0, col_index=1, channel_index=2, fill_mode='nearest', cval=0.,
order=1
):
"""Shear an image randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
inte... | [
"Shear",
"an",
"image",
"randomly",
"or",
"non",
"-",
"randomly",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1045-L1088 | [
"def",
"shear",
"(",
"x",
",",
"intensity",
"=",
"0.1",
",",
"is_random",
"=",
"False",
",",
"row_index",
"=",
"0",
",",
"col_index",
"=",
"1",
",",
"channel_index",
"=",
"2",
",",
"fill_mode",
"=",
"'nearest'",
",",
"cval",
"=",
"0.",
",",
"order",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | shear2 | Shear an image randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
shear : tuple of two floats
Percentage of shear for height and width direction (0, 1).
is_random : boolean
If True, randomly shear. Defau... | tensorlayer/prepro.py | def shear2(
x, shear=(0.1, 0.1), is_random=False, row_index=0, col_index=1, channel_index=2, fill_mode='nearest', cval=0.,
order=1
):
"""Shear an image randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
... | def shear2(
x, shear=(0.1, 0.1), is_random=False, row_index=0, col_index=1, channel_index=2, fill_mode='nearest', cval=0.,
order=1
):
"""Shear an image randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
... | [
"Shear",
"an",
"image",
"randomly",
"or",
"non",
"-",
"randomly",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1125-L1175 | [
"def",
"shear2",
"(",
"x",
",",
"shear",
"=",
"(",
"0.1",
",",
"0.1",
")",
",",
"is_random",
"=",
"False",
",",
"row_index",
"=",
"0",
",",
"col_index",
"=",
"1",
",",
"channel_index",
"=",
"2",
",",
"fill_mode",
"=",
"'nearest'",
",",
"cval",
"=",... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | swirl | Swirl an image randomly or non-randomly, see `scikit-image swirl API <http://scikit-image.org/docs/dev/api/skimage.transform.html#skimage.transform.swirl>`__
and `example <http://scikit-image.org/docs/dev/auto_examples/plot_swirl.html>`__.
Parameters
-----------
x : numpy.array
An image with di... | tensorlayer/prepro.py | def swirl(
x, center=None, strength=1, radius=100, rotation=0, output_shape=None, order=1, mode='constant', cval=0,
clip=True, preserve_range=False, is_random=False
):
"""Swirl an image randomly or non-randomly, see `scikit-image swirl API <http://scikit-image.org/docs/dev/api/skimage.transform.html... | def swirl(
x, center=None, strength=1, radius=100, rotation=0, output_shape=None, order=1, mode='constant', cval=0,
clip=True, preserve_range=False, is_random=False
):
"""Swirl an image randomly or non-randomly, see `scikit-image swirl API <http://scikit-image.org/docs/dev/api/skimage.transform.html... | [
"Swirl",
"an",
"image",
"randomly",
"or",
"non",
"-",
"randomly",
"see",
"scikit",
"-",
"image",
"swirl",
"API",
"<http",
":",
"//",
"scikit",
"-",
"image",
".",
"org",
"/",
"docs",
"/",
"dev",
"/",
"api",
"/",
"skimage",
".",
"transform",
".",
"html... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1219-L1290 | [
"def",
"swirl",
"(",
"x",
",",
"center",
"=",
"None",
",",
"strength",
"=",
"1",
",",
"radius",
"=",
"100",
",",
"rotation",
"=",
"0",
",",
"output_shape",
"=",
"None",
",",
"order",
"=",
"1",
",",
"mode",
"=",
"'constant'",
",",
"cval",
"=",
"0"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | elastic_transform | Elastic transformation for image as described in `[Simard2003] <http://deeplearning.cs.cmu.edu/pdfs/Simard.pdf>`__.
Parameters
-----------
x : numpy.array
A greyscale image.
alpha : float
Alpha value for elastic transformation.
sigma : float or sequence of float
The smaller ... | tensorlayer/prepro.py | def elastic_transform(x, alpha, sigma, mode="constant", cval=0, is_random=False):
"""Elastic transformation for image as described in `[Simard2003] <http://deeplearning.cs.cmu.edu/pdfs/Simard.pdf>`__.
Parameters
-----------
x : numpy.array
A greyscale image.
alpha : float
Alpha valu... | def elastic_transform(x, alpha, sigma, mode="constant", cval=0, is_random=False):
"""Elastic transformation for image as described in `[Simard2003] <http://deeplearning.cs.cmu.edu/pdfs/Simard.pdf>`__.
Parameters
-----------
x : numpy.array
A greyscale image.
alpha : float
Alpha valu... | [
"Elastic",
"transformation",
"for",
"image",
"as",
"described",
"in",
"[",
"Simard2003",
"]",
"<http",
":",
"//",
"deeplearning",
".",
"cs",
".",
"cmu",
".",
"edu",
"/",
"pdfs",
"/",
"Simard",
".",
"pdf",
">",
"__",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1341-L1399 | [
"def",
"elastic_transform",
"(",
"x",
",",
"alpha",
",",
"sigma",
",",
"mode",
"=",
"\"constant\"",
",",
"cval",
"=",
"0",
",",
"is_random",
"=",
"False",
")",
":",
"if",
"is_random",
"is",
"False",
":",
"random_state",
"=",
"np",
".",
"random",
".",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | zoom | Zooming/Scaling a single image that height and width are changed together.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
zoom_range : float or tuple of 2 floats
The zooming/scaling ratio, greater than 1 means larger.
- float... | tensorlayer/prepro.py | def zoom(x, zoom_range=(0.9, 1.1), flags=None, border_mode='constant'):
"""Zooming/Scaling a single image that height and width are changed together.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
zoom_range : float or tuple of 2 floats
... | def zoom(x, zoom_range=(0.9, 1.1), flags=None, border_mode='constant'):
"""Zooming/Scaling a single image that height and width are changed together.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
zoom_range : float or tuple of 2 floats
... | [
"Zooming",
"/",
"Scaling",
"a",
"single",
"image",
"that",
"height",
"and",
"width",
"are",
"changed",
"together",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1454-L1479 | [
"def",
"zoom",
"(",
"x",
",",
"zoom_range",
"=",
"(",
"0.9",
",",
"1.1",
")",
",",
"flags",
"=",
"None",
",",
"border_mode",
"=",
"'constant'",
")",
":",
"zoom_matrix",
"=",
"affine_zoom_matrix",
"(",
"zoom_range",
"=",
"zoom_range",
")",
"h",
",",
"w"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | respective_zoom | Zooming/Scaling a single image that height and width are changed independently.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
h_range : float or tuple of 2 floats
The zooming/scaling ratio of height, greater than 1 means larger.
... | tensorlayer/prepro.py | def respective_zoom(x, h_range=(0.9, 1.1), w_range=(0.9, 1.1), flags=None, border_mode='constant'):
"""Zooming/Scaling a single image that height and width are changed independently.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
h_range : f... | def respective_zoom(x, h_range=(0.9, 1.1), w_range=(0.9, 1.1), flags=None, border_mode='constant'):
"""Zooming/Scaling a single image that height and width are changed independently.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
h_range : f... | [
"Zooming",
"/",
"Scaling",
"a",
"single",
"image",
"that",
"height",
"and",
"width",
"are",
"changed",
"independently",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1482-L1513 | [
"def",
"respective_zoom",
"(",
"x",
",",
"h_range",
"=",
"(",
"0.9",
",",
"1.1",
")",
",",
"w_range",
"=",
"(",
"0.9",
",",
"1.1",
")",
",",
"flags",
"=",
"None",
",",
"border_mode",
"=",
"'constant'",
")",
":",
"zoom_matrix",
"=",
"affine_respective_z... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | zoom_multi | Zoom in and out of images with the same arguments, randomly or non-randomly.
Usually be used for image segmentation which x=[X, Y], X and Y should be matched.
Parameters
-----------
x : list of numpy.array
List of images with dimension of [n_images, row, col, channel] (default).
others : ar... | tensorlayer/prepro.py | def zoom_multi(x, zoom_range=(0.9, 1.1), flags=None, border_mode='constant'):
"""Zoom in and out of images with the same arguments, randomly or non-randomly.
Usually be used for image segmentation which x=[X, Y], X and Y should be matched.
Parameters
-----------
x : list of numpy.array
List... | def zoom_multi(x, zoom_range=(0.9, 1.1), flags=None, border_mode='constant'):
"""Zoom in and out of images with the same arguments, randomly or non-randomly.
Usually be used for image segmentation which x=[X, Y], X and Y should be matched.
Parameters
-----------
x : list of numpy.array
List... | [
"Zoom",
"in",
"and",
"out",
"of",
"images",
"with",
"the",
"same",
"arguments",
"randomly",
"or",
"non",
"-",
"randomly",
".",
"Usually",
"be",
"used",
"for",
"image",
"segmentation",
"which",
"x",
"=",
"[",
"X",
"Y",
"]",
"X",
"and",
"Y",
"should",
... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1516-L1540 | [
"def",
"zoom_multi",
"(",
"x",
",",
"zoom_range",
"=",
"(",
"0.9",
",",
"1.1",
")",
",",
"flags",
"=",
"None",
",",
"border_mode",
"=",
"'constant'",
")",
":",
"zoom_matrix",
"=",
"affine_zoom_matrix",
"(",
"zoom_range",
"=",
"zoom_range",
")",
"results",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | brightness | Change the brightness of a single image, randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
gamma : float
Non negative real number. Default value is 1.
- Small than 1 means brighter.
- If `is... | tensorlayer/prepro.py | def brightness(x, gamma=1, gain=1, is_random=False):
"""Change the brightness of a single image, randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
gamma : float
Non negative real number. Default value is 1.
... | def brightness(x, gamma=1, gain=1, is_random=False):
"""Change the brightness of a single image, randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
gamma : float
Non negative real number. Default value is 1.
... | [
"Change",
"the",
"brightness",
"of",
"a",
"single",
"image",
"randomly",
"or",
"non",
"-",
"randomly",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1549-L1579 | [
"def",
"brightness",
"(",
"x",
",",
"gamma",
"=",
"1",
",",
"gain",
"=",
"1",
",",
"is_random",
"=",
"False",
")",
":",
"if",
"is_random",
":",
"gamma",
"=",
"np",
".",
"random",
".",
"uniform",
"(",
"1",
"-",
"gamma",
",",
"1",
"+",
"gamma",
"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | brightness_multi | Change the brightness of multiply images, randomly or non-randomly.
Usually be used for image segmentation which x=[X, Y], X and Y should be matched.
Parameters
-----------
x : list of numpyarray
List of images with dimension of [n_images, row, col, channel] (default).
others : args
... | tensorlayer/prepro.py | def brightness_multi(x, gamma=1, gain=1, is_random=False):
"""Change the brightness of multiply images, randomly or non-randomly.
Usually be used for image segmentation which x=[X, Y], X and Y should be matched.
Parameters
-----------
x : list of numpyarray
List of images with dimension of ... | def brightness_multi(x, gamma=1, gain=1, is_random=False):
"""Change the brightness of multiply images, randomly or non-randomly.
Usually be used for image segmentation which x=[X, Y], X and Y should be matched.
Parameters
-----------
x : list of numpyarray
List of images with dimension of ... | [
"Change",
"the",
"brightness",
"of",
"multiply",
"images",
"randomly",
"or",
"non",
"-",
"randomly",
".",
"Usually",
"be",
"used",
"for",
"image",
"segmentation",
"which",
"x",
"=",
"[",
"X",
"Y",
"]",
"X",
"and",
"Y",
"should",
"be",
"matched",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1582-L1605 | [
"def",
"brightness_multi",
"(",
"x",
",",
"gamma",
"=",
"1",
",",
"gain",
"=",
"1",
",",
"is_random",
"=",
"False",
")",
":",
"if",
"is_random",
":",
"gamma",
"=",
"np",
".",
"random",
".",
"uniform",
"(",
"1",
"-",
"gamma",
",",
"1",
"+",
"gamma... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | illumination | Perform illumination augmentation for a single image, randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
gamma : float
Change brightness (the same with ``tl.prepro.brightness``)
- if is_random=False, one... | tensorlayer/prepro.py | def illumination(x, gamma=1., contrast=1., saturation=1., is_random=False):
"""Perform illumination augmentation for a single image, randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
gamma : float
Change bright... | def illumination(x, gamma=1., contrast=1., saturation=1., is_random=False):
"""Perform illumination augmentation for a single image, randomly or non-randomly.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
gamma : float
Change bright... | [
"Perform",
"illumination",
"augmentation",
"for",
"a",
"single",
"image",
"randomly",
"or",
"non",
"-",
"randomly",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1608-L1678 | [
"def",
"illumination",
"(",
"x",
",",
"gamma",
"=",
"1.",
",",
"contrast",
"=",
"1.",
",",
"saturation",
"=",
"1.",
",",
"is_random",
"=",
"False",
")",
":",
"if",
"is_random",
":",
"if",
"not",
"(",
"len",
"(",
"gamma",
")",
"==",
"len",
"(",
"c... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | rgb_to_hsv | Input RGB image [0~255] return HSV image [0~1].
Parameters
------------
rgb : numpy.array
An image with values between 0 and 255.
Returns
-------
numpy.array
A processed image. | tensorlayer/prepro.py | def rgb_to_hsv(rgb):
"""Input RGB image [0~255] return HSV image [0~1].
Parameters
------------
rgb : numpy.array
An image with values between 0 and 255.
Returns
-------
numpy.array
A processed image.
"""
# Translated from source of colorsys.rgb_to_hsv
# r,g,b ... | def rgb_to_hsv(rgb):
"""Input RGB image [0~255] return HSV image [0~1].
Parameters
------------
rgb : numpy.array
An image with values between 0 and 255.
Returns
-------
numpy.array
A processed image.
"""
# Translated from source of colorsys.rgb_to_hsv
# r,g,b ... | [
"Input",
"RGB",
"image",
"[",
"0~255",
"]",
"return",
"HSV",
"image",
"[",
"0~1",
"]",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1681-L1716 | [
"def",
"rgb_to_hsv",
"(",
"rgb",
")",
":",
"# Translated from source of colorsys.rgb_to_hsv",
"# r,g,b should be a numpy arrays with values between 0 and 255",
"# rgb_to_hsv returns an array of floats between 0.0 and 1.0.",
"rgb",
"=",
"rgb",
".",
"astype",
"(",
"'float'",
")",
"hs... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | hsv_to_rgb | Input HSV image [0~1] return RGB image [0~255].
Parameters
-------------
hsv : numpy.array
An image with values between 0.0 and 1.0
Returns
-------
numpy.array
A processed image. | tensorlayer/prepro.py | def hsv_to_rgb(hsv):
"""Input HSV image [0~1] return RGB image [0~255].
Parameters
-------------
hsv : numpy.array
An image with values between 0.0 and 1.0
Returns
-------
numpy.array
A processed image.
"""
# Translated from source of colorsys.hsv_to_rgb
# h,s s... | def hsv_to_rgb(hsv):
"""Input HSV image [0~1] return RGB image [0~255].
Parameters
-------------
hsv : numpy.array
An image with values between 0.0 and 1.0
Returns
-------
numpy.array
A processed image.
"""
# Translated from source of colorsys.hsv_to_rgb
# h,s s... | [
"Input",
"HSV",
"image",
"[",
"0~1",
"]",
"return",
"RGB",
"image",
"[",
"0~255",
"]",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1719-L1749 | [
"def",
"hsv_to_rgb",
"(",
"hsv",
")",
":",
"# Translated from source of colorsys.hsv_to_rgb",
"# h,s should be a numpy arrays with values between 0.0 and 1.0",
"# v should be a numpy array with values between 0.0 and 255.0",
"# hsv_to_rgb returns an array of uints between 0 and 255.",
"rgb",
"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | adjust_hue | Adjust hue of an RGB image.
This is a convenience method that converts an RGB image to float representation, converts it to HSV, add an offset to the hue channel, converts back to RGB and then back to the original data type.
For TF, see `tf.image.adjust_hue <https://www.tensorflow.org/api_docs/python/tf/image/... | tensorlayer/prepro.py | def adjust_hue(im, hout=0.66, is_offset=True, is_clip=True, is_random=False):
"""Adjust hue of an RGB image.
This is a convenience method that converts an RGB image to float representation, converts it to HSV, add an offset to the hue channel, converts back to RGB and then back to the original data type.
F... | def adjust_hue(im, hout=0.66, is_offset=True, is_clip=True, is_random=False):
"""Adjust hue of an RGB image.
This is a convenience method that converts an RGB image to float representation, converts it to HSV, add an offset to the hue channel, converts back to RGB and then back to the original data type.
F... | [
"Adjust",
"hue",
"of",
"an",
"RGB",
"image",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1752-L1808 | [
"def",
"adjust_hue",
"(",
"im",
",",
"hout",
"=",
"0.66",
",",
"is_offset",
"=",
"True",
",",
"is_clip",
"=",
"True",
",",
"is_random",
"=",
"False",
")",
":",
"hsv",
"=",
"rgb_to_hsv",
"(",
"im",
")",
"if",
"is_random",
":",
"hout",
"=",
"np",
"."... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | imresize | Resize an image by given output size and method.
Warning, this function will rescale the value to [0, 255].
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
size : list of 2 int or None
For height and width.
interp : str
I... | tensorlayer/prepro.py | def imresize(x, size=None, interp='bicubic', mode=None):
"""Resize an image by given output size and method.
Warning, this function will rescale the value to [0, 255].
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
size : list of 2 int ... | def imresize(x, size=None, interp='bicubic', mode=None):
"""Resize an image by given output size and method.
Warning, this function will rescale the value to [0, 255].
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
size : list of 2 int ... | [
"Resize",
"an",
"image",
"by",
"given",
"output",
"size",
"and",
"method",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1822-L1857 | [
"def",
"imresize",
"(",
"x",
",",
"size",
"=",
"None",
",",
"interp",
"=",
"'bicubic'",
",",
"mode",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"[",
"100",
",",
"100",
"]",
"if",
"x",
".",
"shape",
"[",
"-",
"1",
"]"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | pixel_value_scale | Scales each value in the pixels of the image.
Parameters
-----------
im : numpy.array
An image.
val : float
The scale value for changing pixel value.
- If is_random=False, multiply this value with all pixels.
- If is_random=True, multiply a value between [1-val, ... | tensorlayer/prepro.py | def pixel_value_scale(im, val=0.9, clip=None, is_random=False):
"""Scales each value in the pixels of the image.
Parameters
-----------
im : numpy.array
An image.
val : float
The scale value for changing pixel value.
- If is_random=False, multiply this value with all pix... | def pixel_value_scale(im, val=0.9, clip=None, is_random=False):
"""Scales each value in the pixels of the image.
Parameters
-----------
im : numpy.array
An image.
val : float
The scale value for changing pixel value.
- If is_random=False, multiply this value with all pix... | [
"Scales",
"each",
"value",
"in",
"the",
"pixels",
"of",
"the",
"image",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1861-L1907 | [
"def",
"pixel_value_scale",
"(",
"im",
",",
"val",
"=",
"0.9",
",",
"clip",
"=",
"None",
",",
"is_random",
"=",
"False",
")",
":",
"clip",
"=",
"clip",
"if",
"clip",
"is",
"not",
"None",
"else",
"(",
"-",
"np",
".",
"inf",
",",
"np",
".",
"inf",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | samplewise_norm | Normalize an image by rescale, samplewise centering and samplewise centering in order.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
rescale : float
Rescaling factor. If None or 0, no rescaling is applied, otherwise we multiply the data... | tensorlayer/prepro.py | def samplewise_norm(
x, rescale=None, samplewise_center=False, samplewise_std_normalization=False, channel_index=2, epsilon=1e-7
):
"""Normalize an image by rescale, samplewise centering and samplewise centering in order.
Parameters
-----------
x : numpy.array
An image with dimension of... | def samplewise_norm(
x, rescale=None, samplewise_center=False, samplewise_std_normalization=False, channel_index=2, epsilon=1e-7
):
"""Normalize an image by rescale, samplewise centering and samplewise centering in order.
Parameters
-----------
x : numpy.array
An image with dimension of... | [
"Normalize",
"an",
"image",
"by",
"rescale",
"samplewise",
"centering",
"and",
"samplewise",
"centering",
"in",
"order",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1911-L1965 | [
"def",
"samplewise_norm",
"(",
"x",
",",
"rescale",
"=",
"None",
",",
"samplewise_center",
"=",
"False",
",",
"samplewise_std_normalization",
"=",
"False",
",",
"channel_index",
"=",
"2",
",",
"epsilon",
"=",
"1e-7",
")",
":",
"if",
"rescale",
":",
"x",
"*... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | featurewise_norm | Normalize every pixels by the same given mean and std, which are usually
compute from all examples.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
mean : float
Value for subtraction.
std : float
Value for division.
ep... | tensorlayer/prepro.py | def featurewise_norm(x, mean=None, std=None, epsilon=1e-7):
"""Normalize every pixels by the same given mean and std, which are usually
compute from all examples.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
mean : float
Value ... | def featurewise_norm(x, mean=None, std=None, epsilon=1e-7):
"""Normalize every pixels by the same given mean and std, which are usually
compute from all examples.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
mean : float
Value ... | [
"Normalize",
"every",
"pixels",
"by",
"the",
"same",
"given",
"mean",
"and",
"std",
"which",
"are",
"usually",
"compute",
"from",
"all",
"examples",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1968-L1993 | [
"def",
"featurewise_norm",
"(",
"x",
",",
"mean",
"=",
"None",
",",
"std",
"=",
"None",
",",
"epsilon",
"=",
"1e-7",
")",
":",
"if",
"mean",
":",
"x",
"=",
"x",
"-",
"mean",
"if",
"std",
":",
"x",
"=",
"x",
"/",
"(",
"std",
"+",
"epsilon",
")... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | get_zca_whitening_principal_components_img | Return the ZCA whitening principal components matrix.
Parameters
-----------
x : numpy.array
Batch of images with dimension of [n_example, row, col, channel] (default).
Returns
-------
numpy.array
A processed image. | tensorlayer/prepro.py | def get_zca_whitening_principal_components_img(X):
"""Return the ZCA whitening principal components matrix.
Parameters
-----------
x : numpy.array
Batch of images with dimension of [n_example, row, col, channel] (default).
Returns
-------
numpy.array
A processed image.
... | def get_zca_whitening_principal_components_img(X):
"""Return the ZCA whitening principal components matrix.
Parameters
-----------
x : numpy.array
Batch of images with dimension of [n_example, row, col, channel] (default).
Returns
-------
numpy.array
A processed image.
... | [
"Return",
"the",
"ZCA",
"whitening",
"principal",
"components",
"matrix",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L1997-L2018 | [
"def",
"get_zca_whitening_principal_components_img",
"(",
"X",
")",
":",
"flatX",
"=",
"np",
".",
"reshape",
"(",
"X",
",",
"(",
"X",
".",
"shape",
"[",
"0",
"]",
",",
"X",
".",
"shape",
"[",
"1",
"]",
"*",
"X",
".",
"shape",
"[",
"2",
"]",
"*",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | zca_whitening | Apply ZCA whitening on an image by given principal components matrix.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
principal_components : matrix
Matrix from ``get_zca_whitening_principal_components_img``.
Returns
-------
n... | tensorlayer/prepro.py | def zca_whitening(x, principal_components):
"""Apply ZCA whitening on an image by given principal components matrix.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
principal_components : matrix
Matrix from ``get_zca_whitening_princip... | def zca_whitening(x, principal_components):
"""Apply ZCA whitening on an image by given principal components matrix.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
principal_components : matrix
Matrix from ``get_zca_whitening_princip... | [
"Apply",
"ZCA",
"whitening",
"on",
"an",
"image",
"by",
"given",
"principal",
"components",
"matrix",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2021-L2044 | [
"def",
"zca_whitening",
"(",
"x",
",",
"principal_components",
")",
":",
"flatx",
"=",
"np",
".",
"reshape",
"(",
"x",
",",
"(",
"x",
".",
"size",
")",
")",
"# tl.logging.info(principal_components.shape, x.shape) # ((28160, 28160), (160, 176, 1))",
"# flatx = np.reshap... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | channel_shift | Shift the channels of an image, randomly or non-randomly, see `numpy.rollaxis <https://docs.scipy.org/doc/numpy/reference/generated/numpy.rollaxis.html>`__.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] (default).
intensity : float
Intensity of sh... | tensorlayer/prepro.py | def channel_shift(x, intensity, is_random=False, channel_index=2):
"""Shift the channels of an image, randomly or non-randomly, see `numpy.rollaxis <https://docs.scipy.org/doc/numpy/reference/generated/numpy.rollaxis.html>`__.
Parameters
-----------
x : numpy.array
An image with dimension of [r... | def channel_shift(x, intensity, is_random=False, channel_index=2):
"""Shift the channels of an image, randomly or non-randomly, see `numpy.rollaxis <https://docs.scipy.org/doc/numpy/reference/generated/numpy.rollaxis.html>`__.
Parameters
-----------
x : numpy.array
An image with dimension of [r... | [
"Shift",
"the",
"channels",
"of",
"an",
"image",
"randomly",
"or",
"non",
"-",
"randomly",
"see",
"numpy",
".",
"rollaxis",
"<https",
":",
"//",
"docs",
".",
"scipy",
".",
"org",
"/",
"doc",
"/",
"numpy",
"/",
"reference",
"/",
"generated",
"/",
"numpy... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2060-L2089 | [
"def",
"channel_shift",
"(",
"x",
",",
"intensity",
",",
"is_random",
"=",
"False",
",",
"channel_index",
"=",
"2",
")",
":",
"if",
"is_random",
":",
"factor",
"=",
"np",
".",
"random",
".",
"uniform",
"(",
"-",
"intensity",
",",
"intensity",
")",
"els... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | channel_shift_multi | Shift the channels of images with the same arguments, randomly or non-randomly, see `numpy.rollaxis <https://docs.scipy.org/doc/numpy/reference/generated/numpy.rollaxis.html>`__.
Usually be used for image segmentation which x=[X, Y], X and Y should be matched.
Parameters
-----------
x : list of numpy.a... | tensorlayer/prepro.py | def channel_shift_multi(x, intensity, is_random=False, channel_index=2):
"""Shift the channels of images with the same arguments, randomly or non-randomly, see `numpy.rollaxis <https://docs.scipy.org/doc/numpy/reference/generated/numpy.rollaxis.html>`__.
Usually be used for image segmentation which x=[X, Y], X ... | def channel_shift_multi(x, intensity, is_random=False, channel_index=2):
"""Shift the channels of images with the same arguments, randomly or non-randomly, see `numpy.rollaxis <https://docs.scipy.org/doc/numpy/reference/generated/numpy.rollaxis.html>`__.
Usually be used for image segmentation which x=[X, Y], X ... | [
"Shift",
"the",
"channels",
"of",
"images",
"with",
"the",
"same",
"arguments",
"randomly",
"or",
"non",
"-",
"randomly",
"see",
"numpy",
".",
"rollaxis",
"<https",
":",
"//",
"docs",
".",
"scipy",
".",
"org",
"/",
"doc",
"/",
"numpy",
"/",
"reference",
... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2099-L2129 | [
"def",
"channel_shift_multi",
"(",
"x",
",",
"intensity",
",",
"is_random",
"=",
"False",
",",
"channel_index",
"=",
"2",
")",
":",
"if",
"is_random",
":",
"factor",
"=",
"np",
".",
"random",
".",
"uniform",
"(",
"-",
"intensity",
",",
"intensity",
")",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | drop | Randomly set some pixels to zero by a given keeping probability.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] or [row, col].
keep : float
The keeping probability (0, 1), the lower more values will be set to zero.
Returns
-------
nump... | tensorlayer/prepro.py | def drop(x, keep=0.5):
"""Randomly set some pixels to zero by a given keeping probability.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] or [row, col].
keep : float
The keeping probability (0, 1), the lower more values will be set to zero.
... | def drop(x, keep=0.5):
"""Randomly set some pixels to zero by a given keeping probability.
Parameters
-----------
x : numpy.array
An image with dimension of [row, col, channel] or [row, col].
keep : float
The keeping probability (0, 1), the lower more values will be set to zero.
... | [
"Randomly",
"set",
"some",
"pixels",
"to",
"zero",
"by",
"a",
"given",
"keeping",
"probability",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2133-L2165 | [
"def",
"drop",
"(",
"x",
",",
"keep",
"=",
"0.5",
")",
":",
"if",
"len",
"(",
"x",
".",
"shape",
")",
"==",
"3",
":",
"if",
"x",
".",
"shape",
"[",
"-",
"1",
"]",
"==",
"3",
":",
"# color",
"img_size",
"=",
"x",
".",
"shape",
"mask",
"=",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | array_to_img | Converts a numpy array to PIL image object (uint8 format).
Parameters
----------
x : numpy.array
An image with dimension of 3 and channels of 1 or 3.
dim_ordering : tuple of 3 int
Index of row, col and channel, default (0, 1, 2), for theano (1, 2, 0).
scale : boolean
If True... | tensorlayer/prepro.py | def array_to_img(x, dim_ordering=(0, 1, 2), scale=True):
"""Converts a numpy array to PIL image object (uint8 format).
Parameters
----------
x : numpy.array
An image with dimension of 3 and channels of 1 or 3.
dim_ordering : tuple of 3 int
Index of row, col and channel, default (0, ... | def array_to_img(x, dim_ordering=(0, 1, 2), scale=True):
"""Converts a numpy array to PIL image object (uint8 format).
Parameters
----------
x : numpy.array
An image with dimension of 3 and channels of 1 or 3.
dim_ordering : tuple of 3 int
Index of row, col and channel, default (0, ... | [
"Converts",
"a",
"numpy",
"array",
"to",
"PIL",
"image",
"object",
"(",
"uint8",
"format",
")",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2180-L2227 | [
"def",
"array_to_img",
"(",
"x",
",",
"dim_ordering",
"=",
"(",
"0",
",",
"1",
",",
"2",
")",
",",
"scale",
"=",
"True",
")",
":",
"# if dim_ordering == 'default':",
"# dim_ordering = K.image_dim_ordering()",
"# if dim_ordering == 'th': # theano",
"# x = x.tran... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | find_contours | Find iso-valued contours in a 2D array for a given level value, returns list of (n, 2)-ndarrays
see `skimage.measure.find_contours <http://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.find_contours>`__.
Parameters
------------
x : 2D ndarray of double.
Input data in which ... | tensorlayer/prepro.py | def find_contours(x, level=0.8, fully_connected='low', positive_orientation='low'):
"""Find iso-valued contours in a 2D array for a given level value, returns list of (n, 2)-ndarrays
see `skimage.measure.find_contours <http://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.find_contours>`__.
... | def find_contours(x, level=0.8, fully_connected='low', positive_orientation='low'):
"""Find iso-valued contours in a 2D array for a given level value, returns list of (n, 2)-ndarrays
see `skimage.measure.find_contours <http://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.find_contours>`__.
... | [
"Find",
"iso",
"-",
"valued",
"contours",
"in",
"a",
"2D",
"array",
"for",
"a",
"given",
"level",
"value",
"returns",
"list",
"of",
"(",
"n",
"2",
")",
"-",
"ndarrays",
"see",
"skimage",
".",
"measure",
".",
"find_contours",
"<http",
":",
"//",
"scikit... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2230-L2253 | [
"def",
"find_contours",
"(",
"x",
",",
"level",
"=",
"0.8",
",",
"fully_connected",
"=",
"'low'",
",",
"positive_orientation",
"=",
"'low'",
")",
":",
"return",
"skimage",
".",
"measure",
".",
"find_contours",
"(",
"x",
",",
"level",
",",
"fully_connected",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | pt2map | Inputs a list of points, return a 2D image.
Parameters
--------------
list_points : list of 2 int
[[x, y], [x, y]..] for point coordinates.
size : tuple of 2 int
(w, h) for output size.
val : float or int
For the contour value.
Returns
-------
numpy.array
... | tensorlayer/prepro.py | def pt2map(list_points=None, size=(100, 100), val=1):
"""Inputs a list of points, return a 2D image.
Parameters
--------------
list_points : list of 2 int
[[x, y], [x, y]..] for point coordinates.
size : tuple of 2 int
(w, h) for output size.
val : float or int
For the c... | def pt2map(list_points=None, size=(100, 100), val=1):
"""Inputs a list of points, return a 2D image.
Parameters
--------------
list_points : list of 2 int
[[x, y], [x, y]..] for point coordinates.
size : tuple of 2 int
(w, h) for output size.
val : float or int
For the c... | [
"Inputs",
"a",
"list",
"of",
"points",
"return",
"a",
"2D",
"image",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2256-L2283 | [
"def",
"pt2map",
"(",
"list_points",
"=",
"None",
",",
"size",
"=",
"(",
"100",
",",
"100",
")",
",",
"val",
"=",
"1",
")",
":",
"if",
"list_points",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"list_points : list of 2 int\"",
")",
"i_m",
"=",
"np"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | binary_dilation | Return fast binary morphological dilation of an image.
see `skimage.morphology.binary_dilation <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.binary_dilation>`__.
Parameters
-----------
x : 2D array
A binary image.
radius : int
For the radius of mas... | tensorlayer/prepro.py | def binary_dilation(x, radius=3):
"""Return fast binary morphological dilation of an image.
see `skimage.morphology.binary_dilation <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.binary_dilation>`__.
Parameters
-----------
x : 2D array
A binary image.
r... | def binary_dilation(x, radius=3):
"""Return fast binary morphological dilation of an image.
see `skimage.morphology.binary_dilation <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.binary_dilation>`__.
Parameters
-----------
x : 2D array
A binary image.
r... | [
"Return",
"fast",
"binary",
"morphological",
"dilation",
"of",
"an",
"image",
".",
"see",
"skimage",
".",
"morphology",
".",
"binary_dilation",
"<http",
":",
"//",
"scikit",
"-",
"image",
".",
"org",
"/",
"docs",
"/",
"dev",
"/",
"api",
"/",
"skimage",
"... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2286-L2306 | [
"def",
"binary_dilation",
"(",
"x",
",",
"radius",
"=",
"3",
")",
":",
"mask",
"=",
"disk",
"(",
"radius",
")",
"x",
"=",
"_binary_dilation",
"(",
"x",
",",
"selem",
"=",
"mask",
")",
"return",
"x"
] | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | dilation | Return greyscale morphological dilation of an image,
see `skimage.morphology.dilation <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.dilation>`__.
Parameters
-----------
x : 2D array
An greyscale image.
radius : int
For the radius of mask.
Retu... | tensorlayer/prepro.py | def dilation(x, radius=3):
"""Return greyscale morphological dilation of an image,
see `skimage.morphology.dilation <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.dilation>`__.
Parameters
-----------
x : 2D array
An greyscale image.
radius : int
... | def dilation(x, radius=3):
"""Return greyscale morphological dilation of an image,
see `skimage.morphology.dilation <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.dilation>`__.
Parameters
-----------
x : 2D array
An greyscale image.
radius : int
... | [
"Return",
"greyscale",
"morphological",
"dilation",
"of",
"an",
"image",
"see",
"skimage",
".",
"morphology",
".",
"dilation",
"<http",
":",
"//",
"scikit",
"-",
"image",
".",
"org",
"/",
"docs",
"/",
"dev",
"/",
"api",
"/",
"skimage",
".",
"morphology",
... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2309-L2329 | [
"def",
"dilation",
"(",
"x",
",",
"radius",
"=",
"3",
")",
":",
"mask",
"=",
"disk",
"(",
"radius",
")",
"x",
"=",
"dilation",
"(",
"x",
",",
"selem",
"=",
"mask",
")",
"return",
"x"
] | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | binary_erosion | Return binary morphological erosion of an image,
see `skimage.morphology.binary_erosion <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.binary_erosion>`__.
Parameters
-----------
x : 2D array
A binary image.
radius : int
For the radius of mask.
... | tensorlayer/prepro.py | def binary_erosion(x, radius=3):
"""Return binary morphological erosion of an image,
see `skimage.morphology.binary_erosion <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.binary_erosion>`__.
Parameters
-----------
x : 2D array
A binary image.
radius : i... | def binary_erosion(x, radius=3):
"""Return binary morphological erosion of an image,
see `skimage.morphology.binary_erosion <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.binary_erosion>`__.
Parameters
-----------
x : 2D array
A binary image.
radius : i... | [
"Return",
"binary",
"morphological",
"erosion",
"of",
"an",
"image",
"see",
"skimage",
".",
"morphology",
".",
"binary_erosion",
"<http",
":",
"//",
"scikit",
"-",
"image",
".",
"org",
"/",
"docs",
"/",
"dev",
"/",
"api",
"/",
"skimage",
".",
"morphology",... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2332-L2351 | [
"def",
"binary_erosion",
"(",
"x",
",",
"radius",
"=",
"3",
")",
":",
"mask",
"=",
"disk",
"(",
"radius",
")",
"x",
"=",
"_binary_erosion",
"(",
"x",
",",
"selem",
"=",
"mask",
")",
"return",
"x"
] | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | erosion | Return greyscale morphological erosion of an image,
see `skimage.morphology.erosion <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.erosion>`__.
Parameters
-----------
x : 2D array
A greyscale image.
radius : int
For the radius of mask.
Returns
... | tensorlayer/prepro.py | def erosion(x, radius=3):
"""Return greyscale morphological erosion of an image,
see `skimage.morphology.erosion <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.erosion>`__.
Parameters
-----------
x : 2D array
A greyscale image.
radius : int
For ... | def erosion(x, radius=3):
"""Return greyscale morphological erosion of an image,
see `skimage.morphology.erosion <http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.erosion>`__.
Parameters
-----------
x : 2D array
A greyscale image.
radius : int
For ... | [
"Return",
"greyscale",
"morphological",
"erosion",
"of",
"an",
"image",
"see",
"skimage",
".",
"morphology",
".",
"erosion",
"<http",
":",
"//",
"scikit",
"-",
"image",
".",
"org",
"/",
"docs",
"/",
"dev",
"/",
"api",
"/",
"skimage",
".",
"morphology",
"... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2354-L2373 | [
"def",
"erosion",
"(",
"x",
",",
"radius",
"=",
"3",
")",
":",
"mask",
"=",
"disk",
"(",
"radius",
")",
"x",
"=",
"_erosion",
"(",
"x",
",",
"selem",
"=",
"mask",
")",
"return",
"x"
] | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | obj_box_coords_rescale | Scale down a list of coordinates from pixel unit to the ratio of image size i.e. in the range of [0, 1].
Parameters
------------
coords : list of list of 4 ints or None
For coordinates of more than one images .e.g.[[x, y, w, h], [x, y, w, h], ...].
shape : list of 2 int or None
【height,... | tensorlayer/prepro.py | def obj_box_coords_rescale(coords=None, shape=None):
"""Scale down a list of coordinates from pixel unit to the ratio of image size i.e. in the range of [0, 1].
Parameters
------------
coords : list of list of 4 ints or None
For coordinates of more than one images .e.g.[[x, y, w, h], [x, y, w, ... | def obj_box_coords_rescale(coords=None, shape=None):
"""Scale down a list of coordinates from pixel unit to the ratio of image size i.e. in the range of [0, 1].
Parameters
------------
coords : list of list of 4 ints or None
For coordinates of more than one images .e.g.[[x, y, w, h], [x, y, w, ... | [
"Scale",
"down",
"a",
"list",
"of",
"coordinates",
"from",
"pixel",
"unit",
"to",
"the",
"ratio",
"of",
"image",
"size",
"i",
".",
"e",
".",
"in",
"the",
"range",
"of",
"[",
"0",
"1",
"]",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2376-L2429 | [
"def",
"obj_box_coords_rescale",
"(",
"coords",
"=",
"None",
",",
"shape",
"=",
"None",
")",
":",
"if",
"coords",
"is",
"None",
":",
"coords",
"=",
"[",
"]",
"if",
"shape",
"is",
"None",
":",
"shape",
"=",
"[",
"100",
",",
"200",
"]",
"imh",
",",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | obj_box_coord_rescale | Scale down one coordinates from pixel unit to the ratio of image size i.e. in the range of [0, 1].
It is the reverse process of ``obj_box_coord_scale_to_pixelunit``.
Parameters
------------
coords : list of 4 int or None
One coordinates of one image e.g. [x, y, w, h].
shape : list of 2 int ... | tensorlayer/prepro.py | def obj_box_coord_rescale(coord=None, shape=None):
"""Scale down one coordinates from pixel unit to the ratio of image size i.e. in the range of [0, 1].
It is the reverse process of ``obj_box_coord_scale_to_pixelunit``.
Parameters
------------
coords : list of 4 int or None
One coordinates ... | def obj_box_coord_rescale(coord=None, shape=None):
"""Scale down one coordinates from pixel unit to the ratio of image size i.e. in the range of [0, 1].
It is the reverse process of ``obj_box_coord_scale_to_pixelunit``.
Parameters
------------
coords : list of 4 int or None
One coordinates ... | [
"Scale",
"down",
"one",
"coordinates",
"from",
"pixel",
"unit",
"to",
"the",
"ratio",
"of",
"image",
"size",
"i",
".",
"e",
".",
"in",
"the",
"range",
"of",
"[",
"0",
"1",
"]",
".",
"It",
"is",
"the",
"reverse",
"process",
"of",
"obj_box_coord_scale_to... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2432-L2459 | [
"def",
"obj_box_coord_rescale",
"(",
"coord",
"=",
"None",
",",
"shape",
"=",
"None",
")",
":",
"if",
"coord",
"is",
"None",
":",
"coord",
"=",
"[",
"]",
"if",
"shape",
"is",
"None",
":",
"shape",
"=",
"[",
"100",
",",
"200",
"]",
"return",
"obj_bo... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | obj_box_coord_scale_to_pixelunit | Convert one coordinate [x, y, w (or x2), h (or y2)] in ratio format to image coordinate format.
It is the reverse process of ``obj_box_coord_rescale``.
Parameters
-----------
coord : list of 4 float
One coordinate of one image [x, y, w (or x2), h (or y2)] in ratio format, i.e value range [0~1].... | tensorlayer/prepro.py | def obj_box_coord_scale_to_pixelunit(coord, shape=None):
"""Convert one coordinate [x, y, w (or x2), h (or y2)] in ratio format to image coordinate format.
It is the reverse process of ``obj_box_coord_rescale``.
Parameters
-----------
coord : list of 4 float
One coordinate of one image [x, ... | def obj_box_coord_scale_to_pixelunit(coord, shape=None):
"""Convert one coordinate [x, y, w (or x2), h (or y2)] in ratio format to image coordinate format.
It is the reverse process of ``obj_box_coord_rescale``.
Parameters
-----------
coord : list of 4 float
One coordinate of one image [x, ... | [
"Convert",
"one",
"coordinate",
"[",
"x",
"y",
"w",
"(",
"or",
"x2",
")",
"h",
"(",
"or",
"y2",
")",
"]",
"in",
"ratio",
"format",
"to",
"image",
"coordinate",
"format",
".",
"It",
"is",
"the",
"reverse",
"process",
"of",
"obj_box_coord_rescale",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2462-L2492 | [
"def",
"obj_box_coord_scale_to_pixelunit",
"(",
"coord",
",",
"shape",
"=",
"None",
")",
":",
"if",
"shape",
"is",
"None",
":",
"shape",
"=",
"[",
"100",
",",
"100",
"]",
"imh",
",",
"imw",
"=",
"shape",
"[",
"0",
":",
"2",
"]",
"x",
"=",
"int",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | obj_box_coord_centroid_to_upleft_butright | Convert one coordinate [x_center, y_center, w, h] to [x1, y1, x2, y2] in up-left and botton-right format.
Parameters
------------
coord : list of 4 int/float
One coordinate.
to_int : boolean
Whether to convert output as integer.
Returns
-------
list of 4 numbers
New... | tensorlayer/prepro.py | def obj_box_coord_centroid_to_upleft_butright(coord, to_int=False):
"""Convert one coordinate [x_center, y_center, w, h] to [x1, y1, x2, y2] in up-left and botton-right format.
Parameters
------------
coord : list of 4 int/float
One coordinate.
to_int : boolean
Whether to convert ou... | def obj_box_coord_centroid_to_upleft_butright(coord, to_int=False):
"""Convert one coordinate [x_center, y_center, w, h] to [x1, y1, x2, y2] in up-left and botton-right format.
Parameters
------------
coord : list of 4 int/float
One coordinate.
to_int : boolean
Whether to convert ou... | [
"Convert",
"one",
"coordinate",
"[",
"x_center",
"y_center",
"w",
"h",
"]",
"to",
"[",
"x1",
"y1",
"x2",
"y2",
"]",
"in",
"up",
"-",
"left",
"and",
"botton",
"-",
"right",
"format",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2507-L2539 | [
"def",
"obj_box_coord_centroid_to_upleft_butright",
"(",
"coord",
",",
"to_int",
"=",
"False",
")",
":",
"if",
"len",
"(",
"coord",
")",
"!=",
"4",
":",
"raise",
"AssertionError",
"(",
"\"coordinate should be 4 values : [x, y, w, h]\"",
")",
"x_center",
",",
"y_cent... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | obj_box_coord_upleft_butright_to_centroid | Convert one coordinate [x1, y1, x2, y2] to [x_center, y_center, w, h].
It is the reverse process of ``obj_box_coord_centroid_to_upleft_butright``.
Parameters
------------
coord : list of 4 int/float
One coordinate.
Returns
-------
list of 4 numbers
New bounding box. | tensorlayer/prepro.py | def obj_box_coord_upleft_butright_to_centroid(coord):
"""Convert one coordinate [x1, y1, x2, y2] to [x_center, y_center, w, h].
It is the reverse process of ``obj_box_coord_centroid_to_upleft_butright``.
Parameters
------------
coord : list of 4 int/float
One coordinate.
Returns
--... | def obj_box_coord_upleft_butright_to_centroid(coord):
"""Convert one coordinate [x1, y1, x2, y2] to [x_center, y_center, w, h].
It is the reverse process of ``obj_box_coord_centroid_to_upleft_butright``.
Parameters
------------
coord : list of 4 int/float
One coordinate.
Returns
--... | [
"Convert",
"one",
"coordinate",
"[",
"x1",
"y1",
"x2",
"y2",
"]",
"to",
"[",
"x_center",
"y_center",
"w",
"h",
"]",
".",
"It",
"is",
"the",
"reverse",
"process",
"of",
"obj_box_coord_centroid_to_upleft_butright",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2547-L2569 | [
"def",
"obj_box_coord_upleft_butright_to_centroid",
"(",
"coord",
")",
":",
"if",
"len",
"(",
"coord",
")",
"!=",
"4",
":",
"raise",
"AssertionError",
"(",
"\"coordinate should be 4 values : [x1, y1, x2, y2]\"",
")",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"=",
"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | obj_box_coord_centroid_to_upleft | Convert one coordinate [x_center, y_center, w, h] to [x, y, w, h].
It is the reverse process of ``obj_box_coord_upleft_to_centroid``.
Parameters
------------
coord : list of 4 int/float
One coordinate.
Returns
-------
list of 4 numbers
New bounding box. | tensorlayer/prepro.py | def obj_box_coord_centroid_to_upleft(coord):
"""Convert one coordinate [x_center, y_center, w, h] to [x, y, w, h].
It is the reverse process of ``obj_box_coord_upleft_to_centroid``.
Parameters
------------
coord : list of 4 int/float
One coordinate.
Returns
-------
list of 4 nu... | def obj_box_coord_centroid_to_upleft(coord):
"""Convert one coordinate [x_center, y_center, w, h] to [x, y, w, h].
It is the reverse process of ``obj_box_coord_upleft_to_centroid``.
Parameters
------------
coord : list of 4 int/float
One coordinate.
Returns
-------
list of 4 nu... | [
"Convert",
"one",
"coordinate",
"[",
"x_center",
"y_center",
"w",
"h",
"]",
"to",
"[",
"x",
"y",
"w",
"h",
"]",
".",
"It",
"is",
"the",
"reverse",
"process",
"of",
"obj_box_coord_upleft_to_centroid",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2572-L2593 | [
"def",
"obj_box_coord_centroid_to_upleft",
"(",
"coord",
")",
":",
"if",
"len",
"(",
"coord",
")",
"!=",
"4",
":",
"raise",
"AssertionError",
"(",
"\"coordinate should be 4 values : [x, y, w, h]\"",
")",
"x_center",
",",
"y_center",
",",
"w",
",",
"h",
"=",
"coo... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | parse_darknet_ann_str_to_list | r"""Input string format of class, x, y, w, h, return list of list format.
Parameters
-----------
annotations : str
The annotations in darkent format "class, x, y, w, h ...." seperated by "\\n".
Returns
-------
list of list of 4 numbers
List of bounding box. | tensorlayer/prepro.py | def parse_darknet_ann_str_to_list(annotations):
r"""Input string format of class, x, y, w, h, return list of list format.
Parameters
-----------
annotations : str
The annotations in darkent format "class, x, y, w, h ...." seperated by "\\n".
Returns
-------
list of list of 4 number... | def parse_darknet_ann_str_to_list(annotations):
r"""Input string format of class, x, y, w, h, return list of list format.
Parameters
-----------
annotations : str
The annotations in darkent format "class, x, y, w, h ...." seperated by "\\n".
Returns
-------
list of list of 4 number... | [
"r",
"Input",
"string",
"format",
"of",
"class",
"x",
"y",
"w",
"h",
"return",
"list",
"of",
"list",
"format",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2620-L2645 | [
"def",
"parse_darknet_ann_str_to_list",
"(",
"annotations",
")",
":",
"annotations",
"=",
"annotations",
".",
"split",
"(",
"\"\\n\"",
")",
"ann",
"=",
"[",
"]",
"for",
"a",
"in",
"annotations",
":",
"a",
"=",
"a",
".",
"split",
"(",
")",
"if",
"len",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | parse_darknet_ann_list_to_cls_box | Parse darknet annotation format into two lists for class and bounding box.
Input list of [[class, x, y, w, h], ...], return two list of [class ...] and [[x, y, w, h], ...].
Parameters
------------
annotations : list of list
A list of class and bounding boxes of images e.g. [[class, x, y, w, h]... | tensorlayer/prepro.py | def parse_darknet_ann_list_to_cls_box(annotations):
"""Parse darknet annotation format into two lists for class and bounding box.
Input list of [[class, x, y, w, h], ...], return two list of [class ...] and [[x, y, w, h], ...].
Parameters
------------
annotations : list of list
A list of c... | def parse_darknet_ann_list_to_cls_box(annotations):
"""Parse darknet annotation format into two lists for class and bounding box.
Input list of [[class, x, y, w, h], ...], return two list of [class ...] and [[x, y, w, h], ...].
Parameters
------------
annotations : list of list
A list of c... | [
"Parse",
"darknet",
"annotation",
"format",
"into",
"two",
"lists",
"for",
"class",
"and",
"bounding",
"box",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2648-L2672 | [
"def",
"parse_darknet_ann_list_to_cls_box",
"(",
"annotations",
")",
":",
"class_list",
"=",
"[",
"]",
"bbox_list",
"=",
"[",
"]",
"for",
"ann",
"in",
"annotations",
":",
"class_list",
".",
"append",
"(",
"ann",
"[",
"0",
"]",
")",
"bbox_list",
".",
"appen... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | obj_box_horizontal_flip | Left-right flip the image and coordinates for object detection.
Parameters
----------
im : numpy.array
An image with dimension of [row, col, channel] (default).
coords : list of list of 4 int/float or None
Coordinates [[x, y, w, h], [x, y, w, h], ...].
is_rescale : boolean
S... | tensorlayer/prepro.py | def obj_box_horizontal_flip(im, coords=None, is_rescale=False, is_center=False, is_random=False):
"""Left-right flip the image and coordinates for object detection.
Parameters
----------
im : numpy.array
An image with dimension of [row, col, channel] (default).
coords : list of list of 4 in... | def obj_box_horizontal_flip(im, coords=None, is_rescale=False, is_center=False, is_random=False):
"""Left-right flip the image and coordinates for object detection.
Parameters
----------
im : numpy.array
An image with dimension of [row, col, channel] (default).
coords : list of list of 4 in... | [
"Left",
"-",
"right",
"flip",
"the",
"image",
"and",
"coordinates",
"for",
"object",
"detection",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2675-L2751 | [
"def",
"obj_box_horizontal_flip",
"(",
"im",
",",
"coords",
"=",
"None",
",",
"is_rescale",
"=",
"False",
",",
"is_center",
"=",
"False",
",",
"is_random",
"=",
"False",
")",
":",
"if",
"coords",
"is",
"None",
":",
"coords",
"=",
"[",
"]",
"def",
"_fli... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | obj_box_imresize | Resize an image, and compute the new bounding box coordinates.
Parameters
-------------
im : numpy.array
An image with dimension of [row, col, channel] (default).
coords : list of list of 4 int/float or None
Coordinates [[x, y, w, h], [x, y, w, h], ...]
size interp and mode : args
... | tensorlayer/prepro.py | def obj_box_imresize(im, coords=None, size=None, interp='bicubic', mode=None, is_rescale=False):
"""Resize an image, and compute the new bounding box coordinates.
Parameters
-------------
im : numpy.array
An image with dimension of [row, col, channel] (default).
coords : list of list of 4 i... | def obj_box_imresize(im, coords=None, size=None, interp='bicubic', mode=None, is_rescale=False):
"""Resize an image, and compute the new bounding box coordinates.
Parameters
-------------
im : numpy.array
An image with dimension of [row, col, channel] (default).
coords : list of list of 4 i... | [
"Resize",
"an",
"image",
"and",
"compute",
"the",
"new",
"bounding",
"box",
"coordinates",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2772-L2840 | [
"def",
"obj_box_imresize",
"(",
"im",
",",
"coords",
"=",
"None",
",",
"size",
"=",
"None",
",",
"interp",
"=",
"'bicubic'",
",",
"mode",
"=",
"None",
",",
"is_rescale",
"=",
"False",
")",
":",
"if",
"coords",
"is",
"None",
":",
"coords",
"=",
"[",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | obj_box_crop | Randomly or centrally crop an image, and compute the new bounding box coordinates.
Objects outside the cropped image will be removed.
Parameters
-----------
im : numpy.array
An image with dimension of [row, col, channel] (default).
classes : list of int or None
Class IDs.
coords... | tensorlayer/prepro.py | def obj_box_crop(
im, classes=None, coords=None, wrg=100, hrg=100, is_rescale=False, is_center=False, is_random=False,
thresh_wh=0.02, thresh_wh2=12.
):
"""Randomly or centrally crop an image, and compute the new bounding box coordinates.
Objects outside the cropped image will be removed.
P... | def obj_box_crop(
im, classes=None, coords=None, wrg=100, hrg=100, is_rescale=False, is_center=False, is_random=False,
thresh_wh=0.02, thresh_wh2=12.
):
"""Randomly or centrally crop an image, and compute the new bounding box coordinates.
Objects outside the cropped image will be removed.
P... | [
"Randomly",
"or",
"centrally",
"crop",
"an",
"image",
"and",
"compute",
"the",
"new",
"bounding",
"box",
"coordinates",
".",
"Objects",
"outside",
"the",
"cropped",
"image",
"will",
"be",
"removed",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L2859-L3009 | [
"def",
"obj_box_crop",
"(",
"im",
",",
"classes",
"=",
"None",
",",
"coords",
"=",
"None",
",",
"wrg",
"=",
"100",
",",
"hrg",
"=",
"100",
",",
"is_rescale",
"=",
"False",
",",
"is_center",
"=",
"False",
",",
"is_random",
"=",
"False",
",",
"thresh_w... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | obj_box_shift | Shift an image randomly or non-randomly, and compute the new bounding box coordinates.
Objects outside the cropped image will be removed.
Parameters
-----------
im : numpy.array
An image with dimension of [row, col, channel] (default).
classes : list of int or None
Class IDs.
co... | tensorlayer/prepro.py | def obj_box_shift(
im, classes=None, coords=None, wrg=0.1, hrg=0.1, row_index=0, col_index=1, channel_index=2, fill_mode='nearest',
cval=0., order=1, is_rescale=False, is_center=False, is_random=False, thresh_wh=0.02, thresh_wh2=12.
):
"""Shift an image randomly or non-randomly, and compute the new ... | def obj_box_shift(
im, classes=None, coords=None, wrg=0.1, hrg=0.1, row_index=0, col_index=1, channel_index=2, fill_mode='nearest',
cval=0., order=1, is_rescale=False, is_center=False, is_random=False, thresh_wh=0.02, thresh_wh2=12.
):
"""Shift an image randomly or non-randomly, and compute the new ... | [
"Shift",
"an",
"image",
"randomly",
"or",
"non",
"-",
"randomly",
"and",
"compute",
"the",
"new",
"bounding",
"box",
"coordinates",
".",
"Objects",
"outside",
"the",
"cropped",
"image",
"will",
"be",
"removed",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3012-L3144 | [
"def",
"obj_box_shift",
"(",
"im",
",",
"classes",
"=",
"None",
",",
"coords",
"=",
"None",
",",
"wrg",
"=",
"0.1",
",",
"hrg",
"=",
"0.1",
",",
"row_index",
"=",
"0",
",",
"col_index",
"=",
"1",
",",
"channel_index",
"=",
"2",
",",
"fill_mode",
"=... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | obj_box_zoom | Zoom in and out of a single image, randomly or non-randomly, and compute the new bounding box coordinates.
Objects outside the cropped image will be removed.
Parameters
-----------
im : numpy.array
An image with dimension of [row, col, channel] (default).
classes : list of int or None
... | tensorlayer/prepro.py | def obj_box_zoom(
im, classes=None, coords=None, zoom_range=(0.9,
1.1), row_index=0, col_index=1, channel_index=2, fill_mode='nearest',
cval=0., order=1, is_rescale=False, is_center=False, is_random=False, thresh_wh=0.02, thresh_wh2=12.
):
"""Zoom i... | def obj_box_zoom(
im, classes=None, coords=None, zoom_range=(0.9,
1.1), row_index=0, col_index=1, channel_index=2, fill_mode='nearest',
cval=0., order=1, is_rescale=False, is_center=False, is_random=False, thresh_wh=0.02, thresh_wh2=12.
):
"""Zoom i... | [
"Zoom",
"in",
"and",
"out",
"of",
"a",
"single",
"image",
"randomly",
"or",
"non",
"-",
"randomly",
"and",
"compute",
"the",
"new",
"bounding",
"box",
"coordinates",
".",
"Objects",
"outside",
"the",
"cropped",
"image",
"will",
"be",
"removed",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3147-L3281 | [
"def",
"obj_box_zoom",
"(",
"im",
",",
"classes",
"=",
"None",
",",
"coords",
"=",
"None",
",",
"zoom_range",
"=",
"(",
"0.9",
",",
"1.1",
")",
",",
"row_index",
"=",
"0",
",",
"col_index",
"=",
"1",
",",
"channel_index",
"=",
"2",
",",
"fill_mode",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | pad_sequences | Pads each sequence to the same length:
the length of the longest sequence.
If maxlen is provided, any sequence longer
than maxlen is truncated to maxlen.
Truncation happens off either the beginning (default) or
the end of the sequence.
Supports post-padding and pre-padding (default).
Parame... | tensorlayer/prepro.py | def pad_sequences(sequences, maxlen=None, dtype='int32', padding='post', truncating='pre', value=0.):
"""Pads each sequence to the same length:
the length of the longest sequence.
If maxlen is provided, any sequence longer
than maxlen is truncated to maxlen.
Truncation happens off either the beginni... | def pad_sequences(sequences, maxlen=None, dtype='int32', padding='post', truncating='pre', value=0.):
"""Pads each sequence to the same length:
the length of the longest sequence.
If maxlen is provided, any sequence longer
than maxlen is truncated to maxlen.
Truncation happens off either the beginni... | [
"Pads",
"each",
"sequence",
"to",
"the",
"same",
"length",
":",
"the",
"length",
"of",
"the",
"longest",
"sequence",
".",
"If",
"maxlen",
"is",
"provided",
"any",
"sequence",
"longer",
"than",
"maxlen",
"is",
"truncated",
"to",
"maxlen",
".",
"Truncation",
... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3284-L3362 | [
"def",
"pad_sequences",
"(",
"sequences",
",",
"maxlen",
"=",
"None",
",",
"dtype",
"=",
"'int32'",
",",
"padding",
"=",
"'post'",
",",
"truncating",
"=",
"'pre'",
",",
"value",
"=",
"0.",
")",
":",
"lengths",
"=",
"[",
"len",
"(",
"s",
")",
"for",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | remove_pad_sequences | Remove padding.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
pad_id : int
The pad ID.
Returns
----------
list of list of int
The processed sequences.
Examples
----------
>>> sequences = [[2,3,4,0,0],... | tensorlayer/prepro.py | def remove_pad_sequences(sequences, pad_id=0):
"""Remove padding.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
pad_id : int
The pad ID.
Returns
----------
list of list of int
The processed sequences.
Exa... | def remove_pad_sequences(sequences, pad_id=0):
"""Remove padding.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
pad_id : int
The pad ID.
Returns
----------
list of list of int
The processed sequences.
Exa... | [
"Remove",
"padding",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3365-L3399 | [
"def",
"remove_pad_sequences",
"(",
"sequences",
",",
"pad_id",
"=",
"0",
")",
":",
"sequences_out",
"=",
"copy",
".",
"deepcopy",
"(",
"sequences",
")",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"sequences",
")",
":",
"# for j in range(len(sequences[i])):... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | process_sequences | Set all tokens(ids) after END token to the padding value, and then shorten (option) it to the maximum sequence length in this batch.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
end_id : int
The special token for END.
pad_val : i... | tensorlayer/prepro.py | def process_sequences(sequences, end_id=0, pad_val=0, is_shorten=True, remain_end_id=False):
"""Set all tokens(ids) after END token to the padding value, and then shorten (option) it to the maximum sequence length in this batch.
Parameters
-----------
sequences : list of list of int
All sequenc... | def process_sequences(sequences, end_id=0, pad_val=0, is_shorten=True, remain_end_id=False):
"""Set all tokens(ids) after END token to the padding value, and then shorten (option) it to the maximum sequence length in this batch.
Parameters
-----------
sequences : list of list of int
All sequenc... | [
"Set",
"all",
"tokens",
"(",
"ids",
")",
"after",
"END",
"token",
"to",
"the",
"padding",
"value",
"and",
"then",
"shorten",
"(",
"option",
")",
"it",
"to",
"the",
"maximum",
"sequence",
"length",
"in",
"this",
"batch",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3402-L3449 | [
"def",
"process_sequences",
"(",
"sequences",
",",
"end_id",
"=",
"0",
",",
"pad_val",
"=",
"0",
",",
"is_shorten",
"=",
"True",
",",
"remain_end_id",
"=",
"False",
")",
":",
"max_length",
"=",
"0",
"for",
"_",
",",
"seq",
"in",
"enumerate",
"(",
"sequ... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | sequences_add_start_id | Add special start token(id) in the beginning of each sequence.
Parameters
------------
sequences : list of list of int
All sequences where each row is a sequence.
start_id : int
The start ID.
remove_last : boolean
Remove the last value of each sequences. Usually be used for ... | tensorlayer/prepro.py | def sequences_add_start_id(sequences, start_id=0, remove_last=False):
"""Add special start token(id) in the beginning of each sequence.
Parameters
------------
sequences : list of list of int
All sequences where each row is a sequence.
start_id : int
The start ID.
remove_last : ... | def sequences_add_start_id(sequences, start_id=0, remove_last=False):
"""Add special start token(id) in the beginning of each sequence.
Parameters
------------
sequences : list of list of int
All sequences where each row is a sequence.
start_id : int
The start ID.
remove_last : ... | [
"Add",
"special",
"start",
"token",
"(",
"id",
")",
"in",
"the",
"beginning",
"of",
"each",
"sequence",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3452-L3490 | [
"def",
"sequences_add_start_id",
"(",
"sequences",
",",
"start_id",
"=",
"0",
",",
"remove_last",
"=",
"False",
")",
":",
"sequences_out",
"=",
"[",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"len",
"(",
"sequences",
")",
")",
"]",
"#[[]] * len(sequences)",... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | sequences_add_end_id | Add special end token(id) in the end of each sequence.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
end_id : int
The end ID.
Returns
----------
list of list of int
The processed sequences.
Examples
-----... | tensorlayer/prepro.py | def sequences_add_end_id(sequences, end_id=888):
"""Add special end token(id) in the end of each sequence.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
end_id : int
The end ID.
Returns
----------
list of list of int
... | def sequences_add_end_id(sequences, end_id=888):
"""Add special end token(id) in the end of each sequence.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
end_id : int
The end ID.
Returns
----------
list of list of int
... | [
"Add",
"special",
"end",
"token",
"(",
"id",
")",
"in",
"the",
"end",
"of",
"each",
"sequence",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3493-L3518 | [
"def",
"sequences_add_end_id",
"(",
"sequences",
",",
"end_id",
"=",
"888",
")",
":",
"sequences_out",
"=",
"[",
"[",
"]",
"for",
"_",
"in",
"range",
"(",
"len",
"(",
"sequences",
")",
")",
"]",
"#[[]] * len(sequences)",
"for",
"i",
",",
"_",
"in",
"en... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | sequences_add_end_id_after_pad | Add special end token(id) in the end of each sequence.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
end_id : int
The end ID.
pad_id : int
The pad ID.
Returns
----------
list of list of int
The process... | tensorlayer/prepro.py | def sequences_add_end_id_after_pad(sequences, end_id=888, pad_id=0):
"""Add special end token(id) in the end of each sequence.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
end_id : int
The end ID.
pad_id : int
The pad... | def sequences_add_end_id_after_pad(sequences, end_id=888, pad_id=0):
"""Add special end token(id) in the end of each sequence.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
end_id : int
The end ID.
pad_id : int
The pad... | [
"Add",
"special",
"end",
"token",
"(",
"id",
")",
"in",
"the",
"end",
"of",
"each",
"sequence",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3521-L3567 | [
"def",
"sequences_add_end_id_after_pad",
"(",
"sequences",
",",
"end_id",
"=",
"888",
",",
"pad_id",
"=",
"0",
")",
":",
"# sequences_out = [[] for _ in range(len(sequences))]#[[]] * len(sequences)",
"sequences_out",
"=",
"copy",
".",
"deepcopy",
"(",
"sequences",
")",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | sequences_get_mask | Return mask for sequences.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
pad_val : int
The pad value.
Returns
----------
list of list of int
The mask.
Examples
---------
>>> sentences_ids = [[4, 0, 5,... | tensorlayer/prepro.py | def sequences_get_mask(sequences, pad_val=0):
"""Return mask for sequences.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
pad_val : int
The pad value.
Returns
----------
list of list of int
The mask.
Exam... | def sequences_get_mask(sequences, pad_val=0):
"""Return mask for sequences.
Parameters
-----------
sequences : list of list of int
All sequences where each row is a sequence.
pad_val : int
The pad value.
Returns
----------
list of list of int
The mask.
Exam... | [
"Return",
"mask",
"for",
"sequences",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3570-L3601 | [
"def",
"sequences_get_mask",
"(",
"sequences",
",",
"pad_val",
"=",
"0",
")",
":",
"mask",
"=",
"np",
".",
"ones_like",
"(",
"sequences",
")",
"for",
"i",
",",
"seq",
"in",
"enumerate",
"(",
"sequences",
")",
":",
"for",
"i_w",
"in",
"reversed",
"(",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | keypoint_random_crop | Randomly crop an image and corresponding keypoints without influence scales, given by ``keypoint_random_resize_shortestedge``.
Parameters
-----------
image : 3 channel image
The given image for augmentation.
annos : list of list of floats
The keypoints annotation of people.
mask : s... | tensorlayer/prepro.py | def keypoint_random_crop(image, annos, mask=None, size=(368, 368)):
"""Randomly crop an image and corresponding keypoints without influence scales, given by ``keypoint_random_resize_shortestedge``.
Parameters
-----------
image : 3 channel image
The given image for augmentation.
annos : list... | def keypoint_random_crop(image, annos, mask=None, size=(368, 368)):
"""Randomly crop an image and corresponding keypoints without influence scales, given by ``keypoint_random_resize_shortestedge``.
Parameters
-----------
image : 3 channel image
The given image for augmentation.
annos : list... | [
"Randomly",
"crop",
"an",
"image",
"and",
"corresponding",
"keypoints",
"without",
"influence",
"scales",
"given",
"by",
"keypoint_random_resize_shortestedge",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3604-L3666 | [
"def",
"keypoint_random_crop",
"(",
"image",
",",
"annos",
",",
"mask",
"=",
"None",
",",
"size",
"=",
"(",
"368",
",",
"368",
")",
")",
":",
"_target_height",
"=",
"size",
"[",
"0",
"]",
"_target_width",
"=",
"size",
"[",
"1",
"]",
"target_size",
"=... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | keypoint_resize_random_crop | Reszie the image to make either its width or height equals to the given sizes.
Then randomly crop image without influence scales.
Resize the image match with the minimum size before cropping, this API will change the zoom scale of object.
Parameters
-----------
image : 3 channel image
The g... | tensorlayer/prepro.py | def keypoint_resize_random_crop(image, annos, mask=None, size=(368, 368)):
"""Reszie the image to make either its width or height equals to the given sizes.
Then randomly crop image without influence scales.
Resize the image match with the minimum size before cropping, this API will change the zoom scale of... | def keypoint_resize_random_crop(image, annos, mask=None, size=(368, 368)):
"""Reszie the image to make either its width or height equals to the given sizes.
Then randomly crop image without influence scales.
Resize the image match with the minimum size before cropping, this API will change the zoom scale of... | [
"Reszie",
"the",
"image",
"to",
"make",
"either",
"its",
"width",
"or",
"height",
"equals",
"to",
"the",
"given",
"sizes",
".",
"Then",
"randomly",
"crop",
"image",
"without",
"influence",
"scales",
".",
"Resize",
"the",
"image",
"match",
"with",
"the",
"m... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3669-L3841 | [
"def",
"keypoint_resize_random_crop",
"(",
"image",
",",
"annos",
",",
"mask",
"=",
"None",
",",
"size",
"=",
"(",
"368",
",",
"368",
")",
")",
":",
"if",
"len",
"(",
"np",
".",
"shape",
"(",
"image",
")",
")",
"==",
"2",
":",
"image",
"=",
"cv2"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | keypoint_random_rotate | Rotate an image and corresponding keypoints.
Parameters
-----------
image : 3 channel image
The given image for augmentation.
annos : list of list of floats
The keypoints annotation of people.
mask : single channel image or None
The mask if available.
rg : int or float
... | tensorlayer/prepro.py | def keypoint_random_rotate(image, annos, mask=None, rg=15.):
"""Rotate an image and corresponding keypoints.
Parameters
-----------
image : 3 channel image
The given image for augmentation.
annos : list of list of floats
The keypoints annotation of people.
mask : single channel ... | def keypoint_random_rotate(image, annos, mask=None, rg=15.):
"""Rotate an image and corresponding keypoints.
Parameters
-----------
image : 3 channel image
The given image for augmentation.
annos : list of list of floats
The keypoints annotation of people.
mask : single channel ... | [
"Rotate",
"an",
"image",
"and",
"corresponding",
"keypoints",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3844-L3959 | [
"def",
"keypoint_random_rotate",
"(",
"image",
",",
"annos",
",",
"mask",
"=",
"None",
",",
"rg",
"=",
"15.",
")",
":",
"def",
"_rotate_coord",
"(",
"shape",
",",
"newxy",
",",
"point",
",",
"angle",
")",
":",
"angle",
"=",
"-",
"1",
"*",
"angle",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | keypoint_random_flip | Flip an image and corresponding keypoints.
Parameters
-----------
image : 3 channel image
The given image for augmentation.
annos : list of list of floats
The keypoints annotation of people.
mask : single channel image or None
The mask if available.
prob : float, 0 to 1
... | tensorlayer/prepro.py | def keypoint_random_flip(
image, annos, mask=None, prob=0.5, flip_list=(0, 1, 5, 6, 7, 2, 3, 4, 11, 12, 13, 8, 9, 10, 15, 14, 17, 16, 18)
):
"""Flip an image and corresponding keypoints.
Parameters
-----------
image : 3 channel image
The given image for augmentation.
annos : list of... | def keypoint_random_flip(
image, annos, mask=None, prob=0.5, flip_list=(0, 1, 5, 6, 7, 2, 3, 4, 11, 12, 13, 8, 9, 10, 15, 14, 17, 16, 18)
):
"""Flip an image and corresponding keypoints.
Parameters
-----------
image : 3 channel image
The given image for augmentation.
annos : list of... | [
"Flip",
"an",
"image",
"and",
"corresponding",
"keypoints",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L3962-L4014 | [
"def",
"keypoint_random_flip",
"(",
"image",
",",
"annos",
",",
"mask",
"=",
"None",
",",
"prob",
"=",
"0.5",
",",
"flip_list",
"=",
"(",
"0",
",",
"1",
",",
"5",
",",
"6",
",",
"7",
",",
"2",
",",
"3",
",",
"4",
",",
"11",
",",
"12",
",",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | keypoint_random_resize | Randomly resize an image and corresponding keypoints.
The height and width of image will be changed independently, so the scale will be changed.
Parameters
-----------
image : 3 channel image
The given image for augmentation.
annos : list of list of floats
The keypoints annotation o... | tensorlayer/prepro.py | def keypoint_random_resize(image, annos, mask=None, zoom_range=(0.8, 1.2)):
"""Randomly resize an image and corresponding keypoints.
The height and width of image will be changed independently, so the scale will be changed.
Parameters
-----------
image : 3 channel image
The given image for ... | def keypoint_random_resize(image, annos, mask=None, zoom_range=(0.8, 1.2)):
"""Randomly resize an image and corresponding keypoints.
The height and width of image will be changed independently, so the scale will be changed.
Parameters
-----------
image : 3 channel image
The given image for ... | [
"Randomly",
"resize",
"an",
"image",
"and",
"corresponding",
"keypoints",
".",
"The",
"height",
"and",
"width",
"of",
"image",
"will",
"be",
"changed",
"independently",
"so",
"the",
"scale",
"will",
"be",
"changed",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/prepro.py#L4017-L4062 | [
"def",
"keypoint_random_resize",
"(",
"image",
",",
"annos",
",",
"mask",
"=",
"None",
",",
"zoom_range",
"=",
"(",
"0.8",
",",
"1.2",
")",
")",
":",
"height",
"=",
"image",
".",
"shape",
"[",
"0",
"]",
"width",
"=",
"image",
".",
"shape",
"[",
"1"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | Vgg19 | Build the VGG 19 Model
Parameters
-----------
rgb : rgb image placeholder [batch, height, width, 3] values scaled [0, 1] | examples/pretrained_cnn/tutorial_vgg19.py | def Vgg19(rgb):
"""
Build the VGG 19 Model
Parameters
-----------
rgb : rgb image placeholder [batch, height, width, 3] values scaled [0, 1]
"""
start_time = time.time()
print("build model started")
rgb_scaled = rgb * 255.0
# Convert RGB to BGR
red, green, blue = tf.split(rg... | def Vgg19(rgb):
"""
Build the VGG 19 Model
Parameters
-----------
rgb : rgb image placeholder [batch, height, width, 3] values scaled [0, 1]
"""
start_time = time.time()
print("build model started")
rgb_scaled = rgb * 255.0
# Convert RGB to BGR
red, green, blue = tf.split(rg... | [
"Build",
"the",
"VGG",
"19",
"Model"
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/examples/pretrained_cnn/tutorial_vgg19.py#L72-L137 | [
"def",
"Vgg19",
"(",
"rgb",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"print",
"(",
"\"build model started\"",
")",
"rgb_scaled",
"=",
"rgb",
"*",
"255.0",
"# Convert RGB to BGR",
"red",
",",
"green",
",",
"blue",
"=",
"tf",
".",
"split... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | Vgg19_simple_api | Build the VGG 19 Model
Parameters
-----------
rgb : rgb image placeholder [batch, height, width, 3] values scaled [0, 1] | examples/pretrained_cnn/tutorial_vgg19.py | def Vgg19_simple_api(rgb):
"""
Build the VGG 19 Model
Parameters
-----------
rgb : rgb image placeholder [batch, height, width, 3] values scaled [0, 1]
"""
start_time = time.time()
print("build model started")
rgb_scaled = rgb * 255.0
# Convert RGB to BGR
red, green, blue = ... | def Vgg19_simple_api(rgb):
"""
Build the VGG 19 Model
Parameters
-----------
rgb : rgb image placeholder [batch, height, width, 3] values scaled [0, 1]
"""
start_time = time.time()
print("build model started")
rgb_scaled = rgb * 255.0
# Convert RGB to BGR
red, green, blue = ... | [
"Build",
"the",
"VGG",
"19",
"Model"
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/examples/pretrained_cnn/tutorial_vgg19.py#L140-L206 | [
"def",
"Vgg19_simple_api",
"(",
"rgb",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"print",
"(",
"\"build model started\"",
")",
"rgb_scaled",
"=",
"rgb",
"*",
"255.0",
"# Convert RGB to BGR",
"red",
",",
"green",
",",
"blue",
"=",
"tf",
".... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | prepro | Prepro 210x160x3 uint8 frame into 6400 (80x80) 1D float vector. | examples/reinforcement_learning/tutorial_atari_pong.py | def prepro(I):
"""Prepro 210x160x3 uint8 frame into 6400 (80x80) 1D float vector."""
I = I[35:195]
I = I[::2, ::2, 0]
I[I == 144] = 0
I[I == 109] = 0
I[I != 0] = 1
return I.astype(np.float).ravel() | def prepro(I):
"""Prepro 210x160x3 uint8 frame into 6400 (80x80) 1D float vector."""
I = I[35:195]
I = I[::2, ::2, 0]
I[I == 144] = 0
I[I == 109] = 0
I[I != 0] = 1
return I.astype(np.float).ravel() | [
"Prepro",
"210x160x3",
"uint8",
"frame",
"into",
"6400",
"(",
"80x80",
")",
"1D",
"float",
"vector",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/examples/reinforcement_learning/tutorial_atari_pong.py#L47-L54 | [
"def",
"prepro",
"(",
"I",
")",
":",
"I",
"=",
"I",
"[",
"35",
":",
"195",
"]",
"I",
"=",
"I",
"[",
":",
":",
"2",
",",
":",
":",
"2",
",",
"0",
"]",
"I",
"[",
"I",
"==",
"144",
"]",
"=",
"0",
"I",
"[",
"I",
"==",
"109",
"]",
"=",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | discount_episode_rewards | Take 1D float array of rewards and compute discounted rewards for an
episode. When encount a non-zero value, consider as the end a of an episode.
Parameters
----------
rewards : list
List of rewards
gamma : float
Discounted factor
mode : int
Mode for computing the discou... | tensorlayer/rein.py | def discount_episode_rewards(rewards=None, gamma=0.99, mode=0):
"""Take 1D float array of rewards and compute discounted rewards for an
episode. When encount a non-zero value, consider as the end a of an episode.
Parameters
----------
rewards : list
List of rewards
gamma : float
... | def discount_episode_rewards(rewards=None, gamma=0.99, mode=0):
"""Take 1D float array of rewards and compute discounted rewards for an
episode. When encount a non-zero value, consider as the end a of an episode.
Parameters
----------
rewards : list
List of rewards
gamma : float
... | [
"Take",
"1D",
"float",
"array",
"of",
"rewards",
"and",
"compute",
"discounted",
"rewards",
"for",
"an",
"episode",
".",
"When",
"encount",
"a",
"non",
"-",
"zero",
"value",
"consider",
"as",
"the",
"end",
"a",
"of",
"an",
"episode",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/rein.py#L18-L62 | [
"def",
"discount_episode_rewards",
"(",
"rewards",
"=",
"None",
",",
"gamma",
"=",
"0.99",
",",
"mode",
"=",
"0",
")",
":",
"if",
"rewards",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"rewards should be a list\"",
")",
"discounted_r",
"=",
"np",
".",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | cross_entropy_reward_loss | Calculate the loss for Policy Gradient Network.
Parameters
----------
logits : tensor
The network outputs without softmax. This function implements softmax inside.
actions : tensor or placeholder
The agent actions.
rewards : tensor or placeholder
The rewards.
Returns
... | tensorlayer/rein.py | def cross_entropy_reward_loss(logits, actions, rewards, name=None):
"""Calculate the loss for Policy Gradient Network.
Parameters
----------
logits : tensor
The network outputs without softmax. This function implements softmax inside.
actions : tensor or placeholder
The agent action... | def cross_entropy_reward_loss(logits, actions, rewards, name=None):
"""Calculate the loss for Policy Gradient Network.
Parameters
----------
logits : tensor
The network outputs without softmax. This function implements softmax inside.
actions : tensor or placeholder
The agent action... | [
"Calculate",
"the",
"loss",
"for",
"Policy",
"Gradient",
"Network",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/rein.py#L65-L98 | [
"def",
"cross_entropy_reward_loss",
"(",
"logits",
",",
"actions",
",",
"rewards",
",",
"name",
"=",
"None",
")",
":",
"cross_entropy",
"=",
"tf",
".",
"nn",
".",
"sparse_softmax_cross_entropy_with_logits",
"(",
"labels",
"=",
"actions",
",",
"logits",
"=",
"l... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | log_weight | Log weight.
Parameters
-----------
probs : tensor
If it is a network output, usually we should scale it to [0, 1] via softmax.
weights : tensor
The weights.
Returns
--------
Tensor
The Tensor after appling the log weighted expression. | tensorlayer/rein.py | def log_weight(probs, weights, name='log_weight'):
"""Log weight.
Parameters
-----------
probs : tensor
If it is a network output, usually we should scale it to [0, 1] via softmax.
weights : tensor
The weights.
Returns
--------
Tensor
The Tensor after appling th... | def log_weight(probs, weights, name='log_weight'):
"""Log weight.
Parameters
-----------
probs : tensor
If it is a network output, usually we should scale it to [0, 1] via softmax.
weights : tensor
The weights.
Returns
--------
Tensor
The Tensor after appling th... | [
"Log",
"weight",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/rein.py#L101-L119 | [
"def",
"log_weight",
"(",
"probs",
",",
"weights",
",",
"name",
"=",
"'log_weight'",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"name",
")",
":",
"exp_v",
"=",
"tf",
".",
"reduce_mean",
"(",
"tf",
".",
"log",
"(",
"probs",
")",
"*",
"weights... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | choice_action_by_probs | Choice and return an an action by given the action probability distribution.
Parameters
------------
probs : list of float.
The probability distribution of all actions.
action_list : None or a list of int or others
A list of action in integer, string or others. If None, returns an integ... | tensorlayer/rein.py | def choice_action_by_probs(probs=(0.5, 0.5), action_list=None):
"""Choice and return an an action by given the action probability distribution.
Parameters
------------
probs : list of float.
The probability distribution of all actions.
action_list : None or a list of int or others
A... | def choice_action_by_probs(probs=(0.5, 0.5), action_list=None):
"""Choice and return an an action by given the action probability distribution.
Parameters
------------
probs : list of float.
The probability distribution of all actions.
action_list : None or a list of int or others
A... | [
"Choice",
"and",
"return",
"an",
"an",
"action",
"by",
"given",
"the",
"action",
"probability",
"distribution",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/rein.py#L122-L161 | [
"def",
"choice_action_by_probs",
"(",
"probs",
"=",
"(",
"0.5",
",",
"0.5",
")",
",",
"action_list",
"=",
"None",
")",
":",
"if",
"action_list",
"is",
"None",
":",
"n_action",
"=",
"len",
"(",
"probs",
")",
"action_list",
"=",
"np",
".",
"arange",
"(",... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | cross_entropy | Softmax cross-entropy operation, returns the TensorFlow expression of cross-entropy for two distributions,
it implements softmax internally. See ``tf.nn.sparse_softmax_cross_entropy_with_logits``.
Parameters
----------
output : Tensor
A batch of distribution with shape: [batch_size, num of clas... | tensorlayer/cost.py | def cross_entropy(output, target, name=None):
"""Softmax cross-entropy operation, returns the TensorFlow expression of cross-entropy for two distributions,
it implements softmax internally. See ``tf.nn.sparse_softmax_cross_entropy_with_logits``.
Parameters
----------
output : Tensor
A batch... | def cross_entropy(output, target, name=None):
"""Softmax cross-entropy operation, returns the TensorFlow expression of cross-entropy for two distributions,
it implements softmax internally. See ``tf.nn.sparse_softmax_cross_entropy_with_logits``.
Parameters
----------
output : Tensor
A batch... | [
"Softmax",
"cross",
"-",
"entropy",
"operation",
"returns",
"the",
"TensorFlow",
"expression",
"of",
"cross",
"-",
"entropy",
"for",
"two",
"distributions",
"it",
"implements",
"softmax",
"internally",
".",
"See",
"tf",
".",
"nn",
".",
"sparse_softmax_cross_entrop... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L33-L58 | [
"def",
"cross_entropy",
"(",
"output",
",",
"target",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Please give a unique name to tl.cost.cross_entropy for TF1.0+\"",
")",
"return",
"tf",
".",
"reduce_mean",
"(",... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | sigmoid_cross_entropy | Sigmoid cross-entropy operation, see ``tf.nn.sigmoid_cross_entropy_with_logits``.
Parameters
----------
output : Tensor
A batch of distribution with shape: [batch_size, num of classes].
target : Tensor
A batch of index with shape: [batch_size, ].
name : string
Name of this l... | tensorlayer/cost.py | def sigmoid_cross_entropy(output, target, name=None):
"""Sigmoid cross-entropy operation, see ``tf.nn.sigmoid_cross_entropy_with_logits``.
Parameters
----------
output : Tensor
A batch of distribution with shape: [batch_size, num of classes].
target : Tensor
A batch of index with sh... | def sigmoid_cross_entropy(output, target, name=None):
"""Sigmoid cross-entropy operation, see ``tf.nn.sigmoid_cross_entropy_with_logits``.
Parameters
----------
output : Tensor
A batch of distribution with shape: [batch_size, num of classes].
target : Tensor
A batch of index with sh... | [
"Sigmoid",
"cross",
"-",
"entropy",
"operation",
"see",
"tf",
".",
"nn",
".",
"sigmoid_cross_entropy_with_logits",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L61-L74 | [
"def",
"sigmoid_cross_entropy",
"(",
"output",
",",
"target",
",",
"name",
"=",
"None",
")",
":",
"return",
"tf",
".",
"reduce_mean",
"(",
"tf",
".",
"nn",
".",
"sigmoid_cross_entropy_with_logits",
"(",
"labels",
"=",
"target",
",",
"logits",
"=",
"output",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | binary_cross_entropy | Binary cross entropy operation.
Parameters
----------
output : Tensor
Tensor with type of `float32` or `float64`.
target : Tensor
The target distribution, format the same with `output`.
epsilon : float
A small value to avoid output to be zero.
name : str
An optio... | tensorlayer/cost.py | def binary_cross_entropy(output, target, epsilon=1e-8, name='bce_loss'):
"""Binary cross entropy operation.
Parameters
----------
output : Tensor
Tensor with type of `float32` or `float64`.
target : Tensor
The target distribution, format the same with `output`.
epsilon : float
... | def binary_cross_entropy(output, target, epsilon=1e-8, name='bce_loss'):
"""Binary cross entropy operation.
Parameters
----------
output : Tensor
Tensor with type of `float32` or `float64`.
target : Tensor
The target distribution, format the same with `output`.
epsilon : float
... | [
"Binary",
"cross",
"entropy",
"operation",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L77-L104 | [
"def",
"binary_cross_entropy",
"(",
"output",
",",
"target",
",",
"epsilon",
"=",
"1e-8",
",",
"name",
"=",
"'bce_loss'",
")",
":",
"# with ops.op_scope([output, target], name, \"bce_loss\") as name:",
"# output = ops.convert_to_tensor(output, name=\"preds\")",
"# ... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | mean_squared_error | Return the TensorFlow expression of mean-square-error (L2) of two batch of data.
Parameters
----------
output : Tensor
2D, 3D or 4D tensor i.e. [batch_size, n_feature], [batch_size, height, width] or [batch_size, height, width, channel].
target : Tensor
The target distribution, format t... | tensorlayer/cost.py | def mean_squared_error(output, target, is_mean=False, name="mean_squared_error"):
"""Return the TensorFlow expression of mean-square-error (L2) of two batch of data.
Parameters
----------
output : Tensor
2D, 3D or 4D tensor i.e. [batch_size, n_feature], [batch_size, height, width] or [batch_siz... | def mean_squared_error(output, target, is_mean=False, name="mean_squared_error"):
"""Return the TensorFlow expression of mean-square-error (L2) of two batch of data.
Parameters
----------
output : Tensor
2D, 3D or 4D tensor i.e. [batch_size, n_feature], [batch_size, height, width] or [batch_siz... | [
"Return",
"the",
"TensorFlow",
"expression",
"of",
"mean",
"-",
"square",
"-",
"error",
"(",
"L2",
")",
"of",
"two",
"batch",
"of",
"data",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L111-L150 | [
"def",
"mean_squared_error",
"(",
"output",
",",
"target",
",",
"is_mean",
"=",
"False",
",",
"name",
"=",
"\"mean_squared_error\"",
")",
":",
"# with tf.name_scope(name):",
"if",
"output",
".",
"get_shape",
"(",
")",
".",
"ndims",
"==",
"2",
":",
"# [batch_si... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | normalized_mean_square_error | Return the TensorFlow expression of normalized mean-square-error of two distributions.
Parameters
----------
output : Tensor
2D, 3D or 4D tensor i.e. [batch_size, n_feature], [batch_size, height, width] or [batch_size, height, width, channel].
target : Tensor
The target distribution, fo... | tensorlayer/cost.py | def normalized_mean_square_error(output, target, name="normalized_mean_squared_error_loss"):
"""Return the TensorFlow expression of normalized mean-square-error of two distributions.
Parameters
----------
output : Tensor
2D, 3D or 4D tensor i.e. [batch_size, n_feature], [batch_size, height, wid... | def normalized_mean_square_error(output, target, name="normalized_mean_squared_error_loss"):
"""Return the TensorFlow expression of normalized mean-square-error of two distributions.
Parameters
----------
output : Tensor
2D, 3D or 4D tensor i.e. [batch_size, n_feature], [batch_size, height, wid... | [
"Return",
"the",
"TensorFlow",
"expression",
"of",
"normalized",
"mean",
"-",
"square",
"-",
"error",
"of",
"two",
"distributions",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L153-L177 | [
"def",
"normalized_mean_square_error",
"(",
"output",
",",
"target",
",",
"name",
"=",
"\"normalized_mean_squared_error_loss\"",
")",
":",
"# with tf.name_scope(\"normalized_mean_squared_error_loss\"):",
"if",
"output",
".",
"get_shape",
"(",
")",
".",
"ndims",
"==",
"2",... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | absolute_difference_error | Return the TensorFlow expression of absolute difference error (L1) of two batch of data.
Parameters
----------
output : Tensor
2D, 3D or 4D tensor i.e. [batch_size, n_feature], [batch_size, height, width] or [batch_size, height, width, channel].
target : Tensor
The target distribution, ... | tensorlayer/cost.py | def absolute_difference_error(output, target, is_mean=False, name="absolute_difference_error_loss"):
"""Return the TensorFlow expression of absolute difference error (L1) of two batch of data.
Parameters
----------
output : Tensor
2D, 3D or 4D tensor i.e. [batch_size, n_feature], [batch_size, h... | def absolute_difference_error(output, target, is_mean=False, name="absolute_difference_error_loss"):
"""Return the TensorFlow expression of absolute difference error (L1) of two batch of data.
Parameters
----------
output : Tensor
2D, 3D or 4D tensor i.e. [batch_size, n_feature], [batch_size, h... | [
"Return",
"the",
"TensorFlow",
"expression",
"of",
"absolute",
"difference",
"error",
"(",
"L1",
")",
"of",
"two",
"batch",
"of",
"data",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L180-L215 | [
"def",
"absolute_difference_error",
"(",
"output",
",",
"target",
",",
"is_mean",
"=",
"False",
",",
"name",
"=",
"\"absolute_difference_error_loss\"",
")",
":",
"# with tf.name_scope(\"absolute_difference_error_loss\"):",
"if",
"output",
".",
"get_shape",
"(",
")",
"."... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | dice_coe | Soft dice (Sørensen or Jaccard) coefficient for comparing the similarity
of two batch of data, usually be used for binary image segmentation
i.e. labels are binary. The coefficient between 0 to 1, 1 means totally match.
Parameters
-----------
output : Tensor
A distribution with shape: [batc... | tensorlayer/cost.py | def dice_coe(output, target, loss_type='jaccard', axis=(1, 2, 3), smooth=1e-5):
"""Soft dice (Sørensen or Jaccard) coefficient for comparing the similarity
of two batch of data, usually be used for binary image segmentation
i.e. labels are binary. The coefficient between 0 to 1, 1 means totally match.
... | def dice_coe(output, target, loss_type='jaccard', axis=(1, 2, 3), smooth=1e-5):
"""Soft dice (Sørensen or Jaccard) coefficient for comparing the similarity
of two batch of data, usually be used for binary image segmentation
i.e. labels are binary. The coefficient between 0 to 1, 1 means totally match.
... | [
"Soft",
"dice",
"(",
"Sørensen",
"or",
"Jaccard",
")",
"coefficient",
"for",
"comparing",
"the",
"similarity",
"of",
"two",
"batch",
"of",
"data",
"usually",
"be",
"used",
"for",
"binary",
"image",
"segmentation",
"i",
".",
"e",
".",
"labels",
"are",
"bina... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L218-L265 | [
"def",
"dice_coe",
"(",
"output",
",",
"target",
",",
"loss_type",
"=",
"'jaccard'",
",",
"axis",
"=",
"(",
"1",
",",
"2",
",",
"3",
")",
",",
"smooth",
"=",
"1e-5",
")",
":",
"inse",
"=",
"tf",
".",
"reduce_sum",
"(",
"output",
"*",
"target",
",... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | dice_hard_coe | Non-differentiable Sørensen–Dice coefficient for comparing the similarity
of two batch of data, usually be used for binary image segmentation i.e. labels are binary.
The coefficient between 0 to 1, 1 if totally match.
Parameters
-----------
output : tensor
A distribution with shape: [batch_... | tensorlayer/cost.py | def dice_hard_coe(output, target, threshold=0.5, axis=(1, 2, 3), smooth=1e-5):
"""Non-differentiable Sørensen–Dice coefficient for comparing the similarity
of two batch of data, usually be used for binary image segmentation i.e. labels are binary.
The coefficient between 0 to 1, 1 if totally match.
Par... | def dice_hard_coe(output, target, threshold=0.5, axis=(1, 2, 3), smooth=1e-5):
"""Non-differentiable Sørensen–Dice coefficient for comparing the similarity
of two batch of data, usually be used for binary image segmentation i.e. labels are binary.
The coefficient between 0 to 1, 1 if totally match.
Par... | [
"Non",
"-",
"differentiable",
"Sørensen–Dice",
"coefficient",
"for",
"comparing",
"the",
"similarity",
"of",
"two",
"batch",
"of",
"data",
"usually",
"be",
"used",
"for",
"binary",
"image",
"segmentation",
"i",
".",
"e",
".",
"labels",
"are",
"binary",
".",
... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L268-L304 | [
"def",
"dice_hard_coe",
"(",
"output",
",",
"target",
",",
"threshold",
"=",
"0.5",
",",
"axis",
"=",
"(",
"1",
",",
"2",
",",
"3",
")",
",",
"smooth",
"=",
"1e-5",
")",
":",
"output",
"=",
"tf",
".",
"cast",
"(",
"output",
">",
"threshold",
",",... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | iou_coe | Non-differentiable Intersection over Union (IoU) for comparing the
similarity of two batch of data, usually be used for evaluating binary image segmentation.
The coefficient between 0 to 1, and 1 means totally match.
Parameters
-----------
output : tensor
A batch of distribution with shape:... | tensorlayer/cost.py | def iou_coe(output, target, threshold=0.5, axis=(1, 2, 3), smooth=1e-5):
"""Non-differentiable Intersection over Union (IoU) for comparing the
similarity of two batch of data, usually be used for evaluating binary image segmentation.
The coefficient between 0 to 1, and 1 means totally match.
Parameters... | def iou_coe(output, target, threshold=0.5, axis=(1, 2, 3), smooth=1e-5):
"""Non-differentiable Intersection over Union (IoU) for comparing the
similarity of two batch of data, usually be used for evaluating binary image segmentation.
The coefficient between 0 to 1, and 1 means totally match.
Parameters... | [
"Non",
"-",
"differentiable",
"Intersection",
"over",
"Union",
"(",
"IoU",
")",
"for",
"comparing",
"the",
"similarity",
"of",
"two",
"batch",
"of",
"data",
"usually",
"be",
"used",
"for",
"evaluating",
"binary",
"image",
"segmentation",
".",
"The",
"coefficie... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L307-L340 | [
"def",
"iou_coe",
"(",
"output",
",",
"target",
",",
"threshold",
"=",
"0.5",
",",
"axis",
"=",
"(",
"1",
",",
"2",
",",
"3",
")",
",",
"smooth",
"=",
"1e-5",
")",
":",
"pre",
"=",
"tf",
".",
"cast",
"(",
"output",
">",
"threshold",
",",
"dtype... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | cross_entropy_seq | Returns the expression of cross-entropy of two sequences, implement
softmax internally. Normally be used for fixed length RNN outputs, see `PTB example <https://github.com/tensorlayer/tensorlayer/blob/master/example/tutorial_ptb_lstm_state_is_tuple.py>`__.
Parameters
----------
logits : Tensor
... | tensorlayer/cost.py | def cross_entropy_seq(logits, target_seqs, batch_size=None): # , batch_size=1, num_steps=None):
"""Returns the expression of cross-entropy of two sequences, implement
softmax internally. Normally be used for fixed length RNN outputs, see `PTB example <https://github.com/tensorlayer/tensorlayer/blob/master/exam... | def cross_entropy_seq(logits, target_seqs, batch_size=None): # , batch_size=1, num_steps=None):
"""Returns the expression of cross-entropy of two sequences, implement
softmax internally. Normally be used for fixed length RNN outputs, see `PTB example <https://github.com/tensorlayer/tensorlayer/blob/master/exam... | [
"Returns",
"the",
"expression",
"of",
"cross",
"-",
"entropy",
"of",
"two",
"sequences",
"implement",
"softmax",
"internally",
".",
"Normally",
"be",
"used",
"for",
"fixed",
"length",
"RNN",
"outputs",
"see",
"PTB",
"example",
"<https",
":",
"//",
"github",
... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L377-L412 | [
"def",
"cross_entropy_seq",
"(",
"logits",
",",
"target_seqs",
",",
"batch_size",
"=",
"None",
")",
":",
"# , batch_size=1, num_steps=None):",
"sequence_loss_by_example_fn",
"=",
"tf",
".",
"contrib",
".",
"legacy_seq2seq",
".",
"sequence_loss_by_example",
"loss",
"=",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | cross_entropy_seq_with_mask | Returns the expression of cross-entropy of two sequences, implement
softmax internally. Normally be used for Dynamic RNN with Synced sequence input and output.
Parameters
-----------
logits : Tensor
2D tensor with shape of [batch_size * ?, n_classes], `?` means dynamic IDs for each example.
... | tensorlayer/cost.py | def cross_entropy_seq_with_mask(logits, target_seqs, input_mask, return_details=False, name=None):
"""Returns the expression of cross-entropy of two sequences, implement
softmax internally. Normally be used for Dynamic RNN with Synced sequence input and output.
Parameters
-----------
logits : Tenso... | def cross_entropy_seq_with_mask(logits, target_seqs, input_mask, return_details=False, name=None):
"""Returns the expression of cross-entropy of two sequences, implement
softmax internally. Normally be used for Dynamic RNN with Synced sequence input and output.
Parameters
-----------
logits : Tenso... | [
"Returns",
"the",
"expression",
"of",
"cross",
"-",
"entropy",
"of",
"two",
"sequences",
"implement",
"softmax",
"internally",
".",
"Normally",
"be",
"used",
"for",
"Dynamic",
"RNN",
"with",
"Synced",
"sequence",
"input",
"and",
"output",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L415-L475 | [
"def",
"cross_entropy_seq_with_mask",
"(",
"logits",
",",
"target_seqs",
",",
"input_mask",
",",
"return_details",
"=",
"False",
",",
"name",
"=",
"None",
")",
":",
"targets",
"=",
"tf",
".",
"reshape",
"(",
"target_seqs",
",",
"[",
"-",
"1",
"]",
")",
"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | cosine_similarity | Cosine similarity [-1, 1].
Parameters
----------
v1, v2 : Tensor
Tensor with the same shape [batch_size, n_feature].
References
----------
- `Wiki <https://en.wikipedia.org/wiki/Cosine_similarity>`__. | tensorlayer/cost.py | def cosine_similarity(v1, v2):
"""Cosine similarity [-1, 1].
Parameters
----------
v1, v2 : Tensor
Tensor with the same shape [batch_size, n_feature].
References
----------
- `Wiki <https://en.wikipedia.org/wiki/Cosine_similarity>`__.
"""
return tf.reduce_sum(tf.multiply(... | def cosine_similarity(v1, v2):
"""Cosine similarity [-1, 1].
Parameters
----------
v1, v2 : Tensor
Tensor with the same shape [batch_size, n_feature].
References
----------
- `Wiki <https://en.wikipedia.org/wiki/Cosine_similarity>`__.
"""
return tf.reduce_sum(tf.multiply(... | [
"Cosine",
"similarity",
"[",
"-",
"1",
"1",
"]",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L478-L494 | [
"def",
"cosine_similarity",
"(",
"v1",
",",
"v2",
")",
":",
"return",
"tf",
".",
"reduce_sum",
"(",
"tf",
".",
"multiply",
"(",
"v1",
",",
"v2",
")",
",",
"1",
")",
"/",
"(",
"tf",
".",
"sqrt",
"(",
"tf",
".",
"reduce_sum",
"(",
"tf",
".",
"mul... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | li_regularizer | Li regularization removes the neurons of previous layer. The `i` represents `inputs`.
Returns a function that can be used to apply group li regularization to weights.
The implementation follows `TensorFlow contrib <https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/layers/python/layers/regu... | tensorlayer/cost.py | def li_regularizer(scale, scope=None):
"""Li regularization removes the neurons of previous layer. The `i` represents `inputs`.
Returns a function that can be used to apply group li regularization to weights.
The implementation follows `TensorFlow contrib <https://github.com/tensorflow/tensorflow/blob/maste... | def li_regularizer(scale, scope=None):
"""Li regularization removes the neurons of previous layer. The `i` represents `inputs`.
Returns a function that can be used to apply group li regularization to weights.
The implementation follows `TensorFlow contrib <https://github.com/tensorflow/tensorflow/blob/maste... | [
"Li",
"regularization",
"removes",
"the",
"neurons",
"of",
"previous",
"layer",
".",
"The",
"i",
"represents",
"inputs",
".",
"Returns",
"a",
"function",
"that",
"can",
"be",
"used",
"to",
"apply",
"group",
"li",
"regularization",
"to",
"weights",
".",
"The"... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L498-L543 | [
"def",
"li_regularizer",
"(",
"scale",
",",
"scope",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"scale",
",",
"numbers",
".",
"Integral",
")",
":",
"raise",
"ValueError",
"(",
"'scale cannot be an integer: %s'",
"%",
"scale",
")",
"if",
"isinstance",
"(... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | maxnorm_regularizer | Max-norm regularization returns a function that can be used to apply max-norm regularization to weights.
More about max-norm, see `wiki-max norm <https://en.wikipedia.org/wiki/Matrix_norm#Max_norm>`_.
The implementation follows `TensorFlow contrib <https://github.com/tensorflow/tensorflow/blob/master/tensorflo... | tensorlayer/cost.py | def maxnorm_regularizer(scale=1.0):
"""Max-norm regularization returns a function that can be used to apply max-norm regularization to weights.
More about max-norm, see `wiki-max norm <https://en.wikipedia.org/wiki/Matrix_norm#Max_norm>`_.
The implementation follows `TensorFlow contrib <https://github.com/... | def maxnorm_regularizer(scale=1.0):
"""Max-norm regularization returns a function that can be used to apply max-norm regularization to weights.
More about max-norm, see `wiki-max norm <https://en.wikipedia.org/wiki/Matrix_norm#Max_norm>`_.
The implementation follows `TensorFlow contrib <https://github.com/... | [
"Max",
"-",
"norm",
"regularization",
"returns",
"a",
"function",
"that",
"can",
"be",
"used",
"to",
"apply",
"max",
"-",
"norm",
"regularization",
"to",
"weights",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L593-L636 | [
"def",
"maxnorm_regularizer",
"(",
"scale",
"=",
"1.0",
")",
":",
"if",
"isinstance",
"(",
"scale",
",",
"numbers",
".",
"Integral",
")",
":",
"raise",
"ValueError",
"(",
"'scale cannot be an integer: %s'",
"%",
"scale",
")",
"if",
"isinstance",
"(",
"scale",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | maxnorm_o_regularizer | Max-norm output regularization removes the neurons of current layer.
Returns a function that can be used to apply max-norm regularization to each column of weight matrix.
The implementation follows `TensorFlow contrib <https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/layers/python/layers/... | tensorlayer/cost.py | def maxnorm_o_regularizer(scale):
"""Max-norm output regularization removes the neurons of current layer.
Returns a function that can be used to apply max-norm regularization to each column of weight matrix.
The implementation follows `TensorFlow contrib <https://github.com/tensorflow/tensorflow/blob/master... | def maxnorm_o_regularizer(scale):
"""Max-norm output regularization removes the neurons of current layer.
Returns a function that can be used to apply max-norm regularization to each column of weight matrix.
The implementation follows `TensorFlow contrib <https://github.com/tensorflow/tensorflow/blob/master... | [
"Max",
"-",
"norm",
"output",
"regularization",
"removes",
"the",
"neurons",
"of",
"current",
"layer",
".",
"Returns",
"a",
"function",
"that",
"can",
"be",
"used",
"to",
"apply",
"max",
"-",
"norm",
"regularization",
"to",
"each",
"column",
"of",
"weight",
... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/cost.py#L639-L683 | [
"def",
"maxnorm_o_regularizer",
"(",
"scale",
")",
":",
"if",
"isinstance",
"(",
"scale",
",",
"numbers",
".",
"Integral",
")",
":",
"raise",
"ValueError",
"(",
"'scale cannot be an integer: %s'",
"%",
"scale",
")",
"if",
"isinstance",
"(",
"scale",
",",
"numb... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | ramp | Ramp activation function.
Parameters
----------
x : Tensor
input.
v_min : float
cap input to v_min as a lower bound.
v_max : float
cap input to v_max as a upper bound.
name : str
The function name (optional).
Returns
-------
Tensor
A ``Tensor... | tensorlayer/activation.py | def ramp(x, v_min=0, v_max=1, name=None):
"""Ramp activation function.
Parameters
----------
x : Tensor
input.
v_min : float
cap input to v_min as a lower bound.
v_max : float
cap input to v_max as a upper bound.
name : str
The function name (optional).
... | def ramp(x, v_min=0, v_max=1, name=None):
"""Ramp activation function.
Parameters
----------
x : Tensor
input.
v_min : float
cap input to v_min as a lower bound.
v_max : float
cap input to v_max as a upper bound.
name : str
The function name (optional).
... | [
"Ramp",
"activation",
"function",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/activation.py#L25-L45 | [
"def",
"ramp",
"(",
"x",
",",
"v_min",
"=",
"0",
",",
"v_max",
"=",
"1",
",",
"name",
"=",
"None",
")",
":",
"return",
"tf",
".",
"clip_by_value",
"(",
"x",
",",
"clip_value_min",
"=",
"v_min",
",",
"clip_value_max",
"=",
"v_max",
",",
"name",
"=",... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | leaky_relu | leaky_relu can be used through its shortcut: :func:`tl.act.lrelu`.
This function is a modified version of ReLU, introducing a nonzero gradient for negative input. Introduced by the paper:
`Rectifier Nonlinearities Improve Neural Network Acoustic Models [A. L. Maas et al., 2013] <https://ai.stanford.edu/~amaas/... | tensorlayer/activation.py | def leaky_relu(x, alpha=0.2, name="leaky_relu"):
"""leaky_relu can be used through its shortcut: :func:`tl.act.lrelu`.
This function is a modified version of ReLU, introducing a nonzero gradient for negative input. Introduced by the paper:
`Rectifier Nonlinearities Improve Neural Network Acoustic Models [A... | def leaky_relu(x, alpha=0.2, name="leaky_relu"):
"""leaky_relu can be used through its shortcut: :func:`tl.act.lrelu`.
This function is a modified version of ReLU, introducing a nonzero gradient for negative input. Introduced by the paper:
`Rectifier Nonlinearities Improve Neural Network Acoustic Models [A... | [
"leaky_relu",
"can",
"be",
"used",
"through",
"its",
"shortcut",
":",
":",
"func",
":",
"tl",
".",
"act",
".",
"lrelu",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/activation.py#L49-L88 | [
"def",
"leaky_relu",
"(",
"x",
",",
"alpha",
"=",
"0.2",
",",
"name",
"=",
"\"leaky_relu\"",
")",
":",
"if",
"not",
"(",
"0",
"<",
"alpha",
"<=",
"1",
")",
":",
"raise",
"ValueError",
"(",
"\"`alpha` value must be in [0, 1]`\"",
")",
"with",
"tf",
".",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | leaky_relu6 | :func:`leaky_relu6` can be used through its shortcut: :func:`tl.act.lrelu6`.
This activation function is a modified version :func:`leaky_relu` introduced by the following paper:
`Rectifier Nonlinearities Improve Neural Network Acoustic Models [A. L. Maas et al., 2013] <https://ai.stanford.edu/~amaas/papers/rel... | tensorlayer/activation.py | def leaky_relu6(x, alpha=0.2, name="leaky_relu6"):
""":func:`leaky_relu6` can be used through its shortcut: :func:`tl.act.lrelu6`.
This activation function is a modified version :func:`leaky_relu` introduced by the following paper:
`Rectifier Nonlinearities Improve Neural Network Acoustic Models [A. L. Maa... | def leaky_relu6(x, alpha=0.2, name="leaky_relu6"):
""":func:`leaky_relu6` can be used through its shortcut: :func:`tl.act.lrelu6`.
This activation function is a modified version :func:`leaky_relu` introduced by the following paper:
`Rectifier Nonlinearities Improve Neural Network Acoustic Models [A. L. Maa... | [
":",
"func",
":",
"leaky_relu6",
"can",
"be",
"used",
"through",
"its",
"shortcut",
":",
":",
"func",
":",
"tl",
".",
"act",
".",
"lrelu6",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/activation.py#L91-L134 | [
"def",
"leaky_relu6",
"(",
"x",
",",
"alpha",
"=",
"0.2",
",",
"name",
"=",
"\"leaky_relu6\"",
")",
":",
"if",
"not",
"isinstance",
"(",
"alpha",
",",
"tf",
".",
"Tensor",
")",
"and",
"not",
"(",
"0",
"<",
"alpha",
"<=",
"1",
")",
":",
"raise",
"... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | leaky_twice_relu6 | :func:`leaky_twice_relu6` can be used through its shortcut: :func:`:func:`tl.act.ltrelu6`.
This activation function is a modified version :func:`leaky_relu` introduced by the following paper:
`Rectifier Nonlinearities Improve Neural Network Acoustic Models [A. L. Maas et al., 2013] <https://ai.stanford.edu/~am... | tensorlayer/activation.py | def leaky_twice_relu6(x, alpha_low=0.2, alpha_high=0.2, name="leaky_relu6"):
""":func:`leaky_twice_relu6` can be used through its shortcut: :func:`:func:`tl.act.ltrelu6`.
This activation function is a modified version :func:`leaky_relu` introduced by the following paper:
`Rectifier Nonlinearities Improve N... | def leaky_twice_relu6(x, alpha_low=0.2, alpha_high=0.2, name="leaky_relu6"):
""":func:`leaky_twice_relu6` can be used through its shortcut: :func:`:func:`tl.act.ltrelu6`.
This activation function is a modified version :func:`leaky_relu` introduced by the following paper:
`Rectifier Nonlinearities Improve N... | [
":",
"func",
":",
"leaky_twice_relu6",
"can",
"be",
"used",
"through",
"its",
"shortcut",
":",
":",
"func",
":",
":",
"func",
":",
"tl",
".",
"act",
".",
"ltrelu6",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/activation.py#L137-L192 | [
"def",
"leaky_twice_relu6",
"(",
"x",
",",
"alpha_low",
"=",
"0.2",
",",
"alpha_high",
"=",
"0.2",
",",
"name",
"=",
"\"leaky_relu6\"",
")",
":",
"if",
"not",
"isinstance",
"(",
"alpha_high",
",",
"tf",
".",
"Tensor",
")",
"and",
"not",
"(",
"0",
"<",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | swish | Swish function.
See `Swish: a Self-Gated Activation Function <https://arxiv.org/abs/1710.05941>`__.
Parameters
----------
x : Tensor
input.
name: str
function name (optional).
Returns
-------
Tensor
A ``Tensor`` in the same type as ``x``. | tensorlayer/activation.py | def swish(x, name='swish'):
"""Swish function.
See `Swish: a Self-Gated Activation Function <https://arxiv.org/abs/1710.05941>`__.
Parameters
----------
x : Tensor
input.
name: str
function name (optional).
Returns
-------
Tensor
A ``Tensor`` in the same t... | def swish(x, name='swish'):
"""Swish function.
See `Swish: a Self-Gated Activation Function <https://arxiv.org/abs/1710.05941>`__.
Parameters
----------
x : Tensor
input.
name: str
function name (optional).
Returns
-------
Tensor
A ``Tensor`` in the same t... | [
"Swish",
"function",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/activation.py#L195-L215 | [
"def",
"swish",
"(",
"x",
",",
"name",
"=",
"'swish'",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"name",
")",
":",
"x",
"=",
"tf",
".",
"nn",
".",
"sigmoid",
"(",
"x",
")",
"*",
"x",
"return",
"x"
] | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | pixel_wise_softmax | Return the softmax outputs of images, every pixels have multiple label, the sum of a pixel is 1.
Usually be used for image segmentation.
Parameters
----------
x : Tensor
input.
- For 2d image, 4D tensor (batch_size, height, weight, channel), where channel >= 2.
- For 3d... | tensorlayer/activation.py | def pixel_wise_softmax(x, name='pixel_wise_softmax'):
"""Return the softmax outputs of images, every pixels have multiple label, the sum of a pixel is 1.
Usually be used for image segmentation.
Parameters
----------
x : Tensor
input.
- For 2d image, 4D tensor (batch_size, heigh... | def pixel_wise_softmax(x, name='pixel_wise_softmax'):
"""Return the softmax outputs of images, every pixels have multiple label, the sum of a pixel is 1.
Usually be used for image segmentation.
Parameters
----------
x : Tensor
input.
- For 2d image, 4D tensor (batch_size, heigh... | [
"Return",
"the",
"softmax",
"outputs",
"of",
"images",
"every",
"pixels",
"have",
"multiple",
"label",
"the",
"sum",
"of",
"a",
"pixel",
"is",
"1",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/activation.py#L303-L333 | [
"def",
"pixel_wise_softmax",
"(",
"x",
",",
"name",
"=",
"'pixel_wise_softmax'",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"name",
")",
":",
"return",
"tf",
".",
"nn",
".",
"softmax",
"(",
"x",
")"
] | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | _conv_linear | convolution:
Parameters
----------
args : tensor
4D Tensor or a list of 4D, batch x n, Tensors.
filter_size : tuple of int
Filter height and width.
num_features : int
Nnumber of features.
bias_start : float
Starting value to initialize the bias; 0 by default.
... | tensorlayer/layers/recurrent.py | def _conv_linear(args, filter_size, num_features, bias, bias_start=0.0, scope=None):
"""convolution:
Parameters
----------
args : tensor
4D Tensor or a list of 4D, batch x n, Tensors.
filter_size : tuple of int
Filter height and width.
num_features : int
Nnumber of featu... | def _conv_linear(args, filter_size, num_features, bias, bias_start=0.0, scope=None):
"""convolution:
Parameters
----------
args : tensor
4D Tensor or a list of 4D, batch x n, Tensors.
filter_size : tuple of int
Filter height and width.
num_features : int
Nnumber of featu... | [
"convolution",
":"
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/layers/recurrent.py#L596-L648 | [
"def",
"_conv_linear",
"(",
"args",
",",
"filter_size",
",",
"num_features",
",",
"bias",
",",
"bias_start",
"=",
"0.0",
",",
"scope",
"=",
"None",
")",
":",
"# Calculate the total size of arguments on dimension 1.",
"total_arg_size_depth",
"=",
"0",
"shapes",
"=",
... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | advanced_indexing_op | Advanced Indexing for Sequences, returns the outputs by given sequence lengths.
When return the last output :class:`DynamicRNNLayer` uses it to get the last outputs with the sequence lengths.
Parameters
-----------
inputs : tensor for data
With shape of [batch_size, n_step(max), n_features]
... | tensorlayer/layers/recurrent.py | def advanced_indexing_op(inputs, index):
"""Advanced Indexing for Sequences, returns the outputs by given sequence lengths.
When return the last output :class:`DynamicRNNLayer` uses it to get the last outputs with the sequence lengths.
Parameters
-----------
inputs : tensor for data
With sh... | def advanced_indexing_op(inputs, index):
"""Advanced Indexing for Sequences, returns the outputs by given sequence lengths.
When return the last output :class:`DynamicRNNLayer` uses it to get the last outputs with the sequence lengths.
Parameters
-----------
inputs : tensor for data
With sh... | [
"Advanced",
"Indexing",
"for",
"Sequences",
"returns",
"the",
"outputs",
"by",
"given",
"sequence",
"lengths",
".",
"When",
"return",
"the",
"last",
"output",
":",
"class",
":",
"DynamicRNNLayer",
"uses",
"it",
"to",
"get",
"the",
"last",
"outputs",
"with",
... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/layers/recurrent.py#L798-L846 | [
"def",
"advanced_indexing_op",
"(",
"inputs",
",",
"index",
")",
":",
"batch_size",
"=",
"tf",
".",
"shape",
"(",
"inputs",
")",
"[",
"0",
"]",
"# max_length = int(inputs.get_shape()[1]) # for fixed length rnn, length is given",
"max_length",
"=",
"tf",
".",
"shape... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | retrieve_seq_length_op | An op to compute the length of a sequence from input shape of [batch_size, n_step(max), n_features],
it can be used when the features of padding (on right hand side) are all zeros.
Parameters
-----------
data : tensor
[batch_size, n_step(max), n_features] with zero padding on right hand side.
... | tensorlayer/layers/recurrent.py | def retrieve_seq_length_op(data):
"""An op to compute the length of a sequence from input shape of [batch_size, n_step(max), n_features],
it can be used when the features of padding (on right hand side) are all zeros.
Parameters
-----------
data : tensor
[batch_size, n_step(max), n_features... | def retrieve_seq_length_op(data):
"""An op to compute the length of a sequence from input shape of [batch_size, n_step(max), n_features],
it can be used when the features of padding (on right hand side) are all zeros.
Parameters
-----------
data : tensor
[batch_size, n_step(max), n_features... | [
"An",
"op",
"to",
"compute",
"the",
"length",
"of",
"a",
"sequence",
"from",
"input",
"shape",
"of",
"[",
"batch_size",
"n_step",
"(",
"max",
")",
"n_features",
"]",
"it",
"can",
"be",
"used",
"when",
"the",
"features",
"of",
"padding",
"(",
"on",
"rig... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/layers/recurrent.py#L849-L889 | [
"def",
"retrieve_seq_length_op",
"(",
"data",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"'GetLength'",
")",
":",
"used",
"=",
"tf",
".",
"sign",
"(",
"tf",
".",
"reduce_max",
"(",
"tf",
".",
"abs",
"(",
"data",
")",
",",
"2",
")",
")",
"lengt... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | retrieve_seq_length_op2 | An op to compute the length of a sequence, from input shape of [batch_size, n_step(max)],
it can be used when the features of padding (on right hand side) are all zeros.
Parameters
-----------
data : tensor
[batch_size, n_step(max)] with zero padding on right hand side.
Examples
------... | tensorlayer/layers/recurrent.py | def retrieve_seq_length_op2(data):
"""An op to compute the length of a sequence, from input shape of [batch_size, n_step(max)],
it can be used when the features of padding (on right hand side) are all zeros.
Parameters
-----------
data : tensor
[batch_size, n_step(max)] with zero padding on... | def retrieve_seq_length_op2(data):
"""An op to compute the length of a sequence, from input shape of [batch_size, n_step(max)],
it can be used when the features of padding (on right hand side) are all zeros.
Parameters
-----------
data : tensor
[batch_size, n_step(max)] with zero padding on... | [
"An",
"op",
"to",
"compute",
"the",
"length",
"of",
"a",
"sequence",
"from",
"input",
"shape",
"of",
"[",
"batch_size",
"n_step",
"(",
"max",
")",
"]",
"it",
"can",
"be",
"used",
"when",
"the",
"features",
"of",
"padding",
"(",
"on",
"right",
"hand",
... | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/layers/recurrent.py#L892-L913 | [
"def",
"retrieve_seq_length_op2",
"(",
"data",
")",
":",
"return",
"tf",
".",
"reduce_sum",
"(",
"tf",
".",
"cast",
"(",
"tf",
".",
"greater",
"(",
"data",
",",
"tf",
".",
"zeros_like",
"(",
"data",
")",
")",
",",
"tf",
".",
"int32",
")",
",",
"1",... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
valid | retrieve_seq_length_op3 | Return tensor for sequence length, if input is ``tf.string``. | tensorlayer/layers/recurrent.py | def retrieve_seq_length_op3(data, pad_val=0): # HangSheng: return tensor for sequence length, if input is tf.string
"""Return tensor for sequence length, if input is ``tf.string``."""
data_shape_size = data.get_shape().ndims
if data_shape_size == 3:
return tf.reduce_sum(tf.cast(tf.reduce_any(tf.not... | def retrieve_seq_length_op3(data, pad_val=0): # HangSheng: return tensor for sequence length, if input is tf.string
"""Return tensor for sequence length, if input is ``tf.string``."""
data_shape_size = data.get_shape().ndims
if data_shape_size == 3:
return tf.reduce_sum(tf.cast(tf.reduce_any(tf.not... | [
"Return",
"tensor",
"for",
"sequence",
"length",
"if",
"input",
"is",
"tf",
".",
"string",
"."
] | tensorlayer/tensorlayer | python | https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/layers/recurrent.py#L916-L928 | [
"def",
"retrieve_seq_length_op3",
"(",
"data",
",",
"pad_val",
"=",
"0",
")",
":",
"# HangSheng: return tensor for sequence length, if input is tf.string",
"data_shape_size",
"=",
"data",
".",
"get_shape",
"(",
")",
".",
"ndims",
"if",
"data_shape_size",
"==",
"3",
":... | aa9e52e36c7058a7e6fd81d36563ca6850b21956 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.