'Python Tensorflow dnq agent with distributed strategy

I have tensorflow model build with tensorflow/keras/rl agents.

Now I am going to work with multi-GPUs using tensorflow distributed strategy.

    // Here have some initial settings to start tensorflow distributed strategy.

    // start strategy.
    strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy()
    with strategy.scope():
        main_process() // model built in tensorflow and keras.rl

here, main_process() is built in tensorflow models used tensorflow.kreas.models functions and modules.

But to work with distributed strategy, the problem was for from rl.agents.dqn import DQNAgent I used dqn_agent from keras to fit model which is built in tensorflow. But finally couldn't scope with agent.

dqn = DQNAgent(model=model, // some options )
dqn.compile(adam_v2.Adam(learning_rate=learning_rate_adam), metrics=['mae'])

So I think rl.agents.DQNAgent can't work with tensorflow.distributed.strategy. Then what should I use for dqn agent and why can't I use it?

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source