How to use the redisai.Tensor.scalar function in redisai

To help you get started, we’ve selected a few redisai 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 RedisAI / redisai-py / test / test_model.py View on Github external
def testSKLearnGraph(self):
        sklearn_model, prototype = get_sklearn_model_and_prototype()
        path = f'{time.time()}.onnx'
        self.assertRaises(TypeError, save_model, sklearn_model, path)
        save_model(sklearn_model, path, prototype=prototype)
        model = load_model(path)
        os.remove(path)
        con = self.get_client()
        con.modelset('onnx_skl_model', Backend.onnx, Device.cpu, model)
        con.tensorset('a', Tensor.scalar(DType.float, *([1] * 13)))
        con.modelrun('onnx_skl_model', ['a'], ['outfromonnxskl'])
        tensor = con.tensorget('outfromonnxskl')
        self.assertEqual(len(tensor.value), 1)
github RedisAI / redisai-py / test / test_model.py View on Github external
def testPyTorchGraph(self):
        torch_graph = MyModule()
        path = f'{time.time()}.pt'
        save_model(torch_graph, path)
        model = load_model(path)
        os.remove(path)
        con = self.get_client()
        con.modelset('ptmodel', Backend.torch, Device.cpu, model)
        con.tensorset('a', Tensor.scalar(DType.float, 2, 5))
        con.tensorset('b', Tensor.scalar(DType.float, 3, 7))
        con.modelrun('ptmodel', ['a', 'b'], 'c')
        tensor = con.tensorget('c')
        self.assertEqual([5, 12], tensor.value)
github RedisAI / redisai-py / test / test_model.py View on Github external
def testPyTorchGraph(self):
        torch_graph = MyModule()
        path = f'{time.time()}.pt'
        save_model(torch_graph, path)
        model = load_model(path)
        os.remove(path)
        con = self.get_client()
        con.modelset('ptmodel', Backend.torch, Device.cpu, model)
        con.tensorset('a', Tensor.scalar(DType.float, 2, 5))
        con.tensorset('b', Tensor.scalar(DType.float, 3, 7))
        con.modelrun('ptmodel', ['a', 'b'], 'c')
        tensor = con.tensorget('c')
        self.assertEqual([5, 12], tensor.value)
github RedisAI / redisai-py / test / test_model.py View on Github external
def testScriptLoad(self):
        con = self.get_client()
        dirname = os.path.dirname(__file__)
        path = f'{dirname}/testdata/script.txt'
        script = load_model(path)
        con.scriptset('script', Device.cpu, script)
        con.tensorset('a', Tensor.scalar(DType.float, 2, 5))
        con.tensorset('b', Tensor.scalar(DType.float, 3, 7))
        con.scriptrun('script', 'bar', ['a', 'b'], 'c')
        tensor = con.tensorget('c')
        self.assertEqual([5, 12], tensor.value)