Beispiel #1
0
    def predict(self, data):
        # TODO: this evaluates a single example, i.e. mini-batch of one.
        # generalize this to general case.

        if len(data.shape) == 1:
            data = data.reshape((1, data.shape[0]))

        classification_response = self.skil.api.multipredict(
            deployment_name=self.deployment.name,
            model_name=self.model_name,
            version_name="default",
            body=skil_client.MultiPredictRequest(
                id=str(uuid.uuid1()),
                needs_pre_processing=False,
                inputs=[
                    skil_client.INDArray(ordering='c',
                                         shape=list(data.shape),
                                         data=data.tolist()[0]),
                    skil_client.
                    INDArray(  # This is the keep_prob placeholder data
                        ordering='c',
                        shape=[1],
                        data=[1.0])
                ]))
        output = classification_response.outputs[0]
        prediction = np.asarray(output.data)
        shape = output.shape
        return prediction.reshape(shape)
    def _indarray(np_array):
        """Convert a numpy array to `skil_client.INDArray` instance.

        # Arguments
            np_array: `numpy.ndarray` instance.

        # Returns
            `skil_client.INDArray` instance.
        """
        return skil_client.INDArray(ordering='c',
                                    shape=list(np_array.shape),
                                    data=np_array.reshape(-1).tolist())