Beispiel #1
0
 def unroll(self, arr):
     for i in range(0,len(arr)):
         arr[i]=np.array(arr[i])
         if i==0:
             res=(arr[i]).ravel().T
         else:
             res=np.vstack((res,(arr[i]).ravel().T))
     res.shape=(1, len(res))
     return res
Beispiel #2
0
 def run(self, nn, input):
     z=[0]
     a=[]
     a.append(copy.deepcopy(input))
     a[0]=np.array(a[0]).T # nx1 vector
     logFunc = self.logisticFunction()
     for i in range(1, len(nn['structure'])):
         a[i-1]=np.vstack(([1], a[i-1]))
         z.append(np.dot(nn['theta'][i], a[i-1]))
         a.append(logFunc(z[i]))
     nn['z'] = z
     nn['a'] = a
     return a[len(nn['structure'])-1]