Tuesday, May 11, 2021

 Silly Typo😁



TypeError: __init__() takes from 1 to 3 positional arguments but 10 were given



The "TypeError" above is really a "TYPE" error (means TYPING , not data type😆😆)


I actually forgot to put a square brackets for array inside model.Sequential.


model = tf.keras.models.Sequential(
    tf.keras.layers.Conv2D(163, activation = "relu" , input_shape = (180,180,3)), 
    tf.keras.layers.MaxPooling2D(),
    tf.keras.layers.Conv2D(323, activation = "relu"), 
    tf.keras.layers.MaxPooling2D(),
    tf.keras.layers.Conv2D(643, activation = "relu"), 
    tf.keras.layers.MaxPooling2D(),        
    tf.keras.layers.Flatten(), 
    tf.keras.layers.Dense(512, activation = "relu"),
    tf.keras.layers.Dense(5, activation = "softmax")
)


They all look like parameters rather than array of layers, isn't it ?

Below is the correct code:
model = tf.keras.models.Sequential([
    tf.keras.layers.Conv2D(163, activation = "relu" , input_shape = (180,180,3)), 
    tf.keras.layers.MaxPooling2D(),
    tf.keras.layers.Conv2D(323, activation = "relu"), 
    tf.keras.layers.MaxPooling2D(),
    tf.keras.layers.Conv2D(643, activation = "relu"), 
    tf.keras.layers.MaxPooling2D(),        
    tf.keras.layers.Flatten(), 
    tf.keras.layers.Dense(512, activation = "relu"),
    tf.keras.layers.Dense(5, activation = "softmax")
])

The compiler does some pun when it says Type Error, I think😉

No comments:

Post a Comment

How to check local and global angular versions

 Use the command ng version (or ng v ) to find the version of Angular CLI in the current folder. Run it outside of the Angular project, to f...