Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
legmul | (c1, c2) |
Multiply one Legendre series by another.
Returns the product of two Legendre series `c1` * `c2`. The arguments
are sequences of coefficients, from lowest order "term" to highest,
e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.
Parameters
----------
c1, c2 : array_like
... |
Multiply one Legendre series by another. | def legmul(c1, c2):
"""
Multiply one Legendre series by another.
Returns the product of two Legendre series `c1` * `c2`. The arguments
are sequences of coefficients, from lowest order "term" to highest,
e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``.
Parameters
----------
... | [
"def",
"legmul",
"(",
"c1",
",",
"c2",
")",
":",
"# s1, s2 are trimmed copies",
"[",
"c1",
",",
"c2",
"]",
"=",
"pu",
".",
"as_series",
"(",
"[",
"c1",
",",
"c2",
"]",
")",
"if",
"len",
"(",
"c1",
")",
">",
"len",
"(",
"c2",
")",
":",
"c",
"=... | [
460,
0
] | [
525,
34
] | python | en | ['en', 'error', 'th'] | False |
legdiv | (c1, c2) |
Divide one Legendre series by another.
Returns the quotient-with-remainder of two Legendre series
`c1` / `c2`. The arguments are sequences of coefficients from lowest
order "term" to highest, e.g., [1,2,3] represents the series
``P_0 + 2*P_1 + 3*P_2``.
Parameters
----------
c1, c2 : ... |
Divide one Legendre series by another. | def legdiv(c1, c2):
"""
Divide one Legendre series by another.
Returns the quotient-with-remainder of two Legendre series
`c1` / `c2`. The arguments are sequences of coefficients from lowest
order "term" to highest, e.g., [1,2,3] represents the series
``P_0 + 2*P_1 + 3*P_2``.
Parameters
... | [
"def",
"legdiv",
"(",
"c1",
",",
"c2",
")",
":",
"return",
"pu",
".",
"_div",
"(",
"legmul",
",",
"c1",
",",
"c2",
")"
] | [
528,
0
] | [
574,
34
] | python | en | ['en', 'error', 'th'] | False |
legpow | (c, pow, maxpower=16) | Raise a Legendre series to a power.
Returns the Legendre series `c` raised to the power `pow`. The
argument `c` is a sequence of coefficients ordered from low to high.
i.e., [1,2,3] is the series ``P_0 + 2*P_1 + 3*P_2.``
Parameters
----------
c : array_like
1-D array of Legendre serie... | Raise a Legendre series to a power. | def legpow(c, pow, maxpower=16):
"""Raise a Legendre series to a power.
Returns the Legendre series `c` raised to the power `pow`. The
argument `c` is a sequence of coefficients ordered from low to high.
i.e., [1,2,3] is the series ``P_0 + 2*P_1 + 3*P_2.``
Parameters
----------
c : array_... | [
"def",
"legpow",
"(",
"c",
",",
"pow",
",",
"maxpower",
"=",
"16",
")",
":",
"return",
"pu",
".",
"_pow",
"(",
"legmul",
",",
"c",
",",
"pow",
",",
"maxpower",
")"
] | [
577,
0
] | [
608,
44
] | python | en | ['en', 'en', 'en'] | True |
legder | (c, m=1, scl=1, axis=0) |
Differentiate a Legendre series.
Returns the Legendre series coefficients `c` differentiated `m` times
along `axis`. At each iteration the result is multiplied by `scl` (the
scaling factor is for use in a linear change of variable). The argument
`c` is an array of coefficients from low to high de... |
Differentiate a Legendre series. | def legder(c, m=1, scl=1, axis=0):
"""
Differentiate a Legendre series.
Returns the Legendre series coefficients `c` differentiated `m` times
along `axis`. At each iteration the result is multiplied by `scl` (the
scaling factor is for use in a linear change of variable). The argument
`c` is an... | [
"def",
"legder",
"(",
"c",
",",
"m",
"=",
"1",
",",
"scl",
"=",
"1",
",",
"axis",
"=",
"0",
")",
":",
"c",
"=",
"np",
".",
"array",
"(",
"c",
",",
"ndmin",
"=",
"1",
",",
"copy",
"=",
"1",
")",
"if",
"c",
".",
"dtype",
".",
"char",
"in"... | [
611,
0
] | [
700,
12
] | python | en | ['en', 'error', 'th'] | False |
legint | (c, m=1, k=[], lbnd=0, scl=1, axis=0) |
Integrate a Legendre series.
Returns the Legendre series coefficients `c` integrated `m` times from
`lbnd` along `axis`. At each iteration the resulting series is
**multiplied** by `scl` and an integration constant, `k`, is added.
The scaling factor is for use in a linear change of variable. ("Bu... |
Integrate a Legendre series. | def legint(c, m=1, k=[], lbnd=0, scl=1, axis=0):
"""
Integrate a Legendre series.
Returns the Legendre series coefficients `c` integrated `m` times from
`lbnd` along `axis`. At each iteration the resulting series is
**multiplied** by `scl` and an integration constant, `k`, is added.
The scaling... | [
"def",
"legint",
"(",
"c",
",",
"m",
"=",
"1",
",",
"k",
"=",
"[",
"]",
",",
"lbnd",
"=",
"0",
",",
"scl",
"=",
"1",
",",
"axis",
"=",
"0",
")",
":",
"c",
"=",
"np",
".",
"array",
"(",
"c",
",",
"ndmin",
"=",
"1",
",",
"copy",
"=",
"1... | [
703,
0
] | [
828,
12
] | python | en | ['en', 'error', 'th'] | False |
legval | (x, c, tensor=True) |
Evaluate a Legendre series at points x.
If `c` is of length `n + 1`, this function returns the value:
.. math:: p(x) = c_0 * L_0(x) + c_1 * L_1(x) + ... + c_n * L_n(x)
The parameter `x` is converted to an array only if it is a tuple or a
list, otherwise it is treated as a scalar. In either case,... |
Evaluate a Legendre series at points x. | def legval(x, c, tensor=True):
"""
Evaluate a Legendre series at points x.
If `c` is of length `n + 1`, this function returns the value:
.. math:: p(x) = c_0 * L_0(x) + c_1 * L_1(x) + ... + c_n * L_n(x)
The parameter `x` is converted to an array only if it is a tuple or a
list, otherwise it i... | [
"def",
"legval",
"(",
"x",
",",
"c",
",",
"tensor",
"=",
"True",
")",
":",
"c",
"=",
"np",
".",
"array",
"(",
"c",
",",
"ndmin",
"=",
"1",
",",
"copy",
"=",
"0",
")",
"if",
"c",
".",
"dtype",
".",
"char",
"in",
"'?bBhHiIlLqQpP'",
":",
"c",
... | [
831,
0
] | [
916,
20
] | python | en | ['en', 'error', 'th'] | False |
legval2d | (x, y, c) |
Evaluate a 2-D Legendre series at points (x, y).
This function returns the values:
.. math:: p(x,y) = \\sum_{i,j} c_{i,j} * L_i(x) * L_j(y)
The parameters `x` and `y` are converted to arrays only if they are
tuples or a lists, otherwise they are treated as a scalars and they
must have the sa... |
Evaluate a 2-D Legendre series at points (x, y). | def legval2d(x, y, c):
"""
Evaluate a 2-D Legendre series at points (x, y).
This function returns the values:
.. math:: p(x,y) = \\sum_{i,j} c_{i,j} * L_i(x) * L_j(y)
The parameters `x` and `y` are converted to arrays only if they are
tuples or a lists, otherwise they are treated as a scalars... | [
"def",
"legval2d",
"(",
"x",
",",
"y",
",",
"c",
")",
":",
"return",
"pu",
".",
"_valnd",
"(",
"legval",
",",
"c",
",",
"x",
",",
"y",
")"
] | [
919,
0
] | [
965,
37
] | python | en | ['en', 'error', 'th'] | False |
leggrid2d | (x, y, c) |
Evaluate a 2-D Legendre series on the Cartesian product of x and y.
This function returns the values:
.. math:: p(a,b) = \\sum_{i,j} c_{i,j} * L_i(a) * L_j(b)
where the points `(a, b)` consist of all pairs formed by taking
`a` from `x` and `b` from `y`. The resulting points form a grid with
... |
Evaluate a 2-D Legendre series on the Cartesian product of x and y. | def leggrid2d(x, y, c):
"""
Evaluate a 2-D Legendre series on the Cartesian product of x and y.
This function returns the values:
.. math:: p(a,b) = \\sum_{i,j} c_{i,j} * L_i(a) * L_j(b)
where the points `(a, b)` consist of all pairs formed by taking
`a` from `x` and `b` from `y`. The resulti... | [
"def",
"leggrid2d",
"(",
"x",
",",
"y",
",",
"c",
")",
":",
"return",
"pu",
".",
"_gridnd",
"(",
"legval",
",",
"c",
",",
"x",
",",
"y",
")"
] | [
968,
0
] | [
1018,
38
] | python | en | ['en', 'error', 'th'] | False |
legval3d | (x, y, z, c) |
Evaluate a 3-D Legendre series at points (x, y, z).
This function returns the values:
.. math:: p(x,y,z) = \\sum_{i,j,k} c_{i,j,k} * L_i(x) * L_j(y) * L_k(z)
The parameters `x`, `y`, and `z` are converted to arrays only if
they are tuples or a lists, otherwise they are treated as a scalars and
... |
Evaluate a 3-D Legendre series at points (x, y, z). | def legval3d(x, y, z, c):
"""
Evaluate a 3-D Legendre series at points (x, y, z).
This function returns the values:
.. math:: p(x,y,z) = \\sum_{i,j,k} c_{i,j,k} * L_i(x) * L_j(y) * L_k(z)
The parameters `x`, `y`, and `z` are converted to arrays only if
they are tuples or a lists, otherwise th... | [
"def",
"legval3d",
"(",
"x",
",",
"y",
",",
"z",
",",
"c",
")",
":",
"return",
"pu",
".",
"_valnd",
"(",
"legval",
",",
"c",
",",
"x",
",",
"y",
",",
"z",
")"
] | [
1021,
0
] | [
1069,
40
] | python | en | ['en', 'error', 'th'] | False |
leggrid3d | (x, y, z, c) |
Evaluate a 3-D Legendre series on the Cartesian product of x, y, and z.
This function returns the values:
.. math:: p(a,b,c) = \\sum_{i,j,k} c_{i,j,k} * L_i(a) * L_j(b) * L_k(c)
where the points `(a, b, c)` consist of all triples formed by taking
`a` from `x`, `b` from `y`, and `c` from `z`. The... |
Evaluate a 3-D Legendre series on the Cartesian product of x, y, and z. | def leggrid3d(x, y, z, c):
"""
Evaluate a 3-D Legendre series on the Cartesian product of x, y, and z.
This function returns the values:
.. math:: p(a,b,c) = \\sum_{i,j,k} c_{i,j,k} * L_i(a) * L_j(b) * L_k(c)
where the points `(a, b, c)` consist of all triples formed by taking
`a` from `x`, `... | [
"def",
"leggrid3d",
"(",
"x",
",",
"y",
",",
"z",
",",
"c",
")",
":",
"return",
"pu",
".",
"_gridnd",
"(",
"legval",
",",
"c",
",",
"x",
",",
"y",
",",
"z",
")"
] | [
1072,
0
] | [
1125,
41
] | python | en | ['en', 'error', 'th'] | False |
legvander | (x, deg) | Pseudo-Vandermonde matrix of given degree.
Returns the pseudo-Vandermonde matrix of degree `deg` and sample points
`x`. The pseudo-Vandermonde matrix is defined by
.. math:: V[..., i] = L_i(x)
where `0 <= i <= deg`. The leading indices of `V` index the elements of
`x` and the last index is the de... | Pseudo-Vandermonde matrix of given degree. | def legvander(x, deg):
"""Pseudo-Vandermonde matrix of given degree.
Returns the pseudo-Vandermonde matrix of degree `deg` and sample points
`x`. The pseudo-Vandermonde matrix is defined by
.. math:: V[..., i] = L_i(x)
where `0 <= i <= deg`. The leading indices of `V` index the elements of
`x... | [
"def",
"legvander",
"(",
"x",
",",
"deg",
")",
":",
"ideg",
"=",
"pu",
".",
"_deprecate_as_int",
"(",
"deg",
",",
"\"deg\"",
")",
"if",
"ideg",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"deg must be non-negative\"",
")",
"x",
"=",
"np",
".",
"array"... | [
1128,
0
] | [
1178,
32
] | python | ca | ['nl', 'ca', 'en'] | False |
legvander2d | (x, y, deg) | Pseudo-Vandermonde matrix of given degrees.
Returns the pseudo-Vandermonde matrix of degrees `deg` and sample
points `(x, y)`. The pseudo-Vandermonde matrix is defined by
.. math:: V[..., (deg[1] + 1)*i + j] = L_i(x) * L_j(y),
where `0 <= i <= deg[0]` and `0 <= j <= deg[1]`. The leading indices of
... | Pseudo-Vandermonde matrix of given degrees. | def legvander2d(x, y, deg):
"""Pseudo-Vandermonde matrix of given degrees.
Returns the pseudo-Vandermonde matrix of degrees `deg` and sample
points `(x, y)`. The pseudo-Vandermonde matrix is defined by
.. math:: V[..., (deg[1] + 1)*i + j] = L_i(x) * L_j(y),
where `0 <= i <= deg[0]` and `0 <= j <=... | [
"def",
"legvander2d",
"(",
"x",
",",
"y",
",",
"deg",
")",
":",
"return",
"pu",
".",
"_vander2d",
"(",
"legvander",
",",
"x",
",",
"y",
",",
"deg",
")"
] | [
1181,
0
] | [
1231,
45
] | python | ca | ['nl', 'ca', 'en'] | False |
legvander3d | (x, y, z, deg) | Pseudo-Vandermonde matrix of given degrees.
Returns the pseudo-Vandermonde matrix of degrees `deg` and sample
points `(x, y, z)`. If `l, m, n` are the given degrees in `x, y, z`,
then The pseudo-Vandermonde matrix is defined by
.. math:: V[..., (m+1)(n+1)i + (n+1)j + k] = L_i(x)*L_j(y)*L_k(z),
wh... | Pseudo-Vandermonde matrix of given degrees. | def legvander3d(x, y, z, deg):
"""Pseudo-Vandermonde matrix of given degrees.
Returns the pseudo-Vandermonde matrix of degrees `deg` and sample
points `(x, y, z)`. If `l, m, n` are the given degrees in `x, y, z`,
then The pseudo-Vandermonde matrix is defined by
.. math:: V[..., (m+1)(n+1)i + (n+1)... | [
"def",
"legvander3d",
"(",
"x",
",",
"y",
",",
"z",
",",
"deg",
")",
":",
"return",
"pu",
".",
"_vander3d",
"(",
"legvander",
",",
"x",
",",
"y",
",",
"z",
",",
"deg",
")"
] | [
1234,
0
] | [
1285,
48
] | python | ca | ['nl', 'ca', 'en'] | False |
legfit | (x, y, deg, rcond=None, full=False, w=None) |
Least squares fit of Legendre series to data.
Return the coefficients of a Legendre series of degree `deg` that is the
least squares fit to the data values `y` given at points `x`. If `y` is
1-D the returned coefficients will also be 1-D. If `y` is 2-D multiple
fits are done, one for each column o... |
Least squares fit of Legendre series to data. | def legfit(x, y, deg, rcond=None, full=False, w=None):
"""
Least squares fit of Legendre series to data.
Return the coefficients of a Legendre series of degree `deg` that is the
least squares fit to the data values `y` given at points `x`. If `y` is
1-D the returned coefficients will also be 1-D. I... | [
"def",
"legfit",
"(",
"x",
",",
"y",
",",
"deg",
",",
"rcond",
"=",
"None",
",",
"full",
"=",
"False",
",",
"w",
"=",
"None",
")",
":",
"return",
"pu",
".",
"_fit",
"(",
"legvander",
",",
"x",
",",
"y",
",",
"deg",
",",
"rcond",
",",
"full",
... | [
1288,
0
] | [
1409,
56
] | python | en | ['en', 'error', 'th'] | False |
legcompanion | (c) | Return the scaled companion matrix of c.
The basis polynomials are scaled so that the companion matrix is
symmetric when `c` is an Legendre basis polynomial. This provides
better eigenvalue estimates than the unscaled case and for basis
polynomials the eigenvalues are guaranteed to be real if
`nump... | Return the scaled companion matrix of c. | def legcompanion(c):
"""Return the scaled companion matrix of c.
The basis polynomials are scaled so that the companion matrix is
symmetric when `c` is an Legendre basis polynomial. This provides
better eigenvalue estimates than the unscaled case and for basis
polynomials the eigenvalues are guaran... | [
"def",
"legcompanion",
"(",
"c",
")",
":",
"# c is a trimmed copy",
"[",
"c",
"]",
"=",
"pu",
".",
"as_series",
"(",
"[",
"c",
"]",
")",
"if",
"len",
"(",
"c",
")",
"<",
"2",
":",
"raise",
"ValueError",
"(",
"'Series must have maximum degree of at least 1.... | [
1412,
0
] | [
1453,
14
] | python | en | ['en', 'sm', 'en'] | True |
legroots | (c) |
Compute the roots of a Legendre series.
Return the roots (a.k.a. "zeros") of the polynomial
.. math:: p(x) = \\sum_i c[i] * L_i(x).
Parameters
----------
c : 1-D array_like
1-D array of coefficients.
Returns
-------
out : ndarray
Array of the roots of the series.... |
Compute the roots of a Legendre series. | def legroots(c):
"""
Compute the roots of a Legendre series.
Return the roots (a.k.a. "zeros") of the polynomial
.. math:: p(x) = \\sum_i c[i] * L_i(x).
Parameters
----------
c : 1-D array_like
1-D array of coefficients.
Returns
-------
out : ndarray
Array of ... | [
"def",
"legroots",
"(",
"c",
")",
":",
"# c is a trimmed copy",
"[",
"c",
"]",
"=",
"pu",
".",
"as_series",
"(",
"[",
"c",
"]",
")",
"if",
"len",
"(",
"c",
")",
"<",
"2",
":",
"return",
"np",
".",
"array",
"(",
"[",
"]",
",",
"dtype",
"=",
"c... | [
1456,
0
] | [
1510,
12
] | python | en | ['en', 'error', 'th'] | False |
leggauss | (deg) |
Gauss-Legendre quadrature.
Computes the sample points and weights for Gauss-Legendre quadrature.
These sample points and weights will correctly integrate polynomials of
degree :math:`2*deg - 1` or less over the interval :math:`[-1, 1]` with
the weight function :math:`f(x) = 1`.
Parameters
... |
Gauss-Legendre quadrature. | def leggauss(deg):
"""
Gauss-Legendre quadrature.
Computes the sample points and weights for Gauss-Legendre quadrature.
These sample points and weights will correctly integrate polynomials of
degree :math:`2*deg - 1` or less over the interval :math:`[-1, 1]` with
the weight function :math:`f(x)... | [
"def",
"leggauss",
"(",
"deg",
")",
":",
"ideg",
"=",
"pu",
".",
"_deprecate_as_int",
"(",
"deg",
",",
"\"deg\"",
")",
"if",
"ideg",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"deg must be a positive integer\"",
")",
"# first approximation of roots. We use the ... | [
1513,
0
] | [
1578,
15
] | python | en | ['en', 'error', 'th'] | False |
legweight | (x) |
Weight function of the Legendre polynomials.
The weight function is :math:`1` and the interval of integration is
:math:`[-1, 1]`. The Legendre polynomials are orthogonal, but not
normalized, with respect to this weight function.
Parameters
----------
x : array_like
Values at which ... |
Weight function of the Legendre polynomials. | def legweight(x):
"""
Weight function of the Legendre polynomials.
The weight function is :math:`1` and the interval of integration is
:math:`[-1, 1]`. The Legendre polynomials are orthogonal, but not
normalized, with respect to this weight function.
Parameters
----------
x : array_lik... | [
"def",
"legweight",
"(",
"x",
")",
":",
"w",
"=",
"x",
"*",
"0.0",
"+",
"1.0",
"return",
"w"
] | [
1581,
0
] | [
1606,
12
] | python | en | ['en', 'error', 'th'] | False |
UNet.__init__ | (
self,
num_classes: int = 19,
num_layers: int = 5,
features_start: int = 64,
bilinear: bool = False,
) |
Args:
num_classes: Number of output classes required (default 19 for KITTI dataset)
num_layers: Number of layers in each side of U-net
features_start: Number of features in first layer
bilinear: Whether to use bilinear interpolation or transposed convolutions for... |
Args:
num_classes: Number of output classes required (default 19 for KITTI dataset)
num_layers: Number of layers in each side of U-net
features_start: Number of features in first layer
bilinear: Whether to use bilinear interpolation or transposed convolutions for... | def __init__(
self,
num_classes: int = 19,
num_layers: int = 5,
features_start: int = 64,
bilinear: bool = False,
):
"""
Args:
num_classes: Number of output classes required (default 19 for KITTI dataset)
num_layers: Number of layers in... | [
"def",
"__init__",
"(",
"self",
",",
"num_classes",
":",
"int",
"=",
"19",
",",
"num_layers",
":",
"int",
"=",
"5",
",",
"features_start",
":",
"int",
"=",
"64",
",",
"bilinear",
":",
"bool",
"=",
"False",
",",
")",
":",
"super",
"(",
")",
".",
"... | [
37,
4
] | [
67,
43
] | python | en | ['en', 'error', 'th'] | False |
TestRegression.test_mem_on_invalid_dtype | (self) | Ticket #583 | Ticket #583 | def test_mem_on_invalid_dtype(self):
"Ticket #583"
assert_raises(ValueError, np.fromiter, [['12', ''], ['13', '']], str) | [
"def",
"test_mem_on_invalid_dtype",
"(",
"self",
")",
":",
"assert_raises",
"(",
"ValueError",
",",
"np",
".",
"fromiter",
",",
"[",
"[",
"'12'",
",",
"''",
"]",
",",
"[",
"'13'",
",",
"''",
"]",
"]",
",",
"str",
")"
] | [
821,
4
] | [
823,
77
] | python | de | ['en', 'de', 'sw'] | False |
TestRegression.test_for_zero_length_in_choose | (self) | Ticket #882 | Ticket #882 | def test_for_zero_length_in_choose(self):
"Ticket #882"
a = np.array(1)
assert_raises(ValueError, lambda x: x.choose([]), a) | [
"def",
"test_for_zero_length_in_choose",
"(",
"self",
")",
":",
"a",
"=",
"np",
".",
"array",
"(",
"1",
")",
"assert_raises",
"(",
"ValueError",
",",
"lambda",
"x",
":",
"x",
".",
"choose",
"(",
"[",
"]",
")",
",",
"a",
")"
] | [
1284,
4
] | [
1287,
60
] | python | en | ['en', 'de', 'en'] | False |
TestRegression.test_array_ndmin_overflow | (self) | Ticket #947. | Ticket #947. | def test_array_ndmin_overflow(self):
"Ticket #947."
assert_raises(ValueError, lambda: np.array([1], ndmin=33)) | [
"def",
"test_array_ndmin_overflow",
"(",
"self",
")",
":",
"assert_raises",
"(",
"ValueError",
",",
"lambda",
":",
"np",
".",
"array",
"(",
"[",
"1",
"]",
",",
"ndmin",
"=",
"33",
")",
")"
] | [
1289,
4
] | [
1291,
66
] | python | en | ['en', 'de', 'en'] | False |
TestRegression.test_zerosize_accumulate | (self) | Ticket #1733 | Ticket #1733 | def test_zerosize_accumulate(self):
"Ticket #1733"
x = np.array([[42, 0]], dtype=np.uint32)
assert_equal(np.add.accumulate(x[:-1, 0]), []) | [
"def",
"test_zerosize_accumulate",
"(",
"self",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"42",
",",
"0",
"]",
"]",
",",
"dtype",
"=",
"np",
".",
"uint32",
")",
"assert_equal",
"(",
"np",
".",
"add",
".",
"accumulate",
"(",
"x",
"[",... | [
1882,
4
] | [
1885,
54
] | python | de | ['en', 'de', 'ur'] | False |
TestRegression.test_setting_rank0_string | (self) | Ticket #1736 | Ticket #1736 | def test_setting_rank0_string(self):
"Ticket #1736"
s1 = b"hello1"
s2 = b"hello2"
a = np.zeros((), dtype="S10")
a[()] = s1
assert_equal(a, np.array(s1))
a[()] = np.array(s2)
assert_equal(a, np.array(s2))
a = np.zeros((), dtype='f4')
a[()] ... | [
"def",
"test_setting_rank0_string",
"(",
"self",
")",
":",
"s1",
"=",
"b\"hello1\"",
"s2",
"=",
"b\"hello2\"",
"a",
"=",
"np",
".",
"zeros",
"(",
"(",
")",
",",
"dtype",
"=",
"\"S10\"",
")",
"a",
"[",
"(",
")",
"]",
"=",
"s1",
"assert_equal",
"(",
... | [
1892,
4
] | [
1906,
36
] | python | de | ['en', 'de', 'sw'] | False |
TestRegression.test_string_astype | (self) | Ticket #1748 | Ticket #1748 | def test_string_astype(self):
"Ticket #1748"
s1 = b'black'
s2 = b'white'
s3 = b'other'
a = np.array([[s1], [s2], [s3]])
assert_equal(a.dtype, np.dtype('S5'))
b = a.astype(np.dtype('S0'))
assert_equal(b.dtype, np.dtype('S5')) | [
"def",
"test_string_astype",
"(",
"self",
")",
":",
"s1",
"=",
"b'black'",
"s2",
"=",
"b'white'",
"s3",
"=",
"b'other'",
"a",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"s1",
"]",
",",
"[",
"s2",
"]",
",",
"[",
"s3",
"]",
"]",
")",
"assert_equal",
... | [
1908,
4
] | [
1916,
45
] | python | de | ['en', 'de', 'sw'] | False |
TestRegression.test_ticket_1770 | (self) | Should not segfault on python 3k | Should not segfault on python 3k | def test_ticket_1770(self):
"Should not segfault on python 3k"
import numpy as np
try:
a = np.zeros((1,), dtype=[('f1', 'f')])
a['f1'] = 1
a['f2'] = 1
except ValueError:
pass
except Exception:
raise AssertionError | [
"def",
"test_ticket_1770",
"(",
"self",
")",
":",
"import",
"numpy",
"as",
"np",
"try",
":",
"a",
"=",
"np",
".",
"zeros",
"(",
"(",
"1",
",",
")",
",",
"dtype",
"=",
"[",
"(",
"'f1'",
",",
"'f'",
")",
"]",
")",
"a",
"[",
"'f1'",
"]",
"=",
... | [
1942,
4
] | [
1952,
32
] | python | en | ['en', 'cs', 'en'] | True |
TestRegression.test_ticket_1608 | (self) | x.flat shouldn't modify data | x.flat shouldn't modify data | def test_ticket_1608(self):
"x.flat shouldn't modify data"
x = np.array([[1, 2], [3, 4]]).T
np.array(x.flat)
assert_equal(x, [[1, 3], [2, 4]]) | [
"def",
"test_ticket_1608",
"(",
"self",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"1",
",",
"2",
"]",
",",
"[",
"3",
",",
"4",
"]",
"]",
")",
".",
"T",
"np",
".",
"array",
"(",
"x",
".",
"flat",
")",
"assert_equal",
"(",
"x",
... | [
1954,
4
] | [
1958,
41
] | python | en | ['en', 'mt', 'en'] | True |
TopDownBaseDataset._get_db | (self) | Load dataset. | Load dataset. | def _get_db(self):
"""Load dataset."""
raise NotImplementedError | [
"def",
"_get_db",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
55,
4
] | [
57,
33
] | python | da | ['es', 'da', 'it'] | False |
TopDownBaseDataset.evaluate | (self, cfg, preds, output_dir, *args, **kwargs) | Evaluate keypoint results. | Evaluate keypoint results. | def evaluate(self, cfg, preds, output_dir, *args, **kwargs):
"""Evaluate keypoint results."""
raise NotImplementedError | [
"def",
"evaluate",
"(",
"self",
",",
"cfg",
",",
"preds",
",",
"output_dir",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError"
] | [
60,
4
] | [
62,
33
] | python | en | ['en', 'en', 'en'] | True |
TopDownBaseDataset.__len__ | (self) | Get the size of the dataset. | Get the size of the dataset. | def __len__(self):
"""Get the size of the dataset."""
return len(self.db) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"db",
")"
] | [
64,
4
] | [
66,
27
] | python | en | ['en', 'en', 'en'] | True |
TopDownBaseDataset.__getitem__ | (self, idx) | Get the sample given index. | Get the sample given index. | def __getitem__(self, idx):
"""Get the sample given index."""
results = copy.deepcopy(self.db[idx])
results['ann_info'] = self.ann_info
return self.pipeline(results) | [
"def",
"__getitem__",
"(",
"self",
",",
"idx",
")",
":",
"results",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"db",
"[",
"idx",
"]",
")",
"results",
"[",
"'ann_info'",
"]",
"=",
"self",
".",
"ann_info",
"return",
"self",
".",
"pipeline",
"(",
... | [
68,
4
] | [
72,
37
] | python | en | ['en', 'en', 'en'] | True |
get_activations | (files, model, batch_size=1, dims=64,
cuda=False, verbose=False) | Calculates the activations of the pool_3 layer for all images.
Params:
-- files : List of image files paths
-- model : Instance of inception model
-- batch_size : Batch size of images for the model to process at once.
Make sure that the number of samples is a multiple ... | Calculates the activations of the pool_3 layer for all images. | def get_activations(files, model, batch_size=1, dims=64,
cuda=False, verbose=False):
"""Calculates the activations of the pool_3 layer for all images.
Params:
-- files : List of image files paths
-- model : Instance of inception model
-- batch_size : Batch size of i... | [
"def",
"get_activations",
"(",
"files",
",",
"model",
",",
"batch_size",
"=",
"1",
",",
"dims",
"=",
"64",
",",
"cuda",
"=",
"False",
",",
"verbose",
"=",
"False",
")",
":",
"model",
".",
"eval",
"(",
")",
"if",
"len",
"(",
"files",
")",
"%",
"ba... | [
53,
0
] | [
124,
19
] | python | en | ['en', 'en', 'en'] | True |
calculate_frechet_distance | (mu1, sigma1, mu2, sigma2, eps=1e-6) | Numpy implementation of the Frechet Distance.
The Frechet distance between two multivariate Gaussians X_1 ~ N(mu_1, C_1)
and X_2 ~ N(mu_2, C_2) is
d^2 = ||mu_1 - mu_2||^2 + Tr(C_1 + C_2 - 2*sqrt(C_1*C_2)).
Stable version by Dougal J. Sutherland.
Params:
-- mu1 : Numpy array containin... | Numpy implementation of the Frechet Distance.
The Frechet distance between two multivariate Gaussians X_1 ~ N(mu_1, C_1)
and X_2 ~ N(mu_2, C_2) is
d^2 = ||mu_1 - mu_2||^2 + Tr(C_1 + C_2 - 2*sqrt(C_1*C_2)). | def calculate_frechet_distance(mu1, sigma1, mu2, sigma2, eps=1e-6):
"""Numpy implementation of the Frechet Distance.
The Frechet distance between two multivariate Gaussians X_1 ~ N(mu_1, C_1)
and X_2 ~ N(mu_2, C_2) is
d^2 = ||mu_1 - mu_2||^2 + Tr(C_1 + C_2 - 2*sqrt(C_1*C_2)).
Stable version... | [
"def",
"calculate_frechet_distance",
"(",
"mu1",
",",
"sigma1",
",",
"mu2",
",",
"sigma2",
",",
"eps",
"=",
"1e-6",
")",
":",
"mu1",
"=",
"np",
".",
"atleast_1d",
"(",
"mu1",
")",
"mu2",
"=",
"np",
".",
"atleast_1d",
"(",
"mu2",
")",
"sigma1",
"=",
... | [
127,
0
] | [
181,
46
] | python | en | ['en', 'en', 'en'] | True |
calculate_activation_statistics | (files, model, batch_size=1,
dims=64, cuda=False, verbose=False) | Calculation of the statistics used by the FID.
Params:
-- files : List of image files paths
-- model : Instance of inception model
-- batch_size : The images numpy array is split into batches with
batch size batch_size. A reasonable batch size
depen... | Calculation of the statistics used by the FID.
Params:
-- files : List of image files paths
-- model : Instance of inception model
-- batch_size : The images numpy array is split into batches with
batch size batch_size. A reasonable batch size
depen... | def calculate_activation_statistics(files, model, batch_size=1,
dims=64, cuda=False, verbose=False):
"""Calculation of the statistics used by the FID.
Params:
-- files : List of image files paths
-- model : Instance of inception model
-- batch_size : ... | [
"def",
"calculate_activation_statistics",
"(",
"files",
",",
"model",
",",
"batch_size",
"=",
"1",
",",
"dims",
"=",
"64",
",",
"cuda",
"=",
"False",
",",
"verbose",
"=",
"False",
")",
":",
"act",
"=",
"get_activations",
"(",
"files",
",",
"model",
",",
... | [
184,
0
] | [
204,
20
] | python | en | ['en', 'en', 'en'] | True |
calculate_sifid_given_paths | (path1, path2, batch_size, cuda, dims, suffix) | Calculates the SIFID of two paths | Calculates the SIFID of two paths | def calculate_sifid_given_paths(path1, path2, batch_size, cuda, dims, suffix):
"""Calculates the SIFID of two paths"""
block_idx = InceptionV3.BLOCK_INDEX_BY_DIM[dims]
model = InceptionV3([block_idx])
if cuda:
model.cuda()
path1 = pathlib.Path(path1)
files1 = list(path1.glob('*.%s' %s... | [
"def",
"calculate_sifid_given_paths",
"(",
"path1",
",",
"path2",
",",
"batch_size",
",",
"cuda",
",",
"dims",
",",
"suffix",
")",
":",
"block_idx",
"=",
"InceptionV3",
".",
"BLOCK_INDEX_BY_DIM",
"[",
"dims",
"]",
"model",
"=",
"InceptionV3",
"(",
"[",
"bloc... | [
221,
0
] | [
246,
21
] | python | en | ['en', 'en', 'en'] | True |
colored | (text, color=None, on_color=None, attrs=None) | Colorize text.
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
Available text highlights:
on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
Available attributes:
bold, dark, underline, blink, reverse, concealed.
Example:
color... | Colorize text. | def colored(text, color=None, on_color=None, attrs=None):
"""Colorize text.
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
Available text highlights:
on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
Available attributes:
bold, dark, ... | [
"def",
"colored",
"(",
"text",
",",
"color",
"=",
"None",
",",
"on_color",
"=",
"None",
",",
"attrs",
"=",
"None",
")",
":",
"if",
"os",
".",
"getenv",
"(",
"'ANSI_COLORS_DISABLED'",
")",
"is",
"None",
":",
"fmt_str",
"=",
"'\\033[%dm%s'",
"if",
"color... | [
85,
0
] | [
114,
15
] | python | en | ['en', 'fr', 'en'] | False |
cprint | (text, color=None, on_color=None, attrs=None, **kwargs) | Print colorize text.
It accepts arguments of print function.
| Print colorize text. | def cprint(text, color=None, on_color=None, attrs=None, **kwargs):
"""Print colorize text.
It accepts arguments of print function.
"""
print((colored(text, color, on_color, attrs)), **kwargs) | [
"def",
"cprint",
"(",
"text",
",",
"color",
"=",
"None",
",",
"on_color",
"=",
"None",
",",
"attrs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"print",
"(",
"(",
"colored",
"(",
"text",
",",
"color",
",",
"on_color",
",",
"attrs",
")",
")",... | [
117,
0
] | [
123,
60
] | python | en | ['en', 'fr', 'it'] | False |
test_progress_bar_on | (tmpdir, callbacks, refresh_rate) | Test different ways the progress bar can be turned on. | Test different ways the progress bar can be turned on. | def test_progress_bar_on(tmpdir, callbacks, refresh_rate):
"""Test different ways the progress bar can be turned on."""
trainer = Trainer(
default_root_dir=tmpdir,
callbacks=callbacks,
progress_bar_refresh_rate=refresh_rate,
max_epochs=1,
overfit_batches=5,
)
pr... | [
"def",
"test_progress_bar_on",
"(",
"tmpdir",
",",
"callbacks",
",",
"refresh_rate",
")",
":",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"callbacks",
"=",
"callbacks",
",",
"progress_bar_refresh_rate",
"=",
"refresh_rate",
",",
"max_e... | [
38,
0
] | [
52,
60
] | python | en | ['en', 'en', 'en'] | True |
test_progress_bar_off | (tmpdir, callbacks, refresh_rate) | Test different ways the progress bar can be turned off. | Test different ways the progress bar can be turned off. | def test_progress_bar_off(tmpdir, callbacks, refresh_rate):
"""Test different ways the progress bar can be turned off."""
trainer = Trainer(
default_root_dir=tmpdir,
callbacks=callbacks,
progress_bar_refresh_rate=refresh_rate,
)
progress_bars = [c for c in trainer.callbacks if ... | [
"def",
"test_progress_bar_off",
"(",
"tmpdir",
",",
"callbacks",
",",
"refresh_rate",
")",
":",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"callbacks",
"=",
"callbacks",
",",
"progress_bar_refresh_rate",
"=",
"refresh_rate",
",",
")",
... | [
62,
0
] | [
73,
44
] | python | en | ['en', 'en', 'en'] | True |
test_progress_bar_misconfiguration | () | Test that Trainer doesn't accept multiple progress bars. | Test that Trainer doesn't accept multiple progress bars. | def test_progress_bar_misconfiguration():
"""Test that Trainer doesn't accept multiple progress bars."""
callbacks = [ProgressBar(), ProgressBar(), ModelCheckpoint(dirpath='../trainer')]
with pytest.raises(MisconfigurationException, match=r'^You added multiple progress bar callbacks'):
Trainer(callb... | [
"def",
"test_progress_bar_misconfiguration",
"(",
")",
":",
"callbacks",
"=",
"[",
"ProgressBar",
"(",
")",
",",
"ProgressBar",
"(",
")",
",",
"ModelCheckpoint",
"(",
"dirpath",
"=",
"'../trainer'",
")",
"]",
"with",
"pytest",
".",
"raises",
"(",
"Misconfigura... | [
76,
0
] | [
80,
36
] | python | en | ['en', 'en', 'en'] | True |
test_progress_bar_totals | (tmpdir) | Test that the progress finishes with the correct total steps processed. | Test that the progress finishes with the correct total steps processed. | def test_progress_bar_totals(tmpdir):
"""Test that the progress finishes with the correct total steps processed."""
model = BoringModel()
trainer = Trainer(
default_root_dir=tmpdir,
progress_bar_refresh_rate=1,
limit_val_batches=1.0,
max_epochs=1,
)
bar = trainer.pr... | [
"def",
"test_progress_bar_totals",
"(",
"tmpdir",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"progress_bar_refresh_rate",
"=",
"1",
",",
"limit_val_batches",
"=",
"1.0",
",",
"max_epoc... | [
83,
0
] | [
132,
34
] | python | en | ['en', 'en', 'en'] | True |
test_progress_bar_progress_refresh | (tmpdir, refresh_rate) | Test that the three progress bars get correctly updated when using different refresh rates. | Test that the three progress bars get correctly updated when using different refresh rates. | def test_progress_bar_progress_refresh(tmpdir, refresh_rate):
"""Test that the three progress bars get correctly updated when using different refresh rates."""
model = BoringModel()
class CurrentProgressBar(ProgressBar):
train_batches_seen = 0
val_batches_seen = 0
test_batches_see... | [
"def",
"test_progress_bar_progress_refresh",
"(",
"tmpdir",
",",
"refresh_rate",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"class",
"CurrentProgressBar",
"(",
"ProgressBar",
")",
":",
"train_batches_seen",
"=",
"0",
"val_batches_seen",
"=",
"0",
"test_batches... | [
167,
0
] | [
217,
76
] | python | en | ['en', 'en', 'en'] | True |
test_num_sanity_val_steps_progress_bar | (tmpdir, limit_val_batches, expected) |
Test val_progress_bar total with 'num_sanity_val_steps' Trainer argument.
|
Test val_progress_bar total with 'num_sanity_val_steps' Trainer argument.
| def test_num_sanity_val_steps_progress_bar(tmpdir, limit_val_batches, expected):
"""
Test val_progress_bar total with 'num_sanity_val_steps' Trainer argument.
"""
class CurrentProgressBar(ProgressBar):
def __init__(self):
super().__init__()
self.val_progress_bar_total =... | [
"def",
"test_num_sanity_val_steps_progress_bar",
"(",
"tmpdir",
",",
"limit_val_batches",
",",
"expected",
")",
":",
"class",
"CurrentProgressBar",
"(",
"ProgressBar",
")",
":",
"def",
"__init__",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
... | [
224,
0
] | [
252,
75
] | python | en | ['en', 'error', 'th'] | False |
test_progress_bar_default_value | (tmpdir) | Test that a value of None defaults to refresh rate 1. | Test that a value of None defaults to refresh rate 1. | def test_progress_bar_default_value(tmpdir):
""" Test that a value of None defaults to refresh rate 1. """
trainer = Trainer(default_root_dir=tmpdir)
assert trainer.progress_bar_callback.refresh_rate == 1
trainer = Trainer(default_root_dir=tmpdir, progress_bar_refresh_rate=None)
assert trainer.prog... | [
"def",
"test_progress_bar_default_value",
"(",
"tmpdir",
")",
":",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
")",
"assert",
"trainer",
".",
"progress_bar_callback",
".",
"refresh_rate",
"==",
"1",
"trainer",
"=",
"Trainer",
"(",
"default_r... | [
255,
0
] | [
261,
58
] | python | en | ['en', 'en', 'en'] | True |
test_progress_bar_value_on_colab | (tmpdir) | Test that Trainer will override the default in Google COLAB. | Test that Trainer will override the default in Google COLAB. | def test_progress_bar_value_on_colab(tmpdir):
""" Test that Trainer will override the default in Google COLAB. """
trainer = Trainer(default_root_dir=tmpdir)
assert trainer.progress_bar_callback.refresh_rate == 20
trainer = Trainer(default_root_dir=tmpdir, progress_bar_refresh_rate=None)
assert tra... | [
"def",
"test_progress_bar_value_on_colab",
"(",
"tmpdir",
")",
":",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
")",
"assert",
"trainer",
".",
"progress_bar_callback",
".",
"refresh_rate",
"==",
"20",
"trainer",
"=",
"Trainer",
"(",
"default... | [
265,
0
] | [
274,
59
] | python | en | ['en', 'en', 'en'] | True |
test_main_progress_bar_update_amount | (tmpdir, train_batches, val_batches, refresh_rate, train_deltas, val_deltas) |
Test that the main progress updates with the correct amount together with the val progress. At the end of
the epoch, the progress must not overshoot if the number of steps is not divisible by the refresh rate.
|
Test that the main progress updates with the correct amount together with the val progress. At the end of
the epoch, the progress must not overshoot if the number of steps is not divisible by the refresh rate.
| def test_main_progress_bar_update_amount(tmpdir, train_batches, val_batches, refresh_rate, train_deltas, val_deltas):
"""
Test that the main progress updates with the correct amount together with the val progress. At the end of
the epoch, the progress must not overshoot if the number of steps is not divisib... | [
"def",
"test_main_progress_bar_update_amount",
"(",
"tmpdir",
",",
"train_batches",
",",
"val_batches",
",",
"refresh_rate",
",",
"train_deltas",
",",
"val_deltas",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"progress_bar",
"=",
"MockedUpdateProgressBars",
"(",
... | [
308,
0
] | [
327,
100
] | python | en | ['en', 'error', 'th'] | False |
test_test_progress_bar_update_amount | (tmpdir, test_batches, refresh_rate, test_deltas) |
Test that test progress updates with the correct amount.
|
Test that test progress updates with the correct amount.
| def test_test_progress_bar_update_amount(tmpdir, test_batches, refresh_rate, test_deltas):
"""
Test that test progress updates with the correct amount.
"""
model = BoringModel()
progress_bar = MockedUpdateProgressBars(refresh_rate=refresh_rate)
trainer = Trainer(
default_root_dir=tmpdir,... | [
"def",
"test_test_progress_bar_update_amount",
"(",
"tmpdir",
",",
"test_batches",
",",
"refresh_rate",
",",
"test_deltas",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"progress_bar",
"=",
"MockedUpdateProgressBars",
"(",
"refresh_rate",
"=",
"refresh_rate",
")",... | [
335,
0
] | [
350,
98
] | python | en | ['en', 'error', 'th'] | False |
test_tensor_to_float_conversion | (tmpdir) | Check tensor gets converted to float | Check tensor gets converted to float | def test_tensor_to_float_conversion(tmpdir):
"""Check tensor gets converted to float"""
class TestModel(BoringModel):
def training_step(self, batch, batch_idx):
self.log('foo', torch.tensor(0.123), prog_bar=True)
self.log('bar', {"baz": torch.tensor([1])}, prog_bar=True)
... | [
"def",
"test_tensor_to_float_conversion",
"(",
"tmpdir",
")",
":",
"class",
"TestModel",
"(",
"BoringModel",
")",
":",
"def",
"training_step",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"self",
".",
"log",
"(",
"'foo'",
",",
"torch",
".",
"tens... | [
353,
0
] | [
374,
65
] | python | en | ['en', 'en', 'en'] | True |
test_tqdm_format_num | (input_num, expected) | Check that the specialized tqdm.format_num appends 0 to floats and strings | Check that the specialized tqdm.format_num appends 0 to floats and strings | def test_tqdm_format_num(input_num, expected):
""" Check that the specialized tqdm.format_num appends 0 to floats and strings """
assert tqdm.format_num(input_num) == expected | [
"def",
"test_tqdm_format_num",
"(",
"input_num",
",",
"expected",
")",
":",
"assert",
"tqdm",
".",
"format_num",
"(",
"input_num",
")",
"==",
"expected"
] | [
381,
0
] | [
383,
49
] | python | en | ['en', 'en', 'en'] | True |
test_progress_bar_print | (tqdm_write, tmpdir) | Test that printing in the LightningModule redirects arguments to the progress bar. | Test that printing in the LightningModule redirects arguments to the progress bar. | def test_progress_bar_print(tqdm_write, tmpdir):
""" Test that printing in the LightningModule redirects arguments to the progress bar. """
model = PrintModel()
bar = ProgressBar()
trainer = Trainer(
default_root_dir=tmpdir,
num_sanity_val_steps=0,
limit_train_batches=1,
... | [
"def",
"test_progress_bar_print",
"(",
"tqdm_write",
",",
"tmpdir",
")",
":",
"model",
"=",
"PrintModel",
"(",
")",
"bar",
"=",
"ProgressBar",
"(",
")",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"num_sanity_val_steps",
"=",
"0",
... | [
402,
0
] | [
422,
5
] | python | en | ['en', 'en', 'en'] | True |
test_progress_bar_print_disabled | (tqdm_write, mock_print, tmpdir) | Test that printing in LightningModule goes through built-in print functin when progress bar is disabled. | Test that printing in LightningModule goes through built-in print functin when progress bar is disabled. | def test_progress_bar_print_disabled(tqdm_write, mock_print, tmpdir):
""" Test that printing in LightningModule goes through built-in print functin when progress bar is disabled. """
model = PrintModel()
bar = ProgressBar()
trainer = Trainer(
default_root_dir=tmpdir,
num_sanity_val_steps... | [
"def",
"test_progress_bar_print_disabled",
"(",
"tqdm_write",
",",
"mock_print",
",",
"tmpdir",
")",
":",
"model",
"=",
"PrintModel",
"(",
")",
"bar",
"=",
"ProgressBar",
"(",
")",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"num_sa... | [
427,
0
] | [
449,
34
] | python | en | ['en', 'en', 'en'] | True |
DeterministicModel.training_epoch_end__scalar | (self, outputs) |
There should be an array of scalars without graphs that are all 171 (4 of them)
|
There should be an array of scalars without graphs that are all 171 (4 of them)
| def training_epoch_end__scalar(self, outputs):
"""
There should be an array of scalars without graphs that are all 171 (4 of them)
"""
self.training_epoch_end_called = True
if self._distrib_type in (DistributedType.DP, DistributedType.DDP2):
pass
else:
... | [
"def",
"training_epoch_end__scalar",
"(",
"self",
",",
"outputs",
")",
":",
"self",
".",
"training_epoch_end_called",
"=",
"True",
"if",
"self",
".",
"_distrib_type",
"in",
"(",
"DistributedType",
".",
"DP",
",",
"DistributedType",
".",
"DDP2",
")",
":",
"pass... | [
89,
4
] | [
104,
58
] | python | en | ['en', 'error', 'th'] | False |
DeterministicModel.training_step__for_step_end_dict | (self, batch, batch_idx) | sends outputs to training_batch_end | sends outputs to training_batch_end | def training_step__for_step_end_dict(self, batch, batch_idx):
"""sends outputs to training_batch_end"""
acc = self.step(batch, batch_idx)
logs = {'log_acc1': torch.tensor(12).type_as(acc), 'log_acc2': torch.tensor(7).type_as(acc)}
pbar = {'pbar_acc1': torch.tensor(17).type_as(acc), 'pba... | [
"def",
"training_step__for_step_end_dict",
"(",
"self",
",",
"batch",
",",
"batch_idx",
")",
":",
"acc",
"=",
"self",
".",
"step",
"(",
"batch",
",",
"batch_idx",
")",
"logs",
"=",
"{",
"'log_acc1'",
":",
"torch",
".",
"tensor",
"(",
"12",
")",
".",
"t... | [
118,
4
] | [
129,
21
] | python | en | ['en', 'en', 'en'] | True |
determine_root_gpu_device | (gpus: List[int]) |
Args:
gpus: non-empty list of ints representing which gpus to use
Returns:
designated root GPU device id
|
Args:
gpus: non-empty list of ints representing which gpus to use | def determine_root_gpu_device(gpus: List[int]) -> Optional[int]:
"""
Args:
gpus: non-empty list of ints representing which gpus to use
Returns:
designated root GPU device id
"""
if gpus is None:
return None
if not isinstance(gpus, list):
raise TypeError("gpus sh... | [
"def",
"determine_root_gpu_device",
"(",
"gpus",
":",
"List",
"[",
"int",
"]",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"if",
"gpus",
"is",
"None",
":",
"return",
"None",
"if",
"not",
"isinstance",
"(",
"gpus",
",",
"list",
")",
":",
"raise",
"Ty... | [
21,
0
] | [
40,
19
] | python | en | ['en', 'error', 'th'] | False |
parse_gpu_ids | (gpus: Optional[Union[int, str, List[int]]]) |
Parses the GPU ids given in the format as accepted by the
:class:`~pytorch_lightning.trainer.Trainer`.
Args:
gpus: An int -1 or string '-1' indicate that all available GPUs should be used.
A list of ints or a string containing list of comma separated integers
indicates spec... |
Parses the GPU ids given in the format as accepted by the
:class:`~pytorch_lightning.trainer.Trainer`. | def parse_gpu_ids(gpus: Optional[Union[int, str, List[int]]]) -> Optional[List[int]]:
"""
Parses the GPU ids given in the format as accepted by the
:class:`~pytorch_lightning.trainer.Trainer`.
Args:
gpus: An int -1 or string '-1' indicate that all available GPUs should be used.
A li... | [
"def",
"parse_gpu_ids",
"(",
"gpus",
":",
"Optional",
"[",
"Union",
"[",
"int",
",",
"str",
",",
"List",
"[",
"int",
"]",
"]",
"]",
")",
"->",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
":",
"# nothing was passed into the GPUs argument",
"if",
"calla... | [
43,
0
] | [
82,
15
] | python | en | ['en', 'error', 'th'] | False |
parse_tpu_cores | (tpu_cores: Union[int, str, List]) |
Parses the tpu_cores given in the format as accepted by the
:class:`~pytorch_lightning.trainer.Trainer`.
Args:
tpu_cores: An int 1 or string '1' indicate that 1 core with multi-processing should be used
An int 8 or string '8' indicate that all 8 cores with multi-processing should be us... |
Parses the tpu_cores given in the format as accepted by the
:class:`~pytorch_lightning.trainer.Trainer`. | def parse_tpu_cores(tpu_cores: Union[int, str, List]) -> Optional[Union[List[int], int]]:
"""
Parses the tpu_cores given in the format as accepted by the
:class:`~pytorch_lightning.trainer.Trainer`.
Args:
tpu_cores: An int 1 or string '1' indicate that 1 core with multi-processing should be use... | [
"def",
"parse_tpu_cores",
"(",
"tpu_cores",
":",
"Union",
"[",
"int",
",",
"str",
",",
"List",
"]",
")",
"->",
"Optional",
"[",
"Union",
"[",
"List",
"[",
"int",
"]",
",",
"int",
"]",
"]",
":",
"if",
"callable",
"(",
"tpu_cores",
")",
":",
"return"... | [
85,
0
] | [
114,
20
] | python | en | ['en', 'error', 'th'] | False |
_sanitize_gpu_ids | (gpus: List[int]) |
Checks that each of the GPUs in the list is actually available.
Raises a MisconfigurationException if any of the GPUs is not available.
Args:
gpus: list of ints corresponding to GPU indices
Returns:
unmodified gpus variable
|
Checks that each of the GPUs in the list is actually available.
Raises a MisconfigurationException if any of the GPUs is not available. | def _sanitize_gpu_ids(gpus: List[int]) -> List[int]:
"""
Checks that each of the GPUs in the list is actually available.
Raises a MisconfigurationException if any of the GPUs is not available.
Args:
gpus: list of ints corresponding to GPU indices
Returns:
unmodified gpus variable
... | [
"def",
"_sanitize_gpu_ids",
"(",
"gpus",
":",
"List",
"[",
"int",
"]",
")",
"->",
"List",
"[",
"int",
"]",
":",
"all_available_gpus",
"=",
"_get_all_available_gpus",
"(",
")",
"for",
"gpu",
"in",
"gpus",
":",
"if",
"gpu",
"not",
"in",
"all_available_gpus",... | [
127,
0
] | [
144,
15
] | python | en | ['en', 'error', 'th'] | False |
_get_all_available_gpus | () |
Returns:
a list of all available gpus
|
Returns:
a list of all available gpus
| def _get_all_available_gpus() -> List[int]:
"""
Returns:
a list of all available gpus
"""
return list(range(torch.cuda.device_count())) | [
"def",
"_get_all_available_gpus",
"(",
")",
"->",
"List",
"[",
"int",
"]",
":",
"return",
"list",
"(",
"range",
"(",
"torch",
".",
"cuda",
".",
"device_count",
"(",
")",
")",
")"
] | [
161,
0
] | [
166,
49
] | python | en | ['en', 'error', 'th'] | False |
_check_data_type | (device_ids: Any) |
Checks that the device_ids argument is one of: None, Int, String or List.
Raises a MisconfigurationException otherwise.
Args:
device_ids: gpus/tpu_cores parameter as passed to the Trainer
|
Checks that the device_ids argument is one of: None, Int, String or List.
Raises a MisconfigurationException otherwise. | def _check_data_type(device_ids: Any) -> None:
"""
Checks that the device_ids argument is one of: None, Int, String or List.
Raises a MisconfigurationException otherwise.
Args:
device_ids: gpus/tpu_cores parameter as passed to the Trainer
"""
if device_ids is not None and \
... | [
"def",
"_check_data_type",
"(",
"device_ids",
":",
"Any",
")",
"->",
"None",
":",
"if",
"device_ids",
"is",
"not",
"None",
"and",
"(",
"not",
"isinstance",
"(",
"device_ids",
",",
"(",
"int",
",",
"str",
",",
"MutableSequence",
",",
"tuple",
")",
")",
... | [
169,
0
] | [
179,
113
] | python | en | ['en', 'error', 'th'] | False |
pieces.__init__ | (self, row, col, color) | if (self.color == yellow):
self.direction = -1
else:
self.direction = 1 | if (self.color == yellow):
self.direction = -1
else:
self.direction = 1 | def __init__(self, row, col, color):
self.row = row
self.col = col
self.color = color
self.king = False
'''if (self.color == yellow):
self.direction = -1
else:
self.direction = 1'''
self.x = self.y = 0
self.calculate_pos() | [
"def",
"__init__",
"(",
"self",
",",
"row",
",",
"col",
",",
"color",
")",
":",
"self",
".",
"row",
"=",
"row",
"self",
".",
"col",
"=",
"col",
"self",
".",
"color",
"=",
"color",
"self",
".",
"king",
"=",
"False",
"self",
".",
"x",
"=",
"self"... | [
13,
4
] | [
25,
28
] | python | en | ['en', 'en', 'en'] | True |
find_free_network_port | () |
Finds a free port on localhost.
It is useful in single-node training when we don't want to connect to a real master node but
have to set the `MASTER_PORT` environment variable.
|
Finds a free port on localhost.
It is useful in single-node training when we don't want to connect to a real master node but
have to set the `MASTER_PORT` environment variable.
| def find_free_network_port() -> int:
"""
Finds a free port on localhost.
It is useful in single-node training when we don't want to connect to a real master node but
have to set the `MASTER_PORT` environment variable.
"""
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
... | [
"def",
"find_free_network_port",
"(",
")",
"->",
"int",
":",
"import",
"socket",
"s",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"s",
".",
"bind",
"(",
"(",
"\"\"",
",",
"0",
")",
")",
"s",
... | [
65,
0
] | [
77,
15
] | python | en | ['en', 'error', 'th'] | False |
gather_all_tensors | (result: Union[torch.Tensor], group: Optional[Any] = None) |
Function to gather all tensors from several ddp processes onto a list that
is broadcasted to all processes
Args:
result: the value to sync
group: the process group to gather results from. Defaults to all processes (world)
Return:
gathered_result: list with size equal to the pr... |
Function to gather all tensors from several ddp processes onto a list that
is broadcasted to all processes | def gather_all_tensors(result: Union[torch.Tensor], group: Optional[Any] = None):
"""
Function to gather all tensors from several ddp processes onto a list that
is broadcasted to all processes
Args:
result: the value to sync
group: the process group to gather results from. Defaults to a... | [
"def",
"gather_all_tensors",
"(",
"result",
":",
"Union",
"[",
"torch",
".",
"Tensor",
"]",
",",
"group",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
")",
":",
"if",
"group",
"is",
"None",
":",
"group",
"=",
"torch",
".",
"distributed",
".",
"grou... | [
80,
0
] | [
107,
26
] | python | en | ['en', 'error', 'th'] | False |
sync_ddp_if_available | (
result: Union[torch.Tensor],
group: Optional[Any] = None,
reduce_op: Optional[Union[ReduceOp, str]] = None
) |
Function to reduce a tensor across worker processes during distributed training
Args:
result: the value to sync and reduce (typically tensor or number)
group: the process group to gather results from. Defaults to all processes (world)
reduce_op: the reduction operation. Defaults to sum.... |
Function to reduce a tensor across worker processes during distributed training
Args:
result: the value to sync and reduce (typically tensor or number)
group: the process group to gather results from. Defaults to all processes (world)
reduce_op: the reduction operation. Defaults to sum.... | def sync_ddp_if_available(
result: Union[torch.Tensor],
group: Optional[Any] = None,
reduce_op: Optional[Union[ReduceOp, str]] = None
) -> torch.Tensor:
"""
Function to reduce a tensor across worker processes during distributed training
Args:
result: the value to sync and reduce (typical... | [
"def",
"sync_ddp_if_available",
"(",
"result",
":",
"Union",
"[",
"torch",
".",
"Tensor",
"]",
",",
"group",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
",",
"reduce_op",
":",
"Optional",
"[",
"Union",
"[",
"ReduceOp",
",",
"str",
"]",
"]",
"=",
"... | [
110,
0
] | [
128,
17
] | python | en | ['en', 'error', 'th'] | False |
sync_ddp | (
result: Union[torch.Tensor],
group: Optional[Any] = None,
reduce_op: Optional[Union[ReduceOp, str]] = None
) |
Function to reduce the tensors from several ddp processes to one master process
Args:
result: the value to sync and reduce (typically tensor or number)
group: the process group to gather results from. Defaults to all processes (world)
reduce_op: the reduction operation. Defaults to sum... |
Function to reduce the tensors from several ddp processes to one master process | def sync_ddp(
result: Union[torch.Tensor],
group: Optional[Any] = None,
reduce_op: Optional[Union[ReduceOp, str]] = None
) -> torch.Tensor:
"""
Function to reduce the tensors from several ddp processes to one master process
Args:
result: the value to sync and reduce (typically tensor or... | [
"def",
"sync_ddp",
"(",
"result",
":",
"Union",
"[",
"torch",
".",
"Tensor",
"]",
",",
"group",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
",",
"reduce_op",
":",
"Optional",
"[",
"Union",
"[",
"ReduceOp",
",",
"str",
"]",
"]",
"=",
"None",
")",... | [
131,
0
] | [
165,
17
] | python | en | ['en', 'error', 'th'] | False |
all_gather_ddp_if_available | (
tensor: Union[torch.Tensor], group: Optional[Any] = None, sync_grads: bool = False
) |
Function to gather a tensor from several distributed processes
Args:
tensor: tensor of shape (batch, ...)
group: the process group to gather results from. Defaults to all processes (world)
sync_grads: flag that allows users to synchronize gradients for all_gather op
Return:
... |
Function to gather a tensor from several distributed processes | def all_gather_ddp_if_available(
tensor: Union[torch.Tensor], group: Optional[Any] = None, sync_grads: bool = False
) -> torch.Tensor:
"""
Function to gather a tensor from several distributed processes
Args:
tensor: tensor of shape (batch, ...)
group: the process group to gather results... | [
"def",
"all_gather_ddp_if_available",
"(",
"tensor",
":",
"Union",
"[",
"torch",
".",
"Tensor",
"]",
",",
"group",
":",
"Optional",
"[",
"Any",
"]",
"=",
"None",
",",
"sync_grads",
":",
"bool",
"=",
"False",
")",
"->",
"torch",
".",
"Tensor",
":",
"gro... | [
190,
0
] | [
211,
17
] | python | en | ['en', 'error', 'th'] | False |
TrainerCallbackHookMixin.on_before_accelerator_backend_setup | (self, model) | Called in the beginning of fit and test | Called in the beginning of fit and test | def on_before_accelerator_backend_setup(self, model):
"""Called in the beginning of fit and test"""
for callback in self.callbacks:
callback.on_before_accelerator_backend_setup(self, model) | [
"def",
"on_before_accelerator_backend_setup",
"(",
"self",
",",
"model",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_before_accelerator_backend_setup",
"(",
"self",
",",
"model",
")"
] | [
29,
4
] | [
32,
69
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.setup | (self, model, stage: str) | Called in the beginning of fit and test | Called in the beginning of fit and test | def setup(self, model, stage: str):
"""Called in the beginning of fit and test"""
for callback in self.callbacks:
callback.setup(self, model, stage) | [
"def",
"setup",
"(",
"self",
",",
"model",
",",
"stage",
":",
"str",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"setup",
"(",
"self",
",",
"model",
",",
"stage",
")"
] | [
34,
4
] | [
37,
46
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.teardown | (self, stage: str) | Called at the end of fit and test | Called at the end of fit and test | def teardown(self, stage: str):
"""Called at the end of fit and test"""
for callback in self.callbacks:
callback.teardown(self, self.lightning_module, stage) | [
"def",
"teardown",
"(",
"self",
",",
"stage",
":",
"str",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"teardown",
"(",
"self",
",",
"self",
".",
"lightning_module",
",",
"stage",
")"
] | [
39,
4
] | [
42,
65
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_init_start | (self) | Called when the trainer initialization begins, model has not yet been set. | Called when the trainer initialization begins, model has not yet been set. | def on_init_start(self):
"""Called when the trainer initialization begins, model has not yet been set."""
for callback in self.callbacks:
callback.on_init_start(self) | [
"def",
"on_init_start",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_init_start",
"(",
"self",
")"
] | [
44,
4
] | [
47,
40
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_init_end | (self) | Called when the trainer initialization ends, model has not yet been set. | Called when the trainer initialization ends, model has not yet been set. | def on_init_end(self):
"""Called when the trainer initialization ends, model has not yet been set."""
for callback in self.callbacks:
callback.on_init_end(self) | [
"def",
"on_init_end",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_init_end",
"(",
"self",
")"
] | [
49,
4
] | [
52,
38
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_fit_start | (self) | Called when the trainer initialization begins, model has not yet been set. | Called when the trainer initialization begins, model has not yet been set. | def on_fit_start(self):
"""Called when the trainer initialization begins, model has not yet been set."""
for callback in self.callbacks:
callback.on_fit_start(self, self.lightning_module) | [
"def",
"on_fit_start",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_fit_start",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
54,
4
] | [
57,
62
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_fit_end | (self) | Called when the trainer initialization begins, model has not yet been set. | Called when the trainer initialization begins, model has not yet been set. | def on_fit_end(self):
"""Called when the trainer initialization begins, model has not yet been set."""
for callback in self.callbacks:
callback.on_fit_end(self, self.lightning_module) | [
"def",
"on_fit_end",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_fit_end",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
59,
4
] | [
62,
60
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_sanity_check_start | (self) | Called when the validation sanity check starts. | Called when the validation sanity check starts. | def on_sanity_check_start(self):
"""Called when the validation sanity check starts."""
for callback in self.callbacks:
callback.on_sanity_check_start(self, self.lightning_module) | [
"def",
"on_sanity_check_start",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_sanity_check_start",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
64,
4
] | [
67,
71
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_sanity_check_end | (self) | Called when the validation sanity check ends. | Called when the validation sanity check ends. | def on_sanity_check_end(self):
"""Called when the validation sanity check ends."""
for callback in self.callbacks:
callback.on_sanity_check_end(self, self.lightning_module) | [
"def",
"on_sanity_check_end",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_sanity_check_end",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
69,
4
] | [
72,
69
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_train_epoch_start | (self) | Called when the epoch begins. | Called when the epoch begins. | def on_train_epoch_start(self):
"""Called when the epoch begins."""
for callback in self.callbacks:
callback.on_train_epoch_start(self, self.lightning_module) | [
"def",
"on_train_epoch_start",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_train_epoch_start",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
74,
4
] | [
77,
70
] | python | en | ['en', 'de', 'en'] | True |
TrainerCallbackHookMixin.on_train_epoch_end | (self, outputs) | Called when the epoch ends. | Called when the epoch ends. | def on_train_epoch_end(self, outputs):
"""Called when the epoch ends."""
for callback in self.callbacks:
callback.on_train_epoch_end(self, self.lightning_module, outputs) | [
"def",
"on_train_epoch_end",
"(",
"self",
",",
"outputs",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_train_epoch_end",
"(",
"self",
",",
"self",
".",
"lightning_module",
",",
"outputs",
")"
] | [
79,
4
] | [
82,
77
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_validation_epoch_start | (self) | Called when the epoch begins. | Called when the epoch begins. | def on_validation_epoch_start(self):
"""Called when the epoch begins."""
for callback in self.callbacks:
callback.on_validation_epoch_start(self, self.lightning_module) | [
"def",
"on_validation_epoch_start",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_validation_epoch_start",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
84,
4
] | [
87,
75
] | python | en | ['en', 'de', 'en'] | True |
TrainerCallbackHookMixin.on_validation_epoch_end | (self) | Called when the epoch ends. | Called when the epoch ends. | def on_validation_epoch_end(self):
"""Called when the epoch ends."""
for callback in self.callbacks:
callback.on_validation_epoch_end(self, self.lightning_module) | [
"def",
"on_validation_epoch_end",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_validation_epoch_end",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
89,
4
] | [
92,
73
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_test_epoch_start | (self) | Called when the epoch begins. | Called when the epoch begins. | def on_test_epoch_start(self):
"""Called when the epoch begins."""
for callback in self.callbacks:
callback.on_test_epoch_start(self, self.lightning_module) | [
"def",
"on_test_epoch_start",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_test_epoch_start",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
94,
4
] | [
97,
69
] | python | en | ['en', 'de', 'en'] | True |
TrainerCallbackHookMixin.on_test_epoch_end | (self) | Called when the epoch ends. | Called when the epoch ends. | def on_test_epoch_end(self):
"""Called when the epoch ends."""
for callback in self.callbacks:
callback.on_test_epoch_end(self, self.lightning_module) | [
"def",
"on_test_epoch_end",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_test_epoch_end",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
99,
4
] | [
102,
67
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_epoch_start | (self) | Called when the epoch begins. | Called when the epoch begins. | def on_epoch_start(self):
"""Called when the epoch begins."""
for callback in self.callbacks:
callback.on_epoch_start(self, self.lightning_module) | [
"def",
"on_epoch_start",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_epoch_start",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
104,
4
] | [
107,
64
] | python | en | ['en', 'de', 'en'] | True |
TrainerCallbackHookMixin.on_epoch_end | (self) | Called when the epoch ends. | Called when the epoch ends. | def on_epoch_end(self):
"""Called when the epoch ends."""
for callback in self.callbacks:
callback.on_epoch_end(self, self.lightning_module) | [
"def",
"on_epoch_end",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_epoch_end",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
109,
4
] | [
112,
62
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_train_start | (self) | Called when the train begins. | Called when the train begins. | def on_train_start(self):
"""Called when the train begins."""
for callback in self.callbacks:
callback.on_train_start(self, self.lightning_module) | [
"def",
"on_train_start",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_train_start",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
114,
4
] | [
117,
64
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_train_end | (self) | Called when the train ends. | Called when the train ends. | def on_train_end(self):
"""Called when the train ends."""
for callback in self.callbacks:
callback.on_train_end(self, self.lightning_module) | [
"def",
"on_train_end",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_train_end",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
119,
4
] | [
122,
62
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_pretrain_routine_start | (self, model) | Called when the train begins. | Called when the train begins. | def on_pretrain_routine_start(self, model):
"""Called when the train begins."""
for callback in self.callbacks:
callback.on_pretrain_routine_start(self, model) | [
"def",
"on_pretrain_routine_start",
"(",
"self",
",",
"model",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_pretrain_routine_start",
"(",
"self",
",",
"model",
")"
] | [
124,
4
] | [
127,
59
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_pretrain_routine_end | (self, model) | Called when the train ends. | Called when the train ends. | def on_pretrain_routine_end(self, model):
"""Called when the train ends."""
for callback in self.callbacks:
callback.on_pretrain_routine_end(self, model) | [
"def",
"on_pretrain_routine_end",
"(",
"self",
",",
"model",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_pretrain_routine_end",
"(",
"self",
",",
"model",
")"
] | [
129,
4
] | [
132,
57
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_batch_start | (self) | Called when the training batch begins. | Called when the training batch begins. | def on_batch_start(self):
"""Called when the training batch begins."""
for callback in self.callbacks:
callback.on_batch_start(self, self.lightning_module) | [
"def",
"on_batch_start",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_batch_start",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
134,
4
] | [
137,
64
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_batch_end | (self) | Called when the training batch ends. | Called when the training batch ends. | def on_batch_end(self):
"""Called when the training batch ends."""
for callback in self.callbacks:
callback.on_batch_end(self, self.lightning_module) | [
"def",
"on_batch_end",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_batch_end",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
139,
4
] | [
142,
62
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_train_batch_start | (self, batch, batch_idx, dataloader_idx) | Called when the training batch begins. | Called when the training batch begins. | def on_train_batch_start(self, batch, batch_idx, dataloader_idx):
"""Called when the training batch begins."""
for callback in self.callbacks:
callback.on_train_batch_start(self, self.lightning_module, batch, batch_idx, dataloader_idx) | [
"def",
"on_train_batch_start",
"(",
"self",
",",
"batch",
",",
"batch_idx",
",",
"dataloader_idx",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_train_batch_start",
"(",
"self",
",",
"self",
".",
"lightning_module",
","... | [
144,
4
] | [
147,
104
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_train_batch_end | (self, outputs, batch, batch_idx, dataloader_idx) | Called when the training batch ends. | Called when the training batch ends. | def on_train_batch_end(self, outputs, batch, batch_idx, dataloader_idx):
"""Called when the training batch ends."""
for callback in self.callbacks:
callback.on_train_batch_end(self, self.lightning_module, outputs, batch, batch_idx, dataloader_idx) | [
"def",
"on_train_batch_end",
"(",
"self",
",",
"outputs",
",",
"batch",
",",
"batch_idx",
",",
"dataloader_idx",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_train_batch_end",
"(",
"self",
",",
"self",
".",
"lightnin... | [
149,
4
] | [
152,
111
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_validation_batch_start | (self, batch, batch_idx, dataloader_idx) | Called when the validation batch begins. | Called when the validation batch begins. | def on_validation_batch_start(self, batch, batch_idx, dataloader_idx):
"""Called when the validation batch begins."""
for callback in self.callbacks:
callback.on_validation_batch_start(self, self.lightning_module, batch, batch_idx, dataloader_idx) | [
"def",
"on_validation_batch_start",
"(",
"self",
",",
"batch",
",",
"batch_idx",
",",
"dataloader_idx",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_validation_batch_start",
"(",
"self",
",",
"self",
".",
"lightning_modu... | [
154,
4
] | [
157,
109
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_validation_batch_end | (self, outputs, batch, batch_idx, dataloader_idx) | Called when the validation batch ends. | Called when the validation batch ends. | def on_validation_batch_end(self, outputs, batch, batch_idx, dataloader_idx):
"""Called when the validation batch ends."""
for callback in self.callbacks:
callback.on_validation_batch_end(self, self.lightning_module, outputs, batch, batch_idx, dataloader_idx) | [
"def",
"on_validation_batch_end",
"(",
"self",
",",
"outputs",
",",
"batch",
",",
"batch_idx",
",",
"dataloader_idx",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_validation_batch_end",
"(",
"self",
",",
"self",
".",
... | [
159,
4
] | [
162,
116
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_test_batch_start | (self, batch, batch_idx, dataloader_idx) | Called when the test batch begins. | Called when the test batch begins. | def on_test_batch_start(self, batch, batch_idx, dataloader_idx):
"""Called when the test batch begins."""
for callback in self.callbacks:
callback.on_test_batch_start(self, self.lightning_module, batch, batch_idx, dataloader_idx) | [
"def",
"on_test_batch_start",
"(",
"self",
",",
"batch",
",",
"batch_idx",
",",
"dataloader_idx",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_test_batch_start",
"(",
"self",
",",
"self",
".",
"lightning_module",
",",
... | [
164,
4
] | [
167,
103
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_test_batch_end | (self, outputs, batch, batch_idx, dataloader_idx) | Called when the test batch ends. | Called when the test batch ends. | def on_test_batch_end(self, outputs, batch, batch_idx, dataloader_idx):
"""Called when the test batch ends."""
for callback in self.callbacks:
callback.on_test_batch_end(self, self.lightning_module, outputs, batch, batch_idx, dataloader_idx) | [
"def",
"on_test_batch_end",
"(",
"self",
",",
"outputs",
",",
"batch",
",",
"batch_idx",
",",
"dataloader_idx",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_test_batch_end",
"(",
"self",
",",
"self",
".",
"lightning_... | [
169,
4
] | [
172,
110
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_validation_start | (self) | Called when the validation loop begins. | Called when the validation loop begins. | def on_validation_start(self):
"""Called when the validation loop begins."""
for callback in self.callbacks:
callback.on_validation_start(self, self.lightning_module) | [
"def",
"on_validation_start",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_validation_start",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
174,
4
] | [
177,
69
] | python | en | ['en', 'af', 'en'] | True |
TrainerCallbackHookMixin.on_validation_end | (self) | Called when the validation loop ends. | Called when the validation loop ends. | def on_validation_end(self):
"""Called when the validation loop ends."""
for callback in self.callbacks:
callback.on_validation_end(self, self.lightning_module) | [
"def",
"on_validation_end",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_validation_end",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
179,
4
] | [
182,
67
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_test_start | (self) | Called when the test begins. | Called when the test begins. | def on_test_start(self):
"""Called when the test begins."""
for callback in self.callbacks:
callback.on_test_start(self, self.lightning_module) | [
"def",
"on_test_start",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_test_start",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
184,
4
] | [
187,
63
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_test_end | (self) | Called when the test ends. | Called when the test ends. | def on_test_end(self):
"""Called when the test ends."""
for callback in self.callbacks:
callback.on_test_end(self, self.lightning_module) | [
"def",
"on_test_end",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_test_end",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
189,
4
] | [
192,
61
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_keyboard_interrupt | (self) | Called when the training is interrupted by KeyboardInterrupt. | Called when the training is interrupted by KeyboardInterrupt. | def on_keyboard_interrupt(self):
"""Called when the training is interrupted by KeyboardInterrupt."""
for callback in self.callbacks:
callback.on_keyboard_interrupt(self, self.lightning_module) | [
"def",
"on_keyboard_interrupt",
"(",
"self",
")",
":",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback",
".",
"on_keyboard_interrupt",
"(",
"self",
",",
"self",
".",
"lightning_module",
")"
] | [
194,
4
] | [
197,
71
] | python | en | ['en', 'en', 'en'] | True |
TrainerCallbackHookMixin.on_save_checkpoint | (self) | Called when saving a model checkpoint. | Called when saving a model checkpoint. | def on_save_checkpoint(self):
"""Called when saving a model checkpoint."""
callback_states = {}
for callback in self.callbacks:
callback_class = type(callback)
state = callback.on_save_checkpoint(self, self.lightning_module)
if state:
callback_... | [
"def",
"on_save_checkpoint",
"(",
"self",
")",
":",
"callback_states",
"=",
"{",
"}",
"for",
"callback",
"in",
"self",
".",
"callbacks",
":",
"callback_class",
"=",
"type",
"(",
"callback",
")",
"state",
"=",
"callback",
".",
"on_save_checkpoint",
"(",
"self... | [
199,
4
] | [
207,
30
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.