kerasで簡単な分類NNを作ろうとしている初心者です、以下のようなコードを実行したところエラーが発生してしまいました。環境はgoogleColabratoryです。
import tensorflow as th
from tensorflow import keras
from keras import layers
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from google.colab import files
from sklearn.model_selection import train_test_split as tts
from keras.utils import to_categorical
uploaded = files.upload()
df = pd.read_csv("wine_class.csv")
target = df["Class"]
data = df.drop("Class", axis=1)
data = data.values
target = target.values
train_data, target_data, train_label, target_label =tts(data, target, train_size=0.7)
train_data = np.array(train_data, np.float32)
target_data = np.array(train_label, np.float32)
train_label = np.array(target_data, np.float32)
target_label = np.array(target_label, np.float32)
train_label = train_label - 1
target_label = target_label - 1
train_label = to_categorical(train_label, num_classes=3)
target_label = to_categorical(target_label, num_classes=3)
Classe = keras.Sequential()
Classe.add(layers.Dense(units=10, activation="relu", input_shape=(124,10)))
Classe.add (layers.Dense(units=3, activation="softmax"))
Classe.compile(optimizer="adam",
loss="sparse_categorical_crossentropy",
metrics=["accuracy"])
history = Classe.fit(train_data, train_label,
batch_size=10,
epochs=10,
validation_data=(target_data, target_label))
エラー内容
InvalidArgumentError: Graph execution error:
logits and labels must have the same first dimension, got logits shape [10,3] and labels shape [30]
code中のwine_class.csvはここからダウウンロードできます。