コード例 #1
0
 def y_transform(self, record: TubRecord):
     angle: float = record.underlying['user/angle']
     throttle: float = record.underlying['user/throttle']
     angle = linear_bin(angle, N=15, offset=1, R=2.0)
     throttle = linear_bin(throttle,
                           N=20,
                           offset=0.0,
                           R=self.throttle_range)
     return angle, throttle
コード例 #2
0
    def lstm_get_record_gen(self, record_transform=None, df=None):
        pd.set_option('max_colwidth', 10)

        num_steps = 30
        batch_size = 20
        current_idx = 0
        skip_step = 30
        if df is None:
            df = self.get_df()

        data_size = df.shape[0]
        df.sort_index(inplace=True)

        while True:
            for i in range(batch_size):
                if current_idx + num_steps >= data_size:
                    # reset the index back to the start of the data set
                    current_idx = 0
                #print(df[current_idx:current_idx + num_steps])
                record_dict = df[current_idx:current_idx +
                                 num_steps].to_dict(orient='record')[0]
                record_dict = self.read_record(record_dict)
                current_idx += skip_step

                record_dict["user/angle"] = utils.linear_bin(
                    record_dict["user/angle"])
                #print("-----")
                #print(record_dict)
                yield record_dict
コード例 #3
0
    def __getitem__(self, index):
        count = 0
        records = []
        images = []
        angles = []
        throttles = []

        is_inferred = type(self.keras_model) is KerasInferred
        is_categorical = type(self.keras_model) is KerasCategorical
        is_resnet18_categorical = type(
            self.keras_model) is Resnet18CategoricalKeras

        while count < self.batch_size:
            i = (index * self.batch_size) + count
            if i >= len(self.records):
                break

            record = self.records[i]
            record = self._transform_record(record)
            records.append(record)
            count += 1

        for record in records:
            image = record['cam/image_array']
            angle = record['user/angle']
            throttle = record['user/throttle']

            images.append(image)
            # for categorical convert to one-hot vector
            if is_categorical or is_resnet18_categorical:
                R = self.config.MODEL_CATEGORICAL_MAX_THROTTLE_RANGE
                angle = linear_bin(angle, N=15, offset=1, R=2.0)
                throttle = linear_bin(throttle, N=20, offset=0.0, R=R)
            angles.append(angle)
            throttles.append(throttle)

        X = np.array(images)

        if is_inferred:
            Y = np.array(angles)
        else:
            Y = [np.array(angles), np.array(throttles)]

        return X, Y
コード例 #4
0
ファイル: keras.py プロジェクト: fpineau-sigma/donkeycar-1
 def y_transform(self, record: TubRecord):
     angle: float = record.underlying['user/angle']
     throttle: float = record.underlying['user/throttle']
     angle = linear_bin(angle, N=15, offset=1, R=2.0)
     throttle = linear_bin(throttle, N=20, offset=0.0, R=0.5)
     return {'angle_out': angle, 'throttle_out': throttle}