C2W4 Assingment

In the C2W4 Assignment I’m getting the exception below:

RuntimeError: Method requires being in cross-replica context, use get_replica_context().merge_call()

I tried to search for a solution at StackOverflow, but it didn’t help that much. Did someone saw something similar? What did you do to solve it?


Have a look on this post on stackoverflow, hopefully it solves your problem. Otherwise we might need to have a look at your code, you might be oding something wrong somewhere.


Hi @gent.spah , I was checking the post already. From my understanding the provided code is already following the resolution posted in StackOverflow. The @tf.function is placed appropriately, the float type is being treated already when formatting the images and the
mirrored_strategy.scope(): is not in the model functions.

I think it is something on the Distributed training and testing part of the assignment because the issue happens when we have to use the distribute_train_step function. I tried to look at the Lab example, but so far wasn’t able to figure out where I coded wrong.

Send me the notebook in private I will have a look if I am able to find where the problem is!

One mistake I picked up at def distributed_train_test_step_fns in both functions within the stategy.scope() you have hard coded the arg parameter of strategy.run().

You need to use the input passed to the function given for both functions.

Try this change lets see what happens.

Thank you @gent.spah . The issue was the hard coded arg as you said. It is working properly now.