无法从张量流数据集加载数据



class Jarvis(Model(: definit(self(: 型。初始化(自我( self.model = Sequential((

# Convulational layersw 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((

我建议您使用 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

希望这有帮助!

相关内容

  • 没有找到相关文章

最新更新