ray-project / ray

Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a set of AI Libraries for accelerating ML workloads.
https://ray.io
Apache License 2.0
33.04k stars 5.59k forks source link

Critic Regularized Regression (CRR) model is getting error with Custom Environment (Offline RL) #30411

Open karthikbharadhwajKB opened 1 year ago

karthikbharadhwajKB commented 1 year ago

What happened + What you expected to happen

I am using CRR model with custom environment, I am getting this error

q_vals = q_model(model_out)[rows, actions].unsqueeze(-1) IndexError: tensors used as indices must be long, byte or bool tensors.

So I tried CRR with Cart-Pole environment, It's working fine !!.

Can you please help me on this ??

Thank you

Versions / Dependencies

Python 3.8.8 Ray rllib 2.1.0 pytorch 1.13.0

Reproduction script

model = crr.CRR(

our environment

env = "pagRobot_5D", config = { "framework": "torch", "env_config": { "curr_dir": "data_pxp\FMG", "isTrain": True }, "model": {

"custom_model": "my_model",

    "conv_filters": [[32, [8,8], 4], [64, [4,4], 2], [64, [4,4], 3], [512, [52,8], 1]],
    "conv_activation": "relu",
    "vf_share_layers": True,
   },

   #CRR algorithm specific config
   "weight_type" : "bin",
   "temperature" :1.0,
    "max_weight" : 20.0,
    "advantage_type" : "mean",
    "n_action_sample" :4,

    # target_network_update_freq by default is 100 * train_batch_size
    # if target_network_update_freq is not set. See self.setup for code.
    #Q fucntion update settings
    "target_network_update_freq" : 1,
    "tau": 0.0005,
    "twin_q" : True,

    #normal 
    "input": "expertdata",
    #"postprocess_inputs": True,
    "num_workers": 1,
    "train_batch_size": 32,

},

logger_creator=custom_log_creator( custom_path=os.path.expanduser("results_ray/"), custom_str='CRR' ) )

Issue Severity

Medium: It is a significant difficulty but I can work around it.

ryanmspangler commented 1 year ago

Having the same issue, also with a custom environment.

Python 3.9.13 Ray rllib 2.2.0 pytorch 1.13.0