<jupyter_start><jupyter_text>Classic Net<jupyter_code>import theano
from theano import tensor as T
import numpy as np
from load import mnist
#from foxhound.utils.vis import grayscale_grid_vis, unit_scale
#from foxhound.vis import grayscale_grid_vis, unit_scale
#from scipy.misc import imsave
print(theano.config.device)
import os
os.environ["THEANO_FLAGS"] = "device=gpu"
import theano
print(theano.config.device)
def floatX(X):
    return np.asarray(X, dtype=theano.config.floatX)
def init_weights(shape):
    return theano.shared(floatX(np.random.randn(*shape) * 0.01))
def sgd(cost, params, lr=0.05):
    grads = T.grad(cost=cost, wrt=params)
    updates = []
    for p, g in zip(params, grads):
        updates.append([p, p - g * lr])
    return updates
def model(X, w_h, w_o):
    h = T.nnet.sigmoid(T.dot(X, w_h))
    pyx = T.nnet.softmax(T.dot(h, w_o))
    return pyx
trX, teX, trY, teY = mnist(onehot=True)

X = T.fmatrix()
Y = T.fmatrix()
w_h = init_weights((784, 625))
w_o = init_weights((625, 10))

py_x = model(X, w_h, w_o)
y_x = T.argmax(py_x, axis=1)

cost = T.mean(T.nnet.categorical_crossentropy(py_x, Y))
params = [w_h, w_o]
updates = sgd(cost, params)
train = theano.function(inputs=[X, Y], outputs=cost, updates=updates, allow_input_downcast=True)
predict = theano.function(inputs=[X], outputs=y_x, allow_input_downcast=True)

for i in range(100):
    for start, end in zip(range(0, len(trX), 128), range(128, len(trX), 128)):
        cost = train(trX[start:end], trY[start:end])
    print( np.mean(np.argmax(teY, axis=1) == predict(teX)))<jupyter_output>0.704
0.828
0.8676
0.8832
0.8898
0.8951
0.8987
0.9022
0.9046
0.907
0.9093
0.9116
0.9129
0.9139
0.915
0.9161
0.9168
0.9176
0.918
0.9188
0.9197
0.9198
0.92
0.9203
0.9211
0.9211
0.9215
0.922
0.9226
0.9235
0.9244
0.925
0.9255
0.9259
0.9265
0.9269
0.9276
0.928
0.9278
0.9286
0.9293
0.9299
0.9307
0.9312
0.9317
0.9331
0.9339
0.9343
0.9347
0.9355
0.9361
0.9368
0.938
0.9384
0.9388
0.9394
0.9402
0.9404
0.9407
0.9409
0.9415
0.9418
0.9424
0.9434
0.9438
0.9439
0.9445
0.9448
0.9453
0.9459
0.9465
0.9467
0.947
0.9473
0.9479
0.9484
0.9492
0.9493
0.9495
0.95
0.9502
0.9503
0.951
0.9517
0.9523
0.9528
0.9536
0.9541
0.9542
0.9542
0.9546
0.955
0.9555
0.9558
0.9563
0.9568
0.9571
0.9574
0.9575
0.9576
{'fraction_non_alphanumeric': 0.1488701816570669, 'fraction_numerical': 0.22862206468763846, 'mean_word_length': 3.8559139784946237, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '181173', 'license': 'MIT', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1141, 'n_words': 242, 'path': '3-net.ipynb', 'repo_name': 'ryubidragonfire/deep-learning-tutorial', 'size': '2257'}