Dominguez
Dominguez

Reputation: 41

AttributeError: module 'tensorflow' has no attribute 'data'

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

Upvotes: 4

Views: 2447

Answers (1)

Miriam Silver
Miriam Silver

Reputation: 29

Try to upgrade tensorflow:

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

Upvotes: 1

Related Questions