Example #1
0
def load_instances(sFilename, cMaxInstances=None):
    return nn.load_data(data_filename(sFilename), cMaxInstances)
Example #2
0
def load_data():
    (x_train, y_train), (x_test, y_test) = nn.load_data()
    x_train = np.divide(x_train, 255.)
    x_test = np.divide(x_test, 255.)
    return (x_train, y_train), (x_test, y_test)
Example #3
0
def load_data():
    (x_train, y_train), (x_test, y_test) = nn.load_data()
    x_train = np.expand_dims(np.divide(x_train, 255.), -1)
    x_test = np.expand_dims(np.divide(x_test, 255.), -1)
    return (x_train, y_train), (x_test, y_test)
Example #4
0
#!/usr/bin/python
import nn
n = nn.read_from_file('net.pic')
d = nn.load_data('test_img')

f0 = [nn.feed_forward(n, q.listDblFeatures)[0] for q in d if q.iLabel == 0]
f1 = [nn.feed_forward(n, q.listDblFeatures)[0] for q in d if q.iLabel == 1]

print >>open('d0', 'w'), '\n'.join(map(str, sorted(f0)))
print >>open('d1', 'w'), '\n'.join(map(str, sorted(f1)))
Example #5
0
File: tf.py Project: kespindler/nn
from nn import load_data


def slicer(arr, slice_size):
    i = 0
    assert arr.shape[0] >= slice_size
    while True:
        arr_slice = arr[i:i+slice_size, :]
        if arr_slice.shape[0] < slice_size:
            i = 0
            continue
        i += slice_size
        yield arr_slice


X, Y, test = load_data()

sess = tf.Session()

x = tf.placeholder(tf.float32, [None, 784])
w = tf.Variable(tf.zeros([784, 10]))
y = tf.nn.softmax(tf.matmul(x, w))
y_ = tf.placeholder(tf.float32, [None, 10])

max_w_op = tf.reduce_max(w)
min_w_op = tf.reduce_min(w)
correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))

accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

sq_err = tf.scalar_mul(1/2, tf.reduce_sum(tf.square(y - y_)))
Example #6
0
def load_data():
    (x_train, y_train), (x_test, y_test) = nn.load_data()
    x_train = np.divide(x_train, 255.).reshape([-1, 784])
    x_test = np.divide(x_test, 255.).reshape([-1, 784])
    return (x_train, y_train), (x_test, y_test)
Example #7
0
def load_instances(sFilename, cMaxInstances=None):
    return nn.load_data(data_filename(sFilename), cMaxInstances)
Example #8
0
#!/usr/bin/python
import nn
n = nn.read_from_file('net.pic')
d = nn.load_data('test_img')

f0 = [nn.feed_forward(n, q.listDblFeatures)[0] for q in d if q.iLabel == 0]
f1 = [nn.feed_forward(n, q.listDblFeatures)[0] for q in d if q.iLabel == 1]

print >> open('d0', 'w'), '\n'.join(map(str, sorted(f0)))
print >> open('d1', 'w'), '\n'.join(map(str, sorted(f1)))