1
$\begingroup$

I was trying to use this code. I put part of the parameter list, but as you see the error indicates that it's taking the first member of each list to put in the first row and second ones for the second row and so on ..

from pylab import *
from keras.models import Sequential
from keras.layers import Dense
from keras import optimizers

#Generate dummy data
data = [[45,45,200,300],[44.7,45.6,50,60],[9.9,10,11,12]]
y = data*5

#Define the model
def baseline_model():
   model = Sequential()
   model.add(Dense(1, activation = 'linear', input_dim = 1))
   sgd = optimizers.SGD(lr=0.2)
   model.compile(optimizer = sgd, loss = 'mean_squared_error', metrics = ['accuracy'])
   return model


#Use the model
regr = baseline_model()
regr.fit(data,y,epochs = 4,batch_size = 1)
plot(data, regr.predict(data), 'b', data,y, 'k.')

But was unsuccessful cause I get this error that less argoments were expected :

ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 28 arrays: [array([[ 45. ], [ 44.7 ], [ 9.9 ], [ 65.5 ], [ 110. ], [ 2. ], [ 0.25], [ 13. ], [ 17. ]]), array([[ 45. ], [ 45.6 ],..

$\endgroup$
  • $\begingroup$ What have you passed as input? $\endgroup$ – Media Jul 8 '18 at 17:25
  • $\begingroup$ an input with 6 cols in 28 rows and output 8 cols, 28 rows $\endgroup$ – FabioSpaghetti Jul 8 '18 at 17:30
  • 1
    $\begingroup$ Can you post your exact code $\endgroup$ – dashnick Jul 11 '18 at 4:38
  • 1
    $\begingroup$ @dashnick I'm on mobile phone, don't have access now, will upload $\endgroup$ – FabioSpaghetti Jul 11 '18 at 11:34
  • 1
    $\begingroup$ In the other example data is reshaped into a vector, so y is a vector. You'll also need to change input_dim. $\endgroup$ – dashnick Jul 11 '18 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.