Made a neural network using tensor flows that was supposed matches an Ip to one of the 7 type of vulnerabilities and gives out what type of vulnerability that IP has.

    model = tf.keras.models.Sequential([
  tf.keras.layers.Dense(50, activation=tf.nn.relu),
  tf.keras.layers.Dense(7, activation=tf.nn.softmax)


model.fit(xs, ys, epochs=500)

The output of print(model.predict([181271844])) when this command is executed should be one of the numbers from 1 to 7 but the out put its gives is

[[0.22288103 0.20282331 0.36847615 0.11339897 0.04456346 0.02391759 0.02393949]]

I can't seem to figure out what the problem is.

  • $\begingroup$ xs is the list of IPs and ys is its corrensponding vulnerability from 0 to 6 (seven in total) $\endgroup$ – Uzair Ahmed Sep 19 '19 at 20:17

The numbers you are seeing as output are a probability vector. This is a common output format for multi-class classification models.

In this case, you can interpret the vector as saying:

  • 22% chance of class 1
  • 20% chance of class 2
  • 37% chance of class 3
  • 11% chance of class 4
  • 4% chance of class 5
  • 2% chance of class 6
  • 2% chance of class 7

If you want to get a concrete label out of this, the easiest choice is to compute and return the index of the maximum element.


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.