- Create binding for a simple function
#include<pybind11/pybind11.h>
int add(int i, int j) {
return i + j;
}
# Data file | |
# 1 10 | |
# 2 15 | |
# 3 50 | |
# 4 ... | |
# .... | |
# Can replace x2ticlabel with xticlabel as well | |
# When column(1) modulo 8 is zero, use "2^{....}" else "" |
# line styles for ColorBrewer Set3 | |
# for use with qualitative/categorical data | |
# provides 8 colors that are more saturated than the Pastels but less so than Set2 | |
# compatible with gnuplot >=4.2 | |
# author: Anna Schneider | |
# Modified by Aditya | |
# line styles | |
set style line 1 lc rgb '#a6cee3' | |
set style line 2 lc rgb '#1f78b4' |
# Show all rows | |
pd.set_option('display.max_rows', None) | |
# Reset index after an operation | |
df.sort_values(['country', 'capital']).reset_index(drop=True) |
#include<pybind11/pybind11.h>
int add(int i, int j) {
return i + j;
}
A graph def has nodes. Every node has
Placeholder ops are fed from the user input? Const ops are fed from the variables folder?
import tensorflow as tf
raw_dataset = tf.data.TFRecordDataset("foo.tfrecord")
for raw_record in raw_dataset.take(1):
example = tf.train.Example()
example.ParseFromString(raw_record.numpy())
The json.tool
module provides a simple command line interface to validate and pretty-print JSON objects. link
python -m json.tool foo.json
#!/usr/bin/env python3 | |
import tensorflow as tf | |
from tensorflow_serving.apis import predict_pb2 | |
from tensorflow_serving.apis import prediction_service_pb2_grpc | |
import numpy as np | |
import grpc | |
channel = grpc.insecure_channel("localhost:8500") | |
stub = prediction_service_pb2_grpc.PredictionServiceStub(channel) |
Frozen graph is deprecated in TF2. Using Saved model is the new approach. Instead of creating a configuration file and using bazel
in steps 1 and 2 described here, simply use the saved_model_cli
. The final compilation step of creating a binary can be performed using a makefile
instead of bazel
.
tf.saved_model.save
.saved_model_cli
to perform XLA AOT compilation.saved_model_cli aot_compile_cpu \
--dir resnet/1 \
--tag_set serve \
--signature_def_key serving_default \
tf.function
compiles a function into a callable TensorFlow graph. Documentation
@tf.function
def f(x):
return x + 1
Use the get_concrete_function
method of the callable created by tf.function. It returns a tf.Graph
object.