Example #1
0
from pygfnn import AbsIdentityConnection
from pygfnn.tools.plotting.gfnn import *
import pygfnn.tools.shortcuts as gfnn

import numpy as np
import timeit
import matplotlib.pyplot as plt

if __name__ == '__main__':
    # Choose network parameters (see pygfnn.tools.shortcuts for more)
    oscParams = gfnn.OSC_CRITICAL
    freqDist = { 'fspac': 'log', 'min': 0.25, 'max': 4 }
    fs = 40.

    # Make network
    n = gfnn.buildGFNN(200, fs = fs, oscParams = oscParams, freqDist = freqDist,
        outConn = AbsIdentityConnection)

    # Stimulus - 50 seconds of 1Hz sin
    t = np.arange(0, 50, n['h'].dt)
    x = np.sin(2 * np.pi * 1 * t) * 0.25

    # Run the network
    timer = timeit.default_timer
    start = timer()

    for i in range(len(t)):
        out = n.activate(x[i])

    end = timer()
    print('Elapsed time is %f seconds' % (end - start))
Example #2
0
    ax1.set_yticks(ticks)
    ax1.set_yticklabels(labels)
    plt.ylim((fmin, fmax))
    return fig1

if __name__ == '__main__':
    # Choose network parameters (see pygfnn.tools.shortcuts for more)
    oscParams = gfnn.OSC_CRITICAL
    learnParams = gfnn.LEARN_CRITICAL
    freqDist = { 'fspac': 'log', 'min': 0.5, 'max': 8 }
    fs = 40.

    # Make network - can have a much lower dimentionaliy than normal GFNNs
    dim = 16
    n = gfnn.buildGFNN(dim, fs = fs, oscParams = oscParams, freqDist = freqDist,
        outConn = AbsPhaseIdentityConnection, outDim = dim*2, adaptive=True,
        learnParams = learnParams)
    # setting the eplilon for the frequency changes (deflaut=1)
    n['h'].e_f = .25

    # Stimulus - 40 seconds of cosine wave
    t = np.arange(0, 40, n['h'].dt)
    f = 1 + np.random.random() * 3
    f = 2
    x = np.cos(2 * np.pi * f * t) * 0.1

    # Run the network
    timer = timeit.default_timer
    start = timer()

    fs = []
Example #3
0
from pygfnn import RealMeanFieldConnection
from pygfnn.tools.plotting.gfnn import *
import pygfnn.tools.shortcuts as gfnn

import numpy as np
import timeit
import matplotlib.pyplot as plt

if __name__ == '__main__':
    # Choose network parameters (see pygfnn.tools.shortcuts for more)
    oscParams = gfnn.OSC_CRITICAL
    freqDist = { 'fspac': 'log', 'min': 0.5, 'max': 2 }

    # Make network
    n = gfnn.buildGFNN(200, oscParams = oscParams, freqDist = freqDist,
        outConn = RealMeanFieldConnection, outDim = 8)

    # Stimulus - 50 seconds of 1Hz sin
    t = np.arange(0, 50, n['h'].dt)
    x = np.sin(2 * np.pi * 1 * t) * 0.25

    # Run the network
    timer = timeit.default_timer
    start = timer()

    for i in range(len(t)):
        out = n.activate(x[i])

    end = timer()
    print('Elapsed time is %f seconds' % (end - start))
Example #4
0
from pygfnn.tools.plotting.gfnn import *
import pygfnn.tools.shortcuts as gfnn

import numpy as np
import timeit
import matplotlib.pyplot as plt
import scipy.io as sio

if __name__ == '__main__':
    # Network parameters
    oscParams = { 'a': 1, 'b1': -1, 'b2': -1000, 'd1': 0, 'd2': 0, 'e': 1 } # Limit cycle
    learnParams = gfnn.NOLEARN_ALLFREQ
    freqDist = { 'fspac': 'log', 'min': 0.5, 'max': 8 }

    # Make network
    n = gfnn.buildGFNN(196, oscParams = oscParams, freqDist = freqDist,
        learnParams = learnParams)
    n.recurrentConns[0].c0[:] = gfnn.getInitC(n, n, [(1,1), (1,2), (1,3), (1,4), (1,6), (1,8), (2,3), (3,4), (3,8)], thresh=0.01)
    n.reset()

    # First plots, showing initial connection state
    ampFig1, phaseFig1 = plotConns(n.recurrentConns[0].c, freqDist['min'], freqDist['max'])

    # Stimulus - 50 seconds of 1Hz sin
    t = np.arange(0, 50, n['h'].dt)
    x = np.sin(2 * np.pi * 1 * t) * 0.1

    # Run the network
    timer = timeit.default_timer
    start = timer()

    for i in range(len(t)):
Example #5
0
import pygfnn.tools.shortcuts as gfnn

import numpy as np
import timeit
import matplotlib.pyplot as plt

if __name__ == '__main__':
    # Choose network parameters (see pygfnn.tools.shortcuts for more)
    oscParams = gfnn.OSC_CRITICAL
    freqDist = { 'fspac': 'log', 'min': 1.5, 'max': 2.5 }
    fs = 40.
    dur = 10

    # Make network
    dim = 16
    n = gfnn.buildGFNN(dim, fs = fs, oscParams = oscParams, freqDist = freqDist,
        outConn = AbsPhaseIdentityConnection, outDim = dim*2)

    # Stimulus - 50 seconds of 1Hz sin
    t = np.arange(0, dur, n['h'].dt)
    x = np.sin(2 * np.pi * 2 * t) * 0.25

    # Run the network
    timer = timeit.default_timer
    start = timer()

    for i in range(len(t)):
        out = n.activate(x[i])

    end = timer()
    print('Elapsed time is %f seconds' % (end - start))