• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Layer

a guest Jun 15th, 2019 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import numpy as np
2. class Layer:
3.     def __init__(self):
4.         self.input = np.matrix([]).astype(np.float)
5.
6.         self.output = np.matrix([]).astype(np.float)
7.
8. class affineLayer(Layer):
9.     def __init__(self, neuronsNumber, inputsPerNeuron, isBias, functionName):
10.         super(affineLayer,self).__init__()
11.
12.         self.weights = np.asmatrix(np.random.random((neuronsNumber, inputsPerNeuron))).astype(np.float)
13.             # (2 * np.asmatrix(np.random.random((neuronsNumber, inputsPerNeuron))).astype(np.float) - 1) / 16
14.
15.         self.weightsChanges = np.asmatrix(np.zeros((neuronsNumber, inputsPerNeuron))).astype(np.float)
16.
17.         self.isBias = isBias
18.         if(self.isBias):
19.             self.bias = np.asmatrix(np.random.random((neuronsNumber, 1))).astype(np.float)
20.                 # (2 * np.asmatrix(np.random.random((neuronsNumber, 1))).astype(np.float) - 1) / 16
21.
22.             self.biasChanges = np.asmatrix(np.zeros((neuronsNumber, 1))).astype(np.float)
23.
24.         self.z = np.matrix([]).astype(np.float)
25.
26.         self.error = np.matrix([]).astype(np.float)
27.         self.activator = functionName
28.
29. class rbfLayer(Layer):
30.     def __init__(self,centroids,widths):
31.         super(rbfLayer, self).__init__()
32.         self.centroids = centroids
33.         self.widths = widths
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top