mirror of https://github.com/drowe67/phasenn.git
more realistic range of filters
parent
02bc840667
commit
4fe30e210b
|
|
@ -14,6 +14,9 @@ from keras import initializers
|
|||
import matplotlib.pyplot as plt
|
||||
from scipy import signal
|
||||
from keras import backend as K
|
||||
# make tensorflow less verbose ....
|
||||
import os
|
||||
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
||||
|
||||
# custom loss function
|
||||
def sparse_loss(y_true, y_pred):
|
||||
|
|
@ -33,7 +36,7 @@ assert loss_func([[[0,1,0]], [[0,2,0]]]) == np.array([1])
|
|||
N = 80 # number of time domain samples in frame
|
||||
nb_samples = 400000
|
||||
nb_batch = 32
|
||||
nb_epochs = 100
|
||||
nb_epochs = 10
|
||||
width = 256
|
||||
pairs = 2*width
|
||||
fo_min = 50
|
||||
|
|
@ -64,8 +67,8 @@ for i in range(nb_samples):
|
|||
# sample 2nd order IIR filter with random peak freq
|
||||
|
||||
r = np.random.rand(2)
|
||||
alpha = 0.1*np.pi + 0.8*np.pi*r[0]
|
||||
gamma = r[1]
|
||||
alpha = 0.1*np.pi + 0.4*np.pi*r[0]
|
||||
gamma = 0.9 + 0.09*r[1]
|
||||
w,h = signal.freqz(1, [1, -2*gamma*np.cos(alpha), gamma*gamma], range(1,L[i])*Wo[i])
|
||||
|
||||
for m in range(1,L[i]):
|
||||
|
|
@ -84,7 +87,7 @@ model.add(layers.Dense(pairs))
|
|||
model.summary()
|
||||
|
||||
from keras import optimizers
|
||||
sgd = optimizers.SGD(lr=0.08, decay=1e-6, momentum=0.9, nesterov=True)
|
||||
sgd = optimizers.SGD(lr=0.2, decay=1e-6, momentum=0.9, nesterov=True)
|
||||
model.compile(loss=sparse_loss, optimizer=sgd)
|
||||
history = model.fit(filter_amp, filter_phase_rect, batch_size=nb_batch, epochs=nb_epochs)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue