-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNeuron.py
49 lines (34 loc) · 1.01 KB
/
Neuron.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 9 17:33:12 2017
@author: JG
"""
import numpy as np
class Neuron(object):
"""
Neuron:
=======
Ein Neuron mit mehreren Inputs (inp,ios[[]]).
Und mehreren Outputs (outp,ios)
"""
def __init__(self,inp):
self.__ios = np.zeros((inp,1),dtype=np.float32) #self.__ios[0] = Inputs
def _set_inputs(self,i):
for _ in range(0,len(self.__ios[0])):
self.__ios[_] = i[_]
def __func(self,x):
"""TODO sigmoid durch softmax ersetzen ( bessere Funktion ) """
return 1/1 + np.power(np.e,x)
def __sum(self):
sum = float()
for i in range(0,len(self.__ios[0])):
sum += self.__ios[0][i]
return sum
def __get_result():
return self.__func(self.__sum())
def _get_outputs():
return self.__ios[1]
def run(self):
"""Einmal aktiviert."""
self.ios[1] = self.__get_result()
#End