From 8c8d67de73b1e9b7aaca4319c2913067b8f0565b Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Tue, 27 Mar 2018 16:06:10 +0200 Subject: [PATCH] Bugfix: actually compute interactions in the right order. Fix #5. --- src/fmri/visualisations.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/fmri/visualisations.cpp b/src/fmri/visualisations.cpp index a56aff6..e9ae975 100644 --- a/src/fmri/visualisations.cpp +++ b/src/fmri/visualisations.cpp @@ -106,10 +106,10 @@ static Animation *getFullyConnectedAnimation(const fmri::LayerData &prevState, c const auto numEntries = accumulate(shape.begin(), shape.end(), static_cast(1), multiplies()); vector interactions(numEntries); - const auto stepSize = shape[0]; + const auto stepSize = shape[1]; for (auto i : Range(numEntries / stepSize)) { - caffe::caffe_mul(shape[0], &weights[i * stepSize], data, &interactions[i * stepSize]); + caffe::caffe_mul(shape[1], &weights[i * stepSize], data, &interactions[i * stepSize]); } const auto desiredSize = min(INTERACTION_LIMIT, numEntries); @@ -125,9 +125,26 @@ static Animation *getFullyConnectedAnimation(const fmri::LayerData &prevState, c if (abs(interactions[i]) < EPSILON){ break; } - result.emplace_back(interactions[i], make_pair((i % shape[1]) / normalizer, i / shape[1])); + result.emplace_back(interactions[i], make_pair((i % shape[1]), i / shape[1])); } + for (auto entry : result) { + if (prevState.data()[entry.second.first] < EPSILON) { + std::cerr << "Error in data!" << entry.first << " " + << entry.second.first << " " << entry.second.second + << " " << prevState.data()[entry.second.first] << " " + << "\n"; + } + } + + if (normalizer != 1) { + for (auto& entry : result) { + entry.second.first /= normalizer; + } + } + + cerr.flush(); + return new ActivityAnimation(result, prevPositions.data(), curPositions.data()); }