Giter Site home page Giter Site logo

Encounter a strange issue about ndq HOT 5 CLOSED

tonghanwang avatar tonghanwang commented on August 13, 2024
Encounter a strange issue

from ndq.

Comments (5)

kkkclearlove avatar kkkclearlove commented on August 13, 2024 1

经过观察pymarl及其旧版代码,我找到了问题所在:
首先先介绍我的环境,rtx3090-torch1.7.1-cuda11。需要修改原代码中的两处,他们分别位于:
src/utils/logging.py:
line 48:item = "{:.4f}".format(np.mean([x[1] for x in self.stats[k][-window:]]))
修改为:import torch as th
item = "{:.4f}".format(th.mean(th.tensor([x[1] for x in self.stats[k][-window:]])))
src/learner/q_learner:
line 71: if self.args.double_q:
# Get actions that maximise live Q (for double q-learning)
mac_out[avail_actions == 0] = -9999999
cur_max_actions = mac_out[:, 1:].max(dim=3, keepdim=True)[1]
target_max_qvals = th.gather(target_mac_out, 3, cur_max_actions).squeeze(3)
改为:if self.args.double_q:
# Get actions that maximise live Q (for double q-learning)
mac_out_detach = mac_out.clone().detach()
mac_out_detach[avail_actions == 0] = -9999999
cur_max_actions = mac_out_detach[:, 1:].max(dim=3, keepdim=True)[1]
target_max_qvals = th.gather(target_mac_out, 3, cur_max_actions).squeeze(3)
如上修改后本仓库即可在我的上述环境中运行。

from ndq.

youpengzhao avatar youpengzhao commented on August 13, 2024

I guess it may be due to the version of pytorch. I use the torch whose version is 1.5, different from 0.4. However, I run the pymarl code successfully under pytorch 1.5 ago. So I don't know where the problem is. In fact, I delete the code of computing communication loss, which is different from original pymarl, but the error still exists. I think it's very strange and hope for your answer. Thank you very much!

from ndq.

TonghanWang avatar TonghanWang commented on August 13, 2024

This issue is indeed quite strange. From the shape of the tensor ([32,16,2,3]), I guess there is something wrong with the messages. Since the error is caused by some in-place operations, I guess it is because of the _communication function.

But I guess the most convenient way to deal with this problem is to use torch 0.4.1.post2, given that NDQ is based on a earlier version of PyMARL. :)

from ndq.

kkkclearlove avatar kkkclearlove commented on August 13, 2024

我也遇到了类似问题,请问老铁解决了吗?

from ndq.

youpengzhao avatar youpengzhao commented on August 13, 2024

Sorry for not updating this issue. I solved this issue but forgot to update the result on github. Thanks for kkkclearlove. The code of NDQ indeed has some problems under the pytorch 1.x. The gradient of some tensor may be changed without cloning, so the issue happens. Maybe using pytorch 0.4 can avoid this issue or you can make adjustment just as kkkclearlove said.

from ndq.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.