Skip to content
The Chat Archive
mixtral-8x7b-instruct-v0.1· Mistral AI Arena Human Preference 55K

Consider the function: def splitintowindows( inputs: Dict[str, tf.Tensor], timelen: int,…

  1. User

    Consider the function:

    def _split_into_windows( inputs: Dict[str, tf.Tensor], time_len: int, shift: int = 1, drop_remainder: bool = True, patch_len: Optional[int] = None, ): """Create a windowed dataset with windows of size time_len.

    Args: inputs: Dict of time-series as a sequence of length time_len and multiple date features arranged in a matrix time_len: time length of each window shift: shift between each windows drop_remainder: drop remaining elements when batches cannot be formed. patch_len: input patch_len for training decoder.

    Returns: windowed dataset where each element is a tuple of windowed values and windowed features. """ values, date_features = inputs['values'], inputs['date_features'] windows = tf.data.Dataset.from_tensor_slices(values).window( time_len, shift=shift, drop_remainder=drop_remainder ) windows = windows.flat_map( lambda window: window.padded_batch(time_len, padding_values=PAD_VAL) ) date_windows = tf.data.Dataset.from_tensor_slices(date_features).window( time_len, shift=shift, drop_remainder=drop_remainder ) date_windows = date_windows.flat_map( lambda window: window.padded_batch(time_len, padding_values=PAD_VAL) ) return tf.data.Dataset.zip((windows, date_windows))

    Modify the function such that it converts the first 5 values for each window to 0 and also returns a padding matrix that is of same shape as the window which has zeros everywhere else but the first 5 values that were converted into zeros.

  2. Assistant

    Here's the modified function that converts the first 5 values for each window to 0 and also returns a padding matrix of the same shape with zeros everywhere else but the first 5 values that were converted into zeros:

    def _split_into_windows(
        inputs: Dict[str, tf.Tensor],
        time_len: int,
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.