Yaksh Patel
Yaksh Patel

Reputation: 1

non-broadcastable output operand with shape (168,1) doesn't match the broadcast shape (168,6)

I have using keras GRU model for prediction of SoH of Li-ion Battery where i have 6 input features and 1 output. i get this error while inversing scaled test prediction. i have tried reshaping once still got same error.

path ='/content/drive/MyDrive/stor_bat/b56.csv'
data = pd.read_csv(path)

X = data.drop(['type','SoH','Capacity'],axis=1)
y = data[['Capacity']]

sc = MinMaxScaler(feature_range=(0,1))

X_sc = sc.fit_transform(X)
y = y.to_numpy()

X_train = X_sc.reshape(X_sc.shape[0],X_sc.shape[1],1)
y_train = y.reshape(y.shape[0],y.shape[1],1)

model = keras.Sequential()
#first layer of GRU
model.add(layers.GRU(50, return_sequences=True, input_shape=(X_train.shape[1],1)))
model.add(layers.Dropout(0.2))
#second layer of GRU
model.add(layers.GRU(50, return_sequences=True))
model.add(layers.Dropout(0.2))
#third layer of GRU
model.add(layers.GRU(50))
model.add(layers.Dropout(0.2))
#output layer
model.add(layers.Dense(1))

#compileing model
model.compile(optimizer="Adam",loss="mse")

#fitting model
model.fit(X_train, y_train, epochs=10, batch_size=32)

#loading test datset
data_test = pd.read_csv('/content/drive/MyDrive/stor_bat/b6.csv')
X_t = data_test.drop(['type','SoH','Capacity'],axis=1)

#scaling of test data
xt_sc = sc.transform(X_t)
x_test = xt_sc.reshape(xt_sc.shape[0],xt_sc.shape[1],1)
pred = model.predict(x_test)

predcted = sc.inverse_transform(pred.reshape(-1,1))

Upvotes: 0

Views: 31

Answers (0)

Related Questions