In [1]:
%matplotlib inline
%load_ext autoreload
%autoreload 2
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import logging
# logging.getLogger('pygrfnn').setLevel(logging.INFO) # use/change this for development/debuging (use logging.DEBUG for debugging)
logging.getLogger('pygrfnn').setLevel(logging.INFO)
from pygrfnn import Zparam, GrFNN, Model
from pygrfnn.vis import vector_field
sr = 100
dur = 2.0
t = np.linspace(0, dur, sr*dur)
x = np.exp(2j*np.pi*1*t)
# x[np.real(x)<0] = 0
plt.plot(t, np.real(x))
Out[1]:
In [9]:
zp = Zparam(0.1, -2, -5, epsilon=0.9)
l = GrFNN(zp,
frequency_range=(0.5, 8),
num_oscs=120,
stimulus_conn_type='linear',
name='Layer 1',
z0=0)
vector_field(zp, F=np.arange(0,1,0.1))
plt.ylim(-0.5, 1)
Out[9]:
In [10]:
from pygrfnn.network import make_connections
model = Model()
model.add_layer(l, input_channel=0)
C = make_connections(l, l, modes=[1/2, 1, 2])
model.connect_layers(l, # source
l, # destination
C, # connection matrix
# connection_type='allfreq',
connection_type='3freq',
connection_params={'N': 5, 'tol':1e-5, 'lowest_order_only': True},
weight=0.25,
)
Out[10]:
In [12]:
from pygrfnn.vis import tf_detail
model.run(0.5*x, t, 1/sr)
tf_detail(l.Z, t, l.f, t_detail=dur/2, title='TFR')
# tf_detail(l.Z, t, l.f, t_detail=dur/2, title='TFR', display_op=np.angle)
Out[12]:
In [ ]: