Example #1
0
File: func.py Project: bsv/mag-ifmo
def netdem(source, target, ndiff, npack = 10, nlearn = 500, epoch = 100):
    
    diffx = []

#    for i in xrange(len(source)):
#        val = 0
#        for j in xrange(ndiff):
#            if(i + j < len(source)):
#                val += source[i+j]
#        diffx += [(val/ndiff)]

#    sample = diffx


    sample = source
    
    '''x = []
    for i in xrange(len(sample)):
        frame = []
        for j in xrange(npack):
            if (i-j) < 0:
                frame += [0]
            else:
                frame += [sample[i-j]]
        x += [frame]'''


    x = [sample[i-npack:i] for i in xrange(npack, len(sample)+1, npack)]
    test = [[target[i]] for i in xrange(len(target))]
    
    print 'LEN source = ', len(source)
    print 'LEN X = ', len(x)
    print 'LEN test = ', len(test)

    pnet = per_net([npack, 4, 1], elman = 1)    
    epoch = pnet.per_train(x[:nlearn], test[:nlearn], epoch, 0.001, 0.01)

    return pnet, x
Example #2
0
from per_net.per_net import *
import sys

x = [[0, 0, 0, 0],
     [0, 0, 0, 1],
     [0, 0, 1, 1],
     [0, 1, 1, 1],
     [1, 1, 1, 1]]
t = [[0, 0, 0, 0, 0, 0, 0, 0, 0],
     [1, 0, 0, 0, 0, 0, 0, 0, 0],
     [0, 1, 0, 0, 0, 0, 0, 0, 0],
     [0, 0, 1, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 1, 0, 0, 0, 0, 0]]

a_in = float(sys.argv[2])
n_in = float(sys.argv[3])
c_in = int(sys.argv[1])

p = per_net([4, 20, 9])
epoch = p.per_train(x, t, c_in, n = n_in, alph = a_in)

test_x = [[1, 1, 1, 0]]

if(epoch < 999):
    for i in xrange(len(test_x)):
        print (p.sim_net(test_x[i]))[p.count_layer -1]
    
Example #3
0
Fd = 2400 # символьная скорость
Fc = 1800 # несущая
FsFd = 4  # количество отсчетов на один символ
Fs = Fd * FsFd # частота дискретизации

t = [i/Fs for i in range(N*FsFd)] # дискретное время

x = [2*math.pi*Fc*i for i in t]

x = [[x_tmp[i]/10.0] for i in xrange(len(x_tmp))]

t = [[math.sin(x[i][0])] for i in xrange(len(x_tmp))]

print x
print t
a_in = float(sys.argv[2])
n_in = float(sys.argv[3])
c_in = int(sys.argv[1])

p = per_net([1, 5, 2,  1])
epoch = p.per_train(x, t, c_in, n = n_in, alph = a_in)

x_tmp = xrange(-10, 10, 5)
test_x = [[x_tmp[i]/10.0] for i in xrange(len(x_tmp))]
print test_x

if(epoch < 999):
    for i in xrange(len(test_x)):
        print (p.sim_net(test_x[i]))[p.count_layer -1]