2015 年 9 月

# 測試回合 - 人工刺突神經元 (Artificial Spiking Neurons)

[圖 1 人工峰值神經示範

``````0 0 1 0 1 0 1 1 1 1 0 0 1 0 1 1
1 0 1 1 0 0 0 1 1 1 0 1 1 0 1 1
1 1 0 1 0 0 0 1 1 0 1 1 1 1 1 1
``````

``````0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0
``````

## 了解峰值神經

[圖 2 溢位的整合和-射擊峰值神經行為

``````V = V + sum
= 0 + (0)(4) + (1)(-2) + (1)(3)
= 0 + 1
= 1
``````

``````V = V - leak
= 1 - 1
= 0
``````

V 的新值 = 0 不會超過 8 的臨界值不會突然增加神經因此就會發出輸出尖峰火車 0。接下來，在時間 t = 1、 輸入的值為 (0，0，1)。結合的整合和遺漏步驟提供:

``````V = V + sum - leak
= 0 + (0)(4) + (0)(-2) + (1)(3) - 1
= 0 + 3 - 1
= 2
``````

[圖 2, ，您可以看到在時間 t 發生尖峰事件 = 6。在 t = 5，V 因此 = 5 t 的整合流失計算 = 6 是:

``````V = V + sum - leak
= 5 + (1)(4) + (0)(-2) + (0)(3) - 1
= 5 + 4 - 1
= 8
``````

## 實作示範程式

[圖 3 峰值神經程式

``````using System;
namespace SpikingNeuron
{
class SpikingNeuronProgram
{
static void Main(string[] args)
{
Console.WriteLine("Begin spiking neuron demo");
int[][] inputs = new int[3][];
inputs[0] = new int[] { 0, 0, 1, 0, 1, 0, 1, 1,
1, 1, 0, 0, 1, 0, 1, 1 };
inputs[1] = new int[] { 1, 0, 1, 1, 0, 0, 0, 1,
1, 1, 0, 1, 1, 0, 1, 1 };
inputs[2] = new int[] { 1, 1, 0, 1, 0, 0, 0, 1,
1, 0, 1, 1, 1, 1, 1, 1 };
Console.WriteLine("The inputs are: ");
for (int i = 0; i < inputs.Length; ++i)
ShowVector(inputs[i], false);
Console.WriteLine("");
int[] output = new int[16];
int[] wts = new int[] { 4, -2, 3 };
Console.Write("The weights are: ");
ShowVector(wts, true);
Console.WriteLine("");
int leak = 1;
Console.WriteLine("Leak potential is: " + leak);
int v = 0; // electrical potential (voltage)
int thresh = 8; // Threshold
int spike = 4;  // Increase in v at spike
int tNext = 0; // Time when neuron is active
int latency = 2; // Inactive after spike
Console.WriteLine("Threshold is: " + thresh);
Console.WriteLine("Spike is: " + spike);
Console.WriteLine("Latency time is: " + latency);
Console.WriteLine("Starting processing\");
for (int t = 0; t < 16; ++t)
{
Console.WriteLine("----------------------");
Console.Write(" ");
Console.Write("t = ");
if (t <= 9) Console.Write(" ");
Console.Write(t + ". ");
Console.Write("Inputs = " + inputs[0][t] +
" " + inputs[1][t] +
" " + inputs[2][t]);
if (t != tNext) // Neuron not active
{
Console.Write(". Neuron is inactive. ");
Console.WriteLine("V = " + v);
output[t] = 0;
}
else // Neuron is active
{
Console.Write(". Neuron is   active. ");
int sum = 0;
for (int j = 0; j < inputs.Length; ++j)
sum += inputs[j][t] * wts[j];
v = v + sum;
v = v - leak;
if (v < 0)
v = 0;
Console.WriteLine("V = " + v);
if (v >= thresh) // Spike and reset
{
v = v + spike;
Console.WriteLine(" Spiking, V = " + v);
output[t] = 1;
v = 0;
tNext = t + 1 + latency;
}
else
{
output[t] = 0;
tNext = t + 1;
}
} // Active
} // t
Console.WriteLine("----------------------");
Console.WriteLine("Output spike train = ");
ShowVector(output, false);
Console.WriteLine("End spiking neuron demo");
} // Main
static void ShowVector(int[] vector, bool plus)
{
for (int i = 0; i < vector.Length; ++i)
{
if (plus == true && vector[i] >= 0)
Console.Write("+");
Console.Write(vector[i] + " ");
}
Console.WriteLine("");
}
} // Program
} // ns
``````

``````int[][] inputs = new int[3][];
inputs[0] = new int[] { 0, 0, 1, 0, 1, 0, 1, 1,
1, 1, 0, 0, 1, 0, 1, 1 };
...
int[] output = new int[16];
``````

``````int[] wts = new int[] { 4, -2, 3 };
int leak = 1;
int v = 0; // Electrical potential (voltage)
int thresh = 8; // Needed to fire an output spike
int spike = 4;  // Increase in v at spike event
int tNext = 0; // Next time when neuron is active
int latency = 2; // Number t inactive after spike
``````

``````for (int t = 0; t < 16; ++t)
{
// Compute new V
// Spike if V >= threshold
// Emit a 0 or 1
}
``````

``````if (t != tNext) // Neuron is not active
{
Console.Write(". Neuron is inactive. ");
Console.WriteLine("V = " + v);
output[t] = 0;
}
else
{
// Active
}
``````

``````int sum = 0;
for (int j = 0; j < inputs.Length; ++j)
sum += inputs[j][t] * wts[j];
v = v + sum;
v = v - leak;
if (v < 0) v = 0;
``````

J 下面是輸入資料流 (0，1，2) 的索引和 t 是時間索引。例如，輸入 [1] [8] 是 0 或 1 值針對輸入資料流 1 在時間 t = 8。找出遺漏減去 V 之後，產生的值會檢查以確定 V 不會傳送負值。不過，在真實的神經電力 potentials 可以事實上是負數，所以要考慮的選項是允許 V 去負數。

[圖 4 檢查是否應該發生尖峰事件

``````if (v >= thresh) // Spike and reset
{
v = v + spike;
Console.WriteLine(" Spiking, V = " + v);
output[t] = 1;  // Fire
v = 0;
tNext = t + 1 + latency;
}
else // No spike
{
output[t] = 0;
tNext = t + 1;
}
``````

## 重點何在？

Dr。James McCaffrey Redmond，華盛頓中的 Microsoft Research 的運作方式他曾在包括 Internet Explorer 和 Bing 的數個 Microsoft 產品。Dr.McCaffrey 可以到達 jammc@microsoft.com