5

Using python v3.9.2 and tensorflow v2.10.0 in a google cloudshell environment. I'm trying to build a windowed dataset for use in a bidirectional LSTM model. Here's my function:

def windowed_dataset(series: list, window_size: int, batch_size: int, shuffle_buffer: int) -> tensorflow.python.data.ops.dataset_ops.PrefetchDataset:
    """
    We create time windows to create X and y features.
    For example, if we choose a window of 20, we will create a dataset formed by 20 points as X
    """
    dataset = tf.data.Dataset.from_tensor_slices(series)
    dataset = dataset.window(window_size + 1, shift=1, drop_remainder=True)
    dataset = dataset.flat_map(lambda window: window.batch(window_size + 1))
    dataset = dataset.shuffle(shuffle_buffer)
    dataset = dataset.map(lambda window: (window[:-1], window[-1]))
    dataset = dataset.batch(batch_size).prefetch(1)

    return dataset

However, when I instantiate the function, I get this error: AttributeError: module 'tensorflow' has no attribute 'data' . Any thoughts? Thanks

1
  • ! Could you share a complete stand alone code. I think it might be a bug in 2.10.0 Commented Sep 13, 2022 at 9:00

1 Answer 1

1

Try to upgrade tensorflow:

!pip install -U tensorflow !pip install -U tensorflow_gpu

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.