Skip to content

Commit acc22ab

Browse files
Build network
1 parent 4effeae commit acc22ab

1 file changed

Lines changed: 29 additions & 17 deletions

File tree

Audio_Classification_Using_CNNs.ipynb

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -378,27 +378,39 @@
378378
"cell_type": "code",
379379
"source": [
380380
"from keras.models import Sequential\n",
381-
"from keras.layers import Conv2D, MaxPooling2D\n",
382-
"from keras.layers import Flatten, Dense\n",
383-
"'''\n",
384-
"Hint:\n",
385-
" https://keras.io/api/models/sequential/\n",
386-
" https://keras.io/api/layers/convolution_layers/convolution2d/\n",
387-
" https://keras.io/api/layers/pooling_layers/max_pooling2d/\n",
388-
" https://keras.io/api/layers/reshaping_layers/flatten/\n",
389-
" https://keras.io/api/layers/core_layers/dense/\n",
381+
"from keras.layers import Conv2D, MaxPooling2D, Flatten, Dense\n",
382+
"from keras.optimizers import Adam\n",
390383
"\n",
391-
"finally compile the model with Adam optimizer and CE loss function\n",
392-
"please consider to define the input_shape for first Conv layer which has a same rule as Input layer\n",
393-
"'''\n",
384+
"model = Sequential()\n",
394385
"\n",
386+
"# Layer 1: Conv2D + MaxPool\n",
387+
"model.add(Conv2D(32, (3, 3), activation='relu', input_shape=(224, 224, 3)))\n",
388+
"model.add(MaxPooling2D(pool_size=(2, 2)))\n",
395389
"\n",
396-
"##############################################\n",
397-
"############# YOUR CODES GO HERE #############\n",
398-
"model = ...\n",
390+
"# Layer 2: Conv2D + MaxPool\n",
391+
"model.add(Conv2D(128, (3, 3), activation='relu'))\n",
392+
"model.add(MaxPooling2D(pool_size=(2, 2)))\n",
399393
"\n",
400-
"model.summary()\n",
401-
"##############################################"
394+
"# Layer 3: Conv2D + MaxPool\n",
395+
"model.add(Conv2D(128, (3, 3), activation='relu'))\n",
396+
"model.add(MaxPooling2D(pool_size=(2, 2)))\n",
397+
"\n",
398+
"# Layer 4: Conv2D + MaxPool\n",
399+
"model.add(Conv2D(128, (3, 3), activation='relu'))\n",
400+
"model.add(MaxPooling2D(pool_size=(2, 2)))\n",
401+
"\n",
402+
"# Flatten\n",
403+
"model.add(Flatten())\n",
404+
"\n",
405+
"# Fully Connected Dense Layers\n",
406+
"model.add(Dense(1024, activation='relu'))\n",
407+
"model.add(Dense(4, activation='softmax')) # 4 classes\n",
408+
"\n",
409+
"# Compile the model\n",
410+
"model.compile(optimizer=Adam(), loss='categorical_crossentropy', metrics=['accuracy'])\n",
411+
"\n",
412+
"# Print model summary\n",
413+
"model.summary()"
402414
],
403415
"metadata": {
404416
"id": "dYmB0f5YR4hY"

0 commit comments

Comments
 (0)