def getNeuronRightAnchor(self, neuron): if neuron.__hash__() in self.neuronRightAnchor: cords = self.neuronRightAnchor[neuron.__hash__()] return Point.Point(cords[0], cords[1]) centerPoint = self.getNeuronCenter(neuron) x = centerPoint.x() + (self.layerWidth / 2) y = centerPoint.y() self.neuronRightAnchor[neuron.__hash__()] = (x, y) return Point.Point(x, y)
def getNeuronBottomRight(self, neuron): if neuron.__hash__() in self.neuronBottomRight: cords = self.neuronBottomRight[neuron.__hash__()] return Point.Point(cords[0, cords[1]]) bottomLeft = self.getNeuronTopLeft(neuron) x = bottomLeft.x() + self.neuronWidth y = bottomLeft.y() + self.neuronHeight self.neuronBottomRight[neuron.__hash__()] = (x, y) return Point.Point(x, y)
def getLayerBottomRight(self, layer): if layer.number in self.layerBottomRight: cords = self.layerBottomRight[layer.number] return Point.Point(cords[0], cords[1]) bottomLeft = self.getLayerTopLeft(layer) x = bottomLeft.x() + self.layerWidth y = bottomLeft.y() + self.getLayerHeight(layer) self.layerBottomRight[layer.number] = (x, y) return Point.Point(x, y)
def getLayerTopLeft(self, layer): if layer.number in self.layerTopLeft: cords = self.layerTopLeft[layer.number] return Point.Point(cords[0], cords[1]) x = self.layerXOffset + (layer.number * (self.layerWidth + self.layerMargin)) y = 10 + self.getLayerYOffset(layer) # Storing the cords. Storing a Point object gives strange behaviour self.layerTopLeft[layer.number] = (x, y) return Point.Point(x, y)
def getNeuronTopLeft(self, neuron): if neuron.__hash__() in self.neuronTopLeft: cords = self.neuronTopLeft[neuron.__hash__()] return Point.Point(cords[0], cords[1]) x = (neuron.layer.number * (self.layerWidth + self.layerMargin)) + self.neuronXOffset y = 15 + (neuron.number * self.layerHeightSteps) + self.getNeuronYOffset(neuron) return Point.Point(x, y) self.neuronTopLeft[neuron.__hash__()] = (x, y) return Point.Point(x, y)
def getNeuronCenter(self, neuron): if neuron.__hash__() in self.neuronCenter: cords = self.neuronCenter[neuron.__hash__()] return Point.Point(cords[0], cords[1]) x = (neuron.layer.number * (self.layerWidth + self.layerMargin)) + self.neuronXOffset y = 15 + (neuron.number * self.layerHeightSteps) + self.getNeuronYOffset(neuron) x = x + (self.neuronWidth / 2) y = y + (self.neuronHeight / 2) self.neuronCenter[neuron.__hash__()] = (x, y) return Point.Point(x, y)
def createStrings(self): self.functionNames = list() self.neuronValueStrings = list() for (layerNr, layer) in enumerate(self.brain.layers): if layerNr >= len(self.neuronValueStrings): self.neuronValueStrings.insert(layerNr, list()) for (neuronNr, neuron) in enumerate(layer.neurons): centerPoint = self.points[layerNr][neuronNr] - Point.Point( 20, 12) self.neuronValueStrings[layerNr].insert( neuronNr, Label.Label(centerPoint, str(round(neuron.value, 6)))) functionNamePoint = centerPoint + Point.Point(0, 30) # Input layers do not use the activation function. Therefore hide the label if layerNr != 0: self.functionNames.append( Label.Label(functionNamePoint, str(neuron.activeActivationName)))
def addXPoint(self, x=int): self.registerY(x) point = Point.Point(x, self.heightMap[x]) self.addPoint(point)