Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- #Imports
- #
- import numpy as np
- class BackPropagationNetwork:
- """A back-propagation-network"""
- #
- # Class members
- #
- layerCount = 0
- shape =None
- weights = []
- #
- #class methods
- #
- def __init__(self, layerSize):
- """initialize the network"""
- # Layer info
- self.layerCount = len(layerSize)-1
- self.shape = layerSize
- # Input/Output data from last run
- self.layerInput = []
- self._layerOutput =[]
- # create the weight arrays
- for (l1, l2) in zip(layerSize[:-1], layerSize[1:]):
- self.weights.append(np.random.normal(scale =0.1, size =(l2, l1+1)))
- #
- # If run as script, create a test object
- #
- if __name__ == "__main__":
- bpn = BackPropagationNetwork((2,2,1))
- print(bpn.shape)
- print(bpn.weights)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement