Getting error while training the summarization model (Section 12)

All my unit tests are passed but iam facing while running 12. Train the model section . Iam getting the error “AttributeError: ‘TfMethodTarget’ object has no attribute ‘_update_step’” From the error it looks like being caused by this line “optimizer.apply_gradients(zip(gradients, transformer.trainable_variables))” in this function “def train_step(model, inp, tar):” I tried to look through posts but iam not able to find any similar issues . Please find the below Traceback for detailed understanding

" File “/tmp/ipykernel_5201/”, line 31, in train_step *
optimizer.apply_gradients(zip(gradients, transformer.trainable_variables))
File “/usr/local/lib/python3.8/dist-packages/keras/src/optimizers/”, line 1230, in apply_gradients **
return super().apply_gradients(grads_and_vars, name=name)
File “/usr/local/lib/python3.8/dist-packages/keras/src/optimizers/”, line 652, in apply_gradients
iteration = self._internal_apply_gradients(grads_and_vars)
File “/usr/local/lib/python3.8/dist-packages/keras/src/optimizers/”, line 1260, in _internal_apply_gradients
return tf.internal.distribute.interim.maybe_merge_call(
File “/usr/local/lib/python3.8/dist-packages/keras/src/optimizers/”, line 1352, in _distributed_apply_gradients_fn
File “/usr/local/lib/python3.8/dist-packages/keras/src/optimizers/”, line 1347, in apply_grad_to_update_var **
return self._update_step_xla(grad, var, id(self._var_key(var)))
File “/usr/local/lib/python3.8/dist-packages/keras/src/optimizers/”, line 225, in _update_step_xla
return self._update_step(gradient, variable)

AttributeError: 'TfMethodTarget' object has no attribute '_update_step' "

Hello @Siva_Kumar1

Can you confirm before you started doing the assignment, did you update the lab.

Also confirm the assignment name as it seems you are doing week 2 assignment.

Remember this course was recently updated and now has only 3 weeks and before had 4 weeks.

So in case you are doing an obsolete copy, get a fresh copy and re-do the assignment.

I am sharing a screenshot of my grader cell images, check if it matches with your grade cell names for Course 4 week 3 assignment name question answer assignment.


Hi Iam doing Week 2 Text summarizer assignment .

How do i verify if iam using obselete copy ?

Should i click “Get latest version”. If yes, will it effect my existing code

hey you passed the assignment already? then how are you getting error???

for me this assignment name is Programming Assignment: Transformer Summarizer

but your grader submission do match with the latest one.

Can you mention the grader cell for which you got the error?

HI Deepti,

I have restarted the kernel and ran the whole code again. It is working fine now. Thank you

1 Like