68125821

Date: 2021-06-25 06:23:22
Score: 7
Natty:
Report link

I am facing right now the following problem: I have a sequential model, which looks like this:

    Model: "sequential_176"
    _________________________________________________________________ 
Layer (type)                 Output Shape              Param #   
    ================================================================= 
InputLayer (Dense)           (None, 512)               2048      
    _________________________________________________________________ 
DeepLayer0 (Dense)           (None, 512)               262656    
    _________________________________________________________________ 
OutputLayer (Dense)          (None, 1)                 513       
    ================================================================= 
Total params: 265,217 Trainable params: 265,217 Non-trainable params: 0

With defined input_shape of input of the first layer `input_shape=[self.n_features]=input_shape=[3]

from tensorflow.keras.layers import Dense
# from tensorflow.keras.layers import Dropout
self.model.add(Dense(units=self.hparamsiter['num_units'], activation=self.hparamsiter['activation'], input_shape=[self.n_features],name='InputLayer'))
for cnt in range(self.hparamsiter['num_layers']):
    # self.model.add(Dropout(self.hparamsiter['dropoutrate']))
    self.model.add(Dense(units=self.hparamsiter['num_units'], activation=self.hparamsiter['activation'],kernel_initializer=self.hparamsiter['kernelinitializer'],name='DeepLayer'+str(cnt)))#, input_shape=(self.hparamsiter['num_units'],)))
self.model.add(Dense(units=self.n_outputs, activation=self.hparamsiter['activation'],kernel_initializer=self.hparamsiter['kernelinitializer'],name='OutputLayer'))#, input_shape=[self.hparamsiter['num_units']]))
self.model.compile(optimizer=self.hparamsiter['optimizer'], loss=self.hparamsiter['lossfunc'], metrics = ['acc'])
self.model.summary()
return self

Compiling the model is no problem. However, when I do a prediction and subscribe a vector test_state with:

predictions.append(model.predict(test_state, workers=-1))

where:

np.shape(test_state)
Out[739]: (3,)

I get the following error:

ValueError: Error when checking input: expected InputLayer_input to have shape (3,) but got array with shape (1,)

So I subscribe a vector of shape (3,), but my model complains, that I don't.

Now I would like to check at which point which vector is subscribed. Do you have an idea how to handle this?

Reasons:
  • RegEx Blacklisted phrase (2): Do you have an idea
  • RegEx Blacklisted phrase (2): I get the following error
  • RegEx Blacklisted phrase (1.5): Do you have an
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (1):
Posted by: valvian