官术网_书友最值得收藏!

Problems with traditional NN

Scenario 1: Let's create a new image where the original image is translated by 1 pixel toward the left. In the following code, we are looping through the columns of the image and copying the pixel values of the next column to the current column:

for i in range(pic.shape[0]):
if i<20:
pic[:,i]=pic[:,i+1]
plt.imshow(pic)

The left translated average 1 image looks as follows:

Let’s go ahead and predict the label of the image using the built model:

model.predict(pic.reshape(1,784)/255)

The model's prediction on the translated image is as follows:

We can see a prediction of 1, though with a lower probability than when pixels were not translated.

Scenario 2: A new image is created in which the pixels of the original average 1 image are shifted by 2 pixels to the right:

pic=np.zeros((28,28))
pic2=np.copy(pic)
for i in range(X_train1.shape[0]):
pic2=X_train1[i,:,:]
pic=pic+pic2
pic=(pic/X_train1.shape[0])
pic2=np.copy(pic)
for i in range(pic.shape[0]):
if ((i>6) and (i<26)):
pic[:,i]=pic2[:,(i-1)]
plt.imshow(pic)

The right translated average 1 image looks as follows:

The prediction of this image is as follows:

model.predict(pic.reshape(1,784)/255)

The model's prediction on the translated image is as follows:

We can see that the prediction is incorrect with an output of 3. This is the problem that we will be addressing by using a CNN.

主站蜘蛛池模板: 宁河县| 商城县| 鄂州市| 布拖县| 绍兴市| 岑巩县| 蒙城县| 醴陵市| 邛崃市| 昌宁县| 富平县| 乾安县| 祁门县| 会同县| 尤溪县| 乌兰察布市| 特克斯县| 孟连| 达拉特旗| 包头市| 合水县| 临武县| 胶南市| 阿拉善盟| 大埔区| 汝阳县| 绥化市| 丰宁| 澄城县| 奈曼旗| 璧山县| 克东县| 安龙县| 怀宁县| 大关县| 辉南县| 湖南省| 黎城县| 安阳县| 肇庆市| 金川县|