fix: 让代码同时兼容 tf1 和 tf2 的 API

This commit is contained in:
nl 2021-05-16 21:37:58 +08:00
parent faa8d5ccda
commit 025dc1d2a4
1 changed files with 4 additions and 2 deletions

View File

@ -342,8 +342,10 @@ class ModelSpeech(): # 语音模型类
r = K.ctc_decode(base_pred, in_len, greedy = True, beam_width=100, top_paths=1) r = K.ctc_decode(base_pred, in_len, greedy = True, beam_width=100, top_paths=1)
#print('r', r) #print('r', r)
#r1 = r[0][0].eval(session=tf.compat.v1.Session()) if(tf.__version__[0:2] == '1.'):
r1 = r[0][0].numpy() r1 = r[0][0].eval(session=tf.compat.v1.Session())
else:
r1 = r[0][0].numpy()
#tf.compat.v1.reset_default_graph() #tf.compat.v1.reset_default_graph()
return r1[0] return r1[0]