ROBOTIS-GIT / turtlebot3_machine_learning

Apache License 2.0
123 stars 82 forks source link

Robot stuck/ slow when training #56

Open Qtsho opened 3 years ago

Qtsho commented 3 years ago

Hi, Thanks so much for the repos,

I have a problem that when the memory is >64, then the script start to train the NN model. This makes the robot use the last cmd_vel it was told. The cmd_vel only be updated when the NN is trained and after one step ().

How can I parallel this work?

I am using stage 4 and GPU for running the script.

Thanks

ROBOTIS-Will commented 3 years ago

Hi @Qtsho Thank you for your inquiry. Could you give us more information about your environment and the version of ROS you are running?

Qtsho commented 3 years ago

Hi,

I am using ROS1 melodic on Ubuntu 18.04.

tensorflow 2

I put some debuging line in the code and see it stucks for a long time between the for loop looping through the batch:

Line 114 file turtlebot3_dqn_stage_4.py

`

      for i in range(self.batch_size):

        states = mini_batch[i][0]
        actions = mini_batch[i][1]
        rewards = mini_batch[i][2]
        next_states = mini_batch[i][3]
        dones = mini_batch[i][4]

        q_value = self.model.predict(states.reshape(1, len(states)))
        self.q_value = q_value

        if target:
            next_target = self.target_model.predict(next_states.reshape(1, len(next_states)))

        else:
            next_target = self.model.predict(next_states.reshape(1, len(next_states)))

        next_q_value = self.getQvalue(rewards, next_target, dones)

        X_batch = np.append(X_batch, np.array([states.copy()]), axis=0)
        Y_sample = q_value.copy()

        Y_sample[0][actions] = next_q_value
        Y_batch = np.append(Y_batch, np.array([Y_sample[0]]), axis=0)

        if dones:
            X_batch = np.append(X_batch, np.array([next_states.copy()]), axis=0)
            Y_batch = np.append(Y_batch, np.array([[rewards] * self.action_size]), axis=0)

`

This causes the robot stuck for a while a use the last vel_cmd/. As well as slow down the process a lot

matheuslara commented 1 year ago

Hello.. I am having the same problem with ROS2 Foxy, Ubuntu 20.04, tensorflow. Did you find any solution for this problem?

Zhefan-Xu commented 10 months ago

I am watching the memroy usage and it is obvious the memory usage is keeping increasing.