赞
踩
主要是解决由于1.0版本和2.0版本代码实现不同造成的报错
报错语句:from keras.optimizers import Adam 正确语句:from keras.optimizers import adam_v2
报错语句:
import tensorflow as tf
flags =tf.app.flags
FLAGS = flags.FLAGS
正确语句:
import tensorflow.compat.v1 as tf
flags=tf.app.flags
FLAGS = tf.app.flags.FLAGS
报错语句:import tensorflow.contrib.keras as kr
正确语句:import keras as kr
错误代码:import tensorflow as tf 正确代码: import tensorflow.compat.v1 as tf tf.disable_v2_behavior() tf.compat.v1.disable_eager_execution()
但是改之后出现错误五
错误代码:Cell = tf.contrib.rnn.DropoutWrapper(cell, self.keep_pro)
正确代码:Cell =tf.nn.rnn_cell.DropoutWrapper(cell, self.keep_pro)
(此时tf=tensorflow.compat.v1)
错误语句:import tensorflow as tf
正确语句:import tensorflow.compat.v1 as tf
解决同六
错误语句:
import keras as kr y_pad = kr.utils.to_categorical(label_id)
正确语句:
import tensorflow as tf y_pad = tf.keras.utils.to_categorical(label_id)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。