-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmecdiff.h
92 lines (73 loc) · 2.58 KB
/
mecdiff.h
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Navigating with grid and place cells in cluttered environments
// Edvardsen et al. (2020). Hippocampus, 30(3), 220-232.
//
// Licensed under the EUPL-1.2-or-later.
// Copyright (c) 2019 NTNU - Norwegian University of Science and Technology.
// Author: Vegard Edvardsen (https://github.com/evegard).
#ifndef MECDIFF_H_INCLUDED
#define MECDIFF_H_INCLUDED
#include <cmath>
#include "mec.h"
#include "network.h"
#include "numerical.h"
class MecDiffNetwork : public Network
{
public:
MecDiffNetwork(
bool simplified,
NeuralSheetNetwork *current, NeuralSheetNetwork *target,
int direction_samples, int xy_samples, int offset);
bool simplified;
NeuralSheetNetwork *current;
NeuralSheetNetwork *target;
int direction_samples;
int xy_samples;
int offset;
inline int direction_sample(int i) { return i % this->direction_samples; }
inline int x_sample(int i) { return (i / this->direction_samples) % this->xy_samples; }
inline int y_sample(int i) { return (i / this->direction_samples) / this->xy_samples; }
inline real direction(int i) { return this->direction_sample(i) * 2 * M_PI / this->direction_samples; }
inline int x(int i) { return this->x_sample(i) * MEC_SIZE / this->xy_samples; }
inline int y(int i) { return this->y_sample(i) * MEC_SIZE / this->xy_samples; }
inline int neuron_index(int direction, int x, int y)
{ return (y * this->xy_samples + x) * this->direction_samples + direction; }
protected:
void update_neuron_values();
};
class MecDiffCurrentInput : public MecShiftedMaskInput
{
public:
MecDiffCurrentInput(
MecDiffNetwork *efferent,
NeuralSheetNetwork *afferent);
protected:
MecDiffNetwork *efferent;
real get_weight(int x, int y);
std::pair<int, int> get_shift(int neuron_index);
};
class MecDiffTargetInput : public MecShiftedMaskInput
{
public:
MecDiffTargetInput(
MecDiffNetwork *efferent,
NeuralSheetNetwork *afferent,
int offset);
protected:
MecDiffNetwork *efferent;
int offset;
real get_weight(int x, int y);
std::pair<int, int> get_shift(int neuron_index);
};
class MecDiffSimplifiedInput : public Input
{
public:
MecDiffSimplifiedInput(
MecDiffNetwork *efferent,
NeuralSheetNetwork *afferent,
int offset);
void add_inputs();
protected:
NeuralSheetNetwork *afferent;
int *input_indices;
};
#endif