LSTM issue

Hi

I have this issue when I am runing my app:

NotImplementedError: Cannot convert a symbolic Tensor (lstm/strided_slice:0) to a numpy array

I do not know what is the problem.

Thanks for yout help

1 Like

Hi @Manu_Soria,

Welcome to our forum! :raised_hands:

It’s difficult for me to accurately answer your question without more context. However, one potential solution to consider is using the .numpy() method on a TensorFlow tensor.

To provide a better, more accurate response, it would be helpful to have more information abotu the specific operation that is causing the error.

I hope this helps,
Charly

Thanks for your reply and you are right, I should give more information, so:

  1. I developed this app, and the first time it was running ok in my laptop.

  2. The streamlit cloud is running ok.

  3. After I did a Anaconda upgrade in my laptop and appeared the error that I wrote.

  4. My libraries:
    import math
    import numpy as np
    import pandas as pd
    from sklearn.preprocessing import MinMaxScaler
    from tensorflow.keras.models import Sequential
    from tensorflow.keras.layers import Dense, LSTM
    import matplotlib.pyplot as plt

  5. My LSTM code:
    data = df.filter([β€œ$/Tonelada”])
    #data

    #Converting the dataframe to a numpy array
    dataset = data.values
    #dataset

    #Get /Compute the number of rows to train the model on
    training_data_len = math.ceil( len(dataset) *.8)
    #training_data_len

    #Scale the all of the data to be values between 0 and 1
    scaler = MinMaxScaler(feature_range=(0, 1))
    #scaler

    scaled_data = scaler.fit_transform(dataset)
    #scaled_data

    #Create the scaled training data set
    train_data = scaled_data[0:training_data_len, : ]
    #train_data.shape

    #Split the data into x_train and y_train data sets
    x_train=
    y_train =
    for i in range(60,len(train_data)):
    x_train.append(train_data[i-60:i,0])
    y_train.append(train_data[i,0])

    #Scale the all of the data to be values between 0 and 1
    scaler = MinMaxScaler(feature_range=(0, 1))
    #scaler

    #Convert x_train and y_train to numpy arrays
    x_train, y_train = np.array(x_train), np.array(y_train)
    #x_train.shape, y_train.shape

    #Reshape the data into the shape accepted by the LSTM
    x_train = np.reshape(x_train, (x_train.shape[0],x_train.shape[1],1))
    model = Sequential() #
    model.add(LSTM(units=150, return_sequences=True,input_shape=(x_train.shape[1],1)))
    #model.add(LSTM(units=25, return_sequences=True))
    #model.add(LSTM(units=25, return_sequences=True))
    model.add(LSTM(units=150, return_sequences=False))
    model.add(Dense(units=150))
    model.add(Dense(units=1))

  6. pip versions:

numpy 1.21.6
tensor 0.3.6
tensorboard 2.11.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.6.0.post3
tensorboardX 2.5.1
tensorflow 2.0.1
tensorflow-estimator 2.0.1
tensorrec 0.26.2

I would appreciate your help

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.