Skip to content

Commit f16d4e7

Browse files
committed
lol
1 parent a597d10 commit f16d4e7

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

Fall20/NeuralNetworks4/layers.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
from tensorflow.keras import Model, layers, Input
22
import numpy as np
33

4-
temp_im_test = np.ones((1,128,128,3))
4+
temp_im_test = np.random.rand(1,64,64,3)
55

6-
input_shape_img = (128,128,3)
6+
input_shape_img = (64,64,3)
77

88
img_input = Input(shape=input_shape_img)
99

10-
# convolutional layers with 64 neurons and (3,3) kernel each
11-
conv1_1 = layers.Conv2D(64, (3, 3), activation='relu', padding='same', name='block1_conv1')(img_input)
12-
conv1_2 = layers.Conv2D(64, (3, 3), activation='relu', padding='same', name='block1_conv2')(conv1_1)
10+
# convolutional layers with 32 neurons and (3,3) kernel each
11+
conv1_1 = layers.Conv2D(32, (3, 3), activation='relu', padding='same', name='block1_conv1')(img_input)
12+
conv1_2 = layers.Conv2D(32, (3, 3), activation='relu', padding='same', name='block1_conv2')(conv1_1)
1313

1414
# maxpool2D layer with (2,2) filter and stride (2,2)
15-
max1 = layers.MaxPool2D((2, 2), strides=(2, 2), name='block1_pool')(conv1_2)
15+
max1 = layers.MaxPool2D((2, 2), strides=(2, 2), name='block1_max_pool')(img_input)
16+
17+
# avgpool2D layer with (2,2) filter and stride (2,2)
18+
avg1 = layers.AveragePooling2D((2, 2), strides=(2, 2), name='block1_avg_pool')(img_input)
1619

1720
# globalmax layer
18-
globalmax1 = layers.GlobalMaxPool2D()(max1)
21+
globalmax1 = layers.GlobalMaxPool2D()
1922

2023
# flattens input to 1D array
21-
flatten1 = layers.Flatten()(globalmax1)
24+
flatten1 = layers.Flatten()(avg1)
2225

2326
# dropout layer modifies input layer so some values become 0
2427
drop1 = layers.Dropout(.2)(flatten1)
2528

2629
# standard dense layer
27-
dense1 = layers.Dense(32)(drop1)
30+
dense1 = layers.Dense(10)(drop1)
2831

2932
# compiles model with input: img_input and output as output from dense1
3033
model = Model(inputs = img_input, outputs= dense1)
@@ -35,5 +38,7 @@
3538

3639
# show result on one input
3740
values = model.predict(temp_im_test)
38-
print(values.shape)
39-
print(values)
41+
print("shape of input" + str(temp_im_test.shape))
42+
print("shape of output" + str(values.shape))
43+
print(temp_im_test[0])
44+
print(values[0])

0 commit comments

Comments
 (0)