[Python] i can't fix this error when evaluating my RL model

Discussão em 'Python' iniciado por Stack, Maio 27, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working with a Gym environment and a trained RL model. I'm running an evaluation loop to collect observations and rewards. Here's a snippet of the code:

    total_reward = 0
    obs_test = env_test.reset()
    all_mirs = []

    for step in range(1728): # For 24 hours with 5-min intervals
    action, _ = model.predict(obs_test)
    obs_test, reward, done, info = env_test.step(action)

    all_mirs += list(obs_test[0][20:30]) # <-- This line causes the error

    total_reward += reward / 1728
    if done:
    obs_test = env_test.reset()


    And here’s the error I’m getting:

    IndexError: single positional indexer is out-of-bounds


    knowing that: obs_test length = 1 First element shape = (70,)

    Continue reading...

Compartilhe esta Página