1
$\begingroup$

I have data with about 100 numerical features and a multi-labelling that encodes ownership of a certain product (i.e. my labels are of the form $[x_i, i=1, \dots, n]$ where n is the number of products and $x_i$ is either 0 or 1). My neural network approach to this currently looks like this

model = Sequential()
model.add(Dense(1024, activation='relu', input_dim=X_train.shape[1]))
model.add(Dense(1024, activation='relu'))
model.add(Dense(1024, activation='relu'))
model.add(Dense(1024, activation='relu'))
model.add(Dense(y_train.shape[1], activation='softmax'))

in Keras (i.e. a couple of dense layers with ReLu activation, then an output layer with softmax).

Now my question is: will the network consider labels of the other products when considering a probability to assign to the label of one product? I would like that to happen, but I can't quite grasp whether it does (my suspicion is no).

I'm new to multilabel classification and relatively new to NN in general, so I hope this isn't too inept a question.

$\endgroup$
1
$\begingroup$

Firstly you should use sigmoid in your last layer instead of softmax. Softmax returns a probability distribution, meaning that when one labels probability increases the other will decrease, which is not always the case. Secondly in order for keras to use all the labels you should use binary_crossentropy as the loss function.

$\endgroup$
  • $\begingroup$ Thanks! I actually already used Sigmoid, just copied the wrong parts here, and also binary_crossentropy (following on Francois Chollet's book on Keras). This means it's working as intended. $\endgroup$ – Joseph Doob Apr 26 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.