1. 安装tensorflow和golang(参考https://tensorflow.google.cn/install/install_go)
2. python训练模型,这里以keras example的imdb_cnn.py为例:
# coding:utf-8
import tensorflow as tf
from keras.models import Sequential
from keras.layer import Embedding, Dropout, Conv1D, Dense, GlobalMaxPooling1D
from keras.preprocessing import sequence
from keras.datasets import imdb
from keras import backend as K
# 代码源于keras example的 imdb_cnn.py
max_features = 5000
maxlen = 20
batch_size = 32
embedding_dims = 50
filters = 250
kernel_size = 3
hidden_dims = 250
epochs = 2
# 读取数据
print('Loading data...')
(x_train, y_train), (x_test, y_test) = imdb.load_data(num_words=max_features)
print(len(x_train), 'train sequences')
print(len(x_test), 'test sequences')
print('Pad sequences (samples x tim