The recent release of SAP HANA 2.0 SPS 03 brings new capabilities to the External Machine Learning (EML) library.
You might have already seen my earlier blogs introducing SAP HANA External Machine Learning library and SAP HANA External Machine Learning: Take 2 which hopefully got you started?
With SPS 02 only a single inference operation could be done at a time (using the PREDICT function).
SPS 03 introduces the PREDICTM function which allows multiple rows of data as input and the capability takes full advantage of not only parallelism but also improved load balancing and high availability.
-- create table types CREATE TYPE "T_PARAMS" AS TABLE ("Parameter" VARCHAR(100), "Value" VARCHAR(100)); CREATE TYPE "T_DATA" AS TABLE ("Label" INTEGER, "Image" BLOB); CREATE TYPE "T_RESULTS" AS TABLE ("Label" INTEGER, "Class1" VARCHAR(100), "Class2" VARCHAR(100), "Class3" VARCHAR(100), "Class4" VARCHAR(100), "Class5" VARCHAR(100), "Class6" VARCHAR(100), "Class7" VARCHAR(100), "Class8" VARCHAR(100), "Class9" VARCHAR(100), "Class10" VARCHAR(100), "Score1" FLOAT, "Score2" FLOAT, "Score3" FLOAT, "Score4" FLOAT, "Score5" FLOAT, "Score6" FLOAT, "Score7" FLOAT, "Score8" FLOAT, "Score9" FLOAT, "Score10" FLOAT); -- create signature table then generate stored procedure CREATE COLUMN TABLE "SIGNATURE" ("POSITION" INTEGER, "SCHEMA_NAME" NVARCHAR(256), "TYPE_NAME" NVARCHAR(256), "PARAMETER_TYPE" VARCHAR(7)); INSERT INTO "SIGNATURE" VALUES (1, 'EMLUSER', 'T_PARAMS', 'IN'); INSERT INTO "SIGNATURE" VALUES (2, 'EMLUSER', 'T_DATA', 'IN'); INSERT INTO "SIGNATURE" VALUES (3, 'EMLUSER', 'T_RESULTS', 'OUT'); CALL "SYS"."AFLLANG_WRAPPER_PROCEDURE_CREATE" ('EML', 'PREDICTM', 'EMLUSER', 'SCORE_DIGITS', "SIGNATURE");
You need to provide an integer column as id on the input data – so it’s handy that SPS 03 also introduces support for integer data types! Due to the parallelism be aware the the result dataset may not be in the same order as the input.
Watch a video tutorial of this in action: EML 13. Real-Time Scoring – Multiple
In terms of load balancing and high availability the actual load levels of each TensorFlow Server are now considered and should aTensorFlow Server be slow or unresponsive requests are automatically re-tried.
To enable scenarios where you hostHANA behind a firewall (perhaps on-premise) but the TensorFlow Server is hosted on the public internet – it’s now possible to specify proxy settings when creating the remote source to TensorFlow Serving. Use the proxyhost and proxyuser options:
-- create remote source CREATE REMOTE SOURCE "TensorFlowModelServer" ADAPTER "grpc" CONFIGURATION 'server=tmshostname;port=9000;proxyhost=proxy.mydomain.org;proxyuser:username:password';
It’s also now possible to create remote sources interactively (in addition to using SQL!) via the Database Explorer:
A very common request is how to install TensorFlow serving on SUSE Linux – as this is typically where HANA is installed. That scenario isn’t supported for productive use but can greatly simplify evaluation and learning – when you just want to have a “play” so to speak. Installing Python and TensorFlow is straightforward but TensorFlow Serving has to be built – which is quite an involved process. Wouldn’t it be nice if someone had already done it for you? Well my esteemed colleague Burkhard Neidecker-Lutz has and you can access the binaries here. Whilst this is not supported by SAP hopefully this may save you some blood, sweat and tears. The binaries should be able to serve any saved models between TensorFlow 1.0 and 1.6.
Watch a video tutorial showing how to install TensorFlow Serving on SUSE: EML 14. Install TensorFlow Serving on SUSE
For the bigger picture, the EML playlist covers all aspects of SAP HANA External Machine Learning Library.
Have fun with TensorFlow and HANA!
The SAP HANA Academy provides free online video tutorials for the developers, consultants, partners and customers of SAP HANA.
Topics range from practical how-to instructions on administration, data loading and modeling, and integration with other SAP solutions, to more conceptual projects to help build out new solutions using mobile applications or predictive analysis.
For the full library, see SAP HANA Academy Library – by the SAP HANA Academy
For the full list of blogs, see Blog Posts – by the SAP HANA Academy