amin
amin

Reputation: 289

Using tf.data.Dataset to produce multi-input data

I have a dataset (instance of tf.data.Dataset) which produces image as input and label as output. My model needs to get [image, label] as input and label as output. So how can I make this happen?

I've tried this:

dataset = dataset.map(suit_IO)

def suit_IO(img, label):
  return [img, label], label

but gives this error:

TypeError: Unsupported return value from function passed to Dataset.map(): ([<tf.Tensor 'args_0:0' shape=(320, 320, 3) dtype=float32>, <tf.Tensor 'args_1:0' shape=() dtype=int32>], <tf.Tensor 'args_1:0' shape=() dtype=int32>).

Upvotes: 0

Views: 151

Answers (1)

Lescurel
Lescurel

Reputation: 11631

You need to use nested tuples, not a list :

def suit_IO(img, label):
  return (img, label), label

Upvotes: 1

Related Questions