Exemplo n.º 1
0
 def send(self):
     data = dict()
     for box in self.boxes:
         data[box] = self.boxes[box].text()
     if send(**data):
         for box in self.boxes:
             self.boxes[box].clear()
     else:
         self.show_failure()
Exemplo n.º 2
0
def new_epoch(train_loss, train_accuracy, val_loss, val_accuracy, epoch):
    #saving the arrays to a dict
    plot_value_dict = {
        "train_accuracy": list(train_accuracy),
        "train_loss": list(train_loss),
        "val_accuracy": list(val_accuracy),
        "val_loss": list(val_loss),
        "epoch": epoch
    }
    train_accuracy_string = ','.join(map(str, list(train_accuracy)))
    train_loss_string = ','.join(map(str, list(train_loss)))
    val_accuracy_string = ','.join(map(str, list(val_accuracy)))
    val_loss_string = ','.join(map(str, list(val_loss)))

    #send metrics to UI for plotting graph
    send('{"type":"train_loss", "value" : train_loss_string}')
    send('{"type":"val_loss", "value" : val_loss_string}')
    send('{"type":"train_acc", "value": train_accuracy_string}')
    send('{"type":"val_acc", "value":val_accuracy_string}')
    send('{"type":"epoch", "value":str(epoch)}')

    file_path = "./Network/plot_values.json"
    json.dump(plot_value_dict,
              codecs.open(file_path, 'w',
                          encoding='utf-8'))  #saving the arrays in json format
    with open('./Network/train_accuracy.npy', 'wb') as f:
        np.save(f, train_accuracy)

    with open('./Network/train_loss.npy', 'wb') as f:
        np.save(f, train_loss)

    with open('./Network/val_accuracy.npy', 'wb') as f:
        np.save(f, val_accuracy)

    with open('./Network/val_loss.npy', 'wb') as f:
        np.save(f, val_loss)
Exemplo n.º 3
0
 def queue(self, data: dict):
     send(**data)
Exemplo n.º 4
0
 def run(self):
     send(**self.data)
from data import send
from numpy.random import randint
import time


def getJSON(val1, val2):
    return '{' + '"type":' + '"' + val1 + '"' + ',"value":' + '"' + val2 + '"' + '}'


items = [
    '{"type":"train_loss", "value":"10,2,3,4"}',
    '{"type":"train_acc", "value":"0.87,1,0.99,0.2"}',
    '{"type":"val_acc", "value":"1.2,1.67,0.1,-0.2"}',
    '{"type":"val_loss", "value":"-.9, 2, 11, 0"}',
]

params = ["train_loss", "val_loss", "train_acc", "val_acc"]
l = [[], [], [], []]
for j in range(10):
    for i in range(len(l)):
        l[i].append(randint(-10, 100))
        # print(getJSON(params[i], ','.join([str(x) for x in l[i]])))
        send(getJSON(params[i], ','.join([str(x) for x in l[i]])))
        send(getJSON("ETA", str(10 - j)))
        send(getJSON("epoch", str(j)))
Exemplo n.º 6
0
#!/usr/bin/env python
import data


if __name__ == "__main__":
    N = 100000
    while True:
        points = [(r, x) for r, x in data.generate(N)]
        for i in range(100):
            data.send(points, N=1000 * len(points))
            for idx in range(len(points)):
                r, x = points[idx]
                for j in range(1000):
                    x = r * x * (1 - x)
                points[idx] = r, x
Exemplo n.º 7
0
#!/usr/bin/env python
import data


class Point(object):
    def __init__(self, r, x):
        self.r = r
        self.x = x

    def next(self):
        self.x = self.r * self.x * (1 - self.x)
        return self.r, self.x


if __name__ == "__main__":
    N = 100000
    while True:
        points = [Point(r, x) for r, x in data.generate(N)]
        for i in range(10000):
            data.send([p.next() for p in points])
Exemplo n.º 8
0
#!/usr/bin/env python
import data
import numpy


if __name__ == "__main__":
    N = 100000
    while True:
        points = [(r, x) for r, x in data.generate(N)]
        R = numpy.array([r for r, x in points])
        X = numpy.array([x for r, x in points])
        for i in range(100):
            points = [(R[idx], X[idx]) for idx in range(8000)]
            data.send(points, N=1000 * N)
            for j in range(1000):
                X = R * X * (1 - X)
Exemplo n.º 9
0
#!/usr/bin/env python
import data


def next(p):
    r, x = p
    x = r * x * (1 - x)
    return (r, x)


if __name__ == "__main__":
    N = 100000
    while True:
        points = [(r, x) for r, x in data.generate(N)]
        for i in range(10000):
            data.send(points)
            points = [next(p) for p in points]