Skip to content

Flat Buffer

make_flat_buffer(max_length, min_length, sample_batch_size, add_sequences=False, add_batch_size=None) #

Makes a trajectory buffer act as a flat buffer.

Parameters:

Name Type Description Default
max_length int

The maximum length of the buffer.

required
min_length int

The minimum length of the buffer.

required
sample_batch_size int

The batch size of the samples.

required
add_sequences Optional[bool]

Whether data is being added in sequences to the buffer. If False, single transitions are being added each time add is called. Defaults to False.

False
add_batch_size Optional[int]

If adding data in batches, what is the batch size that is being added each time. If None, single transitions or single sequences are being added each time add is called. Defaults to None.

None

Returns:

Type Description
TrajectoryBuffer

The buffer.

Source code in flashbax/buffers/flat_buffer.py
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
def make_flat_buffer(
    max_length: int,
    min_length: int,
    sample_batch_size: int,
    add_sequences: bool = False,
    add_batch_size: Optional[int] = None,
) -> TrajectoryBuffer:
    """Makes a trajectory buffer act as a flat buffer.

    Args:
        max_length (int): The maximum length of the buffer.
        min_length (int): The minimum length of the buffer.
        sample_batch_size (int): The batch size of the samples.
        add_sequences (Optional[bool], optional): Whether data is being added in sequences
            to the buffer. If False, single transitions are being added each time add
            is called. Defaults to False.
        add_batch_size (Optional[int], optional): If adding data in batches, what is the
            batch size that is being added each time. If None, single transitions or single
            sequences are being added each time add is called. Defaults to None.

    Returns:
        The buffer."""

    return create_flat_buffer(
        max_length=max_length,
        min_length=min_length,
        sample_batch_size=sample_batch_size,
        add_sequences=add_sequences,
        add_batch_size=add_batch_size,
    )