I'm trying the Image segmentation tutorial by TensorFlow https://www.tensorflow.org/tutorials/images/segmentation
and I'm running into a problem here:
def show_predictions(dataset=None, num=1):
if dataset:
for image, mask in dataset.take(num):
pred_mask = model.predict(image)
display([image[0], mask[0], create_mask(pred_mask)])
else:
display([sample_image, sample_mask,
create_mask(model.predict(sample_image[tf.newaxis, ...]))])
The error is:
TypeError: tuple indices must be integers or slices, not tuple
and with some debugging I figured out that it points to this part of the code: sample_image[tf.newaxis, ...]
However, though I know that there is a problem here, I don't know what the problem is and how to solve it. sample_image is a tf.Tensor object. Can anyone please help out?
Thank you!
question from:
https://stackoverflow.com/questions/66054341/tensorflow-tf-newaxis 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…