I am attempting to train a neural network to do simple mapping i.e. X to Y. In this case I am attempting to map a value to its respective error. Both X and Y are arrays of size 1077.
The data has a lot of noise and the relationship is, essentially, non-existent. Therefore, I decided to go with classification rather than regression. If I use MSE (seen below), the accuracy never goes above zero and the loss is enormous and non-changing.
# Data preprocessing
from sklearn.model_selection import train_test_split
A_train, A_test, Aerror_train, Aerror_test = train_test_split(A, A_error,
test_size=0.33, random_state=42)
# Defining and compiling the model
model = Sequential() # initializing a sequential model
model.add(Dense(1, activation = 'relu', input_shape = (1,))) #first layer
model.add(Dropout(0.2))
model.add(Dense(1, activation = 'relu'))
model.add(Dropout(0.2))
model.add(Dense(1, activation ='softmax'))
model.summary()
model.compile(loss = 'mean_squared_error', optimizer = 'sgd',
metrics = ['accuracy'] ) #sgd = stochastic gradient descent, cat_ce =
probability that increases as the predicted and actual values diverge
If I try to use the loss function sparse categorical crossentropy, since I want to do multilabel classification
I receive the following error:
InvalidArgumentError (see above for traceback): Received a label value of
15614 which is outside the valid range of [0, 1).