How to use the bigdl.util.common.JTensor.from_ndarray function in bigdl

To help you get started, we’ve selected a few bigdl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github intel-analytics / BigDL / pyspark / bigdl / nn / layer.py View on Github external
bias_regularizer=None,
                 init_weight=None,
                 init_bias=None,
                 init_grad_weight=None,
                 init_grad_bias=None,
                 bigdl_type="float"):
        super(TemporalConvolution, self).__init__(None, bigdl_type,
                                                 input_frame_size,
                                                 output_frame_size,
                                                 kernel_w,
                                                 stride_w,
                                                 propagate_back,
                                                 weight_regularizer,
                                                 bias_regularizer,
                                                 JTensor.from_ndarray(init_weight),
                                                 JTensor.from_ndarray(init_bias),
                                                 JTensor.from_ndarray(init_grad_weight),
                                                 JTensor.from_ndarray(init_grad_bias))
    def set_init_method(self, weight_init_method = None, bias_init_method = None):
github intel-analytics / BigDL / pyspark / bigdl / nn / layer.py View on Github external
def __init__(self,
                 n_input_plane=1,
                 kernel=None,
                 threshold=1e-4,
                 thresval=1e-4,
                 bigdl_type="float"):
        super(SpatialDivisiveNormalization, self).__init__(None, bigdl_type,
                                                           n_input_plane,
                                                           JTensor.from_ndarray(kernel),
                                                           threshold,
                                                           thresval)
github intel-analytics / BigDL / pyspark / bigdl / nn / layer.py View on Github external
with_bias=True,
                 bigdl_type="float"):
        super(SpatialShareConvolution, self).__init__(None, bigdl_type,
                                                      n_input_plane,
                                                      n_output_plane,
                                                      kernel_w,
                                                      kernel_h,
                                                      stride_w,
                                                      stride_h,
                                                      pad_w,
                                                      pad_h,
                                                      n_group,
                                                      propagate_back,
                                                      wRegularizer,
                                                      bRegularizer,
                                                      JTensor.from_ndarray(init_weight),
                                                      JTensor.from_ndarray(init_bias),
                                                      JTensor.from_ndarray(init_grad_weight),
                                                      JTensor.from_ndarray(init_grad_bias),
                                                      with_bias)
    def set_init_method(self, weight_init_method = None, bias_init_method = None):
github intel-analytics / BigDL / pyspark / bigdl / nn / onnx / layer.py View on Github external
def __init__(self, value, bigdl_type="float"):
        super(Constant, self).__init__(None, bigdl_type, JTensor.from_ndarray(value))
github intel-analytics / BigDL / pyspark / bigdl / nn / layer.py View on Github external
The layer does not have weight/bias
        >>> add = Add(2)
        creating: createAdd
        >>> try:
        ...     add.set_weights([np.array([7,8]), np.array([1,2])])
        ... except Py4JJavaError as err:
        ...     print(err.java_exception)
        ...
        java.lang.IllegalArgumentException: requirement failed: the number of input weight/bias is not consistant with number of weight/bias of this layer
        >>> cAdd = CAdd([4, 1])
        creating: createCAdd
        >>> cAdd.set_weights(np.ones([4, 1]))
        >>> (cAdd.get_weights()[0] == np.ones([4, 1])).all()
        True
        """
        tensors = [JTensor.from_ndarray(param, self.bigdl_type) for param in to_list(weights)]
        callBigDlFunc(self.bigdl_type, "setWeights", self.value, tensors)
github intel-analytics / BigDL / pyspark / bigdl / nn / layer.py View on Github external
def __init__(self,
                 n_input_plane=1,
                 kernel=None,
                 bigdl_type="float"):
        super(SpatialSubtractiveNormalization, self).__init__(None, bigdl_type,
                                                              n_input_plane,
                                                              JTensor.from_ndarray(kernel))
github intel-analytics / BigDL / pyspark / bigdl / nn / criterion.py View on Github external
def __init__(self,
                 weights=None,
                 size_average=True,
                 logProbAsInput=True,
                 bigdl_type="float"):
        super(ClassNLLCriterion, self).__init__(None, bigdl_type,
                                                JTensor.from_ndarray(weights),
                                                size_average, logProbAsInput)
github intel-analytics / BigDL / pyspark / bigdl / nn / layer.py View on Github external
def __init__(self, input_size, output_size, with_bias=True, wRegularizer=None, bRegularizer=None,
                 init_weight=None, init_bias=None, init_grad_weight=None, init_grad_bias=None, bigdl_type="float"):
        super(Linear, self).__init__(None, bigdl_type, input_size, output_size,
                                     with_bias, wRegularizer, bRegularizer,
                                     JTensor.from_ndarray(init_weight),
                                     JTensor.from_ndarray(init_bias),
                                     JTensor.from_ndarray(init_grad_weight),
                                     JTensor.from_ndarray(init_grad_bias))