Skip to content

Commit

Permalink
Update lab_1.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ddman1101 authored Nov 28, 2018
1 parent 8773251 commit a3228d5
Showing 1 changed file with 2 additions and 38 deletions.
40 changes: 2 additions & 38 deletions lab_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,11 @@
@author: HP
"""

#from PIL import Image
#import matplotlib.pyplot as plt
#import numpy as np
#im = Image.open( "C:\\Users\\HP\\Desktop\\碩士班\\類神經網路與深度學習\\training\\9\\*.png" )
#print(im)
#show image information
#print (im.format, im.size, im.mode)
#plt.imshow(im)
#matrix = np.array(im)
#print(matrix)
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
import random
import math
import skimage.io as io
import winsound
from skimage import data_dir

str0='C:/Users/HP/Desktop/碩士班/類神經網路與深度學習/training/0/*.png'
Expand Down Expand Up @@ -165,11 +152,6 @@ def f(x):

for u in range(40000):
matrix[u] = allmatrix[u,10:40000]
#for k in range(number_of_hidden_layers):
# weight[k] = np.matrix(np.random.uniform(-1,1,(hidden_layers_nod,hidden_layers_nod)))

#def forward_input(k):
# hidden_layer_output[k] = np.matrix( np.array(weight_list)[0] * matrix_0[d])

def f(x):
return 1 / (1 + np.exp(-x))
Expand All @@ -194,25 +176,6 @@ def f(x):
weight_input = weight_input + np.transpose(delta_weight_hidden_layer)
weight_output = weight_output + np.transpose(delta_weight_output_layer)

#back propogation


#class NN():
# def __init__(self,layers,learning_rate):
# self.layers = layers
# self.learning_rate = learning_rate

# def activation_function(self, x):
# return 1 / (1 + math.exp(-x))

#hidden_layers1 = 5
#weight_num = 784*hidden_layers1
#weight1 = np.matrix(np.random.rand(28,hidden_layers1))
#weight2 = np.matrix(np.random.rand(5,10))
#print(weight1)
#print(weight2)
#len(weight1)
#test1 = matrix0 * weight1

#測試
def cost_function(x):
Expand Down Expand Up @@ -348,7 +311,8 @@ def f(x):
answers = temp_list.index([np.asscalar(min(temp))])
answer[p] = answers
print(answers)


#生成檔案
answer1 = np.transpose(np.array(answer,dtype = int))
f = open('C:\\Users\\HP\\Desktop\\碩士班\\類神經網路與深度學習\\A.txt', 'w', encoding = 'UTF-8')
for y in range(10000):
Expand Down

0 comments on commit a3228d5

Please sign in to comment.