How to use the bigdl.nn.layer.Layer.check_input 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 / analytics-zoo / pyzoo / zoo / models / seq2seq / seq2seq.py View on Github external
def infer(self, input, start_sign, max_seq_len=30, stop_sign=None, build_output=None):
        """
        Inference API for given input

        # Arguments
        input: a sequence of data feed into encoder, eg: batch x seqLen x featureSize
        start_sign: a ndarray which represents start and is fed into decoder
        max_seq_len: max sequence length for final output
        stop_sign: a ndarray that indicates model should stop infer further if current output
        is the same with stopSign
        build_output: Feeding model output to buildOutput to generate final result
        """
        jinput, input_is_table = Layer.check_input(input)
        assert not input_is_table
        jstart_sign, start_sign_is_table = Layer.check_input(start_sign)
        assert not start_sign_is_table
        if stop_sign:
            jstop_sign, stop_sign_is_table = Layer.check_input(stop_sign)
            assert not start_sign_is_table
        else:
            jstop_sign = None
        results = callZooFunc(self.bigdl_type, "seq2seqInfer",
                              self.value,
                              jinput[0],
                              jstart_sign[0],
                              max_seq_len,
                              jstop_sign[0] if jstop_sign else None,
                              build_output)
        return results
github intel-analytics / analytics-zoo / pyzoo / zoo / pipeline / api / autograd.py View on Github external
def forward(self, y_true, y_pred):
        """
        NB: It's for debug only, please use optimizer.optimize() in production.
        Takes an input object, and computes the corresponding loss of the criterion,
        compared with `target`

        :param input: ndarray or list of ndarray
        :param target: ndarray or list of ndarray
        :return: value of loss
        """
        input = y_pred
        target = y_true
        jinput, input_is_table = Layer.check_input(input)
        jtarget, target_is_table = Layer.check_input(target)
        output = callZooFunc(self.bigdl_type,
                             "criterionForward",
                             self.value,
                             jinput,
                             input_is_table,
                             jtarget,
                             target_is_table)
        return output
github intel-analytics / BigDL / pyspark / bigdl / nn / criterion.py View on Github external
def forward(self, input, target):
        """
        NB: It's for debug only, please use optimizer.optimize() in production.
        Takes an input object, and computes the corresponding loss of the criterion,
        compared with `target`

        :param input: ndarray or list of ndarray
        :param target: ndarray or list of ndarray
        :return: value of loss
        """
        jinput, input_is_table = Layer.check_input(input)
        jtarget, target_is_table = Layer.check_input(target)
        output = callBigDlFunc(self.bigdl_type,
                               "criterionForward",
                               self.value,
                               jinput,
                               input_is_table,
                               jtarget,
                               target_is_table)
        return output
github intel-analytics / analytics-zoo / pyzoo / zoo / pipeline / api / autograd.py View on Github external
def backward(self, y_true, y_pred):
        """
        NB: It's for debug only, please use optimizer.optimize() in production.
        Performs a back-propagation step through the criterion, with respect to the given input.

        :param input: ndarray or list of ndarray
        :param target: ndarray or list of ndarray
        :return: ndarray
        """
        input = y_pred
        target = y_true
        jinput, input_is_table = Layer.check_input(input)
        jtarget, target_is_table = Layer.check_input(target)
        output = callZooFunc(self.bigdl_type,
                             "criterionBackward",
                             self.value,
                             jinput,
                             input_is_table,
                             jtarget,
                             target_is_table)
        return Layer.convert_output(output)
github intel-analytics / analytics-zoo / pyzoo / zoo / models / seq2seq / seq2seq.py View on Github external
def infer(self, input, start_sign, max_seq_len=30, stop_sign=None, build_output=None):
        """
        Inference API for given input

        # Arguments
        input: a sequence of data feed into encoder, eg: batch x seqLen x featureSize
        start_sign: a ndarray which represents start and is fed into decoder
        max_seq_len: max sequence length for final output
        stop_sign: a ndarray that indicates model should stop infer further if current output
        is the same with stopSign
        build_output: Feeding model output to buildOutput to generate final result
        """
        jinput, input_is_table = Layer.check_input(input)
        assert not input_is_table
        jstart_sign, start_sign_is_table = Layer.check_input(start_sign)
        assert not start_sign_is_table
        if stop_sign:
            jstop_sign, stop_sign_is_table = Layer.check_input(stop_sign)
            assert not start_sign_is_table
        else:
            jstop_sign = None
        results = callZooFunc(self.bigdl_type, "seq2seqInfer",
                              self.value,
                              jinput[0],
                              jstart_sign[0],
                              max_seq_len,
                              jstop_sign[0] if jstop_sign else None,
                              build_output)
        return results
github intel-analytics / analytics-zoo / pyzoo / zoo / pipeline / inference / inference_model.py View on Github external
def predict(self, inputs):
        """
        Do prediction on inputs.

        :param inputs: A numpy array or a list of numpy arrays or JTensor or a list of JTensors.
        """
        jinputs, input_is_table = Layer.check_input(inputs)
        output = callZooFunc(self.bigdl_type,
                             "inferenceModelPredict",
                             self.value,
                             jinputs,
                             input_is_table)
        return KerasNet.convert_output(output)
github intel-analytics / analytics-zoo / pyzoo / zoo / pipeline / api / autograd.py View on Github external
def backward(self, y_true, y_pred):
        """
        NB: It's for debug only, please use optimizer.optimize() in production.
        Performs a back-propagation step through the criterion, with respect to the given input.

        :param input: ndarray or list of ndarray
        :param target: ndarray or list of ndarray
        :return: ndarray
        """
        input = y_pred
        target = y_true
        jinput, input_is_table = Layer.check_input(input)
        jtarget, target_is_table = Layer.check_input(target)
        output = callZooFunc(self.bigdl_type,
                             "criterionBackward",
                             self.value,
                             jinput,
                             input_is_table,
                             jtarget,
                             target_is_table)
        return Layer.convert_output(output)
github intel-analytics / analytics-zoo / pyzoo / zoo / pipeline / api / autograd.py View on Github external
def forward(self, y_true, y_pred):
        """
        NB: It's for debug only, please use optimizer.optimize() in production.
        Takes an input object, and computes the corresponding loss of the criterion,
        compared with `target`

        :param input: ndarray or list of ndarray
        :param target: ndarray or list of ndarray
        :return: value of loss
        """
        input = y_pred
        target = y_true
        jinput, input_is_table = Layer.check_input(input)
        jtarget, target_is_table = Layer.check_input(target)
        output = callZooFunc(self.bigdl_type,
                             "criterionForward",
                             self.value,
                             jinput,
                             input_is_table,
                             jtarget,
                             target_is_table)
        return output
github intel-analytics / BigDL / pyspark / bigdl / nn / criterion.py View on Github external
def backward(self, input, target):
        """
        NB: It's for debug only, please use optimizer.optimize() in production.
        Performs a back-propagation step through the criterion, with respect to the given input.

        :param input: ndarray or list of ndarray
        :param target: ndarray or list of ndarray
        :return: ndarray
        """
        jinput, input_is_table = Layer.check_input(input)
        jtarget, target_is_table = Layer.check_input(target)
        output = callBigDlFunc(self.bigdl_type,
                               "criterionBackward",
                               self.value,
                               jinput,
                               input_is_table,
                               jtarget,
                               target_is_table)
        return Layer.convert_output(output)