Jarvis类(模型): def init (自己): 模型。初始化(个体) self.model = Sequential()
# Convulational layers\w MaxPooling
self.model.add(Conv2D(64, (5, 5), activation="relu"))
self.model.add(MaxPooling2D((2, 2)))
self.model.add(Conv2D(64, (5, 5), activation="relu"))
self.model.add(MaxPooling2D((2, 2)))
# Flattening layers
self.model.add(Flatten())
# Dense layers
self.model.add(Dense(1000))
self.model.add(Dense(10, activation="softmax"))
# Compiling model
self.model.compile(optimizer="adam",
loss="categorical_crossentropy",
metrics=["accuracy"])
self.model.fit(x=train_x, y=train_y,
epochs=8, batch_size=100)
我正在像这样加载数据
(train_x,train_y),(test_x,test_y)= tfds.load(“ glue”,split =“ train”,data_dir = os.path.dirname( file ))
答案 0 :(得分:1)
我建议您使用scikit Learn加载数据,因为这样会更好!
首先将数据加载为csv或excel文件:
import pandas as pd
data = pd.read_csv('Example$Path$')
然后从scikitlearn导入train_test_split:
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=101)
#X and y over here are the columns of the data. X is the training coluns and y is the column you are trying to predict
希望这对您有所帮助!