简体   繁体   中英

Reinforcement Learning (Using Tensorflow and a Matlab Env)

I coupled a RL agent with a environment which is implemted in matlab. So I let the python script (using tensorflow V2) run, write a txt file with the actions and call the matlab environment via system command. In matlab the txt file is read, then the calculation is carried out in matlab and a result txt file is written. This txt file is then read by python, and the py script runs further.

That works, however the calculation times are relative long, one step takes between 9 and 13 seconds, although the matlab calculation need only about 1.5 -2 seconds. Therefore the training time is very high which is very annoying. Unfortunately you can't rewrite the environment to Python, would be too much work and compiling to c++ would also be rather difficult.

Is there nevertheless a better way? Does anyone have an idea how to improve that? Is there any interface between python and matlab which could help here?

Thanks in advance!

Best Chris

I would try calling matlab from python using subprocess and setting up a stdin/out pipe. You can read all about that here or here . Writing into and reading from files (depending on your OS of course, but generally) takes much, much more time than piping data between processes. Feel free to read up on IPC (Inter Process Communication), in my opinion, stdio is the best choice for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM