-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPBGWeightedConnection.m
69 lines (56 loc) · 1.03 KB
/
PBGWeightedConnection.m
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// PBGWeightedConnection.m
// neurosis
//
// Created by Patrick B. Gibson on 27/10/07.
// Copyright 2007 Patrick B. Gibson. All rights reserved.
//
#import "PBGWeightedConnection.h"
@implementation PBGWeightedConnection
- (id)initWithInput:(PBGNeuron *)newInput weight:(double)w adjustable:(BOOL)adjustableValue
{
self = [super init];
if (self != nil) {
weight = w;
inputNeuron = [newInput retain];
canBeAdjusted = adjustableValue;
}
return self;
}
- (double)outputValue
{
return (double) ([inputNeuron outputValue] * weight);
}
- (PBGNeuron *)inputNeuron
{
return inputNeuron;
}
- (double)weight
{
return weight;
}
- (void)setWeight:(double)w
{
weight = w;
}
- (void)setNewWeight:(double)w
{
newWeight = w;
}
- (void)updateNow
{
if (DEBUG_LOGGING)
NSLog(@"Updating %@ to %f", self, newWeight);
weight = newWeight;
[inputNeuron updateNow];
}
- (NSString *)description
{
return [NSString stringWithFormat:@"%@ - %f ->", inputNeuron, weight];
}
- (void) dealloc
{
[inputNeuron release];
[super dealloc];
}
@end