tensorflow版本其实和keras版本一样,就是前缀tensorflow即可
大家可以看我前面写的文本分类是keras版本写的,今天就水一篇博客
只要在开头导入的库换成tensoflow即可
from keras.preprocessing.text import Tokenizer
from keras.preprocessing.sequence import pad_sequences
from sklearn.model_selection import train_test_split
from keras.layers import Dense, Embedding, LSTM, SpatialDropout1D
from keras.models import Sequential
from keras.callbacks import EarlyStopping
替换成
from tensorflow.keras.preprocessing.text import Tokenizer
from tensorflow.keras.preprocessing.sequence import pad_sequences
from sklearn.model_selection import tr