forked from hldwby/ASR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.py
33 lines (24 loc) · 840 Bytes
/
train.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from keras.backend.tensorflow_backend import set_session
from keras.callbacks import ModelCheckpoint
from general_function.data_generator import Data
from model.SpeechModel import ModelSpeech
import os
import platform as plat
import tensorflow as tf
DATA_PATH = '/home/wuboyong/corpus/'
MODEL_PATH = 'model_speech'
epoch=2
save_step=1000
batch_size=32
if __name__ == '__main__':
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
# 进行配置,使用95%的GPU
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.95
# config.gpu_options.allow_growth=True #不全部占满显存, 按需分配
set_session(tf.Session(config=config))
if not os.path.exists(MODEL_PATH):
os.makedirs(MODEL_PATH)
ms = ModelSpeech(DATA_PATH)
data = Data()
model, _ = ms.CreateModel()