前馈或反馈抑制
大约 6 分钟案例案例
尽管在神经系统中大部分信号都是由兴奋神经元传递的, 但抑制性神经元在局部信息处理上依然具有及其关键的作用。 两个广泛使用的回路是前馈或反馈抑制。
在前馈抑制中,一个抑制神经元从一个突触前兴奋神经元接收输入,同时抑制神经元的输出或突触前兴奋神经元的输出都汇聚输出给同一个突触后神经元。
在反馈抑制中,一个抑制神经元从一个兴奋神经元接收输入,并将其自身的输出返回给该兴奋神经元。 在灵长目动物视觉系统的视觉通路中,几乎每一个兴奋连接都伴随着前馈抑制和反馈抑制。
前馈抑制比反馈抑制作用更加快速,其达到目标神经元只需要一个突触延迟,而反馈抑制需要两个突触延迟。前馈抑制与输入强度成正比, 而反馈抑制与输出强度成正比。二者都可以用于调节输入兴奋信号的持续时间及幅度。例如,限制对感觉输入的反应的激活持续时间, 可以让电路快速返回到它们的基线活动水平, 以最大限度地提高它们对未来环境变化信号输入的敏感性。
神经元网络前馈和反馈抑制通常协同作用,可以执行许多有趣的功能,如调节输入信号的增益和动态范围,促进同步或振荡放电。 前馈和反馈抑制在保持兴奋和抑制之间的“平衡”(例如,强兴奋伴随着强抑制)中也起着至关重要的作用,以防止过度兴奋或抑制状态。 这种平衡网络可以提高信息处理的速度和信噪比。
简要拓扑图
代码示例
#
# Copyright (c) 2022 Neurocean Group
# All rights reserved.
# Created by damone
#
import numpy as np
import ocean
from ocean import Session, CompileOption
from matplotlib import pyplot as plt
from ocean.utils.VisualizeHelper import visualizeHelper
def randomInput(number, timezone):
return np.random.randint(2, size=(timezone, number), dtype=np.int8)
def visualizeResults(session, hidden, output):
plt.figure()
# Hidden1
plt.subplot(2, 1, 1)
plt.title("Hidden1 potentials")
captures = session.getCaptures(
hidden, ["potentials", "output", "firePotentials"])
visualizeHelper.plotPotentials(captures, [0])
# output
plt.subplot(2, 1, 2)
plt.title("Output potentials")
captures = session.getCaptures(
output, ["potentials", "output", "firePotentials"])
visualizeHelper.plotPotentials(captures, [0])
plt.show()
def FeedForwardInhibition():
# Session
session = Session("session")
# Make input group
input = session.makeNeuronGroup(
"SequenceInput",
number=1,
totalTime=512,
inputBuffer=randomInput(1, 512)
)
# Make hidden group
hidden = session.makeNeuronGroup(
"General",
number=1,
thresholds=-25,
restingPotentials=-70,
decays=0.8,
potentials=-70
)
# Make output group
output = session.makeNeuronGroup(
"General",
number=1,
thresholds=-25,
restingPotentials=-70,
decays=0.1,
potentials=-70
)
# Make output reduce
outputReduce = session.makeModel(
"Reduce",
number=2
)
outputReduce.output("output").connect(output.input("input"))
# Make edge1
edge1 = session.makeSynapseGroup(
"SimpleSynapse",
inputNumber=1,
outputNumber=1,
weights=9
)
input.output("output").connect(edge1.input("input"))
edge1.output("output").connect(hidden.input("input"))
edge1.connect()
# Make edge2
edge2 = session.makeSynapseGroup(
"SimpleSynapse",
inputNumber=1,
outputNumber=1,
weights=6
)
input.output("output").connect(edge2.input("input"))
edge2.output("output").connect(outputReduce.input("input0"))
edge2.connect()
# Make edge3
edge3 = session.makeSynapseGroup(
"SimpleSynapse",
inputNumber=1,
outputNumber=1,
weights=-18
)
hidden.output("output").connect(edge3.input("input"))
edge3.output("output").connect(outputReduce.input("input1"))
edge3.connect()
# Add monitor
POTENTIALS = ["potentials", "output", "firePotentials"]
session.addMonitors(hidden, POTENTIALS)
session.addMonitors(output, POTENTIALS)
# Run model
option = ocean.RunOption(False, False, 512)
if not (session.run(CompileOption.cpu(), option)):
print("Run Model failed")
return
# Get captures, visualize it
visualizeResults(session, hidden, output)
if __name__ == "__main__":
FeedForwardInhibition()
/**
* Copyright (c) 2022 Neurocean Group
* All rights reserved.
* Created by damone
*/
#include <frontend/Option.hpp>
#include <frontend/Session.hpp>
#include <frontend/Filler.hpp>
#include "VisualizeHelper.hpp"
ocean::Tensor randomInput(int time, int inputSize) {
ocean::Tensor inputs(inputSize, time, ocean::INT8);
size_t total = inputs.total();
uint8_t *data = (uint8_t *) inputs.getData();
for (size_t i = 0; i < total; i++) {
data[i] = rand() % 2;
}
return inputs;
}
void FeedForwardInhibition() {
/// Session
ocean::Session session;
/// createExecutionEngine input group
ocean::Arguments args;
args["number"] = 1u;
args["totalTime"] = 512u;
auto input = session.makeNeuronGroup("SequenceInput", args);
/// hidden group
args.clear();
args["number"] = 1u;
args["thresholds"] = -25.f;
args["decays"] = 0.8f;
args["restingPotentials"] = -75.f;
args["potentials"] = {-70.f, -30.f};
auto hidden = session.makeNeuronGroup("General", args);
/// output group
args.clear();
args["number"] = 1u;
args["thresholds"] = -25.f;
args["decays"] = 0.1f;
args["restingPotentials"] = -75.f;
args["potentials"] = {-70.f, -30.f};
auto output = session.makeNeuronGroup("General", args);
/// output reduce
args.clear();
args["number"] = 2u;
auto outputReduce = session.makeModel("Reduce", args);
outputReduce->out("output")->connect(output->in("input"));
/// edge1
args.clear();
args["weights"] = 9.f;
args["inputNumber"] = 1;
args["outputNumber"] = 1;
auto edge1 = session.makeSynapseGroup("SimpleSynapse", args);
input->out("output")->connect(edge1->in("input"));
edge1->out("output")->connect(hidden->in("input"));
edge1->connect();
args.clear();
args["weights"] = 6.f;
args["inputNumber"] = 1;
args["outputNumber"] = 1;
auto edge2 = session.makeSynapseGroup("SimpleSynapse", args);
input->out("output")->connect(edge2->in("input"));
edge2->out("output")->connect(outputReduce->in("input0"));
edge2->connect();
/// edge2
args.clear();
args["weights"] = -18.f;
args["inputNumber"] = 1;
args["outputNumber"] = 1;
auto edge3 = session.makeSynapseGroup("SimpleSynapse", args);
hidden->out("output")->connect(edge3->in("input"));
edge3->out("output")->connect(outputReduce->in("input1"));
edge3->connect();
/// compile model
if (!session.compile(ocean::CompileOption::cpu())) {
std::cout << "Compile model failed" << std::endl;
return;
}
/// add monitor
session.addMonitors(hidden, {"potentials", "output", "firePotentials"});
session.addMonitors(output, {"potentials", "output", "firePotentials"});
/// set input
input->setStatus("inputBuffer", randomInput(1, 512));
/// run model
ocean::RunOption option{false, true, 512};
session.run(option);
auto monitorVars1 = session.getCaptures(hidden, {"potentials", "output", "firePotentials"});
auto monitorVars2 = session.getCaptures(output, {"potentials", "output", "firePotentials"});
if(monitorVars1.size() == 3 && monitorVars2.size() == 3){
/// hidden potentials
plt::subplot(2, 1, 1);
plt::title("Hidden1 potentials");
ocean::plotSingleNeuronStates(monitorVars1, {0}, hidden->getStep());
/// output potentials
plt::subplot(2, 1, 2);
plt::title("Output potentials");
ocean::plotSingleNeuronStates(monitorVars2, {0}, output->getStep());
plt::show();
}
}
int main(int argc, char *argv[]) {
FeedForwardInhibition();
return 0;
}
#
# Copyright (c) 2022 Neurocean Group
# All rights reserved.
# Created by damone
#
import numpy as np
import ocean
from ocean import Session, CompileOption
from matplotlib import pyplot as plt
from ocean.utils.VisualizeHelper import visualizeHelper
def randomInput(number, timezone):
return np.random.randint(2, size=(timezone, number), dtype=np.int8)
def visualizeResults(session, hidden, output):
plt.figure()
# Hidden1
plt.subplot(2, 1, 1)
plt.title("Hidden1 potentials")
captures = session.getCaptures(
hidden, ["potentials", "output", "firePotentials"])
visualizeHelper.plotPotentials(captures, [0])
# output
plt.subplot(2, 1, 2)
plt.title("Output potentials")
captures = session.getCaptures(
output, ["potentials", "output", "firePotentials"])
visualizeHelper.plotPotentials(captures, [0])
plt.show()
def FeedBackInhibition():
# Session
session = Session("session")
# Make input group
input = session.makeNeuronGroup(
"SequenceInput",
number=1,
totalTime=512,
inputBuffer=randomInput(1, 512)
)
# Make hidden group
hidden = session.makeNeuronGroup(
"General",
number=1,
thresholds=-25,
restingPotentials=-70,
decays=0.8,
potentials=-70
)
# Make output group
output = session.makeNeuronGroup(
"General",
number=1,
thresholds=-25,
restingPotentials=-70,
decays=0.1,
potentials=-70
)
# Make output reduce
outputReduce = session.makeModel(
"Reduce",
number=2
)
outputReduce.output("output").connect(output.input("input"))
# Make edge1
edge1 = session.makeSynapseGroup(
"SimpleSynapse",
inputNumber=1,
outputNumber=1,
weights=20
)
output.output("output").connect(edge1.input("input"))
edge1.output("output").connect(hidden.input("input"))
edge1.connect()
# Make edge2
edge2 = session.makeSynapseGroup(
"SimpleSynapse",
inputNumber=1,
outputNumber=1,
weights=15
)
input.output("output").connect(edge2.input("input"))
edge2.output("output").connect(outputReduce.input("input0"))
edge2.connect()
# Make edge3
edge3 = session.makeSynapseGroup(
"SimpleSynapse",
inputNumber=1,
outputNumber=1,
weights=-38
)
hidden.output("output").connect(edge3.input("input"))
edge3.output("output").connect(outputReduce.input("input1"))
edge3.connect()
# Add monitor
POTENTIALS = ["potentials", "output", "firePotentials"]
session.addMonitors(hidden, POTENTIALS)
session.addMonitors(output, POTENTIALS)
# Run model
option = ocean.RunOption(False, False, 512)
if not (session.run(CompileOption.cpu(), option)):
print("Run Model failed")
return
# Get captures, visualize it
visualizeResults(session, hidden, output)
if __name__ == "__main__":
FeedBackInhibition()
/**
* Copyright (c) 2022 Neurocean Group
* All rights reserved.
* Created by damone
*/
#include <frontend/Option.hpp>
#include <frontend/Session.hpp>
#include <frontend/Filler.hpp>
#include "VisualizeHelper.hpp"
ocean::Tensor randomInput(int time, int inputSize) {
ocean::Tensor inputs(inputSize, time, ocean::INT8);
size_t total = inputs.total();
uint8_t *data = (uint8_t *) inputs.getData();
for (size_t i = 0; i < total; i++) {
data[i] = rand() % 2;
}
return inputs;
}
void FeedBackInhibition() {
/// Session
ocean::Session session;
/// createExecutionEngine input group
ocean::Arguments args;
args["number"] = 1u;
args["totalTime"] = 512u;
auto input = session.makeNeuronGroup("SequenceInput", args);
/// hidden group
args.clear();
args["number"] = 1u;
args["thresholds"] = -25.f;
args["restingPotentials"] = -75.f;
args["decays"] = 0.8f;
args["potentials"] = {-70.f, -30.f};
auto hidden = session.makeNeuronGroup("General", args);
/// output group
args.clear();
args["number"] = 1u;
args["thresholds"] = -25.f;
args["restingPotentials"] = -75.f;
args["decays"] = 0.1f;
args["potentials"] = {-70.f, -30.f};
auto output = session.makeNeuronGroup("General", args);
/// output reduce
args.clear();
args["number"] = 2u;
auto outputReduce = session.makeModel("Reduce", args);
outputReduce->out("output")->connect(output->in("input"));
/// edge1
args.clear();
args["weights"] = 17.f;
args["inputNumber"] = 1;
args["outputNumber"] = 1;
auto edge1 = session.makeSynapseGroup("SimpleSynapse", args);
output->out("output")->connect(edge1->in("input"));
edge1->out("output")->connect(hidden->in("input"));
edge1->connect();
args.clear();
args["weights"] = 11.f;
args["inputNumber"] = 1;
args["outputNumber"] = 1;
auto edge2 = session.makeSynapseGroup("SimpleSynapse", args);
input->out("output")->connect(edge2->in("input"));
edge2->out("output")->connect(outputReduce->in("input0"));
edge2->connect();
/// edge2
args.clear();
args["weights"] = -38.f;
args["inputNumber"] = 1;
args["outputNumber"] = 1;
auto edge3 = session.makeSynapseGroup("SimpleSynapse", args);
hidden->out("output")->connect(edge3->in("input"));
edge3->out("output")->connect(outputReduce->in("input1"));
edge3->connect();
/// compile model
if (!session.compile(ocean::CompileOption::cpu())) {
std::cout << "Compile model failed" << std::endl;
return;
}
/// add monitor
session.addMonitors(hidden, {"potentials", "output", "firePotentials"});
session.addMonitors(output, {"potentials", "output", "firePotentials"});
/// set input
input->setStatus("inputBuffer", randomInput(1, 512));
/// run model
ocean::RunOption option{false, true, 512};
session.run(option);
auto monitorVars1 = session.getCaptures(hidden, {"potentials", "output", "firePotentials"});
auto monitorVars2 = session.getCaptures(output, {"potentials", "output", "firePotentials"});
if(monitorVars1.size() == 3 && monitorVars2.size() == 3){
/// hidden potentials
plt::subplot(2, 1, 1);
plt::title("Hidden1 potentials");
ocean::plotSingleNeuronStates(monitorVars1, {0}, hidden->getStep());
/// output potentials
plt::subplot(2, 1, 2);
plt::title("Output potentials");
ocean::plotSingleNeuronStates(monitorVars2, {0}, output->getStep());
plt::show();
}
}
int main(int argc, char *argv[]) {
FeedBackInhibition();
return 0;
}
电位变化图
- Neurocean仿真前馈抑制神经元电位变化图:
- Neurocean仿真反馈抑制神经元电位变化图: