-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathneuron.py
More file actions
33 lines (23 loc) · 778 Bytes
/
neuron.py
File metadata and controls
33 lines (23 loc) · 778 Bytes
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
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 transpalette <transpalette@arch-cactus>
#
# Distributed under terms of the MIT license.
"""
Neuron class
"""
from synapse import Synapse
class Neuron:
def __init__(self):
self.value = 0
self.synapses_from = [] # Those synapses lead to the neurons of the next layer
self.synapses_to = [] # Those synapses lead to the neurons of the previous layer
# Add a (positive or negative) value to the bias
def update_bias(self, value):
self.bias += value
def connect_to(self, nextNeuron):
self.synapses_to.append(Synapse(nextNeuron))
def connect_from(self, previousNeuron):
self.synapses_from.append(Synapse(previousNeuron))