import pandas as pd
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
df = pd.read_csv('C:\\Users\\operator09\\PycharmProjects\\pythonProject\\TEST\\data\\clothsize.csv')
df['age'] = df['age'].fillna(df['age'].median())
df['height'] = df['height'].fillna(df['height'].median())
df['size'] = df['size'].map({'M': 0, 'S': 1, 'XXXL': 2, 'XL': 3, 'L': 4, 'XXS': 5, 'XXL': 6})
x = df.drop("size", axis=1)
y = df['size']
model = tf.keras.models.Sequential([tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dense(1028, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(64, activation='relu'),
tf.keras.layers.Dense(6, activation='softmax')
])
opt = tf.keras.optimizers.Adam(learning_rate=0.0001)
model.compile(optimizer=opt, loss='binary_crossentropy', metrics=['accuracy'])
model.fit(x, y, epochs=1000)
I'm practicing making a program that predicts the size of my weight, height, and age
ValueError: logits
and labels
must have the same shape, received ((None, 6) vs (None, 1)). There's an error like that. What should I do?
The last floor of the Keras model ends with six outputs. By the way, the label is one size number. Therefore, it seems that an error occurred that the shape is not correct.
Add your answers.
It's a classification question. We're not going to fix the network, we're going to have to change the target y of the input to one- There are 7 classes from 0 to 6, so the network end should be 7 outputs.
Have a nice day.
865 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
565 Who developed the "avformat-59.dll" that comes with FFmpeg?
564 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
592 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.