@sahermaan_712 Are you sure this is from week 4 ? What exercise is it ?
Sorry w2
And exercise # ? (I need to know where to look-- It’s not like I have all this memorized in my head )
exercise 3
Are you making sure to set the seed parameter of the distribution function ?
I did but the same issue is occurring
Looking… but of note, you should not need to explicitly specify RandomUniform anywhere in this exercise, it is all Glorot.
I know it is very long, but can you copy/paste or otherwise show me what you are getting for a model summary ?
Model: “ResNet50”
Layer (type) Output Shape Param # Connected to
input_27 (InputLayer) [(None, 64, 64, 3)] 0
zero_padding2d_20 (ZeroPadding (None, 70, 70, 3) 0 [‘input_27[0][0]’]
2D)
conv2d_1298 (Conv2D) (None, 32, 32, 64) 9472 [‘zero_padding2d_20[0][0]’]
batch_normalization_1298 (Batc (None, 32, 32, 64) 256 [‘conv2d_1298[0][0]’]
hNormalization)
activation_1199 (Activation) (None, 32, 32, 64) 0 [‘batch_normalization_1298[0][0]’
]
max_pooling2d_26 (MaxPooling2D (None, 15, 15, 64) 0 [‘activation_1199[0][0]’]
)
conv2d_1299 (Conv2D) (None, 15, 15, 64) 4160 [‘max_pooling2d_26[0][0]’]
batch_normalization_1299 (Batc (None, 15, 15, 64) 256 [‘conv2d_1299[0][0]’]
hNormalization)
activation_1200 (Activation) (None, 15, 15, 64) 0 [‘batch_normalization_1299[0][0]’
]
conv2d_1300 (Conv2D) (None, 15, 15, 64) 36928 [‘activation_1200[0][0]’]
batch_normalization_1300 (Batc (None, 15, 15, 64) 256 [‘conv2d_1300[0][0]’]
hNormalization)
activation_1201 (Activation) (None, 15, 15, 64) 0 [‘batch_normalization_1300[0][0]’
]
conv2d_1301 (Conv2D) (None, 15, 15, 256) 16640 [‘activation_1201[0][0]’]
conv2d_1302 (Conv2D) (None, 15, 15, 256) 16640 [‘max_pooling2d_26[0][0]’]
batch_normalization_1301 (Batc (None, 15, 15, 256) 1024 [‘conv2d_1301[0][0]’]
hNormalization)
batch_normalization_1302 (Batc (None, 15, 15, 256) 1024 [‘conv2d_1302[0][0]’]
hNormalization)
add_391 (Add) (None, 15, 15, 256) 0 [‘batch_normalization_1301[0][0]’
, 'batch_normalization_1302[0][0]
']
activation_1202 (Activation) (None, 15, 15, 256) 0 [‘add_391[0][0]’]
conv2d_1303 (Conv2D) (None, 15, 15, 64) 16448 [‘activation_1202[0][0]’]
batch_normalization_1303 (Batc (None, 15, 15, 64) 256 [‘conv2d_1303[0][0]’]
hNormalization)
activation_1203 (Activation) (None, 15, 15, 64) 0 [‘batch_normalization_1303[0][0]’
]
conv2d_1304 (Conv2D) (None, 15, 15, 64) 36928 [‘activation_1203[0][0]’]
batch_normalization_1304 (Batc (None, 15, 15, 64) 256 [‘conv2d_1304[0][0]’]
hNormalization)
activation_1204 (Activation) (None, 15, 15, 64) 0 [‘batch_normalization_1304[0][0]’
]
conv2d_1305 (Conv2D) (None, 15, 15, 256) 16640 [‘activation_1204[0][0]’]
batch_normalization_1305 (Batc (None, 15, 15, 256) 1024 [‘conv2d_1305[0][0]’]
hNormalization)
add_392 (Add) (None, 15, 15, 256) 0 [‘batch_normalization_1305[0][0]’
, ‘activation_1202[0][0]’]
activation_1205 (Activation) (None, 15, 15, 256) 0 [‘add_392[0][0]’]
conv2d_1306 (Conv2D) (None, 15, 15, 64) 16448 [‘activation_1205[0][0]’]
batch_normalization_1306 (Batc (None, 15, 15, 64) 256 [‘conv2d_1306[0][0]’]
hNormalization)
activation_1206 (Activation) (None, 15, 15, 64) 0 [‘batch_normalization_1306[0][0]’
]
conv2d_1307 (Conv2D) (None, 15, 15, 64) 36928 [‘activation_1206[0][0]’]
batch_normalization_1307 (Batc (None, 15, 15, 64) 256 [‘conv2d_1307[0][0]’]
hNormalization)
activation_1207 (Activation) (None, 15, 15, 64) 0 [‘batch_normalization_1307[0][0]’
]
conv2d_1308 (Conv2D) (None, 15, 15, 256) 16640 [‘activation_1207[0][0]’]
batch_normalization_1308 (Batc (None, 15, 15, 256) 1024 [‘conv2d_1308[0][0]’]
hNormalization)
add_393 (Add) (None, 15, 15, 256) 0 [‘batch_normalization_1308[0][0]’
, ‘activation_1205[0][0]’]
activation_1208 (Activation) (None, 15, 15, 256) 0 [‘add_393[0][0]’]
conv2d_1309 (Conv2D) (None, 8, 8, 128) 32896 [‘activation_1208[0][0]’]
batch_normalization_1309 (Batc (None, 8, 8, 128) 512 [‘conv2d_1309[0][0]’]
hNormalization)
activation_1209 (Activation) (None, 8, 8, 128) 0 [‘batch_normalization_1309[0][0]’
]
conv2d_1310 (Conv2D) (None, 8, 8, 128) 147584 [‘activation_1209[0][0]’]
batch_normalization_1310 (Batc (None, 8, 8, 128) 512 [‘conv2d_1310[0][0]’]
hNormalization)
activation_1210 (Activation) (None, 8, 8, 128) 0 [‘batch_normalization_1310[0][0]’
]
conv2d_1311 (Conv2D) (None, 8, 8, 512) 66048 [‘activation_1210[0][0]’]
conv2d_1312 (Conv2D) (None, 8, 8, 512) 131584 [‘activation_1208[0][0]’]
batch_normalization_1311 (Batc (None, 8, 8, 512) 2048 [‘conv2d_1311[0][0]’]
hNormalization)
batch_normalization_1312 (Batc (None, 8, 8, 512) 2048 [‘conv2d_1312[0][0]’]
hNormalization)
add_394 (Add) (None, 8, 8, 512) 0 [‘batch_normalization_1311[0][0]’
, 'batch_normalization_1312[0][0]
']
activation_1211 (Activation) (None, 8, 8, 512) 0 [‘add_394[0][0]’]
conv2d_1313 (Conv2D) (None, 8, 8, 128) 65664 [‘activation_1211[0][0]’]
batch_normalization_1313 (Batc (None, 8, 8, 128) 512 [‘conv2d_1313[0][0]’]
hNormalization)
activation_1212 (Activation) (None, 8, 8, 128) 0 [‘batch_normalization_1313[0][0]’
]
conv2d_1314 (Conv2D) (None, 8, 8, 128) 147584 [‘activation_1212[0][0]’]
batch_normalization_1314 (Batc (None, 8, 8, 128) 512 [‘conv2d_1314[0][0]’]
hNormalization)
activation_1213 (Activation) (None, 8, 8, 128) 0 [‘batch_normalization_1314[0][0]’
]
conv2d_1315 (Conv2D) (None, 8, 8, 512) 66048 [‘activation_1213[0][0]’]
batch_normalization_1315 (Batc (None, 8, 8, 512) 2048 [‘conv2d_1315[0][0]’]
hNormalization)
add_395 (Add) (None, 8, 8, 512) 0 [‘batch_normalization_1315[0][0]’
, ‘activation_1211[0][0]’]
activation_1214 (Activation) (None, 8, 8, 512) 0 [‘add_395[0][0]’]
conv2d_1316 (Conv2D) (None, 8, 8, 128) 65664 [‘activation_1214[0][0]’]
batch_normalization_1316 (Batc (None, 8, 8, 128) 512 [‘conv2d_1316[0][0]’]
hNormalization)
activation_1215 (Activation) (None, 8, 8, 128) 0 [‘batch_normalization_1316[0][0]’
]
conv2d_1317 (Conv2D) (None, 8, 8, 128) 147584 [‘activation_1215[0][0]’]
batch_normalization_1317 (Batc (None, 8, 8, 128) 512 [‘conv2d_1317[0][0]’]
hNormalization)
activation_1216 (Activation) (None, 8, 8, 128) 0 [‘batch_normalization_1317[0][0]’
]
conv2d_1318 (Conv2D) (None, 8, 8, 512) 66048 [‘activation_1216[0][0]’]
batch_normalization_1318 (Batc (None, 8, 8, 512) 2048 [‘conv2d_1318[0][0]’]
hNormalization)
add_396 (Add) (None, 8, 8, 512) 0 [‘batch_normalization_1318[0][0]’
, ‘activation_1214[0][0]’]
activation_1217 (Activation) (None, 8, 8, 512) 0 [‘add_396[0][0]’]
conv2d_1319 (Conv2D) (None, 8, 8, 128) 65664 [‘activation_1217[0][0]’]
batch_normalization_1319 (Batc (None, 8, 8, 128) 512 [‘conv2d_1319[0][0]’]
hNormalization)
activation_1218 (Activation) (None, 8, 8, 128) 0 [‘batch_normalization_1319[0][0]’
]
conv2d_1320 (Conv2D) (None, 8, 8, 128) 147584 [‘activation_1218[0][0]’]
batch_normalization_1320 (Batc (None, 8, 8, 128) 512 [‘conv2d_1320[0][0]’]
hNormalization)
activation_1219 (Activation) (None, 8, 8, 128) 0 [‘batch_normalization_1320[0][0]’
]
conv2d_1321 (Conv2D) (None, 8, 8, 512) 66048 [‘activation_1219[0][0]’]
batch_normalization_1321 (Batc (None, 8, 8, 512) 2048 [‘conv2d_1321[0][0]’]
hNormalization)
add_397 (Add) (None, 8, 8, 512) 0 [‘batch_normalization_1321[0][0]’
, ‘activation_1217[0][0]’]
activation_1220 (Activation) (None, 8, 8, 512) 0 [‘add_397[0][0]’]
conv2d_1322 (Conv2D) (None, 4, 4, 256) 131328 [‘activation_1220[0][0]’]
batch_normalization_1322 (Batc (None, 4, 4, 256) 1024 [‘conv2d_1322[0][0]’]
hNormalization)
activation_1221 (Activation) (None, 4, 4, 256) 0 [‘batch_normalization_1322[0][0]’
]
conv2d_1323 (Conv2D) (None, 4, 4, 256) 590080 [‘activation_1221[0][0]’]
batch_normalization_1323 (Batc (None, 4, 4, 256) 1024 [‘conv2d_1323[0][0]’]
hNormalization)
activation_1222 (Activation) (None, 4, 4, 256) 0 [‘batch_normalization_1323[0][0]’
]
conv2d_1324 (Conv2D) (None, 4, 4, 1024) 263168 [‘activation_1222[0][0]’]
conv2d_1325 (Conv2D) (None, 4, 4, 1024) 525312 [‘activation_1220[0][0]’]
batch_normalization_1324 (Batc (None, 4, 4, 1024) 4096 [‘conv2d_1324[0][0]’]
hNormalization)
batch_normalization_1325 (Batc (None, 4, 4, 1024) 4096 [‘conv2d_1325[0][0]’]
hNormalization)
add_398 (Add) (None, 4, 4, 1024) 0 [‘batch_normalization_1324[0][0]’
, 'batch_normalization_1325[0][0]
']
activation_1223 (Activation) (None, 4, 4, 1024) 0 [‘add_398[0][0]’]
conv2d_1326 (Conv2D) (None, 4, 4, 256) 262400 [‘activation_1223[0][0]’]
batch_normalization_1326 (Batc (None, 4, 4, 256) 1024 [‘conv2d_1326[0][0]’]
hNormalization)
activation_1224 (Activation) (None, 4, 4, 256) 0 [‘batch_normalization_1326[0][0]’
]
conv2d_1327 (Conv2D) (None, 4, 4, 256) 590080 [‘activation_1224[0][0]’]
batch_normalization_1327 (Batc (None, 4, 4, 256) 1024 [‘conv2d_1327[0][0]’]
hNormalization)
activation_1225 (Activation) (None, 4, 4, 256) 0 [‘batch_normalization_1327[0][0]’
]
conv2d_1328 (Conv2D) (None, 4, 4, 1024) 263168 [‘activation_1225[0][0]’]
batch_normalization_1328 (Batc (None, 4, 4, 1024) 4096 [‘conv2d_1328[0][0]’]
hNormalization)
add_399 (Add) (None, 4, 4, 1024) 0 [‘batch_normalization_1328[0][0]’
, ‘activation_1223[0][0]’]
activation_1226 (Activation) (None, 4, 4, 1024) 0 [‘add_399[0][0]’]
conv2d_1329 (Conv2D) (None, 4, 4, 256) 262400 [‘activation_1226[0][0]’]
batch_normalization_1329 (Batc (None, 4, 4, 256) 1024 [‘conv2d_1329[0][0]’]
hNormalization)
activation_1227 (Activation) (None, 4, 4, 256) 0 [‘batch_normalization_1329[0][0]’
]
conv2d_1330 (Conv2D) (None, 4, 4, 256) 590080 [‘activation_1227[0][0]’]
batch_normalization_1330 (Batc (None, 4, 4, 256) 1024 [‘conv2d_1330[0][0]’]
hNormalization)
activation_1228 (Activation) (None, 4, 4, 256) 0 [‘batch_normalization_1330[0][0]’
]
conv2d_1331 (Conv2D) (None, 4, 4, 1024) 263168 [‘activation_1228[0][0]’]
batch_normalization_1331 (Batc (None, 4, 4, 1024) 4096 [‘conv2d_1331[0][0]’]
hNormalization)
add_400 (Add) (None, 4, 4, 1024) 0 [‘batch_normalization_1331[0][0]’
, ‘activation_1226[0][0]’]
activation_1229 (Activation) (None, 4, 4, 1024) 0 [‘add_400[0][0]’]
conv2d_1332 (Conv2D) (None, 4, 4, 256) 262400 [‘activation_1229[0][0]’]
batch_normalization_1332 (Batc (None, 4, 4, 256) 1024 [‘conv2d_1332[0][0]’]
hNormalization)
activation_1230 (Activation) (None, 4, 4, 256) 0 [‘batch_normalization_1332[0][0]’
]
conv2d_1333 (Conv2D) (None, 4, 4, 256) 590080 [‘activation_1230[0][0]’]
batch_normalization_1333 (Batc (None, 4, 4, 256) 1024 [‘conv2d_1333[0][0]’]
hNormalization)
activation_1231 (Activation) (None, 4, 4, 256) 0 [‘batch_normalization_1333[0][0]’
]
conv2d_1334 (Conv2D) (None, 4, 4, 1024) 263168 [‘activation_1231[0][0]’]
batch_normalization_1334 (Batc (None, 4, 4, 1024) 4096 [‘conv2d_1334[0][0]’]
hNormalization)
add_401 (Add) (None, 4, 4, 1024) 0 [‘batch_normalization_1334[0][0]’
, ‘activation_1229[0][0]’]
activation_1232 (Activation) (None, 4, 4, 1024) 0 [‘add_401[0][0]’]
conv2d_1335 (Conv2D) (None, 4, 4, 256) 262400 [‘activation_1232[0][0]’]
batch_normalization_1335 (Batc (None, 4, 4, 256) 1024 [‘conv2d_1335[0][0]’]
hNormalization)
activation_1233 (Activation) (None, 4, 4, 256) 0 [‘batch_normalization_1335[0][0]’
]
conv2d_1336 (Conv2D) (None, 4, 4, 256) 590080 [‘activation_1233[0][0]’]
batch_normalization_1336 (Batc (None, 4, 4, 256) 1024 [‘conv2d_1336[0][0]’]
hNormalization)
activation_1234 (Activation) (None, 4, 4, 256) 0 [‘batch_normalization_1336[0][0]’
]
conv2d_1337 (Conv2D) (None, 4, 4, 1024) 263168 [‘activation_1234[0][0]’]
batch_normalization_1337 (Batc (None, 4, 4, 1024) 4096 [‘conv2d_1337[0][0]’]
hNormalization)
add_402 (Add) (None, 4, 4, 1024) 0 [‘batch_normalization_1337[0][0]’
, ‘activation_1232[0][0]’]
activation_1235 (Activation) (None, 4, 4, 1024) 0 [‘add_402[0][0]’]
conv2d_1338 (Conv2D) (None, 4, 4, 256) 262400 [‘activation_1235[0][0]’]
batch_normalization_1338 (Batc (None, 4, 4, 256) 1024 [‘conv2d_1338[0][0]’]
hNormalization)
activation_1236 (Activation) (None, 4, 4, 256) 0 [‘batch_normalization_1338[0][0]’
]
conv2d_1339 (Conv2D) (None, 4, 4, 256) 590080 [‘activation_1236[0][0]’]
batch_normalization_1339 (Batc (None, 4, 4, 256) 1024 [‘conv2d_1339[0][0]’]
hNormalization)
activation_1237 (Activation) (None, 4, 4, 256) 0 [‘batch_normalization_1339[0][0]’
]
conv2d_1340 (Conv2D) (None, 4, 4, 1024) 263168 [‘activation_1237[0][0]’]
batch_normalization_1340 (Batc (None, 4, 4, 1024) 4096 [‘conv2d_1340[0][0]’]
hNormalization)
add_403 (Add) (None, 4, 4, 1024) 0 [‘batch_normalization_1340[0][0]’
, ‘activation_1235[0][0]’]
activation_1238 (Activation) (None, 4, 4, 1024) 0 [‘add_403[0][0]’]
conv2d_1341 (Conv2D) (None, 2, 2, 512) 524800 [‘activation_1238[0][0]’]
batch_normalization_1341 (Batc (None, 2, 2, 512) 2048 [‘conv2d_1341[0][0]’]
hNormalization)
activation_1239 (Activation) (None, 2, 2, 512) 0 [‘batch_normalization_1341[0][0]’
]
conv2d_1342 (Conv2D) (None, 2, 2, 512) 2359808 [‘activation_1239[0][0]’]
batch_normalization_1342 (Batc (None, 2, 2, 512) 2048 [‘conv2d_1342[0][0]’]
hNormalization)
activation_1240 (Activation) (None, 2, 2, 512) 0 [‘batch_normalization_1342[0][0]’
]
conv2d_1343 (Conv2D) (None, 2, 2, 2048) 1050624 [‘activation_1240[0][0]’]
conv2d_1344 (Conv2D) (None, 2, 2, 2048) 2099200 [‘activation_1238[0][0]’]
batch_normalization_1343 (Batc (None, 2, 2, 2048) 8192 [‘conv2d_1343[0][0]’]
hNormalization)
batch_normalization_1344 (Batc (None, 2, 2, 2048) 8192 [‘conv2d_1344[0][0]’]
hNormalization)
add_404 (Add) (None, 2, 2, 2048) 0 [‘batch_normalization_1343[0][0]’
, 'batch_normalization_1344[0][0]
']
activation_1241 (Activation) (None, 2, 2, 2048) 0 [‘add_404[0][0]’]
conv2d_1345 (Conv2D) (None, 2, 2, 512) 1049088 [‘activation_1241[0][0]’]
batch_normalization_1345 (Batc (None, 2, 2, 512) 2048 [‘conv2d_1345[0][0]’]
hNormalization)
activation_1242 (Activation) (None, 2, 2, 512) 0 [‘batch_normalization_1345[0][0]’
]
conv2d_1346 (Conv2D) (None, 2, 2, 512) 2359808 [‘activation_1242[0][0]’]
batch_normalization_1346 (Batc (None, 2, 2, 512) 2048 [‘conv2d_1346[0][0]’]
hNormalization)
activation_1243 (Activation) (None, 2, 2, 512) 0 [‘batch_normalization_1346[0][0]’
]
conv2d_1347 (Conv2D) (None, 2, 2, 2048) 1050624 [‘activation_1243[0][0]’]
batch_normalization_1347 (Batc (None, 2, 2, 2048) 8192 [‘conv2d_1347[0][0]’]
hNormalization)
add_405 (Add) (None, 2, 2, 2048) 0 [‘batch_normalization_1347[0][0]’
, ‘activation_1241[0][0]’]
activation_1244 (Activation) (None, 2, 2, 2048) 0 [‘add_405[0][0]’]
conv2d_1348 (Conv2D) (None, 2, 2, 512) 1049088 [‘activation_1244[0][0]’]
batch_normalization_1348 (Batc (None, 2, 2, 512) 2048 [‘conv2d_1348[0][0]’]
hNormalization)
activation_1245 (Activation) (None, 2, 2, 512) 0 [‘batch_normalization_1348[0][0]’
]
conv2d_1349 (Conv2D) (None, 2, 2, 512) 2359808 [‘activation_1245[0][0]’]
batch_normalization_1349 (Batc (None, 2, 2, 512) 2048 [‘conv2d_1349[0][0]’]
hNormalization)
activation_1246 (Activation) (None, 2, 2, 512) 0 [‘batch_normalization_1349[0][0]’
]
conv2d_1350 (Conv2D) (None, 2, 2, 2048) 1050624 [‘activation_1246[0][0]’]
batch_normalization_1350 (Batc (None, 2, 2, 2048) 8192 [‘conv2d_1350[0][0]’]
hNormalization)
add_406 (Add) (None, 2, 2, 2048) 0 [‘batch_normalization_1350[0][0]’
, ‘activation_1244[0][0]’]
activation_1247 (Activation) (None, 2, 2, 2048) 0 [‘add_406[0][0]’]
average_pooling2d_24 (AverageP (None, 1, 1, 2048) 0 [‘activation_1247[0][0]’]
ooling2D)
dense_24 (Dense) (None, 1, 1, 6) 12294 [‘average_pooling2d_24[0][0]’]
==================================================================================================
Total params: 23,600,006
Trainable params: 23,546,886
Non-trainable params: 53,120
None
Ah !
You are going to get yourself in trouble posting your code-- it is against the forum rules.
I didn’t say post your code, I asked for your model summary like this:
A quick look though, you don’t need a shape on your AveragePooling. Try removing that.
Still the same error
Yeah, you have a lot going on here that I don’t have in mine… For ex, you don’t have to set up the initializer for every single layer, so you can just remove that.
Also note, from the provided header code:
from tensorflow.keras.initializers import random_uniform, glorot_uniform, constant, identity
glorot_uniform is what we pull in. I imagine the TF GlorotUniform is the same, but I don’t know. Try swapping that. I am also not sure it is a good idea to use it as a ‘global variable’ like that either. Better just to instantiate it when/where you need it.
Here we fix the seed, but in most cases you won’t.
@sahermaan_712 sorry, I have to go out for a bit-- But looking over your model summary, I think you forgot to flatten everything before applying your dense layer.
Most of the rest from quick glances (in addition to what I said above), seems ok.
you are probably mixing your input values.
if I remember your previous error was reverse, so check if you’re assigning randomuniform and glorotuniform at right places.
if you notice your codes, for conv_block and identity block you are suppose to use initializer GlorotUniform and for conv2D kernel_initiaizer as init as per the assigned call arguments.
Regards
DP