bigdl.util package

Submodules

bigdl.util.common module

class bigdl.util.common.JTensor(storage, shape, bigdl_type='float')[source]

Bases: object

A wrapper to easy our work when need to pass or return Tensor to/from Scala.

>>> import numpy as np
>>> from bigdl.util.common import JTensor
>>> np.random.seed(123)
>>>
classmethod flatten_ndarray(a_ndarray)[source]

Utility method to flatten a ndarray

Returns:(storage, shape)
>>> from bigdl.util.common import JTensor
>>> np.random.seed(123)
>>> data = np.random.uniform(0, 1, (2, 3))
>>> (storage, shape) = JTensor.flatten_ndarray(data)
>>> shape
[2, 3]
>>> (storage, shape) = JTensor.flatten_ndarray(np.array(2))
>>> shape
[1]
classmethod from_ndarray(a_ndarray, bigdl_type='float')[source]

Convert a ndarray to Tensor 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")
>>> result = JTensor.from_ndarray(data)
>>> data_back = result.to_ndarray()
>>> (data == data_back).all()
True
>>> tensor1 = callBigDlFunc("float", "testTensor", JTensor.from_ndarray(data))  # noqa
>>> array_from_tensor = tensor1.to_ndarray()
>>> (array_from_tensor == data).all()
True
to_ndarray()[source]
class bigdl.util.common.JavaCreator(bigdl_type)[source]

Bases: bigdl.util.common.SingletonMixin

classmethod get_creator_class()[source]
classmethod set_creator_class(cclass)[source]
class bigdl.util.common.JavaValue(jvalue, bigdl_type, *args)[source]

Bases: object

jvm_class_constructor()[source]
class bigdl.util.common.RNG(bigdl_type='float')[source]

generate tensor data with seed

set_seed(seed)[source]
uniform(a, b, size)[source]
class bigdl.util.common.Sample(features, label, features_shape, label_shape, bigdl_type='float')[source]

Bases: object

classmethod from_ndarray(features, label, bigdl_type='float')[source]
class bigdl.util.common.SingletonMixin[source]

Bases: object

classmethod instance(bigdl_type='float')[source]
class bigdl.util.common.TestResult(result, total_num, method)[source]

A testing result used to benchmark the model quality.

bigdl.util.common.callBigDlFunc(bigdl_type, name, *args)[source]

Call API in PythonBigDL

bigdl.util.common.callJavaFunc(sc, func, *args)[source]

Call Java Function

bigdl.util.common.create_spark_conf()[source]
bigdl.util.common.get_bigdl_conf()[source]
bigdl.util.common.get_spark_context(conf=None)[source]

Get the current active spark context and create one if no active instance :param conf: combining bigdl configs into spark conf :return: SparkContext

bigdl.util.common.get_spark_sql_context(sc)[source]
bigdl.util.common.init_engine(bigdl_type='float')[source]
bigdl.util.common.to_list(a)[source]

bigdl.util.engine module

bigdl.util.engine.prepare_env()[source]

bigdl.util.tf_utils module

Module contents