Esempio n. 1
0
def spiral_data(minv=-0.1, maxv=0.1):
    global N
    data = []
    labels = []

    for i in xrange(N / 2):
        r = i / N * 5 + convnet.randf(minv, maxv)
        t = 1.25 * i / N * 2 * math.pi + convnet.randf(minv, maxv)
        data.append((r * math.sin(t), r * math.cos(t)))
        labels.append(1)

    for i in xrange(N / 2):
        r = i / N * 5 + convnet.randf(minv, maxv)
        t = 1.25 * i / N * 2 * math.pi + math.pi + convnet.randf(minv, maxv)
        data.append((r * math.sin(t), r * math.cos(t)))
        labels.append(0)

    return data, labels
Esempio n. 2
0
def random_data(minv=-3, maxv=3):
    global N
    data = [(convnet.randf(minv, maxv), convnet.randf(minv, maxv)) for x in xrange(N)]
    labels = [1 if convnet.randf(0, 1) > 0.5 else 0 for i in xrange(N)]  # Randomly assign red / green
    return data, labels