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 (in Keras)

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'))

So, it has a couple of dense layers with ReLu activation, then an output layer with softmax.

Now, my question is: will the neural network consider labels of the other products when assigning a probability 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 multi-label classification and relatively new to NN in general, so I hope this isn't too inept a question.

$\endgroup$

1 Answer 1

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 the binary cross-entropy as the loss function.

$\endgroup$
1
  • $\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$ Apr 26, 2019 at 10:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .