Giter VIP home page Giter VIP logo

rl_learning's Issues

想问一下关于固定策略的问题

作者你好,感谢能够开源代码,我在自己尝试复现的过程中遇到了一些问题,然后我在训练了您的模型1000轮之后想要看看固定后的策略,发现结果并不是很理想,想知道是不是我的固定策略的代码出问题了呢?(我在运行时看不到作者写的输出部分,可能是有些库不完善)
下面贴出我的代码:

if (epoch+1)%50==0: # 测试
    n_actions=5
    action_img = ['↑', '→', '↓', '←','o'] # 五个方向对应的图标
    print('--- test epoch ---')
    # 固定策略(对于每个state固定)
    for x in range(5):
        for y in range(5):
            s = torch.tensor((x, y), dtype=torch.float)
            q_value = torch.zeros((n_actions), dtype=torch.float) # 分配五个活动对应的空间,下面分别计算
            for act in range(n_actions):
                nxt_s_in = torch.cat((s, torch.tensor(act).unsqueeze(0)))
                # print(nxt_s_in)
                q_value[act] = q_net(nxt_s_in) 
            max_idx = torch.argmax(q_value)
            print(action_img[max_idx], end=' ')
        print()

大致意思就是枚举每个状态(x,y)和每个活动action组成输入,预测最大的action的结果作为输出。
我得到的结果是这样的:
PixPin_2024-06-05_16-17-07
求助大佬回答

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.