C3W3 Assignment Task 4. Preparing TFJob syntax error near unexpected token `('

I’m having a repeat issue with this course 3 week 3 lab - Distributed Multi-worker TensorFlow Training on Kubernetes.

I had the same issue when I tried to run it about a month ago & still unresolved as I’ve come back to it.

On C3W3 Task 4. Preparing TFJob, I consistently get the same error
syntax error near unexpected token `(’

Code causing errors is:
strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy()
task_type = strategy.cluster_resolver.task_type
task_id = strategy.cluster_resolver.task_id
global_batch_size = per_worker_batch * strategy.num_replicas_in_sync

I don’t know how to get past this and I’m stuck here on this lab.
Any help would be much appreciated.


Please look at the community user guide to move your topic to the right subcategory. I’m sure this topic belongs to MLEP and not MLS.

Appreciated, Balaji. Thanks. Updated.

1 Like

There’s no need for you to change the main.py file. The instructions are to observe specific lines of code to setup distributed training. Did you change anything inside the file?

Please share the stacktrace for better context.

Hi Balaji,
Thanks for getting back to me.

The last response I got did not really address the issue I was having which is that the code for the lab in question simply fails when copied and pasted and run.

There are syntactical issues with the code as is.

After taking a necessary break from the course, I have returned to it to attempt to re-run (in the hope that it has been updated), and I am now getting a notification saying that I have “exceeded my quota for this lab?”

Is there any other resolution for me on this please?

I have completed every aspect of the “Machine-learning modeling pipelines in production” course and this lab “Distributed Multi-worker TensorFlow Training on Kubernetes”, with the syntactical code errors, is the only thing holding me back from completion.

You will see from my record that I have had no trouble following any of the other labs up until this point.

Your assistance in resolving and getting my certificate would be greatly appreciated.



Mentors don’t have access to student lab environment and records.
Please talk to qwiklabs help center regarding quota issues.