为什么要running在golang上
- Current infrastructure is already running Kubernetes / Docker containers and Golang makes the binaries extremely small and efficient 运行比较小
 - Web frameworks for Go are much faster than the Python ones golang的web性能高
 - The team aren’t necessarily data scientists working in Python and work in Go 没必要切换语言?
 - Pushing data internally using GRPC for faster communication between micro services
 
Binary Classification in Keras
1  | # Use TF to save the graph model instead of Keras save model to load it in Golang  | 
采用saveModel的方式
loading and running the model in Go
1  | package main  | 
The tensor we input is in the shape [batch size][width][height][channels]. 
相同版本的python代码
1  | %%time  | 
可以尝试比较一下相关的时间问题?
Performance
Recall the model was:
3x3x32 Convolutional Layer
3x3x32 Convolutional Layer
2x2 Max Pool Layer
64 Node Fully Connected Layer with Dropout
1 Sigmoid output Layer
For Python:
- CPU: - ~2.72s to warm up and run one inference and ~0.049s for each inference after
 - GPU: - ~3.52s to warm up and run one inference and ~0.009s for each inference after
 - Saved Model Size (HDF5) 242MB
 
For Go:
- CPU: - ~0.255s to warm up and run one inference and ~0.045s for each inference after
 - GPU: - N/A
 - Saved Model Size(Protobuf binaries) 236MB
 
use Go to serve up your models in prod
感觉在k8s上运行更好一些?
在于model训练之后,基本稳定后的predict的操作