multi-label classification

113 views
Skip to first unread message

Hasan Cheema

unread,
Nov 16, 2020, 12:34:44 AM11/16/20
to TensorFlow Extended (TFX)
Hey Everyone,

I'm looking into creating a custom TFX component to read input image data but would like to set up a multi-label classification paradigm. Are there any tutorials/code for setting up this type of problem?

Cheers

Robert Crowe

unread,
Nov 16, 2020, 1:24:43 PM11/16/20
to TensorFlow Extended (TFX)
Hi Hasan,

To read in data you should develop a custom ExampleGen.  It's a little different than other custom components: https://www.tensorflow.org/tfx/guide/examplegen#custom_examplegen

For multi-label classification I'm really not sure what you're thinking of doing differently in the ExampleGen.  Could you clarify?

thanks,

Robert

Robert Crowe | TensorFlow Developer Engineer | rober...@google.com  | @robert_crowe



--
You received this message because you are subscribed to the Google Groups "TensorFlow Extended (TFX)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfx+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfx/b87b7990-e554-4a71-942e-618933e5130dn%40tensorflow.org.

Hasan Cheema

unread,
Nov 16, 2020, 2:33:24 PM11/16/20
to TensorFlow Extended (TFX), rober...@google.com
Hey Robert,

I had a typo and it should be multi-class classification NOT multi-label.

I understand the part where I'm going to need to create a custom ExampleGen component by creating a custom executor to read the jpg images and labels as integers but am curious how to store multiple labels. For example, if I have a jpg image of a flower and would like to predict the color and shape of the flower I'll need two labels for that image. Can I simply create a custom executor (i.e. apache beam pipeline) to read the image and the labels as a list of integers when creating my custom ExampleGen component? This way, when the model makes predictions, it will predict a list of softmax scores for color and shape and I can compare the output of the model with the given labels. I'm curious if there's any code that does this for a similar multi-class classification problem so I can have a skeleton to follow.

Cheers

Robert Crowe

unread,
Nov 16, 2020, 4:19:57 PM11/16/20
to TensorFlow Extended (TFX)
Hi Hasan,

It sounds like you're planning to do something like keras.preprocessing.image_dataset_from_directory. My current recommendation would be to treat the image data as simply binary data in tf.examples, saved in tf.record files.  The tf.examples will include a bytes_list feature (the image), as well as the labels and any other features that you want to include in your feature vector.  Then in your Transform component you can use  tf.io.decode_jpeg in the preprocessing_fn if there are any image preprocessing things that you want to do.

I hope that helps,

Robert
Robert Crowe | TensorFlow Developer Engineer | rober...@google.com  | @robert_crowe


Reply all
Reply to author
Forward
0 new messages