# ValueError: Input 0 of layer conv1d is incompatible with the layer: : expected min_ndim=3, found ndim=2

## Issue

So I was tinkering with some code for time series forecasting. I have dealt with this error before (the formatting of my data was wrong). But in this case I can’t figure out what I’ve done wrong.
Here is the source of the problem

``````    monk= tf.keras.models.Sequential()
monk.fit(X_train,y_train,epochs=10)
``````

where the shape of X_train is (100,5,1) and the shape of y_train is (100,)

The fully reproducible code

``````from random import shuffle
from torch import are_deterministic_algorithms_enabled
import yfinance as yf
import tensorflow as tf
import datetime
import time
import numpy as np
def retrain(symbol):

todayy  = [int(item) for item in str(datetime.datetime.today()).split(' ')[0].split('-')]
start = datetime.datetime(todayy[0]-2,todayy[1],todayy[2])
end = datetime.datetime(todayy[0],todayy[1],todayy[2])
print(stock)
for x in range(stock.shape[0]):
open = stock.iloc[x]['Open']
close=stock.iloc[x]['Close']
if close-open>0:
else:
X = []
y= []
temp=[]
temp.append(np.array([item]))
if len(temp)>=5:
X.append(np.array(temp))
temp=[]
try:
except:
break
sellz=[]
for item in list(zip(X,y)):
print(item)
if item[1]==1:
else:
sellz.append(item)

all = []
all.append(item)
for item in sellz:
all.append(item)
shuffle(all)
X_train = []
y_train =[]
for item in all:
print(item)
X_train.append(item[0])
y_train.append(item[1])
#input()
X_train=np.array(X_train)
y_train=np.array(y_train)
print(X_train)
print(y_train)
print(X_train.shape)
print(y_train.shape)
monk= tf.keras.models.Sequential()
monk.fit(X_train,y_train,epochs=10)
#print(monk(X))

retrain('LEVI')

``````

Any help would be much appreciated.

## Solution

Remove `tf.keras.layers.Flatten()`, since it is flattening your 3D tensor `(batch size, timesteps, features)` to `(batch size, features)`.

You should add the `Flatten` layer again after `tf.keras.layers.Activation('relu')`.