8 #include "ANNErrorLayer.hpp" 10 void ANNErrorLayer_update_state(
28 const float errScale);
32 ANNErrorLayer::ANNErrorLayer() { initialize_base(); }
34 ANNErrorLayer::ANNErrorLayer(
const char *name, HyPerCol *hc) {
35 int status = initialize_base();
36 if (status == PV_SUCCESS) {
37 status = initialize(name, hc);
39 if (status != PV_SUCCESS) {
40 Fatal().printf(
"Creating ANNErrorLayer \"%s\" failed.\n", name);
44 ANNErrorLayer::~ANNErrorLayer() {}
46 int ANNErrorLayer::initialize_base() {
51 int ANNErrorLayer::initialize(
const char *name, HyPerCol *hc) {
52 int status = ANNLayer::initialize(name, hc);
63 parent->parameters()->ioParamValue(
64 ioFlag, name,
"errScale", &errScale, errScale,
true );
73 verticesV = (
float *)malloc((
size_t)numVertices *
sizeof(*verticesV));
74 verticesA = (
float *)malloc((
size_t)numVertices *
sizeof(*verticesA));
75 if (verticesV == NULL || verticesA == NULL) {
77 "%s: unable to allocate memory for vertices: %s\n",
81 verticesV[0] = -VThresh;
82 verticesA[0] = -VThresh;
83 verticesV[1] = -VThresh;
85 verticesV[2] = VThresh;
87 verticesV[3] = VThresh;
88 verticesA[3] = VThresh;
93 verticesV = (
float *)malloc((
size_t)numVertices *
sizeof(*verticesV));
94 verticesA = (
float *)malloc((
size_t)numVertices *
sizeof(*verticesA));
95 if (verticesV == NULL || verticesA == NULL) {
97 "%s: unable to allocate memory for vertices: %s\n",
108 int status = PV_SUCCESS;
109 if (VThresh < 0 && VThresh > -(
float)0.999 * FLT_MAX) {
112 if (parent->columnId() == 0) {
114 "%s: VThresh cannot be negative (value is %f).\n",
126 Response::Status ANNErrorLayer::updateState(
double time,
double dt) {
128 float *A = clayer->activity->data;
130 int num_channels = getNumChannels();
131 float *gSynHead = GSyn == NULL ? NULL : GSyn[0];
135 int num_neurons = nx * ny * nf;
136 int nbatch = loc->nbatch;
137 ANNErrorLayer_update_state(
155 return Response::SUCCESS;
160 void ANNErrorLayer_update_state(
162 const int numNeurons,
178 const float errScale) {
179 updateV_ANNErrorLayer(
bool layerListsVerticesInParams() const
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override
virtual int checkVertices() const override
virtual void ioParam_errScale(enum ParamsIOFlag ioFlag)
: errScale: The input to the error layer is multiplied by errScale before applying the threshold...
virtual int checkVertices() const
virtual int setVertices() override
virtual int ioParamsFillGroup(enum ParamsIOFlag ioFlag) override