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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | _create_input_order | Returns a degree vectors for the input. | tensorflow_probability/python/bijectors/masked_autoregressive.py | def _create_input_order(input_size, input_order="left-to-right"):
"""Returns a degree vectors for the input."""
if isinstance(input_order, six.string_types):
if input_order == "left-to-right":
return np.arange(start=1, stop=input_size + 1)
elif input_order == "right-to-left":
return np.arange(st... | def _create_input_order(input_size, input_order="left-to-right"):
"""Returns a degree vectors for the input."""
if isinstance(input_order, six.string_types):
if input_order == "left-to-right":
return np.arange(start=1, stop=input_size + 1)
elif input_order == "right-to-left":
return np.arange(st... | [
"Returns",
"a",
"degree",
"vectors",
"for",
"the",
"input",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/masked_autoregressive.py#L886-L900 | [
"def",
"_create_input_order",
"(",
"input_size",
",",
"input_order",
"=",
"\"left-to-right\"",
")",
":",
"if",
"isinstance",
"(",
"input_order",
",",
"six",
".",
"string_types",
")",
":",
"if",
"input_order",
"==",
"\"left-to-right\"",
":",
"return",
"np",
".",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _create_degrees | Returns a list of degree vectors, one for each input and hidden layer.
A unit with degree d can only receive input from units with degree < d. Output
units always have the same degree as their associated input unit.
Args:
input_size: Number of inputs.
hidden_units: list with the number of hidden units p... | tensorflow_probability/python/bijectors/masked_autoregressive.py | def _create_degrees(input_size,
hidden_units=None,
input_order="left-to-right",
hidden_degrees="equal"):
"""Returns a list of degree vectors, one for each input and hidden layer.
A unit with degree d can only receive input from units with degree < d. Outp... | def _create_degrees(input_size,
hidden_units=None,
input_order="left-to-right",
hidden_degrees="equal"):
"""Returns a list of degree vectors, one for each input and hidden layer.
A unit with degree d can only receive input from units with degree < d. Outp... | [
"Returns",
"a",
"list",
"of",
"degree",
"vectors",
"one",
"for",
"each",
"input",
"and",
"hidden",
"layer",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/masked_autoregressive.py#L903-L954 | [
"def",
"_create_degrees",
"(",
"input_size",
",",
"hidden_units",
"=",
"None",
",",
"input_order",
"=",
"\"left-to-right\"",
",",
"hidden_degrees",
"=",
"\"equal\"",
")",
":",
"input_order",
"=",
"_create_input_order",
"(",
"input_size",
",",
"input_order",
")",
"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _create_masks | Returns a list of binary mask matrices enforcing autoregressivity. | tensorflow_probability/python/bijectors/masked_autoregressive.py | def _create_masks(degrees):
"""Returns a list of binary mask matrices enforcing autoregressivity."""
return [
# Create input->hidden and hidden->hidden masks.
inp[:, np.newaxis] <= out
for inp, out in zip(degrees[:-1], degrees[1:])
] + [
# Create hidden->output mask.
degrees[-1][:, n... | def _create_masks(degrees):
"""Returns a list of binary mask matrices enforcing autoregressivity."""
return [
# Create input->hidden and hidden->hidden masks.
inp[:, np.newaxis] <= out
for inp, out in zip(degrees[:-1], degrees[1:])
] + [
# Create hidden->output mask.
degrees[-1][:, n... | [
"Returns",
"a",
"list",
"of",
"binary",
"mask",
"matrices",
"enforcing",
"autoregressivity",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/masked_autoregressive.py#L957-L966 | [
"def",
"_create_masks",
"(",
"degrees",
")",
":",
"return",
"[",
"# Create input->hidden and hidden->hidden masks.",
"inp",
"[",
":",
",",
"np",
".",
"newaxis",
"]",
"<=",
"out",
"for",
"inp",
",",
"out",
"in",
"zip",
"(",
"degrees",
"[",
":",
"-",
"1",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _make_masked_initializer | Returns a masked version of the given initializer. | tensorflow_probability/python/bijectors/masked_autoregressive.py | def _make_masked_initializer(mask, initializer):
"""Returns a masked version of the given initializer."""
initializer = tf.keras.initializers.get(initializer)
def masked_initializer(shape, dtype=None, partition_info=None):
# If no `partition_info` is given, then don't pass it to `initializer`, as
# `initi... | def _make_masked_initializer(mask, initializer):
"""Returns a masked version of the given initializer."""
initializer = tf.keras.initializers.get(initializer)
def masked_initializer(shape, dtype=None, partition_info=None):
# If no `partition_info` is given, then don't pass it to `initializer`, as
# `initi... | [
"Returns",
"a",
"masked",
"version",
"of",
"the",
"given",
"initializer",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/masked_autoregressive.py#L969-L981 | [
"def",
"_make_masked_initializer",
"(",
"mask",
",",
"initializer",
")",
":",
"initializer",
"=",
"tf",
".",
"keras",
".",
"initializers",
".",
"get",
"(",
"initializer",
")",
"def",
"masked_initializer",
"(",
"shape",
",",
"dtype",
"=",
"None",
",",
"partit... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | AutoregressiveLayer.build | See tfkl.Layer.build. | tensorflow_probability/python/bijectors/masked_autoregressive.py | def build(self, input_shape):
"""See tfkl.Layer.build."""
if self._event_shape is None:
# `event_shape` wasn't specied at __init__, so infer from `input_shape`.
self._event_shape = [tf.compat.dimension_value(input_shape[-1])]
self._event_size = self._event_shape[-1]
self._event_ndims = l... | def build(self, input_shape):
"""See tfkl.Layer.build."""
if self._event_shape is None:
# `event_shape` wasn't specied at __init__, so infer from `input_shape`.
self._event_shape = [tf.compat.dimension_value(input_shape[-1])]
self._event_size = self._event_shape[-1]
self._event_ndims = l... | [
"See",
"tfkl",
".",
"Layer",
".",
"build",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/masked_autoregressive.py#L794-L852 | [
"def",
"build",
"(",
"self",
",",
"input_shape",
")",
":",
"if",
"self",
".",
"_event_shape",
"is",
"None",
":",
"# `event_shape` wasn't specied at __init__, so infer from `input_shape`.",
"self",
".",
"_event_shape",
"=",
"[",
"tf",
".",
"compat",
".",
"dimension_v... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | AutoregressiveLayer.call | See tfkl.Layer.call. | tensorflow_probability/python/bijectors/masked_autoregressive.py | def call(self, x):
"""See tfkl.Layer.call."""
with tf.compat.v2.name_scope(self.name or "AutoregressiveLayer_call"):
x = tf.convert_to_tensor(value=x, dtype=self.dtype, name="x")
input_shape = tf.shape(input=x)
# TODO(b/67594795): Better support for dynamic shapes.
if tensorshape_util.ra... | def call(self, x):
"""See tfkl.Layer.call."""
with tf.compat.v2.name_scope(self.name or "AutoregressiveLayer_call"):
x = tf.convert_to_tensor(value=x, dtype=self.dtype, name="x")
input_shape = tf.shape(input=x)
# TODO(b/67594795): Better support for dynamic shapes.
if tensorshape_util.ra... | [
"See",
"tfkl",
".",
"Layer",
".",
"call",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/bijectors/masked_autoregressive.py#L854-L863 | [
"def",
"call",
"(",
"self",
",",
"x",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v2",
".",
"name_scope",
"(",
"self",
".",
"name",
"or",
"\"AutoregressiveLayer_call\"",
")",
":",
"x",
"=",
"tf",
".",
"convert_to_tensor",
"(",
"value",
"=",
"x",
","... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | draw_sample | Sample a multinomial.
The batch shape is given by broadcasting num_trials with
remove_last_dimension(logits).
Args:
num_samples: Python int or singleton integer Tensor: number of multinomial
samples to draw.
num_classes: Python int or singleton integer Tensor: number of classes.
logits: Floati... | tensorflow_probability/python/distributions/multinomial.py | def draw_sample(num_samples, num_classes, logits, num_trials, dtype, seed):
"""Sample a multinomial.
The batch shape is given by broadcasting num_trials with
remove_last_dimension(logits).
Args:
num_samples: Python int or singleton integer Tensor: number of multinomial
samples to draw.
num_class... | def draw_sample(num_samples, num_classes, logits, num_trials, dtype, seed):
"""Sample a multinomial.
The batch shape is given by broadcasting num_trials with
remove_last_dimension(logits).
Args:
num_samples: Python int or singleton integer Tensor: number of multinomial
samples to draw.
num_class... | [
"Sample",
"a",
"multinomial",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/multinomial.py#L285-L355 | [
"def",
"draw_sample",
"(",
"num_samples",
",",
"num_classes",
",",
"logits",
",",
"num_trials",
",",
"dtype",
",",
"seed",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"\"multinomial.draw_sample\"",
")",
":",
"# broadcast the num_trials and logits to same shape",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _zero_dimensional_mvndiag | Build a zero-dimensional MVNDiag object. | tensorflow_probability/python/sts/regression.py | def _zero_dimensional_mvndiag(dtype):
"""Build a zero-dimensional MVNDiag object."""
dummy_mvndiag = tfd.MultivariateNormalDiag(
scale_diag=tf.ones([0], dtype=dtype))
dummy_mvndiag.covariance = lambda: dummy_mvndiag.variance()[..., tf.newaxis]
return dummy_mvndiag | def _zero_dimensional_mvndiag(dtype):
"""Build a zero-dimensional MVNDiag object."""
dummy_mvndiag = tfd.MultivariateNormalDiag(
scale_diag=tf.ones([0], dtype=dtype))
dummy_mvndiag.covariance = lambda: dummy_mvndiag.variance()[..., tf.newaxis]
return dummy_mvndiag | [
"Build",
"a",
"zero",
"-",
"dimensional",
"MVNDiag",
"object",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/regression.py#L32-L37 | [
"def",
"_zero_dimensional_mvndiag",
"(",
"dtype",
")",
":",
"dummy_mvndiag",
"=",
"tfd",
".",
"MultivariateNormalDiag",
"(",
"scale_diag",
"=",
"tf",
".",
"ones",
"(",
"[",
"0",
"]",
",",
"dtype",
"=",
"dtype",
")",
")",
"dummy_mvndiag",
".",
"covariance",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _observe_timeseries_fn | Build an observation_noise_fn that observes a Tensor timeseries. | tensorflow_probability/python/sts/regression.py | def _observe_timeseries_fn(timeseries):
"""Build an observation_noise_fn that observes a Tensor timeseries."""
def observation_noise_fn(t):
current_slice = timeseries[..., t, :]
return tfd.MultivariateNormalDiag(
loc=current_slice,
scale_diag=tf.zeros_like(current_slice))
return observatio... | def _observe_timeseries_fn(timeseries):
"""Build an observation_noise_fn that observes a Tensor timeseries."""
def observation_noise_fn(t):
current_slice = timeseries[..., t, :]
return tfd.MultivariateNormalDiag(
loc=current_slice,
scale_diag=tf.zeros_like(current_slice))
return observatio... | [
"Build",
"an",
"observation_noise_fn",
"that",
"observes",
"a",
"Tensor",
"timeseries",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/regression.py#L40-L47 | [
"def",
"_observe_timeseries_fn",
"(",
"timeseries",
")",
":",
"def",
"observation_noise_fn",
"(",
"t",
")",
":",
"current_slice",
"=",
"timeseries",
"[",
"...",
",",
"t",
",",
":",
"]",
"return",
"tfd",
".",
"MultivariateNormalDiag",
"(",
"loc",
"=",
"curren... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | SparseLinearRegression.params_to_weights | Build regression weights from model parameters. | tensorflow_probability/python/sts/regression.py | def params_to_weights(self,
global_scale_variance,
global_scale_noncentered,
local_scale_variances,
local_scales_noncentered,
weights_noncentered):
"""Build regression weights from model parameter... | def params_to_weights(self,
global_scale_variance,
global_scale_noncentered,
local_scale_variances,
local_scales_noncentered,
weights_noncentered):
"""Build regression weights from model parameter... | [
"Build",
"regression",
"weights",
"from",
"model",
"parameters",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/regression.py#L474-L486 | [
"def",
"params_to_weights",
"(",
"self",
",",
"global_scale_variance",
",",
"global_scale_noncentered",
",",
"local_scale_variances",
",",
"local_scales_noncentered",
",",
"weights_noncentered",
")",
":",
"global_scale",
"=",
"(",
"global_scale_noncentered",
"*",
"tf",
".... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _depth | Computes the number of edges on longest path from node to root. | tensorflow_probability/python/distributions/joint_distribution_named.py | def _depth(g):
"""Computes the number of edges on longest path from node to root."""
def _explore(v):
if v.depth < 0:
v.depth = ((1 + max([-1] + [_explore(annotated_graph[u])
for u in v.parents]))
if v.parents else 0)
return v.depth
annotated_graph ... | def _depth(g):
"""Computes the number of edges on longest path from node to root."""
def _explore(v):
if v.depth < 0:
v.depth = ((1 + max([-1] + [_explore(annotated_graph[u])
for u in v.parents]))
if v.parents else 0)
return v.depth
annotated_graph ... | [
"Computes",
"the",
"number",
"of",
"edges",
"on",
"longest",
"path",
"from",
"node",
"to",
"root",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/joint_distribution_named.py#L204-L215 | [
"def",
"_depth",
"(",
"g",
")",
":",
"def",
"_explore",
"(",
"v",
")",
":",
"if",
"v",
".",
"depth",
"<",
"0",
":",
"v",
".",
"depth",
"=",
"(",
"(",
"1",
"+",
"max",
"(",
"[",
"-",
"1",
"]",
"+",
"[",
"_explore",
"(",
"annotated_graph",
"[... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _best_order | Creates tuple of str tuple-str pairs representing resolved & sorted DAG. | tensorflow_probability/python/distributions/joint_distribution_named.py | def _best_order(g):
"""Creates tuple of str tuple-str pairs representing resolved & sorted DAG."""
def _explore(u):
"""Recursive function to ascend up through unvisited dependencies."""
if u.depth < 0:
return # Already visited.
if not u.parents:
result.append((u.name, u.parents))
u.de... | def _best_order(g):
"""Creates tuple of str tuple-str pairs representing resolved & sorted DAG."""
def _explore(u):
"""Recursive function to ascend up through unvisited dependencies."""
if u.depth < 0:
return # Already visited.
if not u.parents:
result.append((u.name, u.parents))
u.de... | [
"Creates",
"tuple",
"of",
"str",
"tuple",
"-",
"str",
"pairs",
"representing",
"resolved",
"&",
"sorted",
"DAG",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/joint_distribution_named.py#L218-L242 | [
"def",
"_best_order",
"(",
"g",
")",
":",
"def",
"_explore",
"(",
"u",
")",
":",
"\"\"\"Recursive function to ascend up through unvisited dependencies.\"\"\"",
"if",
"u",
".",
"depth",
"<",
"0",
":",
"return",
"# Already visited.",
"if",
"not",
"u",
".",
"parents"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _prob_chain_rule_flatten | Creates lists of callables suitable for JDSeq. | tensorflow_probability/python/distributions/joint_distribution_named.py | def _prob_chain_rule_flatten(named_makers):
"""Creates lists of callables suitable for JDSeq."""
def _make(dist_fn, args):
if args is None:
return lambda *_: dist_fn
if not args:
return lambda *_: dist_fn()
def _fn(*xs):
kwargs = dict(zip(args, reversed(xs[-len(args):])))
kwargs.... | def _prob_chain_rule_flatten(named_makers):
"""Creates lists of callables suitable for JDSeq."""
def _make(dist_fn, args):
if args is None:
return lambda *_: dist_fn
if not args:
return lambda *_: dist_fn()
def _fn(*xs):
kwargs = dict(zip(args, reversed(xs[-len(args):])))
kwargs.... | [
"Creates",
"lists",
"of",
"callables",
"suitable",
"for",
"JDSeq",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/joint_distribution_named.py#L245-L267 | [
"def",
"_prob_chain_rule_flatten",
"(",
"named_makers",
")",
":",
"def",
"_make",
"(",
"dist_fn",
",",
"args",
")",
":",
"if",
"args",
"is",
"None",
":",
"return",
"lambda",
"*",
"_",
":",
"dist_fn",
"if",
"not",
"args",
":",
"return",
"lambda",
"*",
"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | JointDistributionNamed._build | Creates `dist_fn`, `dist_fn_wrapped`, `dist_fn_args`, `dist_fn_name`. | tensorflow_probability/python/distributions/joint_distribution_named.py | def _build(self, model):
"""Creates `dist_fn`, `dist_fn_wrapped`, `dist_fn_args`, `dist_fn_name`."""
if not _is_dict_like(model):
raise TypeError('`model` must be convertible to `dict` (saw: {}).'.format(
type(model).__name__))
[
self._dist_fn,
self._dist_fn_wrapped,
... | def _build(self, model):
"""Creates `dist_fn`, `dist_fn_wrapped`, `dist_fn_args`, `dist_fn_name`."""
if not _is_dict_like(model):
raise TypeError('`model` must be convertible to `dict` (saw: {}).'.format(
type(model).__name__))
[
self._dist_fn,
self._dist_fn_wrapped,
... | [
"Creates",
"dist_fn",
"dist_fn_wrapped",
"dist_fn_args",
"dist_fn_name",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/joint_distribution_named.py#L172-L182 | [
"def",
"_build",
"(",
"self",
",",
"model",
")",
":",
"if",
"not",
"_is_dict_like",
"(",
"model",
")",
":",
"raise",
"TypeError",
"(",
"'`model` must be convertible to `dict` (saw: {}).'",
".",
"format",
"(",
"type",
"(",
"model",
")",
".",
"__name__",
")",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | VariationalGaussianProcess.variational_loss | Variational loss for the VGP.
Given `observations` and `observation_index_points`, compute the
negative variational lower bound as specified in [Hensman, 2013][1].
Args:
observations: `float` `Tensor` representing collection, or batch of
collections, of observations corresponding to
... | tensorflow_probability/python/distributions/variational_gaussian_process.py | def variational_loss(self,
observations,
observation_index_points=None,
kl_weight=1.,
name='variational_loss'):
"""Variational loss for the VGP.
Given `observations` and `observation_index_points`, compute the
negat... | def variational_loss(self,
observations,
observation_index_points=None,
kl_weight=1.,
name='variational_loss'):
"""Variational loss for the VGP.
Given `observations` and `observation_index_points`, compute the
negat... | [
"Variational",
"loss",
"for",
"the",
"VGP",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/variational_gaussian_process.py#L728-L842 | [
"def",
"variational_loss",
"(",
"self",
",",
"observations",
",",
"observation_index_points",
"=",
"None",
",",
"kl_weight",
"=",
"1.",
",",
"name",
"=",
"'variational_loss'",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"name",
"or",
"'variational_gp_loss'",... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | VariationalGaussianProcess.optimal_variational_posterior | Model selection for optimal variational hyperparameters.
Given the full training set (parameterized by `observations` and
`observation_index_points`), compute the optimal variational
location and scale for the VGP. This is based of the method suggested
in [Titsias, 2009][1].
Args:
kernel: `P... | tensorflow_probability/python/distributions/variational_gaussian_process.py | def optimal_variational_posterior(
kernel,
inducing_index_points,
observation_index_points,
observations,
observation_noise_variance,
mean_fn=None,
jitter=1e-6,
name=None):
"""Model selection for optimal variational hyperparameters.
Given the full training set (p... | def optimal_variational_posterior(
kernel,
inducing_index_points,
observation_index_points,
observations,
observation_noise_variance,
mean_fn=None,
jitter=1e-6,
name=None):
"""Model selection for optimal variational hyperparameters.
Given the full training set (p... | [
"Model",
"selection",
"for",
"optimal",
"variational",
"hyperparameters",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/variational_gaussian_process.py#L845-L964 | [
"def",
"optimal_variational_posterior",
"(",
"kernel",
",",
"inducing_index_points",
",",
"observation_index_points",
",",
"observations",
",",
"observation_noise_variance",
",",
"mean_fn",
"=",
"None",
",",
"jitter",
"=",
"1e-6",
",",
"name",
"=",
"None",
")",
":",... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | build_is_last_day_of_season | Build utility method to compute whether the season is changing. | tensorflow_probability/python/sts/seasonal.py | def build_is_last_day_of_season(num_steps_per_season):
"""Build utility method to compute whether the season is changing."""
num_steps_per_cycle = np.sum(num_steps_per_season)
changepoints = np.cumsum(np.ravel(num_steps_per_season)) - 1
def is_last_day_of_season(t):
t_ = dist_util.maybe_get_static_value(t)
... | def build_is_last_day_of_season(num_steps_per_season):
"""Build utility method to compute whether the season is changing."""
num_steps_per_cycle = np.sum(num_steps_per_season)
changepoints = np.cumsum(np.ravel(num_steps_per_season)) - 1
def is_last_day_of_season(t):
t_ = dist_util.maybe_get_static_value(t)
... | [
"Build",
"utility",
"method",
"to",
"compute",
"whether",
"the",
"season",
"is",
"changing",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/seasonal.py#L513-L526 | [
"def",
"build_is_last_day_of_season",
"(",
"num_steps_per_season",
")",
":",
"num_steps_per_cycle",
"=",
"np",
".",
"sum",
"(",
"num_steps_per_season",
")",
"changepoints",
"=",
"np",
".",
"cumsum",
"(",
"np",
".",
"ravel",
"(",
"num_steps_per_season",
")",
")",
... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | build_effects_to_residuals_matrix | Build change-of-basis matrices for constrained seasonal effects.
This method builds the matrix that transforms seasonal effects into
effect residuals (differences from the mean effect), and additionally
projects these residuals onto the subspace where the mean effect is zero.
See `ConstrainedSeasonalStateSpac... | tensorflow_probability/python/sts/seasonal.py | def build_effects_to_residuals_matrix(num_seasons, dtype):
"""Build change-of-basis matrices for constrained seasonal effects.
This method builds the matrix that transforms seasonal effects into
effect residuals (differences from the mean effect), and additionally
projects these residuals onto the subspace whe... | def build_effects_to_residuals_matrix(num_seasons, dtype):
"""Build change-of-basis matrices for constrained seasonal effects.
This method builds the matrix that transforms seasonal effects into
effect residuals (differences from the mean effect), and additionally
projects these residuals onto the subspace whe... | [
"Build",
"change",
"-",
"of",
"-",
"basis",
"matrices",
"for",
"constrained",
"seasonal",
"effects",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/seasonal.py#L529-L570 | [
"def",
"build_effects_to_residuals_matrix",
"(",
"num_seasons",
",",
"dtype",
")",
":",
"# Build the matrix that converts effects `e_i` into differences from the mean",
"# effect `(e_i - sum(e_i)) / num_seasons`, with the mean effect in the last",
"# row so that the transformation is invertible.... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | build_seasonal_transition_matrix | Build a function computing transitions for a seasonal effect model. | tensorflow_probability/python/sts/seasonal.py | def build_seasonal_transition_matrix(
num_seasons, is_last_day_of_season, dtype,
basis_change_matrix=None, basis_change_matrix_inv=None):
"""Build a function computing transitions for a seasonal effect model."""
with tf.compat.v1.name_scope('build_seasonal_transition_matrix'):
# If the season is changi... | def build_seasonal_transition_matrix(
num_seasons, is_last_day_of_season, dtype,
basis_change_matrix=None, basis_change_matrix_inv=None):
"""Build a function computing transitions for a seasonal effect model."""
with tf.compat.v1.name_scope('build_seasonal_transition_matrix'):
# If the season is changi... | [
"Build",
"a",
"function",
"computing",
"transitions",
"for",
"a",
"seasonal",
"effect",
"model",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/seasonal.py#L573-L604 | [
"def",
"build_seasonal_transition_matrix",
"(",
"num_seasons",
",",
"is_last_day_of_season",
",",
"dtype",
",",
"basis_change_matrix",
"=",
"None",
",",
"basis_change_matrix_inv",
"=",
"None",
")",
":",
"with",
"tf",
".",
"compat",
".",
"v1",
".",
"name_scope",
"(... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | build_seasonal_transition_noise | Build the transition noise model for a SeasonalStateSpaceModel. | tensorflow_probability/python/sts/seasonal.py | def build_seasonal_transition_noise(
drift_scale, num_seasons, is_last_day_of_season):
"""Build the transition noise model for a SeasonalStateSpaceModel."""
# If the current season has just ended, increase the variance of its effect
# following drift_scale. (the just-ended seasonal effect will always be the
... | def build_seasonal_transition_noise(
drift_scale, num_seasons, is_last_day_of_season):
"""Build the transition noise model for a SeasonalStateSpaceModel."""
# If the current season has just ended, increase the variance of its effect
# following drift_scale. (the just-ended seasonal effect will always be the
... | [
"Build",
"the",
"transition",
"noise",
"model",
"for",
"a",
"SeasonalStateSpaceModel",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/seasonal.py#L607-L625 | [
"def",
"build_seasonal_transition_noise",
"(",
"drift_scale",
",",
"num_seasons",
",",
"is_last_day_of_season",
")",
":",
"# If the current season has just ended, increase the variance of its effect",
"# following drift_scale. (the just-ended seasonal effect will always be the",
"# bottom el... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | build_constrained_seasonal_transition_noise | Build transition noise distribution for a ConstrainedSeasonalSSM. | tensorflow_probability/python/sts/seasonal.py | def build_constrained_seasonal_transition_noise(
drift_scale, num_seasons, is_last_day_of_season):
"""Build transition noise distribution for a ConstrainedSeasonalSSM."""
# Conceptually, this method takes the noise covariance on effects L @ L'
# computed by `build_seasonal_transition_noise`, with scale facto... | def build_constrained_seasonal_transition_noise(
drift_scale, num_seasons, is_last_day_of_season):
"""Build transition noise distribution for a ConstrainedSeasonalSSM."""
# Conceptually, this method takes the noise covariance on effects L @ L'
# computed by `build_seasonal_transition_noise`, with scale facto... | [
"Build",
"transition",
"noise",
"distribution",
"for",
"a",
"ConstrainedSeasonalSSM",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/sts/seasonal.py#L628-L691 | [
"def",
"build_constrained_seasonal_transition_noise",
"(",
"drift_scale",
",",
"num_seasons",
",",
"is_last_day_of_season",
")",
":",
"# Conceptually, this method takes the noise covariance on effects L @ L'",
"# computed by `build_seasonal_transition_noise`, with scale factor",
"# L =... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _is_empty_observation_data | Returns `True` if given observation data is empty.
Emptiness means either
1. Both `observation_index_points` and `observations` are `None`, or
2. the "number of observations" shape is 0. The shape of
`observation_index_points` is `[..., N, f1, ..., fF]`, where `N` is the
number of observations and th... | tensorflow_probability/python/distributions/gaussian_process_regression_model.py | def _is_empty_observation_data(
feature_ndims, observation_index_points, observations):
"""Returns `True` if given observation data is empty.
Emptiness means either
1. Both `observation_index_points` and `observations` are `None`, or
2. the "number of observations" shape is 0. The shape of
`observa... | def _is_empty_observation_data(
feature_ndims, observation_index_points, observations):
"""Returns `True` if given observation data is empty.
Emptiness means either
1. Both `observation_index_points` and `observations` are `None`, or
2. the "number of observations" shape is 0. The shape of
`observa... | [
"Returns",
"True",
"if",
"given",
"observation",
"data",
"is",
"empty",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/gaussian_process_regression_model.py#L39-L70 | [
"def",
"_is_empty_observation_data",
"(",
"feature_ndims",
",",
"observation_index_points",
",",
"observations",
")",
":",
"# If both input locations and observations are `None`, we consider this",
"# \"empty\" observation data.",
"if",
"observation_index_points",
"is",
"None",
"and"... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _validate_observation_data | Ensure that observation data and locations have consistent shapes.
This basically means that the batch shapes are broadcastable. We can only
ensure this when those shapes are fully statically defined.
Args:
kernel: The GP kernel.
observation_index_points: the observation data locations in the index set... | tensorflow_probability/python/distributions/gaussian_process_regression_model.py | def _validate_observation_data(
kernel, observation_index_points, observations):
"""Ensure that observation data and locations have consistent shapes.
This basically means that the batch shapes are broadcastable. We can only
ensure this when those shapes are fully statically defined.
Args:
kernel: Th... | def _validate_observation_data(
kernel, observation_index_points, observations):
"""Ensure that observation data and locations have consistent shapes.
This basically means that the batch shapes are broadcastable. We can only
ensure this when those shapes are fully statically defined.
Args:
kernel: Th... | [
"Ensure",
"that",
"observation",
"data",
"and",
"locations",
"have",
"consistent",
"shapes",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/gaussian_process_regression_model.py#L73-L103 | [
"def",
"_validate_observation_data",
"(",
"kernel",
",",
"observation_index_points",
",",
"observations",
")",
":",
"# Check that observation index points and observation counts broadcast.",
"ndims",
"=",
"kernel",
".",
"feature_ndims",
"if",
"(",
"tensorshape_util",
".",
"is... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | _kl_gamma_gamma | Calculate the batched KL divergence KL(g0 || g1) with g0 and g1 Gamma.
Args:
g0: instance of a Gamma distribution object.
g1: instance of a Gamma distribution object.
name: (optional) Name to use for created operations. Default is
"kl_gamma_gamma".
Returns:
kl_gamma_gamma: `Tensor`. The batc... | tensorflow_probability/python/distributions/gamma.py | def _kl_gamma_gamma(g0, g1, name=None):
"""Calculate the batched KL divergence KL(g0 || g1) with g0 and g1 Gamma.
Args:
g0: instance of a Gamma distribution object.
g1: instance of a Gamma distribution object.
name: (optional) Name to use for created operations. Default is
"kl_gamma_gamma".
Re... | def _kl_gamma_gamma(g0, g1, name=None):
"""Calculate the batched KL divergence KL(g0 || g1) with g0 and g1 Gamma.
Args:
g0: instance of a Gamma distribution object.
g1: instance of a Gamma distribution object.
name: (optional) Name to use for created operations. Default is
"kl_gamma_gamma".
Re... | [
"Calculate",
"the",
"batched",
"KL",
"divergence",
"KL",
"(",
"g0",
"||",
"g1",
")",
"with",
"g0",
"and",
"g1",
"Gamma",
"."
] | tensorflow/probability | python | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/gamma.py#L273-L296 | [
"def",
"_kl_gamma_gamma",
"(",
"g0",
",",
"g1",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"name",
"or",
"\"kl_gamma_gamma\"",
")",
":",
"# Result from:",
"# http://www.fil.ion.ucl.ac.uk/~wpenny/publications/densities.ps",
"# For deriv... | e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5 |
test | SequentialSchedule.add | Add a learning rate scheduler to the contained `schedules`
:param scheduler: learning rate scheduler to be add
:param max_iteration: iteration numbers this scheduler will run | pyspark/bigdl/optim/optimizer.py | def add(self, scheduler, max_iteration, bigdl_type="float"):
"""
Add a learning rate scheduler to the contained `schedules`
:param scheduler: learning rate scheduler to be add
:param max_iteration: iteration numbers this scheduler will run
"""
return callBigDlFunc(bigdl_... | def add(self, scheduler, max_iteration, bigdl_type="float"):
"""
Add a learning rate scheduler to the contained `schedules`
:param scheduler: learning rate scheduler to be add
:param max_iteration: iteration numbers this scheduler will run
"""
return callBigDlFunc(bigdl_... | [
"Add",
"a",
"learning",
"rate",
"scheduler",
"to",
"the",
"contained",
"schedules"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/optim/optimizer.py#L425-L432 | [
"def",
"add",
"(",
"self",
",",
"scheduler",
",",
"max_iteration",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"return",
"callBigDlFunc",
"(",
"bigdl_type",
",",
"\"addScheduler\"",
",",
"self",
".",
"value",
",",
"scheduler",
",",
"max_iteration",
")"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | OptimMethod.save | save OptimMethod
:param path path
:param overWrite whether to overwrite | pyspark/bigdl/optim/optimizer.py | def save(self, path, overWrite):
"""
save OptimMethod
:param path path
:param overWrite whether to overwrite
"""
method=self.value
return callBigDlFunc(self.bigdl_type, "saveOptimMethod", method, path, overWrite) | def save(self, path, overWrite):
"""
save OptimMethod
:param path path
:param overWrite whether to overwrite
"""
method=self.value
return callBigDlFunc(self.bigdl_type, "saveOptimMethod", method, path, overWrite) | [
"save",
"OptimMethod",
":",
"param",
"path",
"path",
":",
"param",
"overWrite",
"whether",
"to",
"overwrite"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/optim/optimizer.py#L453-L460 | [
"def",
"save",
"(",
"self",
",",
"path",
",",
"overWrite",
")",
":",
"method",
"=",
"self",
".",
"value",
"return",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"saveOptimMethod\"",
",",
"method",
",",
"path",
",",
"overWrite",
")"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | BaseOptimizer.set_checkpoint | Configure checkpoint settings.
:param checkpoint_trigger: the interval to write snapshots
:param checkpoint_path: the path to write snapshots into
:param isOverWrite: whether to overwrite existing snapshots in path.default is True | pyspark/bigdl/optim/optimizer.py | def set_checkpoint(self, checkpoint_trigger,
checkpoint_path, isOverWrite=True):
"""
Configure checkpoint settings.
:param checkpoint_trigger: the interval to write snapshots
:param checkpoint_path: the path to write snapshots into
:param isOverWrite: whe... | def set_checkpoint(self, checkpoint_trigger,
checkpoint_path, isOverWrite=True):
"""
Configure checkpoint settings.
:param checkpoint_trigger: the interval to write snapshots
:param checkpoint_path: the path to write snapshots into
:param isOverWrite: whe... | [
"Configure",
"checkpoint",
"settings",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/optim/optimizer.py#L719-L732 | [
"def",
"set_checkpoint",
"(",
"self",
",",
"checkpoint_trigger",
",",
"checkpoint_path",
",",
"isOverWrite",
"=",
"True",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"checkpoint_path",
")",
":",
"mkpath",
"(",
"checkpoint_path",
")",
"callB... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | BaseOptimizer.set_gradclip_const | Configure constant clipping settings.
:param min_value: the minimum value to clip by
:param max_value: the maxmimum value to clip by | pyspark/bigdl/optim/optimizer.py | def set_gradclip_const(self, min_value, max_value):
"""
Configure constant clipping settings.
:param min_value: the minimum value to clip by
:param max_value: the maxmimum value to clip by
"""
callBigDlFunc(self.bigdl_type, "setConstantClip", self.value, min_value, max_... | def set_gradclip_const(self, min_value, max_value):
"""
Configure constant clipping settings.
:param min_value: the minimum value to clip by
:param max_value: the maxmimum value to clip by
"""
callBigDlFunc(self.bigdl_type, "setConstantClip", self.value, min_value, max_... | [
"Configure",
"constant",
"clipping",
"settings",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/optim/optimizer.py#L734-L742 | [
"def",
"set_gradclip_const",
"(",
"self",
",",
"min_value",
",",
"max_value",
")",
":",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"setConstantClip\"",
",",
"self",
".",
"value",
",",
"min_value",
",",
"max_value",
")"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | BaseOptimizer.optimize | Do an optimization. | pyspark/bigdl/optim/optimizer.py | def optimize(self):
"""
Do an optimization.
"""
jmodel = callJavaFunc(self.value.optimize)
from bigdl.nn.layer import Layer
return Layer.of(jmodel) | def optimize(self):
"""
Do an optimization.
"""
jmodel = callJavaFunc(self.value.optimize)
from bigdl.nn.layer import Layer
return Layer.of(jmodel) | [
"Do",
"an",
"optimization",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/optim/optimizer.py#L760-L766 | [
"def",
"optimize",
"(",
"self",
")",
":",
"jmodel",
"=",
"callJavaFunc",
"(",
"self",
".",
"value",
".",
"optimize",
")",
"from",
"bigdl",
".",
"nn",
".",
"layer",
"import",
"Layer",
"return",
"Layer",
".",
"of",
"(",
"jmodel",
")"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | BaseOptimizer.set_train_summary | Set train summary. A TrainSummary object contains information
necessary for the optimizer to know how often the logs are recorded,
where to store the logs and how to retrieve them, etc. For details,
refer to the docs of TrainSummary.
:param summary: a TrainSummary object | pyspark/bigdl/optim/optimizer.py | def set_train_summary(self, summary):
"""
Set train summary. A TrainSummary object contains information
necessary for the optimizer to know how often the logs are recorded,
where to store the logs and how to retrieve them, etc. For details,
refer to the docs of TrainSummary.
... | def set_train_summary(self, summary):
"""
Set train summary. A TrainSummary object contains information
necessary for the optimizer to know how often the logs are recorded,
where to store the logs and how to retrieve them, etc. For details,
refer to the docs of TrainSummary.
... | [
"Set",
"train",
"summary",
".",
"A",
"TrainSummary",
"object",
"contains",
"information",
"necessary",
"for",
"the",
"optimizer",
"to",
"know",
"how",
"often",
"the",
"logs",
"are",
"recorded",
"where",
"to",
"store",
"the",
"logs",
"and",
"how",
"to",
"retr... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/optim/optimizer.py#L768-L780 | [
"def",
"set_train_summary",
"(",
"self",
",",
"summary",
")",
":",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"setTrainSummary\"",
",",
"self",
".",
"value",
",",
"summary",
")",
"return",
"self"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | BaseOptimizer.set_val_summary | Set validation summary. A ValidationSummary object contains information
necessary for the optimizer to know how often the logs are recorded,
where to store the logs and how to retrieve them, etc. For details,
refer to the docs of ValidationSummary.
:param summary: a ValidationSummary o... | pyspark/bigdl/optim/optimizer.py | def set_val_summary(self, summary):
"""
Set validation summary. A ValidationSummary object contains information
necessary for the optimizer to know how often the logs are recorded,
where to store the logs and how to retrieve them, etc. For details,
refer to the docs of Validation... | def set_val_summary(self, summary):
"""
Set validation summary. A ValidationSummary object contains information
necessary for the optimizer to know how often the logs are recorded,
where to store the logs and how to retrieve them, etc. For details,
refer to the docs of Validation... | [
"Set",
"validation",
"summary",
".",
"A",
"ValidationSummary",
"object",
"contains",
"information",
"necessary",
"for",
"the",
"optimizer",
"to",
"know",
"how",
"often",
"the",
"logs",
"are",
"recorded",
"where",
"to",
"store",
"the",
"logs",
"and",
"how",
"to... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/optim/optimizer.py#L782-L796 | [
"def",
"set_val_summary",
"(",
"self",
",",
"summary",
")",
":",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"setValSummary\"",
",",
"self",
".",
"value",
",",
"summary",
")",
"return",
"self"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Optimizer.create | Create an optimizer.
Depend on the input type, the returning optimizer can be a local optimizer \
or a distributed optimizer.
:param model: the neural net model
:param training_set: (features, label) for local mode. RDD[Sample] for distributed mode.
:param criterion: the loss fu... | pyspark/bigdl/optim/optimizer.py | def create(model,
training_set,
criterion,
end_trigger=None,
batch_size=32,
optim_method=None,
cores=None,
bigdl_type="float"):
"""
Create an optimizer.
Depend on the input type, the returnin... | def create(model,
training_set,
criterion,
end_trigger=None,
batch_size=32,
optim_method=None,
cores=None,
bigdl_type="float"):
"""
Create an optimizer.
Depend on the input type, the returnin... | [
"Create",
"an",
"optimizer",
".",
"Depend",
"on",
"the",
"input",
"type",
"the",
"returning",
"optimizer",
"can",
"be",
"a",
"local",
"optimizer",
"\\",
"or",
"a",
"distributed",
"optimizer",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/optim/optimizer.py#L848-L894 | [
"def",
"create",
"(",
"model",
",",
"training_set",
",",
"criterion",
",",
"end_trigger",
"=",
"None",
",",
"batch_size",
"=",
"32",
",",
"optim_method",
"=",
"None",
",",
"cores",
"=",
"None",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"if",
"not",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Optimizer.set_validation | Configure validation settings.
:param batch_size: validation batch size
:param val_rdd: validation dataset
:param trigger: validation interval
:param val_method: the ValidationMethod to use,e.g. "Top1Accuracy", "Top5Accuracy", "Loss" | pyspark/bigdl/optim/optimizer.py | def set_validation(self, batch_size, val_rdd, trigger, val_method=None):
"""
Configure validation settings.
:param batch_size: validation batch size
:param val_rdd: validation dataset
:param trigger: validation interval
:param val_method: the ValidationMethod to use,e.g... | def set_validation(self, batch_size, val_rdd, trigger, val_method=None):
"""
Configure validation settings.
:param batch_size: validation batch size
:param val_rdd: validation dataset
:param trigger: validation interval
:param val_method: the ValidationMethod to use,e.g... | [
"Configure",
"validation",
"settings",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/optim/optimizer.py#L896-L912 | [
"def",
"set_validation",
"(",
"self",
",",
"batch_size",
",",
"val_rdd",
",",
"trigger",
",",
"val_method",
"=",
"None",
")",
":",
"if",
"val_method",
"is",
"None",
":",
"val_method",
"=",
"[",
"Top1Accuracy",
"(",
")",
"]",
"func_name",
"=",
"\"setValidat... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Optimizer.set_traindata | Set new training dataset, for optimizer reuse
:param training_rdd: the training dataset
:param batch_size: training batch size
:return: | pyspark/bigdl/optim/optimizer.py | def set_traindata(self, training_rdd, batch_size):
"""
Set new training dataset, for optimizer reuse
:param training_rdd: the training dataset
:param batch_size: training batch size
:return:
"""
callBigDlFunc(self.bigdl_type, "setTrainData", self.value,
... | def set_traindata(self, training_rdd, batch_size):
"""
Set new training dataset, for optimizer reuse
:param training_rdd: the training dataset
:param batch_size: training batch size
:return:
"""
callBigDlFunc(self.bigdl_type, "setTrainData", self.value,
... | [
"Set",
"new",
"training",
"dataset",
"for",
"optimizer",
"reuse"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/optim/optimizer.py#L914-L923 | [
"def",
"set_traindata",
"(",
"self",
",",
"training_rdd",
",",
"batch_size",
")",
":",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"setTrainData\"",
",",
"self",
".",
"value",
",",
"training_rdd",
",",
"batch_size",
")"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | LocalOptimizer.set_validation | Configure validation settings.
:param batch_size: validation batch size
:param X_val: features of validation dataset
:param Y_val: label of validation dataset
:param trigger: validation interval
:param val_method: the ValidationMethod to use,e.g. "Top1Accuracy", "Top5Accuracy", ... | pyspark/bigdl/optim/optimizer.py | def set_validation(self, batch_size, X_val, Y_val, trigger, val_method=None):
"""
Configure validation settings.
:param batch_size: validation batch size
:param X_val: features of validation dataset
:param Y_val: label of validation dataset
:param trigger: validation int... | def set_validation(self, batch_size, X_val, Y_val, trigger, val_method=None):
"""
Configure validation settings.
:param batch_size: validation batch size
:param X_val: features of validation dataset
:param Y_val: label of validation dataset
:param trigger: validation int... | [
"Configure",
"validation",
"settings",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/optim/optimizer.py#L1009-L1023 | [
"def",
"set_validation",
"(",
"self",
",",
"batch_size",
",",
"X_val",
",",
"Y_val",
",",
"trigger",
",",
"val_method",
"=",
"None",
")",
":",
"if",
"val_method",
"is",
"None",
":",
"val_method",
"=",
"[",
"Top1Accuracy",
"(",
")",
"]",
"callBigDlFunc",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | TrainSummary.set_summary_trigger | Set the interval of recording for each indicator.
:param tag: tag name. Supported tag names are "LearningRate", "Loss","Throughput", "Parameters". "Parameters" is an umbrella tag thatincludes weight, bias, gradWeight, gradBias, and some running status(eg. runningMean and runningVar in BatchNormalization). If ... | pyspark/bigdl/optim/optimizer.py | def set_summary_trigger(self, name, trigger):
"""
Set the interval of recording for each indicator.
:param tag: tag name. Supported tag names are "LearningRate", "Loss","Throughput", "Parameters". "Parameters" is an umbrella tag thatincludes weight, bias, gradWeight, gradBias, and some running... | def set_summary_trigger(self, name, trigger):
"""
Set the interval of recording for each indicator.
:param tag: tag name. Supported tag names are "LearningRate", "Loss","Throughput", "Parameters". "Parameters" is an umbrella tag thatincludes weight, bias, gradWeight, gradBias, and some running... | [
"Set",
"the",
"interval",
"of",
"recording",
"for",
"each",
"indicator",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/optim/optimizer.py#L1062-L1071 | [
"def",
"set_summary_trigger",
"(",
"self",
",",
"name",
",",
"trigger",
")",
":",
"return",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"summarySetTrigger\"",
",",
"self",
".",
"value",
",",
"name",
",",
"trigger",
")"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | read_data_sets | Parse or download mnist data if train_dir is empty.
:param: train_dir: The directory storing the mnist data
:param: data_type: Reading training set or testing set.It can be either "train" or "test"
:return:
```
(ndarray, ndarray) representing (features, labels)
features is a 4D unit8 numpy a... | pyspark/bigdl/dataset/mnist.py | def read_data_sets(train_dir, data_type="train"):
"""
Parse or download mnist data if train_dir is empty.
:param: train_dir: The directory storing the mnist data
:param: data_type: Reading training set or testing set.It can be either "train" or "test"
:return:
```
(ndarray, ndarray) repr... | def read_data_sets(train_dir, data_type="train"):
"""
Parse or download mnist data if train_dir is empty.
:param: train_dir: The directory storing the mnist data
:param: data_type: Reading training set or testing set.It can be either "train" or "test"
:return:
```
(ndarray, ndarray) repr... | [
"Parse",
"or",
"download",
"mnist",
"data",
"if",
"train_dir",
"is",
"empty",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/dataset/mnist.py#L77-L121 | [
"def",
"read_data_sets",
"(",
"train_dir",
",",
"data_type",
"=",
"\"train\"",
")",
":",
"TRAIN_IMAGES",
"=",
"'train-images-idx3-ubyte.gz'",
"TRAIN_LABELS",
"=",
"'train-labels-idx1-ubyte.gz'",
"TEST_IMAGES",
"=",
"'t10k-images-idx3-ubyte.gz'",
"TEST_LABELS",
"=",
"'t10k-l... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | get_news20 | Parse or download news20 if source_dir is empty.
:param source_dir: The directory storing news data.
:return: A list of (tokens, label) | pyspark/bigdl/dataset/news20.py | def get_news20(source_dir="./data/news20/"):
"""
Parse or download news20 if source_dir is empty.
:param source_dir: The directory storing news data.
:return: A list of (tokens, label)
"""
news_dir = download_news20(source_dir)
texts = [] # list of text samples
label_id = 0
for nam... | def get_news20(source_dir="./data/news20/"):
"""
Parse or download news20 if source_dir is empty.
:param source_dir: The directory storing news data.
:return: A list of (tokens, label)
"""
news_dir = download_news20(source_dir)
texts = [] # list of text samples
label_id = 0
for nam... | [
"Parse",
"or",
"download",
"news20",
"if",
"source_dir",
"is",
"empty",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/dataset/news20.py#L53-L79 | [
"def",
"get_news20",
"(",
"source_dir",
"=",
"\"./data/news20/\"",
")",
":",
"news_dir",
"=",
"download_news20",
"(",
"source_dir",
")",
"texts",
"=",
"[",
"]",
"# list of text samples",
"label_id",
"=",
"0",
"for",
"name",
"in",
"sorted",
"(",
"os",
".",
"l... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | get_glove_w2v | Parse or download the pre-trained glove word2vec if source_dir is empty.
:param source_dir: The directory storing the pre-trained word2vec
:param dim: The dimension of a vector
:return: A dict mapping from word to vector | pyspark/bigdl/dataset/news20.py | def get_glove_w2v(source_dir="./data/news20/", dim=100):
"""
Parse or download the pre-trained glove word2vec if source_dir is empty.
:param source_dir: The directory storing the pre-trained word2vec
:param dim: The dimension of a vector
:return: A dict mapping from word to vector
"""
w2v_d... | def get_glove_w2v(source_dir="./data/news20/", dim=100):
"""
Parse or download the pre-trained glove word2vec if source_dir is empty.
:param source_dir: The directory storing the pre-trained word2vec
:param dim: The dimension of a vector
:return: A dict mapping from word to vector
"""
w2v_d... | [
"Parse",
"or",
"download",
"the",
"pre",
"-",
"trained",
"glove",
"word2vec",
"if",
"source_dir",
"is",
"empty",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/dataset/news20.py#L82-L101 | [
"def",
"get_glove_w2v",
"(",
"source_dir",
"=",
"\"./data/news20/\"",
",",
"dim",
"=",
"100",
")",
":",
"w2v_dir",
"=",
"download_glove_w2v",
"(",
"source_dir",
")",
"w2v_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"w2v_dir",
",",
"\"glove.6B.%sd.txt\"",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | KerasModel.compile | Configures the learning process. Must be called before fit or evaluate.
# Arguments
optimizer: Optimization method to be used. One can alternatively pass in the corresponding
string representation, such as 'sgd'.
loss: Criterion to be used. One can alternatively pass in the c... | pyspark/bigdl/nn/keras/topology.py | def compile(self, optimizer, loss, metrics=None):
"""
Configures the learning process. Must be called before fit or evaluate.
# Arguments
optimizer: Optimization method to be used. One can alternatively pass in the corresponding
string representation, such as 'sgd'.
... | def compile(self, optimizer, loss, metrics=None):
"""
Configures the learning process. Must be called before fit or evaluate.
# Arguments
optimizer: Optimization method to be used. One can alternatively pass in the corresponding
string representation, such as 'sgd'.
... | [
"Configures",
"the",
"learning",
"process",
".",
"Must",
"be",
"called",
"before",
"fit",
"or",
"evaluate",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/keras/topology.py#L82-L103 | [
"def",
"compile",
"(",
"self",
",",
"optimizer",
",",
"loss",
",",
"metrics",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"optimizer",
",",
"six",
".",
"string_types",
")",
":",
"optimizer",
"=",
"self",
".",
"__convert_optim_method",
"(",
"optimizer",... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | KerasModel.fit | Train a model for a fixed number of epochs on a dataset.
# Arguments
x: Input data. A Numpy array or RDD of Sample or Image DataSet.
y: Labels. A Numpy array. Default is None if x is already RDD of Sample or Image DataSet.
batch_size: Number of samples per gradient update.
nb_ep... | pyspark/bigdl/nn/keras/topology.py | def fit(self, x, y=None, batch_size=32, nb_epoch=10, validation_data=None, distributed=True):
"""
Train a model for a fixed number of epochs on a dataset.
# Arguments
x: Input data. A Numpy array or RDD of Sample or Image DataSet.
y: Labels. A Numpy array. Default is None if x i... | def fit(self, x, y=None, batch_size=32, nb_epoch=10, validation_data=None, distributed=True):
"""
Train a model for a fixed number of epochs on a dataset.
# Arguments
x: Input data. A Numpy array or RDD of Sample or Image DataSet.
y: Labels. A Numpy array. Default is None if x i... | [
"Train",
"a",
"model",
"for",
"a",
"fixed",
"number",
"of",
"epochs",
"on",
"a",
"dataset",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/keras/topology.py#L105-L148 | [
"def",
"fit",
"(",
"self",
",",
"x",
",",
"y",
"=",
"None",
",",
"batch_size",
"=",
"32",
",",
"nb_epoch",
"=",
"10",
",",
"validation_data",
"=",
"None",
",",
"distributed",
"=",
"True",
")",
":",
"if",
"distributed",
":",
"if",
"isinstance",
"(",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | KerasModel.evaluate | Evaluate a model on a given dataset in distributed mode.
# Arguments
x: Input data. A Numpy array or RDD of Sample.
y: Labels. A Numpy array. Default is None if x is already RDD of Sample.
batch_size: Number of samples per gradient update. | pyspark/bigdl/nn/keras/topology.py | def evaluate(self, x, y=None, batch_size=32):
"""
Evaluate a model on a given dataset in distributed mode.
# Arguments
x: Input data. A Numpy array or RDD of Sample.
y: Labels. A Numpy array. Default is None if x is already RDD of Sample.
batch_size: Number of samples pe... | def evaluate(self, x, y=None, batch_size=32):
"""
Evaluate a model on a given dataset in distributed mode.
# Arguments
x: Input data. A Numpy array or RDD of Sample.
y: Labels. A Numpy array. Default is None if x is already RDD of Sample.
batch_size: Number of samples pe... | [
"Evaluate",
"a",
"model",
"on",
"a",
"given",
"dataset",
"in",
"distributed",
"mode",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/keras/topology.py#L150-L168 | [
"def",
"evaluate",
"(",
"self",
",",
"x",
",",
"y",
"=",
"None",
",",
"batch_size",
"=",
"32",
")",
":",
"if",
"isinstance",
"(",
"x",
",",
"np",
".",
"ndarray",
")",
"and",
"isinstance",
"(",
"y",
",",
"np",
".",
"ndarray",
")",
":",
"evaluation... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | KerasModel.predict | Use a model to do prediction.
# Arguments
x: Input data. A Numpy array or RDD of Sample.
distributed: Boolean. Whether to do prediction in distributed mode or local mode.
Default is True. In local mode, x must be a Numpy array. | pyspark/bigdl/nn/keras/topology.py | def predict(self, x, distributed=True):
"""
Use a model to do prediction.
# Arguments
x: Input data. A Numpy array or RDD of Sample.
distributed: Boolean. Whether to do prediction in distributed mode or local mode.
Default is True. In local mode, x must be a... | def predict(self, x, distributed=True):
"""
Use a model to do prediction.
# Arguments
x: Input data. A Numpy array or RDD of Sample.
distributed: Boolean. Whether to do prediction in distributed mode or local mode.
Default is True. In local mode, x must be a... | [
"Use",
"a",
"model",
"to",
"do",
"prediction",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/keras/topology.py#L170-L191 | [
"def",
"predict",
"(",
"self",
",",
"x",
",",
"distributed",
"=",
"True",
")",
":",
"if",
"is_distributed",
":",
"if",
"isinstance",
"(",
"x",
",",
"np",
".",
"ndarray",
")",
":",
"features",
"=",
"to_sample_rdd",
"(",
"x",
",",
"np",
".",
"zeros",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Sequential.from_jvalue | Create a Python Model base on the given java value
:param jvalue: Java object create by Py4j
:return: A Python Model | pyspark/bigdl/nn/keras/topology.py | def from_jvalue(jvalue, bigdl_type="float"):
"""
Create a Python Model base on the given java value
:param jvalue: Java object create by Py4j
:return: A Python Model
"""
model = Sequential(jvalue=jvalue)
model.value = jvalue
return model | def from_jvalue(jvalue, bigdl_type="float"):
"""
Create a Python Model base on the given java value
:param jvalue: Java object create by Py4j
:return: A Python Model
"""
model = Sequential(jvalue=jvalue)
model.value = jvalue
return model | [
"Create",
"a",
"Python",
"Model",
"base",
"on",
"the",
"given",
"java",
"value",
":",
"param",
"jvalue",
":",
"Java",
"object",
"create",
"by",
"Py4j",
":",
"return",
":",
"A",
"Python",
"Model"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/keras/topology.py#L208-L216 | [
"def",
"from_jvalue",
"(",
"jvalue",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"model",
"=",
"Sequential",
"(",
"jvalue",
"=",
"jvalue",
")",
"model",
".",
"value",
"=",
"jvalue",
"return",
"model"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Model.from_jvalue | Create a Python Model base on the given java value
:param jvalue: Java object create by Py4j
:return: A Python Model | pyspark/bigdl/nn/keras/topology.py | def from_jvalue(jvalue, bigdl_type="float"):
"""
Create a Python Model base on the given java value
:param jvalue: Java object create by Py4j
:return: A Python Model
"""
model = Model([], [], jvalue=jvalue)
model.value = jvalue
return model | def from_jvalue(jvalue, bigdl_type="float"):
"""
Create a Python Model base on the given java value
:param jvalue: Java object create by Py4j
:return: A Python Model
"""
model = Model([], [], jvalue=jvalue)
model.value = jvalue
return model | [
"Create",
"a",
"Python",
"Model",
"base",
"on",
"the",
"given",
"java",
"value",
":",
"param",
"jvalue",
":",
"Java",
"object",
"create",
"by",
"Py4j",
":",
"return",
":",
"A",
"Python",
"Model"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/keras/topology.py#L238-L246 | [
"def",
"from_jvalue",
"(",
"jvalue",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"model",
"=",
"Model",
"(",
"[",
"]",
",",
"[",
"]",
",",
"jvalue",
"=",
"jvalue",
")",
"model",
".",
"value",
"=",
"jvalue",
"return",
"model"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | get_mnist | Get mnist dataset and parallelize into RDDs.
Data would be downloaded automatically if it doesn't present at the specific location.
:param sc: SparkContext.
:param data_type: "train" for training data and "test" for testing data.
:param location: Location to store mnist dataset.
:return: RDD of (fe... | pyspark/bigdl/models/lenet/utils.py | def get_mnist(sc, data_type="train", location="/tmp/mnist"):
"""
Get mnist dataset and parallelize into RDDs.
Data would be downloaded automatically if it doesn't present at the specific location.
:param sc: SparkContext.
:param data_type: "train" for training data and "test" for testing data.
... | def get_mnist(sc, data_type="train", location="/tmp/mnist"):
"""
Get mnist dataset and parallelize into RDDs.
Data would be downloaded automatically if it doesn't present at the specific location.
:param sc: SparkContext.
:param data_type: "train" for training data and "test" for testing data.
... | [
"Get",
"mnist",
"dataset",
"and",
"parallelize",
"into",
"RDDs",
".",
"Data",
"would",
"be",
"downloaded",
"automatically",
"if",
"it",
"doesn",
"t",
"present",
"at",
"the",
"specific",
"location",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/models/lenet/utils.py#L22-L36 | [
"def",
"get_mnist",
"(",
"sc",
",",
"data_type",
"=",
"\"train\"",
",",
"location",
"=",
"\"/tmp/mnist\"",
")",
":",
"(",
"images",
",",
"labels",
")",
"=",
"mnist",
".",
"read_data_sets",
"(",
"location",
",",
"data_type",
")",
"images",
"=",
"sc",
".",... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | preprocess_mnist | Preprocess mnist dataset.
Normalize and transform into Sample of RDDs. | pyspark/bigdl/models/lenet/utils.py | def preprocess_mnist(sc, options):
"""
Preprocess mnist dataset.
Normalize and transform into Sample of RDDs.
"""
train_data = get_mnist(sc, "train", options.dataPath)\
.map(lambda rec_tuple: (normalizer(rec_tuple[0], mnist.TRAIN_MEAN, mnist.TRAIN_STD),
rec_tu... | def preprocess_mnist(sc, options):
"""
Preprocess mnist dataset.
Normalize and transform into Sample of RDDs.
"""
train_data = get_mnist(sc, "train", options.dataPath)\
.map(lambda rec_tuple: (normalizer(rec_tuple[0], mnist.TRAIN_MEAN, mnist.TRAIN_STD),
rec_tu... | [
"Preprocess",
"mnist",
"dataset",
".",
"Normalize",
"and",
"transform",
"into",
"Sample",
"of",
"RDDs",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/models/lenet/utils.py#L39-L52 | [
"def",
"preprocess_mnist",
"(",
"sc",
",",
"options",
")",
":",
"train_data",
"=",
"get_mnist",
"(",
"sc",
",",
"\"train\"",
",",
"options",
".",
"dataPath",
")",
".",
"map",
"(",
"lambda",
"rec_tuple",
":",
"(",
"normalizer",
"(",
"rec_tuple",
"[",
"0",... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | get_end_trigger | When to end the optimization based on input option. | pyspark/bigdl/models/lenet/utils.py | def get_end_trigger(options):
"""
When to end the optimization based on input option.
"""
if options.endTriggerType.lower() == "epoch":
return MaxEpoch(options.endTriggerNum)
else:
return MaxIteration(options.endTriggerNum) | def get_end_trigger(options):
"""
When to end the optimization based on input option.
"""
if options.endTriggerType.lower() == "epoch":
return MaxEpoch(options.endTriggerNum)
else:
return MaxIteration(options.endTriggerNum) | [
"When",
"to",
"end",
"the",
"optimization",
"based",
"on",
"input",
"option",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/models/lenet/utils.py#L55-L62 | [
"def",
"get_end_trigger",
"(",
"options",
")",
":",
"if",
"options",
".",
"endTriggerType",
".",
"lower",
"(",
")",
"==",
"\"epoch\"",
":",
"return",
"MaxEpoch",
"(",
"options",
".",
"endTriggerNum",
")",
"else",
":",
"return",
"MaxIteration",
"(",
"options"... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | validate_optimizer | Set validation and checkpoint for distributed optimizer. | pyspark/bigdl/models/lenet/utils.py | def validate_optimizer(optimizer, test_data, options):
"""
Set validation and checkpoint for distributed optimizer.
"""
optimizer.set_validation(
batch_size=options.batchSize,
val_rdd=test_data,
trigger=EveryEpoch(),
val_method=[Top1Accuracy()]
)
optimizer.set_che... | def validate_optimizer(optimizer, test_data, options):
"""
Set validation and checkpoint for distributed optimizer.
"""
optimizer.set_validation(
batch_size=options.batchSize,
val_rdd=test_data,
trigger=EveryEpoch(),
val_method=[Top1Accuracy()]
)
optimizer.set_che... | [
"Set",
"validation",
"and",
"checkpoint",
"for",
"distributed",
"optimizer",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/models/lenet/utils.py#L65-L75 | [
"def",
"validate_optimizer",
"(",
"optimizer",
",",
"test_data",
",",
"options",
")",
":",
"optimizer",
".",
"set_validation",
"(",
"batch_size",
"=",
"options",
".",
"batchSize",
",",
"val_rdd",
"=",
"test_data",
",",
"trigger",
"=",
"EveryEpoch",
"(",
")",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | HasBatchSize.setBatchSize | Sets the value of :py:attr:`batchSize`. | pyspark/bigdl/models/ml_pipeline/dl_classifier.py | def setBatchSize(self, val):
"""
Sets the value of :py:attr:`batchSize`.
"""
self._paramMap[self.batchSize] = val
pythonBigDL_method_name = "setBatchSize" + self.__class__.__name__
callBigDlFunc(self.bigdl_type, pythonBigDL_method_name, self.value, val)
return sel... | def setBatchSize(self, val):
"""
Sets the value of :py:attr:`batchSize`.
"""
self._paramMap[self.batchSize] = val
pythonBigDL_method_name = "setBatchSize" + self.__class__.__name__
callBigDlFunc(self.bigdl_type, pythonBigDL_method_name, self.value, val)
return sel... | [
"Sets",
"the",
"value",
"of",
":",
"py",
":",
"attr",
":",
"batchSize",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/models/ml_pipeline/dl_classifier.py#L25-L32 | [
"def",
"setBatchSize",
"(",
"self",
",",
"val",
")",
":",
"self",
".",
"_paramMap",
"[",
"self",
".",
"batchSize",
"]",
"=",
"val",
"pythonBigDL_method_name",
"=",
"\"setBatchSize\"",
"+",
"self",
".",
"__class__",
".",
"__name__",
"callBigDlFunc",
"(",
"sel... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | ModelBroadcast.value | Return the broadcasted value | pyspark/bigdl/models/utils/model_broadcast.py | def value(self):
""" Return the broadcasted value
"""
if not hasattr(self, "_value") and self._path is not None:
self._value = self._load(self._path)
return self._value | def value(self):
""" Return the broadcasted value
"""
if not hasattr(self, "_value") and self._path is not None:
self._value = self._load(self._path)
return self._value | [
"Return",
"the",
"broadcasted",
"value"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/models/utils/model_broadcast.py#L61-L66 | [
"def",
"value",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_value\"",
")",
"and",
"self",
".",
"_path",
"is",
"not",
"None",
":",
"self",
".",
"_value",
"=",
"self",
".",
"_load",
"(",
"self",
".",
"_path",
")",
"return",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | to_sample_rdd | Conver x and y into RDD[Sample]
:param x: ndarray and the first dimension should be batch
:param y: ndarray and the first dimension should be batch
:param numSlices:
:return: | pyspark/bigdl/util/common.py | def to_sample_rdd(x, y, numSlices=None):
"""
Conver x and y into RDD[Sample]
:param x: ndarray and the first dimension should be batch
:param y: ndarray and the first dimension should be batch
:param numSlices:
:return:
"""
sc = get_spark_context()
from bigdl.util.common import Sampl... | def to_sample_rdd(x, y, numSlices=None):
"""
Conver x and y into RDD[Sample]
:param x: ndarray and the first dimension should be batch
:param y: ndarray and the first dimension should be batch
:param numSlices:
:return:
"""
sc = get_spark_context()
from bigdl.util.common import Sampl... | [
"Conver",
"x",
"and",
"y",
"into",
"RDD",
"[",
"Sample",
"]",
":",
"param",
"x",
":",
"ndarray",
"and",
"the",
"first",
"dimension",
"should",
"be",
"batch",
":",
"param",
"y",
":",
"ndarray",
"and",
"the",
"first",
"dimension",
"should",
"be",
"batch"... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/util/common.py#L478-L490 | [
"def",
"to_sample_rdd",
"(",
"x",
",",
"y",
",",
"numSlices",
"=",
"None",
")",
":",
"sc",
"=",
"get_spark_context",
"(",
")",
"from",
"bigdl",
".",
"util",
".",
"common",
"import",
"Sample",
"x_rdd",
"=",
"sc",
".",
"parallelize",
"(",
"x",
",",
"nu... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | get_spark_context | Get the current active spark context and create one if no active instance
:param conf: combining bigdl configs into spark conf
:return: SparkContext | pyspark/bigdl/util/common.py | def get_spark_context(conf=None):
"""
Get the current active spark context and create one if no active instance
:param conf: combining bigdl configs into spark conf
:return: SparkContext
"""
if hasattr(SparkContext, "getOrCreate"):
with SparkContext._lock:
if SparkContext._ac... | def get_spark_context(conf=None):
"""
Get the current active spark context and create one if no active instance
:param conf: combining bigdl configs into spark conf
:return: SparkContext
"""
if hasattr(SparkContext, "getOrCreate"):
with SparkContext._lock:
if SparkContext._ac... | [
"Get",
"the",
"current",
"active",
"spark",
"context",
"and",
"create",
"one",
"if",
"no",
"active",
"instance",
":",
"param",
"conf",
":",
"combining",
"bigdl",
"configs",
"into",
"spark",
"conf",
":",
"return",
":",
"SparkContext"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/util/common.py#L520-L541 | [
"def",
"get_spark_context",
"(",
"conf",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"SparkContext",
",",
"\"getOrCreate\"",
")",
":",
"with",
"SparkContext",
".",
"_lock",
":",
"if",
"SparkContext",
".",
"_active_spark_context",
"is",
"None",
":",
"spark_con... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | callBigDlFunc | Call API in PythonBigDL | pyspark/bigdl/util/common.py | def callBigDlFunc(bigdl_type, name, *args):
""" Call API in PythonBigDL """
gateway = _get_gateway()
error = Exception("Cannot find function: %s" % name)
for jinvoker in JavaCreator.instance(bigdl_type, gateway).value:
# hasattr(jinvoker, name) always return true here,
# so you need to i... | def callBigDlFunc(bigdl_type, name, *args):
""" Call API in PythonBigDL """
gateway = _get_gateway()
error = Exception("Cannot find function: %s" % name)
for jinvoker in JavaCreator.instance(bigdl_type, gateway).value:
# hasattr(jinvoker, name) always return true here,
# so you need to i... | [
"Call",
"API",
"in",
"PythonBigDL"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/util/common.py#L576-L592 | [
"def",
"callBigDlFunc",
"(",
"bigdl_type",
",",
"name",
",",
"*",
"args",
")",
":",
"gateway",
"=",
"_get_gateway",
"(",
")",
"error",
"=",
"Exception",
"(",
"\"Cannot find function: %s\"",
"%",
"name",
")",
"for",
"jinvoker",
"in",
"JavaCreator",
".",
"inst... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | callJavaFunc | Call Java Function | pyspark/bigdl/util/common.py | def callJavaFunc(func, *args):
""" Call Java Function """
gateway = _get_gateway()
args = [_py2java(gateway, a) for a in args]
result = func(*args)
return _java2py(gateway, result) | def callJavaFunc(func, *args):
""" Call Java Function """
gateway = _get_gateway()
args = [_py2java(gateway, a) for a in args]
result = func(*args)
return _java2py(gateway, result) | [
"Call",
"Java",
"Function"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/util/common.py#L630-L635 | [
"def",
"callJavaFunc",
"(",
"func",
",",
"*",
"args",
")",
":",
"gateway",
"=",
"_get_gateway",
"(",
")",
"args",
"=",
"[",
"_py2java",
"(",
"gateway",
",",
"a",
")",
"for",
"a",
"in",
"args",
"]",
"result",
"=",
"func",
"(",
"*",
"args",
")",
"r... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | _to_java_object_rdd | Return a JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever
the RDD is serialized in batch or not. | pyspark/bigdl/util/common.py | def _to_java_object_rdd(rdd):
""" Return a JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever
the RDD is serialized in batch or not.
"""
rdd = rdd._reserialize(AutoBatchedSerializer(PickleSerializer()))
return \
rdd.ctx._jvm.org.ap... | def _to_java_object_rdd(rdd):
""" Return a JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever
the RDD is serialized in batch or not.
"""
rdd = rdd._reserialize(AutoBatchedSerializer(PickleSerializer()))
return \
rdd.ctx._jvm.org.ap... | [
"Return",
"a",
"JavaRDD",
"of",
"Object",
"by",
"unpickling"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/util/common.py#L638-L648 | [
"def",
"_to_java_object_rdd",
"(",
"rdd",
")",
":",
"rdd",
"=",
"rdd",
".",
"_reserialize",
"(",
"AutoBatchedSerializer",
"(",
"PickleSerializer",
"(",
")",
")",
")",
"return",
"rdd",
".",
"ctx",
".",
"_jvm",
".",
"org",
".",
"apache",
".",
"spark",
".",... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | _py2java | Convert Python object into Java | pyspark/bigdl/util/common.py | def _py2java(gateway, obj):
""" Convert Python object into Java """
if isinstance(obj, RDD):
obj = _to_java_object_rdd(obj)
elif isinstance(obj, DataFrame):
obj = obj._jdf
elif isinstance(obj, SparkContext):
obj = obj._jsc
elif isinstance(obj, (list, tuple)):
obj = Li... | def _py2java(gateway, obj):
""" Convert Python object into Java """
if isinstance(obj, RDD):
obj = _to_java_object_rdd(obj)
elif isinstance(obj, DataFrame):
obj = obj._jdf
elif isinstance(obj, SparkContext):
obj = obj._jsc
elif isinstance(obj, (list, tuple)):
obj = Li... | [
"Convert",
"Python",
"object",
"into",
"Java"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/util/common.py#L651-L676 | [
"def",
"_py2java",
"(",
"gateway",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"RDD",
")",
":",
"obj",
"=",
"_to_java_object_rdd",
"(",
"obj",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"DataFrame",
")",
":",
"obj",
"=",
"obj",
".",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | get_activation_by_name | Convert to a bigdl activation layer
given the name of the activation as a string | pyspark/bigdl/util/common.py | def get_activation_by_name(activation_name, activation_id=None):
""" Convert to a bigdl activation layer
given the name of the activation as a string """
import bigdl.nn.layer as BLayer
activation = None
activation_name = activation_name.lower()
if activation_name == "tanh":
activat... | def get_activation_by_name(activation_name, activation_id=None):
""" Convert to a bigdl activation layer
given the name of the activation as a string """
import bigdl.nn.layer as BLayer
activation = None
activation_name = activation_name.lower()
if activation_name == "tanh":
activat... | [
"Convert",
"to",
"a",
"bigdl",
"activation",
"layer",
"given",
"the",
"name",
"of",
"the",
"activation",
"as",
"a",
"string"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/util/common.py#L704-L730 | [
"def",
"get_activation_by_name",
"(",
"activation_name",
",",
"activation_id",
"=",
"None",
")",
":",
"import",
"bigdl",
".",
"nn",
".",
"layer",
"as",
"BLayer",
"activation",
"=",
"None",
"activation_name",
"=",
"activation_name",
".",
"lower",
"(",
")",
"if"... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | JTensor.from_ndarray | Convert a ndarray to a DenseTensor which would be used in Java side.
>>> import numpy as np
>>> from bigdl.util.common import JTensor
>>> from bigdl.util.common import callBigDlFunc
>>> np.random.seed(123)
>>> data = np.random.uniform(0, 1, (2, 3)).astype("float32")
>>> ... | pyspark/bigdl/util/common.py | def from_ndarray(cls, a_ndarray, bigdl_type="float"):
"""
Convert a ndarray to a DenseTensor which would be used in Java side.
>>> import numpy as np
>>> from bigdl.util.common import JTensor
>>> from bigdl.util.common import callBigDlFunc
>>> np.random.seed(123)
... | def from_ndarray(cls, a_ndarray, bigdl_type="float"):
"""
Convert a ndarray to a DenseTensor which would be used in Java side.
>>> import numpy as np
>>> from bigdl.util.common import JTensor
>>> from bigdl.util.common import callBigDlFunc
>>> np.random.seed(123)
... | [
"Convert",
"a",
"ndarray",
"to",
"a",
"DenseTensor",
"which",
"would",
"be",
"used",
"in",
"Java",
"side",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/util/common.py#L184-L212 | [
"def",
"from_ndarray",
"(",
"cls",
",",
"a_ndarray",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"if",
"a_ndarray",
"is",
"None",
":",
"return",
"None",
"assert",
"isinstance",
"(",
"a_ndarray",
",",
"np",
".",
"ndarray",
")",
",",
"\"input should be a np... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | JTensor.sparse | Convert a three ndarray to SparseTensor which would be used in Java side.
For example:
a_ndarray = [1, 3, 2, 4]
i_ndarray = [[0, 0, 1, 2],
[0, 3, 2, 1]]
shape = [3, 4]
Present a dense tensor
[[ 1, 0, 0, 3],
[ 0, 0, 2, 0],
[ 0, ... | pyspark/bigdl/util/common.py | def sparse(cls, a_ndarray, i_ndarray, shape, bigdl_type="float"):
"""
Convert a three ndarray to SparseTensor which would be used in Java side.
For example:
a_ndarray = [1, 3, 2, 4]
i_ndarray = [[0, 0, 1, 2],
[0, 3, 2, 1]]
shape = [3, 4]
Prese... | def sparse(cls, a_ndarray, i_ndarray, shape, bigdl_type="float"):
"""
Convert a three ndarray to SparseTensor which would be used in Java side.
For example:
a_ndarray = [1, 3, 2, 4]
i_ndarray = [[0, 0, 1, 2],
[0, 3, 2, 1]]
shape = [3, 4]
Prese... | [
"Convert",
"a",
"three",
"ndarray",
"to",
"SparseTensor",
"which",
"would",
"be",
"used",
"in",
"Java",
"side",
".",
"For",
"example",
":",
"a_ndarray",
"=",
"[",
"1",
"3",
"2",
"4",
"]",
"i_ndarray",
"=",
"[[",
"0",
"0",
"1",
"2",
"]",
"[",
"0",
... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/util/common.py#L215-L266 | [
"def",
"sparse",
"(",
"cls",
",",
"a_ndarray",
",",
"i_ndarray",
",",
"shape",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"if",
"a_ndarray",
"is",
"None",
":",
"return",
"None",
"assert",
"isinstance",
"(",
"a_ndarray",
",",
"np",
".",
"ndarray",
")"... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | JTensor.to_ndarray | Transfer JTensor to ndarray.
As SparseTensor may generate an very big ndarray, so we don't support this function for SparseTensor.
:return: a ndarray | pyspark/bigdl/util/common.py | def to_ndarray(self):
"""
Transfer JTensor to ndarray.
As SparseTensor may generate an very big ndarray, so we don't support this function for SparseTensor.
:return: a ndarray
"""
assert self.indices is None, "sparseTensor to ndarray is not supported"
return np.ar... | def to_ndarray(self):
"""
Transfer JTensor to ndarray.
As SparseTensor may generate an very big ndarray, so we don't support this function for SparseTensor.
:return: a ndarray
"""
assert self.indices is None, "sparseTensor to ndarray is not supported"
return np.ar... | [
"Transfer",
"JTensor",
"to",
"ndarray",
".",
"As",
"SparseTensor",
"may",
"generate",
"an",
"very",
"big",
"ndarray",
"so",
"we",
"don",
"t",
"support",
"this",
"function",
"for",
"SparseTensor",
".",
":",
"return",
":",
"a",
"ndarray"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/util/common.py#L268-L275 | [
"def",
"to_ndarray",
"(",
"self",
")",
":",
"assert",
"self",
".",
"indices",
"is",
"None",
",",
"\"sparseTensor to ndarray is not supported\"",
"return",
"np",
".",
"array",
"(",
"self",
".",
"storage",
",",
"dtype",
"=",
"get_dtype",
"(",
"self",
".",
"big... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Sample.from_ndarray | Convert a ndarray of features and labels to Sample, which would be used in Java side.
:param features: an ndarray or a list of ndarrays
:param labels: an ndarray or a list of ndarrays or a scalar
:param bigdl_type: "double" or "float"
>>> import numpy as np
>>> from bigdl.util.c... | pyspark/bigdl/util/common.py | def from_ndarray(cls, features, labels, bigdl_type="float"):
"""
Convert a ndarray of features and labels to Sample, which would be used in Java side.
:param features: an ndarray or a list of ndarrays
:param labels: an ndarray or a list of ndarrays or a scalar
:param bigdl_type: ... | def from_ndarray(cls, features, labels, bigdl_type="float"):
"""
Convert a ndarray of features and labels to Sample, which would be used in Java side.
:param features: an ndarray or a list of ndarrays
:param labels: an ndarray or a list of ndarrays or a scalar
:param bigdl_type: ... | [
"Convert",
"a",
"ndarray",
"of",
"features",
"and",
"labels",
"to",
"Sample",
"which",
"would",
"be",
"used",
"in",
"Java",
"side",
".",
":",
"param",
"features",
":",
"an",
"ndarray",
"or",
"a",
"list",
"of",
"ndarrays",
":",
"param",
"labels",
":",
"... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/util/common.py#L306-L345 | [
"def",
"from_ndarray",
"(",
"cls",
",",
"features",
",",
"labels",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"if",
"isinstance",
"(",
"features",
",",
"np",
".",
"ndarray",
")",
":",
"features",
"=",
"[",
"features",
"]",
"else",
":",
"assert",
"a... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | FeatureTransformer.transform | transform ImageFeature | pyspark/bigdl/transform/vision/image.py | def transform(self, image_feature, bigdl_type="float"):
"""
transform ImageFeature
"""
callBigDlFunc(bigdl_type, "transformImageFeature", self.value, image_feature)
return image_feature | def transform(self, image_feature, bigdl_type="float"):
"""
transform ImageFeature
"""
callBigDlFunc(bigdl_type, "transformImageFeature", self.value, image_feature)
return image_feature | [
"transform",
"ImageFeature"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/transform/vision/image.py#L36-L41 | [
"def",
"transform",
"(",
"self",
",",
"image_feature",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"callBigDlFunc",
"(",
"bigdl_type",
",",
"\"transformImageFeature\"",
",",
"self",
".",
"value",
",",
"image_feature",
")",
"return",
"image_feature"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | ImageFeature.get_label | get label as ndarray from ImageFeature | pyspark/bigdl/transform/vision/image.py | def get_label(self):
"""
get label as ndarray from ImageFeature
"""
label = callBigDlFunc(self.bigdl_type, "imageFeatureToLabelTensor", self.value)
return label.to_ndarray() | def get_label(self):
"""
get label as ndarray from ImageFeature
"""
label = callBigDlFunc(self.bigdl_type, "imageFeatureToLabelTensor", self.value)
return label.to_ndarray() | [
"get",
"label",
"as",
"ndarray",
"from",
"ImageFeature"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/transform/vision/image.py#L87-L92 | [
"def",
"get_label",
"(",
"self",
")",
":",
"label",
"=",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"imageFeatureToLabelTensor\"",
",",
"self",
".",
"value",
")",
"return",
"label",
".",
"to_ndarray",
"(",
")"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | ImageFrame.read | Read images as Image Frame
if sc is defined, Read image as DistributedImageFrame from local file system or HDFS
if sc is null, Read image as LocalImageFrame from local file system
:param path path to read images
if sc is defined, path can be local or HDFS. Wildcard character are supporte... | pyspark/bigdl/transform/vision/image.py | def read(cls, path, sc=None, min_partitions=1, bigdl_type="float"):
"""
Read images as Image Frame
if sc is defined, Read image as DistributedImageFrame from local file system or HDFS
if sc is null, Read image as LocalImageFrame from local file system
:param path path to read ima... | def read(cls, path, sc=None, min_partitions=1, bigdl_type="float"):
"""
Read images as Image Frame
if sc is defined, Read image as DistributedImageFrame from local file system or HDFS
if sc is null, Read image as LocalImageFrame from local file system
:param path path to read ima... | [
"Read",
"images",
"as",
"Image",
"Frame",
"if",
"sc",
"is",
"defined",
"Read",
"image",
"as",
"DistributedImageFrame",
"from",
"local",
"file",
"system",
"or",
"HDFS",
"if",
"sc",
"is",
"null",
"Read",
"image",
"as",
"LocalImageFrame",
"from",
"local",
"file... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/transform/vision/image.py#L115-L127 | [
"def",
"read",
"(",
"cls",
",",
"path",
",",
"sc",
"=",
"None",
",",
"min_partitions",
"=",
"1",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"return",
"ImageFrame",
"(",
"jvalue",
"=",
"callBigDlFunc",
"(",
"bigdl_type",
",",
"\"read\"",
",",
"path",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | ImageFrame.read_parquet | Read parquet file as DistributedImageFrame | pyspark/bigdl/transform/vision/image.py | def read_parquet(cls, path, sc, bigdl_type="float"):
"""
Read parquet file as DistributedImageFrame
"""
return DistributedImageFrame(jvalue=callBigDlFunc(bigdl_type, "readParquet", path, sc)) | def read_parquet(cls, path, sc, bigdl_type="float"):
"""
Read parquet file as DistributedImageFrame
"""
return DistributedImageFrame(jvalue=callBigDlFunc(bigdl_type, "readParquet", path, sc)) | [
"Read",
"parquet",
"file",
"as",
"DistributedImageFrame"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/transform/vision/image.py#L130-L134 | [
"def",
"read_parquet",
"(",
"cls",
",",
"path",
",",
"sc",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"return",
"DistributedImageFrame",
"(",
"jvalue",
"=",
"callBigDlFunc",
"(",
"bigdl_type",
",",
"\"readParquet\"",
",",
"path",
",",
"sc",
")",
")"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | ImageFrame.write_parquet | write ImageFrame as parquet file | pyspark/bigdl/transform/vision/image.py | def write_parquet(cls, path, output, sc, partition_num = 1, bigdl_type="float"):
"""
write ImageFrame as parquet file
"""
return callBigDlFunc(bigdl_type, "writeParquet", path, output, sc, partition_num) | def write_parquet(cls, path, output, sc, partition_num = 1, bigdl_type="float"):
"""
write ImageFrame as parquet file
"""
return callBigDlFunc(bigdl_type, "writeParquet", path, output, sc, partition_num) | [
"write",
"ImageFrame",
"as",
"parquet",
"file"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/transform/vision/image.py#L137-L141 | [
"def",
"write_parquet",
"(",
"cls",
",",
"path",
",",
"output",
",",
"sc",
",",
"partition_num",
"=",
"1",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"return",
"callBigDlFunc",
"(",
"bigdl_type",
",",
"\"writeParquet\"",
",",
"path",
",",
"output",
","... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | ImageFrame.transform | transformImageFrame | pyspark/bigdl/transform/vision/image.py | def transform(self, transformer, bigdl_type="float"):
"""
transformImageFrame
"""
self.value = callBigDlFunc(bigdl_type,
"transformImageFrame", transformer, self.value)
return self | def transform(self, transformer, bigdl_type="float"):
"""
transformImageFrame
"""
self.value = callBigDlFunc(bigdl_type,
"transformImageFrame", transformer, self.value)
return self | [
"transformImageFrame"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/transform/vision/image.py#L155-L161 | [
"def",
"transform",
"(",
"self",
",",
"transformer",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"self",
".",
"value",
"=",
"callBigDlFunc",
"(",
"bigdl_type",
",",
"\"transformImageFrame\"",
",",
"transformer",
",",
"self",
".",
"value",
")",
"return",
"... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | ImageFrame.get_image | get image from ImageFrame | pyspark/bigdl/transform/vision/image.py | def get_image(self, float_key="floats", to_chw=True):
"""
get image from ImageFrame
"""
return self.image_frame.get_image(float_key, to_chw) | def get_image(self, float_key="floats", to_chw=True):
"""
get image from ImageFrame
"""
return self.image_frame.get_image(float_key, to_chw) | [
"get",
"image",
"from",
"ImageFrame"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/transform/vision/image.py#L163-L167 | [
"def",
"get_image",
"(",
"self",
",",
"float_key",
"=",
"\"floats\"",
",",
"to_chw",
"=",
"True",
")",
":",
"return",
"self",
".",
"image_frame",
".",
"get_image",
"(",
"float_key",
",",
"to_chw",
")"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | ImageFrame.random_split | Random split imageframes according to weights
:param weights: weights for each ImageFrame
:return: | pyspark/bigdl/transform/vision/image.py | def random_split(self, weights):
"""
Random split imageframes according to weights
:param weights: weights for each ImageFrame
:return:
"""
jvalues = self.image_frame.random_split(weights)
return [ImageFrame(jvalue) for jvalue in jvalues] | def random_split(self, weights):
"""
Random split imageframes according to weights
:param weights: weights for each ImageFrame
:return:
"""
jvalues = self.image_frame.random_split(weights)
return [ImageFrame(jvalue) for jvalue in jvalues] | [
"Random",
"split",
"imageframes",
"according",
"to",
"weights",
":",
"param",
"weights",
":",
"weights",
"for",
"each",
"ImageFrame",
":",
"return",
":"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/transform/vision/image.py#L200-L207 | [
"def",
"random_split",
"(",
"self",
",",
"weights",
")",
":",
"jvalues",
"=",
"self",
".",
"image_frame",
".",
"random_split",
"(",
"weights",
")",
"return",
"[",
"ImageFrame",
"(",
"jvalue",
")",
"for",
"jvalue",
"in",
"jvalues",
"]"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | LocalImageFrame.get_image | get image list from ImageFrame | pyspark/bigdl/transform/vision/image.py | def get_image(self, float_key="floats", to_chw=True):
"""
get image list from ImageFrame
"""
tensors = callBigDlFunc(self.bigdl_type,
"localImageFrameToImageTensor", self.value, float_key, to_chw)
return map(lambda tensor: tensor.to_ndarray(), t... | def get_image(self, float_key="floats", to_chw=True):
"""
get image list from ImageFrame
"""
tensors = callBigDlFunc(self.bigdl_type,
"localImageFrameToImageTensor", self.value, float_key, to_chw)
return map(lambda tensor: tensor.to_ndarray(), t... | [
"get",
"image",
"list",
"from",
"ImageFrame"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/transform/vision/image.py#L226-L232 | [
"def",
"get_image",
"(",
"self",
",",
"float_key",
"=",
"\"floats\"",
",",
"to_chw",
"=",
"True",
")",
":",
"tensors",
"=",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"localImageFrameToImageTensor\"",
",",
"self",
".",
"value",
",",
"float_key",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | DistributedImageFrame.get_label | get label rdd from ImageFrame | pyspark/bigdl/transform/vision/image.py | def get_label(self):
"""
get label rdd from ImageFrame
"""
tensor_rdd = callBigDlFunc(self.bigdl_type, "distributedImageFrameToLabelTensorRdd", self.value)
return tensor_rdd.map(lambda tensor: tensor.to_ndarray()) | def get_label(self):
"""
get label rdd from ImageFrame
"""
tensor_rdd = callBigDlFunc(self.bigdl_type, "distributedImageFrameToLabelTensorRdd", self.value)
return tensor_rdd.map(lambda tensor: tensor.to_ndarray()) | [
"get",
"label",
"rdd",
"from",
"ImageFrame"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/transform/vision/image.py#L283-L288 | [
"def",
"get_label",
"(",
"self",
")",
":",
"tensor_rdd",
"=",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"distributedImageFrameToLabelTensorRdd\"",
",",
"self",
".",
"value",
")",
"return",
"tensor_rdd",
".",
"map",
"(",
"lambda",
"tensor",
":",
"... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | DistributedImageFrame.get_predict | get prediction rdd from ImageFrame | pyspark/bigdl/transform/vision/image.py | def get_predict(self, key="predict"):
"""
get prediction rdd from ImageFrame
"""
predicts = callBigDlFunc(self.bigdl_type, "distributedImageFrameToPredict", self.value, key)
return predicts.map(lambda predict: (predict[0], predict[1].to_ndarray()) if predict[1] else (predict[0], ... | def get_predict(self, key="predict"):
"""
get prediction rdd from ImageFrame
"""
predicts = callBigDlFunc(self.bigdl_type, "distributedImageFrameToPredict", self.value, key)
return predicts.map(lambda predict: (predict[0], predict[1].to_ndarray()) if predict[1] else (predict[0], ... | [
"get",
"prediction",
"rdd",
"from",
"ImageFrame"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/transform/vision/image.py#L290-L295 | [
"def",
"get_predict",
"(",
"self",
",",
"key",
"=",
"\"predict\"",
")",
":",
"predicts",
"=",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"distributedImageFrameToPredict\"",
",",
"self",
".",
"value",
",",
"key",
")",
"return",
"predicts",
".",
"... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | SeqFileFolder.files_to_image_frame | Extract hadoop sequence files from an HDFS path as ImageFrame
:param url: sequence files folder path
:param sc: spark context
:param class_num: class number of data
:param partition_num: partition number, default: Engine.nodeNumber() * Engine.coreNumber() | pyspark/bigdl/transform/vision/image.py | def files_to_image_frame(cls,
url,
sc,
class_num,
partition_num=-1,
bigdl_type="float"):
"""
Extract hadoop sequence files from an HDFS path as ImageFrame
... | def files_to_image_frame(cls,
url,
sc,
class_num,
partition_num=-1,
bigdl_type="float"):
"""
Extract hadoop sequence files from an HDFS path as ImageFrame
... | [
"Extract",
"hadoop",
"sequence",
"files",
"from",
"an",
"HDFS",
"path",
"as",
"ImageFrame",
":",
"param",
"url",
":",
"sequence",
"files",
"folder",
"path",
":",
"param",
"sc",
":",
"spark",
"context",
":",
"param",
"class_num",
":",
"class",
"number",
"of... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/transform/vision/image.py#L729-L748 | [
"def",
"files_to_image_frame",
"(",
"cls",
",",
"url",
",",
"sc",
",",
"class_num",
",",
"partition_num",
"=",
"-",
"1",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"jvalue",
"=",
"callBigDlFunc",
"(",
"bigdl_type",
",",
"\"seqFilesToImageFrame\"",
",",
"... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | KerasModelWrapper.evaluate | Evaluate a model by the given metrics.
:param x: ndarray or list of ndarray for local mode.
RDD[Sample] for distributed mode
:param y: ndarray or list of ndarray for local mode and would be None for cluster mode.
:param batch_size
:param is_distributed: run in local mod... | pyspark/bigdl/keras/backend.py | def evaluate(self, x, y, batch_size=32, sample_weight=None, is_distributed=False):
"""
Evaluate a model by the given metrics.
:param x: ndarray or list of ndarray for local mode.
RDD[Sample] for distributed mode
:param y: ndarray or list of ndarray for local mode and wo... | def evaluate(self, x, y, batch_size=32, sample_weight=None, is_distributed=False):
"""
Evaluate a model by the given metrics.
:param x: ndarray or list of ndarray for local mode.
RDD[Sample] for distributed mode
:param y: ndarray or list of ndarray for local mode and wo... | [
"Evaluate",
"a",
"model",
"by",
"the",
"given",
"metrics",
".",
":",
"param",
"x",
":",
"ndarray",
"or",
"list",
"of",
"ndarray",
"for",
"local",
"mode",
".",
"RDD",
"[",
"Sample",
"]",
"for",
"distributed",
"mode",
":",
"param",
"y",
":",
"ndarray",
... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/keras/backend.py#L33-L58 | [
"def",
"evaluate",
"(",
"self",
",",
"x",
",",
"y",
",",
"batch_size",
"=",
"32",
",",
"sample_weight",
"=",
"None",
",",
"is_distributed",
"=",
"False",
")",
":",
"if",
"sample_weight",
":",
"unsupport_exp",
"(",
"\"sample_weight\"",
")",
"if",
"is_distri... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | KerasModelWrapper.predict | Generates output predictions for the input samples,
processing the samples in a batched way.
# Arguments
x: the input data, as a Numpy array or list of Numpy array for local mode.
as RDD[Sample] for distributed mode
is_distributed: used to control run in local or ... | pyspark/bigdl/keras/backend.py | def predict(self, x, batch_size=None, verbose=None, is_distributed=False):
"""Generates output predictions for the input samples,
processing the samples in a batched way.
# Arguments
x: the input data, as a Numpy array or list of Numpy array for local mode.
as RDD[Sam... | def predict(self, x, batch_size=None, verbose=None, is_distributed=False):
"""Generates output predictions for the input samples,
processing the samples in a batched way.
# Arguments
x: the input data, as a Numpy array or list of Numpy array for local mode.
as RDD[Sam... | [
"Generates",
"output",
"predictions",
"for",
"the",
"input",
"samples",
"processing",
"the",
"samples",
"in",
"a",
"batched",
"way",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/keras/backend.py#L60-L83 | [
"def",
"predict",
"(",
"self",
",",
"x",
",",
"batch_size",
"=",
"None",
",",
"verbose",
"=",
"None",
",",
"is_distributed",
"=",
"False",
")",
":",
"if",
"batch_size",
"or",
"verbose",
":",
"raise",
"Exception",
"(",
"\"we don't support batch_size or verbose ... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | KerasModelWrapper.fit | Optimize the model by the given options
:param x: ndarray or list of ndarray for local mode.
RDD[Sample] for distributed mode
:param y: ndarray or list of ndarray for local mode and would be None for cluster mode.
is_distributed: used to control run in local or cluster. th... | pyspark/bigdl/keras/backend.py | def fit(self, x, y=None, batch_size=32, nb_epoch=10, verbose=1, callbacks=None,
validation_split=0., validation_data=None, shuffle=True,
class_weight=None, sample_weight=None, initial_epoch=0, is_distributed=False):
"""Optimize the model by the given options
:param x: ndarray or... | def fit(self, x, y=None, batch_size=32, nb_epoch=10, verbose=1, callbacks=None,
validation_split=0., validation_data=None, shuffle=True,
class_weight=None, sample_weight=None, initial_epoch=0, is_distributed=False):
"""Optimize the model by the given options
:param x: ndarray or... | [
"Optimize",
"the",
"model",
"by",
"the",
"given",
"options"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/keras/backend.py#L85-L117 | [
"def",
"fit",
"(",
"self",
",",
"x",
",",
"y",
"=",
"None",
",",
"batch_size",
"=",
"32",
",",
"nb_epoch",
"=",
"10",
",",
"verbose",
"=",
"1",
",",
"callbacks",
"=",
"None",
",",
"validation_split",
"=",
"0.",
",",
"validation_data",
"=",
"None",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | DLImageTransformer.transform | Apply the transformer to the images in "inputCol" and store the transformed result
into "outputCols" | pyspark/bigdl/dlframes/dl_image_transformer.py | def transform(self, dataset):
"""
Apply the transformer to the images in "inputCol" and store the transformed result
into "outputCols"
"""
self._transfer_params_to_java()
return callBigDlFunc(self.bigdl_type, "dlImageTransform", self.value, dataset) | def transform(self, dataset):
"""
Apply the transformer to the images in "inputCol" and store the transformed result
into "outputCols"
"""
self._transfer_params_to_java()
return callBigDlFunc(self.bigdl_type, "dlImageTransform", self.value, dataset) | [
"Apply",
"the",
"transformer",
"to",
"the",
"images",
"in",
"inputCol",
"and",
"store",
"the",
"transformed",
"result",
"into",
"outputCols"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/dlframes/dl_image_transformer.py#L44-L50 | [
"def",
"transform",
"(",
"self",
",",
"dataset",
")",
":",
"self",
".",
"_transfer_params_to_java",
"(",
")",
"return",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"dlImageTransform\"",
",",
"self",
".",
"value",
",",
"dataset",
")"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | save_keras_definition | Save a Keras model definition to JSON with given path | pyspark/bigdl/examples/keras/keras_utils.py | def save_keras_definition(keras_model, path):
"""
Save a Keras model definition to JSON with given path
"""
model_json = keras_model.to_json()
with open(path, "w") as json_file:
json_file.write(model_json) | def save_keras_definition(keras_model, path):
"""
Save a Keras model definition to JSON with given path
"""
model_json = keras_model.to_json()
with open(path, "w") as json_file:
json_file.write(model_json) | [
"Save",
"a",
"Keras",
"model",
"definition",
"to",
"JSON",
"with",
"given",
"path"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/examples/keras/keras_utils.py#L20-L26 | [
"def",
"save_keras_definition",
"(",
"keras_model",
",",
"path",
")",
":",
"model_json",
"=",
"keras_model",
".",
"to_json",
"(",
")",
"with",
"open",
"(",
"path",
",",
"\"w\"",
")",
"as",
"json_file",
":",
"json_file",
".",
"write",
"(",
"model_json",
")"... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | get_mnist | Download or load MNIST dataset to/from the specified path.
Normalize and transform input data into an RDD of Sample | pyspark/bigdl/examples/keras/mnist_cnn.py | def get_mnist(sc, data_type="train", location="/tmp/mnist"):
"""
Download or load MNIST dataset to/from the specified path.
Normalize and transform input data into an RDD of Sample
"""
from bigdl.dataset import mnist
from bigdl.dataset.transformer import normalizer
(images, labels) = mnist.r... | def get_mnist(sc, data_type="train", location="/tmp/mnist"):
"""
Download or load MNIST dataset to/from the specified path.
Normalize and transform input data into an RDD of Sample
"""
from bigdl.dataset import mnist
from bigdl.dataset.transformer import normalizer
(images, labels) = mnist.r... | [
"Download",
"or",
"load",
"MNIST",
"dataset",
"to",
"/",
"from",
"the",
"specified",
"path",
".",
"Normalize",
"and",
"transform",
"input",
"data",
"into",
"an",
"RDD",
"of",
"Sample"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/examples/keras/mnist_cnn.py#L34-L48 | [
"def",
"get_mnist",
"(",
"sc",
",",
"data_type",
"=",
"\"train\"",
",",
"location",
"=",
"\"/tmp/mnist\"",
")",
":",
"from",
"bigdl",
".",
"dataset",
"import",
"mnist",
"from",
"bigdl",
".",
"dataset",
".",
"transformer",
"import",
"normalizer",
"(",
"images... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | build_keras_model | Define a convnet model in Keras 1.2.2 | pyspark/bigdl/examples/keras/mnist_cnn.py | def build_keras_model():
"""
Define a convnet model in Keras 1.2.2
"""
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Convolution2D, MaxPooling2D
keras_model = Sequential()
keras_model.add(Convolution2D(32, 3, 3,... | def build_keras_model():
"""
Define a convnet model in Keras 1.2.2
"""
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Convolution2D, MaxPooling2D
keras_model = Sequential()
keras_model.add(Convolution2D(32, 3, 3,... | [
"Define",
"a",
"convnet",
"model",
"in",
"Keras",
"1",
".",
"2",
".",
"2"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/examples/keras/mnist_cnn.py#L51-L73 | [
"def",
"build_keras_model",
"(",
")",
":",
"from",
"keras",
".",
"models",
"import",
"Sequential",
"from",
"keras",
".",
"layers",
"import",
"Dense",
",",
"Dropout",
",",
"Activation",
",",
"Flatten",
"from",
"keras",
".",
"layers",
"import",
"Convolution2D",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | SharedStaticUtils.load | Load a pre-trained Bigdl model.
:param path: The path containing the pre-trained model.
:return: A pre-trained model. | pyspark/bigdl/nn/layer.py | def load(path, bigdl_type="float"):
"""
Load a pre-trained Bigdl model.
:param path: The path containing the pre-trained model.
:return: A pre-trained model.
"""
jmodel = callBigDlFunc(bigdl_type, "loadBigDL", path)
return Layer.of(jmodel) | def load(path, bigdl_type="float"):
"""
Load a pre-trained Bigdl model.
:param path: The path containing the pre-trained model.
:return: A pre-trained model.
"""
jmodel = callBigDlFunc(bigdl_type, "loadBigDL", path)
return Layer.of(jmodel) | [
"Load",
"a",
"pre",
"-",
"trained",
"Bigdl",
"model",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L68-L76 | [
"def",
"load",
"(",
"path",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"jmodel",
"=",
"callBigDlFunc",
"(",
"bigdl_type",
",",
"\"loadBigDL\"",
",",
"path",
")",
"return",
"Layer",
".",
"of",
"(",
"jmodel",
")"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | SharedStaticUtils.of | Create a Python Layer base on the given java value and the real type.
:param jvalue: Java object create by Py4j
:return: A Python Layer | pyspark/bigdl/nn/layer.py | def of(jvalue, bigdl_type="float"):
"""
Create a Python Layer base on the given java value and the real type.
:param jvalue: Java object create by Py4j
:return: A Python Layer
"""
def get_py_name(jclass_name):
if jclass_name == "StaticGraph" or jclass_name == ... | def of(jvalue, bigdl_type="float"):
"""
Create a Python Layer base on the given java value and the real type.
:param jvalue: Java object create by Py4j
:return: A Python Layer
"""
def get_py_name(jclass_name):
if jclass_name == "StaticGraph" or jclass_name == ... | [
"Create",
"a",
"Python",
"Layer",
"base",
"on",
"the",
"given",
"java",
"value",
"and",
"the",
"real",
"type",
".",
":",
"param",
"jvalue",
":",
"Java",
"object",
"create",
"by",
"Py4j",
":",
"return",
":",
"A",
"Python",
"Layer"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L80-L115 | [
"def",
"of",
"(",
"jvalue",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"def",
"get_py_name",
"(",
"jclass_name",
")",
":",
"if",
"jclass_name",
"==",
"\"StaticGraph\"",
"or",
"jclass_name",
"==",
"\"DynamicGraph\"",
":",
"return",
"\"Model\"",
"elif",
"jcl... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.set_running_mean | Set the running mean of the layer.
Only use this method for a BatchNormalization layer.
:param running_mean: a Numpy array. | pyspark/bigdl/nn/layer.py | def set_running_mean(self, running_mean):
"""
Set the running mean of the layer.
Only use this method for a BatchNormalization layer.
:param running_mean: a Numpy array.
"""
callBigDlFunc(self.bigdl_type, "setRunningMean",
self.value, JTensor.from_nd... | def set_running_mean(self, running_mean):
"""
Set the running mean of the layer.
Only use this method for a BatchNormalization layer.
:param running_mean: a Numpy array.
"""
callBigDlFunc(self.bigdl_type, "setRunningMean",
self.value, JTensor.from_nd... | [
"Set",
"the",
"running",
"mean",
"of",
"the",
"layer",
".",
"Only",
"use",
"this",
"method",
"for",
"a",
"BatchNormalization",
"layer",
".",
":",
"param",
"running_mean",
":",
"a",
"Numpy",
"array",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L134-L142 | [
"def",
"set_running_mean",
"(",
"self",
",",
"running_mean",
")",
":",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"setRunningMean\"",
",",
"self",
".",
"value",
",",
"JTensor",
".",
"from_ndarray",
"(",
"running_mean",
")",
")",
"return",
"self"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.set_running_std | Set the running variance of the layer.
Only use this method for a BatchNormalization layer.
:param running_std: a Numpy array. | pyspark/bigdl/nn/layer.py | def set_running_std(self, running_std):
"""
Set the running variance of the layer.
Only use this method for a BatchNormalization layer.
:param running_std: a Numpy array.
"""
callBigDlFunc(self.bigdl_type, "setRunningStd",
self.value, JTensor.from_nd... | def set_running_std(self, running_std):
"""
Set the running variance of the layer.
Only use this method for a BatchNormalization layer.
:param running_std: a Numpy array.
"""
callBigDlFunc(self.bigdl_type, "setRunningStd",
self.value, JTensor.from_nd... | [
"Set",
"the",
"running",
"variance",
"of",
"the",
"layer",
".",
"Only",
"use",
"this",
"method",
"for",
"a",
"BatchNormalization",
"layer",
".",
":",
"param",
"running_std",
":",
"a",
"Numpy",
"array",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L144-L152 | [
"def",
"set_running_std",
"(",
"self",
",",
"running_std",
")",
":",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"setRunningStd\"",
",",
"self",
".",
"value",
",",
"JTensor",
".",
"from_ndarray",
"(",
"running_std",
")",
")",
"return",
"self"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.from_jvalue | Create a Python Model base on the given java value
:param jvalue: Java object create by Py4j
:return: A Python Model | pyspark/bigdl/nn/layer.py | def from_jvalue(jvalue, bigdl_type="float"):
"""
Create a Python Model base on the given java value
:param jvalue: Java object create by Py4j
:return: A Python Model
"""
model = Layer(jvalue=jvalue, bigdl_type=bigdl_type)
model.value = jvalue
return model | def from_jvalue(jvalue, bigdl_type="float"):
"""
Create a Python Model base on the given java value
:param jvalue: Java object create by Py4j
:return: A Python Model
"""
model = Layer(jvalue=jvalue, bigdl_type=bigdl_type)
model.value = jvalue
return model | [
"Create",
"a",
"Python",
"Model",
"base",
"on",
"the",
"given",
"java",
"value",
":",
"param",
"jvalue",
":",
"Java",
"object",
"create",
"by",
"Py4j",
":",
"return",
":",
"A",
"Python",
"Model"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L177-L185 | [
"def",
"from_jvalue",
"(",
"jvalue",
",",
"bigdl_type",
"=",
"\"float\"",
")",
":",
"model",
"=",
"Layer",
"(",
"jvalue",
"=",
"jvalue",
",",
"bigdl_type",
"=",
"bigdl_type",
")",
"model",
".",
"value",
"=",
"jvalue",
"return",
"model"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.check_input | :param input: ndarray or list of ndarray or JTensor or list of JTensor.
:return: (list of JTensor, isTable) | pyspark/bigdl/nn/layer.py | def check_input(input):
"""
:param input: ndarray or list of ndarray or JTensor or list of JTensor.
:return: (list of JTensor, isTable)
"""
def to_jtensor(i):
if isinstance(i, np.ndarray):
return JTensor.from_ndarray(i)
elif isinstance(i, J... | def check_input(input):
"""
:param input: ndarray or list of ndarray or JTensor or list of JTensor.
:return: (list of JTensor, isTable)
"""
def to_jtensor(i):
if isinstance(i, np.ndarray):
return JTensor.from_ndarray(i)
elif isinstance(i, J... | [
":",
"param",
"input",
":",
"ndarray",
"or",
"list",
"of",
"ndarray",
"or",
"JTensor",
"or",
"list",
"of",
"JTensor",
".",
":",
"return",
":",
"(",
"list",
"of",
"JTensor",
"isTable",
")"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L218-L235 | [
"def",
"check_input",
"(",
"input",
")",
":",
"def",
"to_jtensor",
"(",
"i",
")",
":",
"if",
"isinstance",
"(",
"i",
",",
"np",
".",
"ndarray",
")",
":",
"return",
"JTensor",
".",
"from_ndarray",
"(",
"i",
")",
"elif",
"isinstance",
"(",
"i",
",",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.forward | NB: It's for debug only, please use optimizer.optimize() in production.
Takes an input object, and computes the corresponding output of the module
:param input: ndarray or list of ndarray
:param input: ndarray or list of ndarray or JTensor or list of JTensor.
:return: ndarray or list of... | pyspark/bigdl/nn/layer.py | def forward(self, input):
"""
NB: It's for debug only, please use optimizer.optimize() in production.
Takes an input object, and computes the corresponding output of the module
:param input: ndarray or list of ndarray
:param input: ndarray or list of ndarray or JTensor or list o... | def forward(self, input):
"""
NB: It's for debug only, please use optimizer.optimize() in production.
Takes an input object, and computes the corresponding output of the module
:param input: ndarray or list of ndarray
:param input: ndarray or list of ndarray or JTensor or list o... | [
"NB",
":",
"It",
"s",
"for",
"debug",
"only",
"please",
"use",
"optimizer",
".",
"optimize",
"()",
"in",
"production",
".",
"Takes",
"an",
"input",
"object",
"and",
"computes",
"the",
"corresponding",
"output",
"of",
"the",
"module"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L246-L261 | [
"def",
"forward",
"(",
"self",
",",
"input",
")",
":",
"jinput",
",",
"input_is_table",
"=",
"self",
".",
"check_input",
"(",
"input",
")",
"output",
"=",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"modelForward\"",
",",
"self",
".",
"value",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.backward | NB: It's for debug only, please use optimizer.optimize() in production.
Performs a back-propagation step through the module, with respect to the given input. In
general this method makes the assumption forward(input) has been called before, with the same
input. This is necessary for optimization... | pyspark/bigdl/nn/layer.py | def backward(self, input, grad_output):
"""
NB: It's for debug only, please use optimizer.optimize() in production.
Performs a back-propagation step through the module, with respect to the given input. In
general this method makes the assumption forward(input) has been called before, wit... | def backward(self, input, grad_output):
"""
NB: It's for debug only, please use optimizer.optimize() in production.
Performs a back-propagation step through the module, with respect to the given input. In
general this method makes the assumption forward(input) has been called before, wit... | [
"NB",
":",
"It",
"s",
"for",
"debug",
"only",
"please",
"use",
"optimizer",
".",
"optimize",
"()",
"in",
"production",
".",
"Performs",
"a",
"back",
"-",
"propagation",
"step",
"through",
"the",
"module",
"with",
"respect",
"to",
"the",
"given",
"input",
... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L263-L284 | [
"def",
"backward",
"(",
"self",
",",
"input",
",",
"grad_output",
")",
":",
"jinput",
",",
"input_is_table",
"=",
"self",
".",
"check_input",
"(",
"input",
")",
"jgrad_output",
",",
"grad_output_is_table",
"=",
"self",
".",
"check_input",
"(",
"grad_output",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.parameters | Get the model parameters which containing: weight, bias, gradBias, gradWeight
:return: dict(layername -> dict(parametername -> ndarray)) | pyspark/bigdl/nn/layer.py | def parameters(self):
"""
Get the model parameters which containing: weight, bias, gradBias, gradWeight
:return: dict(layername -> dict(parametername -> ndarray))
"""
name_to_params = callBigDlFunc(self.bigdl_type,
"modelGetParameters",
... | def parameters(self):
"""
Get the model parameters which containing: weight, bias, gradBias, gradWeight
:return: dict(layername -> dict(parametername -> ndarray))
"""
name_to_params = callBigDlFunc(self.bigdl_type,
"modelGetParameters",
... | [
"Get",
"the",
"model",
"parameters",
"which",
"containing",
":",
"weight",
"bias",
"gradBias",
"gradWeight"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L310-L327 | [
"def",
"parameters",
"(",
"self",
")",
":",
"name_to_params",
"=",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"modelGetParameters\"",
",",
"self",
".",
"value",
")",
"def",
"to_ndarray",
"(",
"params",
")",
":",
"return",
"dict",
"(",
"(",
"pa... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.evaluate | No argument passed in:
Evaluate the model to set train = false, useful when doing test/forward
:return: layer itself
Three arguments passed in:
A method to benchmark the model quality.
:param dataset: the input data
:param batch_size: batch size
:param val_metho... | pyspark/bigdl/nn/layer.py | def evaluate(self, *args):
"""
No argument passed in:
Evaluate the model to set train = false, useful when doing test/forward
:return: layer itself
Three arguments passed in:
A method to benchmark the model quality.
:param dataset: the input data
:param ... | def evaluate(self, *args):
"""
No argument passed in:
Evaluate the model to set train = false, useful when doing test/forward
:return: layer itself
Three arguments passed in:
A method to benchmark the model quality.
:param dataset: the input data
:param ... | [
"No",
"argument",
"passed",
"in",
":",
"Evaluate",
"the",
"model",
"to",
"set",
"train",
"=",
"false",
"useful",
"when",
"doing",
"test",
"/",
"forward",
":",
"return",
":",
"layer",
"itself"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L329-L360 | [
"def",
"evaluate",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"evaluate\"",
",",
"self",
".",
"value",
")",
"return",
"self",
"elif",
"len",
"(",
"... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.predict_local | :param X: X can be a ndarray or list of ndarray if the model has multiple inputs.
The first dimension of X should be batch.
:param batch_size: total batch size of prediction.
:return: a ndarray as the prediction result. | pyspark/bigdl/nn/layer.py | def predict_local(self, X, batch_size = -1):
"""
:param X: X can be a ndarray or list of ndarray if the model has multiple inputs.
The first dimension of X should be batch.
:param batch_size: total batch size of prediction.
:return: a ndarray as the prediction result.
... | def predict_local(self, X, batch_size = -1):
"""
:param X: X can be a ndarray or list of ndarray if the model has multiple inputs.
The first dimension of X should be batch.
:param batch_size: total batch size of prediction.
:return: a ndarray as the prediction result.
... | [
":",
"param",
"X",
":",
"X",
"can",
"be",
"a",
"ndarray",
"or",
"list",
"of",
"ndarray",
"if",
"the",
"model",
"has",
"multiple",
"inputs",
".",
"The",
"first",
"dimension",
"of",
"X",
"should",
"be",
"batch",
".",
":",
"param",
"batch_size",
":",
"t... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L372-L386 | [
"def",
"predict_local",
"(",
"self",
",",
"X",
",",
"batch_size",
"=",
"-",
"1",
")",
":",
"jresults",
"=",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"predictLocal\"",
",",
"self",
".",
"value",
",",
"self",
".",
"_to_jtensors",
"(",
"X",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.predict | Model inference base on the given data.
:param features: it can be a ndarray or list of ndarray for locally inference
or RDD[Sample] for running in distributed fashion
:param batch_size: total batch size of prediction.
:return: ndarray or RDD[Sample] depend on the the ty... | pyspark/bigdl/nn/layer.py | def predict(self, features, batch_size = -1):
"""
Model inference base on the given data.
:param features: it can be a ndarray or list of ndarray for locally inference
or RDD[Sample] for running in distributed fashion
:param batch_size: total batch size of predic... | def predict(self, features, batch_size = -1):
"""
Model inference base on the given data.
:param features: it can be a ndarray or list of ndarray for locally inference
or RDD[Sample] for running in distributed fashion
:param batch_size: total batch size of predic... | [
"Model",
"inference",
"base",
"on",
"the",
"given",
"data",
".",
":",
"param",
"features",
":",
"it",
"can",
"be",
"a",
"ndarray",
"or",
"list",
"of",
"ndarray",
"for",
"locally",
"inference",
"or",
"RDD",
"[",
"Sample",
"]",
"for",
"running",
"in",
"d... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L401-L412 | [
"def",
"predict",
"(",
"self",
",",
"features",
",",
"batch_size",
"=",
"-",
"1",
")",
":",
"if",
"isinstance",
"(",
"features",
",",
"RDD",
")",
":",
"return",
"self",
".",
"predict_distributed",
"(",
"features",
",",
"batch_size",
")",
"else",
":",
"... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.predict_class | Model inference base on the given data which returning label
:param features: it can be a ndarray or list of ndarray for locally inference
or RDD[Sample] for running in distributed fashion
:return: ndarray or RDD[Sample] depend on the the type of features. | pyspark/bigdl/nn/layer.py | def predict_class(self, features):
"""
Model inference base on the given data which returning label
:param features: it can be a ndarray or list of ndarray for locally inference
or RDD[Sample] for running in distributed fashion
:return: ndarray or RDD[Sample] dep... | def predict_class(self, features):
"""
Model inference base on the given data which returning label
:param features: it can be a ndarray or list of ndarray for locally inference
or RDD[Sample] for running in distributed fashion
:return: ndarray or RDD[Sample] dep... | [
"Model",
"inference",
"base",
"on",
"the",
"given",
"data",
"which",
"returning",
"label",
":",
"param",
"features",
":",
"it",
"can",
"be",
"a",
"ndarray",
"or",
"list",
"of",
"ndarray",
"for",
"locally",
"inference",
"or",
"RDD",
"[",
"Sample",
"]",
"f... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L414-L424 | [
"def",
"predict_class",
"(",
"self",
",",
"features",
")",
":",
"if",
"isinstance",
"(",
"features",
",",
"RDD",
")",
":",
"return",
"self",
".",
"predict_class_distributed",
"(",
"features",
")",
"else",
":",
"return",
"self",
".",
"predict_class_local",
"(... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.predict_distributed | Model inference base on the given data.
You need to invoke collect() to trigger those action \
as the returning result is an RDD.
:param data_rdd: the data to be predict.
:param batch_size: total batch size of prediction.
:return: An RDD represent the predict result. | pyspark/bigdl/nn/layer.py | def predict_distributed(self, data_rdd, batch_size = -1):
"""
Model inference base on the given data.
You need to invoke collect() to trigger those action \
as the returning result is an RDD.
:param data_rdd: the data to be predict.
:param batch_size: total batch size of... | def predict_distributed(self, data_rdd, batch_size = -1):
"""
Model inference base on the given data.
You need to invoke collect() to trigger those action \
as the returning result is an RDD.
:param data_rdd: the data to be predict.
:param batch_size: total batch size of... | [
"Model",
"inference",
"base",
"on",
"the",
"given",
"data",
".",
"You",
"need",
"to",
"invoke",
"collect",
"()",
"to",
"trigger",
"those",
"action",
"\\",
"as",
"the",
"returning",
"result",
"is",
"an",
"RDD",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L426-L438 | [
"def",
"predict_distributed",
"(",
"self",
",",
"data_rdd",
",",
"batch_size",
"=",
"-",
"1",
")",
":",
"result",
"=",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"modelPredictRDD\"",
",",
"self",
".",
"value",
",",
"data_rdd",
",",
"batch_size",... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.predict_class_distributed | module predict, return the predict label
:param data_rdd: the data to be predict.
:return: An RDD represent the predict label. | pyspark/bigdl/nn/layer.py | def predict_class_distributed(self, data_rdd):
"""
module predict, return the predict label
:param data_rdd: the data to be predict.
:return: An RDD represent the predict label.
"""
result = callBigDlFunc(self.bigdl_type,
"modelPredictClass... | def predict_class_distributed(self, data_rdd):
"""
module predict, return the predict label
:param data_rdd: the data to be predict.
:return: An RDD represent the predict label.
"""
result = callBigDlFunc(self.bigdl_type,
"modelPredictClass... | [
"module",
"predict",
"return",
"the",
"predict",
"label"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L440-L449 | [
"def",
"predict_class_distributed",
"(",
"self",
",",
"data_rdd",
")",
":",
"result",
"=",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"modelPredictClass\"",
",",
"self",
".",
"value",
",",
"data_rdd",
")",
"return",
"result"
] | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.predict_image | model predict images, return imageFrame with predicted tensor
:param image_frame imageFrame that contains images
:param output_layer if output_layer is not null, the output of layer that matches
output_layer will be used as predicted output
:param share_buffer whether to share same memor... | pyspark/bigdl/nn/layer.py | def predict_image(self, image_frame, output_layer=None, share_buffer=False,
batch_per_partition=4, predict_key="predict"):
"""
model predict images, return imageFrame with predicted tensor
:param image_frame imageFrame that contains images
:param output_layer if out... | def predict_image(self, image_frame, output_layer=None, share_buffer=False,
batch_per_partition=4, predict_key="predict"):
"""
model predict images, return imageFrame with predicted tensor
:param image_frame imageFrame that contains images
:param output_layer if out... | [
"model",
"predict",
"images",
"return",
"imageFrame",
"with",
"predicted",
"tensor",
":",
"param",
"image_frame",
"imageFrame",
"that",
"contains",
"images",
":",
"param",
"output_layer",
"if",
"output_layer",
"is",
"not",
"null",
"the",
"output",
"of",
"layer",
... | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L451-L469 | [
"def",
"predict_image",
"(",
"self",
",",
"image_frame",
",",
"output_layer",
"=",
"None",
",",
"share_buffer",
"=",
"False",
",",
"batch_per_partition",
"=",
"4",
",",
"predict_key",
"=",
"\"predict\"",
")",
":",
"image_frame",
"=",
"callBigDlFunc",
"(",
"sel... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.set_weights | Set weights for this layer
:param weights: a list of numpy arrays which represent weight and bias
:return:
>>> linear = Linear(3,2)
creating: createLinear
>>> linear.set_weights([np.array([[1,2,3],[4,5,6]]), np.array([7,8])])
>>> weights = linear.get_weights()
>... | pyspark/bigdl/nn/layer.py | def set_weights(self, weights):
"""
Set weights for this layer
:param weights: a list of numpy arrays which represent weight and bias
:return:
>>> linear = Linear(3,2)
creating: createLinear
>>> linear.set_weights([np.array([[1,2,3],[4,5,6]]), np.array([7,8])])
... | def set_weights(self, weights):
"""
Set weights for this layer
:param weights: a list of numpy arrays which represent weight and bias
:return:
>>> linear = Linear(3,2)
creating: createLinear
>>> linear.set_weights([np.array([[1,2,3],[4,5,6]]), np.array([7,8])])
... | [
"Set",
"weights",
"for",
"this",
"layer"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L471-L512 | [
"def",
"set_weights",
"(",
"self",
",",
"weights",
")",
":",
"tensors",
"=",
"[",
"JTensor",
".",
"from_ndarray",
"(",
"param",
",",
"self",
".",
"bigdl_type",
")",
"for",
"param",
"in",
"to_list",
"(",
"weights",
")",
"]",
"callBigDlFunc",
"(",
"self",
... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.get_weights | Get weights for this layer
:return: list of numpy arrays which represent weight and bias | pyspark/bigdl/nn/layer.py | def get_weights(self):
"""
Get weights for this layer
:return: list of numpy arrays which represent weight and bias
"""
tensorWeights = callBigDlFunc(self.bigdl_type,
"getWeights", self.value)
if tensorWeights is not None:
return... | def get_weights(self):
"""
Get weights for this layer
:return: list of numpy arrays which represent weight and bias
"""
tensorWeights = callBigDlFunc(self.bigdl_type,
"getWeights", self.value)
if tensorWeights is not None:
return... | [
"Get",
"weights",
"for",
"this",
"layer"
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L514-L526 | [
"def",
"get_weights",
"(",
"self",
")",
":",
"tensorWeights",
"=",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"getWeights\"",
",",
"self",
".",
"value",
")",
"if",
"tensorWeights",
"is",
"not",
"None",
":",
"return",
"[",
"tensor",
".",
"to_nd... | e9c19788285986ab789a2e2998f9a85d7524779f |
test | Layer.save_tensorflow | Save a model to protobuf files so that it can be used in tensorflow inference.
When saving the model, placeholders will be added to the tf model as input nodes. So
you need to pass in the names and shapes of the placeholders. BigDL model doesn't have
such information. The order of the placehold... | pyspark/bigdl/nn/layer.py | def save_tensorflow(self, inputs, path, byte_order="little_endian", data_format="nhwc"):
"""
Save a model to protobuf files so that it can be used in tensorflow inference.
When saving the model, placeholders will be added to the tf model as input nodes. So
you need to pass in the names ... | def save_tensorflow(self, inputs, path, byte_order="little_endian", data_format="nhwc"):
"""
Save a model to protobuf files so that it can be used in tensorflow inference.
When saving the model, placeholders will be added to the tf model as input nodes. So
you need to pass in the names ... | [
"Save",
"a",
"model",
"to",
"protobuf",
"files",
"so",
"that",
"it",
"can",
"be",
"used",
"in",
"tensorflow",
"inference",
"."
] | intel-analytics/BigDL | python | https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/nn/layer.py#L543-L557 | [
"def",
"save_tensorflow",
"(",
"self",
",",
"inputs",
",",
"path",
",",
"byte_order",
"=",
"\"little_endian\"",
",",
"data_format",
"=",
"\"nhwc\"",
")",
":",
"callBigDlFunc",
"(",
"self",
".",
"bigdl_type",
",",
"\"saveTF\"",
",",
"self",
".",
"value",
",",... | e9c19788285986ab789a2e2998f9a85d7524779f |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.