introtodeeplearning icon indicating copy to clipboard operation
introtodeeplearning copied to clipboard

Lab 3 Part 2 resampling gives error

Open jt-health-dev opened this issue 2 years ago • 2 comments

Starting epoch 1/6

AttributeError Traceback (most recent call last) in <cell line: 5>() 7 # Get a batch of training data and compute the training step 8 for step, data in enumerate(train_loader): ----> 9 metrics = wrapper.train_step(data) 10 if step % 100 == 0: 11 print(step)

2 frames /usr/local/lib/python3.10/dist-packages/keras/engine/compile_utils.py in match_dtype_and_rank(y_t, y_p, sw) 829 def match_dtype_and_rank(y_t, y_p, sw): 830 """Match dtype and rank of predictions.""" --> 831 if y_t.shape.rank == 1 and y_p.shape.rank == 2: 832 y_t = tf.expand_dims(y_t, axis=-1) 833 if sw is not None:

AttributeError: 'tuple' object has no attribute 'rank'

jt-health-dev avatar May 03 '23 03:05 jt-health-dev

image

Same error here. Seems like the team updated the library.

@aamini please help

kennylids avatar May 05 '23 08:05 kennylids

Here is a messy workaround for this data type casting issue... ` for step, data in enumerate(train_loader): x,y = data xx = [tf.convert_to_tensor(a) for a in x] yy = [tf.convert_to_tensor(b) for b in y] xx = tf.convert_to_tensor(xx) yy = tf.convert_to_tensor(yy)

data = (xx,yy)
metrics = wrapper.train_step(data)`

fractalclockwork avatar May 13 '23 19:05 fractalclockwork