Multicellular classifier in tensor flow

I want to develop a classifier with multiple labels with TensorFlow, I want to say that there is a multiple label containing several classes. To illustrate this, you can create a situation such as:

  • label-1 class: illuminating rain, rain, partial rain, rain
  • label-2 classes: sunny, cloudy, cloudy, very cloudy.

I want to classify these two tags with a neural network. At the moment, I used different class labels for each class (label-1, label-2). This means that I have 4 x 4 = 16 different shortcuts.

Teaching my model with

current losses

cross_entropy = tf.reduce_mean(-tf.reduce_sum(ys * tf.log(prediction), reduction_indices=[1])) 

# prediction is sofmaxed
loss = cross_entropy + regul * schema['regul_ratio'] # regul things is for regularization 
train_step = tf.train.GradientDescentOptimizer(0.1).minimize(loss)

However, I believe that learning with multiple labels will work better in that state.

  • My functions will be [n_samples, n_features]
  • My tags will be [n_samples, n_classes, 2]

n_samples [x1, x2, x3, x4...] #

n_samples [[0, 0, 0, 1], [0, 0, 1, 0]] #

softmax . - , . ?

+4
1

?

network β†’ 1 2

prediction1 prediction2 [#, #, #, #], , , , .

loss1 = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(prediction1, labels_1))
loss2 = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(prediction2, labels_2))

loss = loss1 + loss2
+4

Source: https://habr.com/ru/post/1653152/


All Articles