<commit_before>import os
import sys
sys.path.insert(0, os.path.abspath('..'))

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn import metrics

import numpy as np
from aorun import datasets
from aorun.models import Model
from aorun.layers import Conv2D
from aorun.layers import Dense
from aorun.layers import Activation

(X, y), (X_test, y_test) = datasets.load_mnist()
X = X / 127.0
X_test = X_test / 127.0
y = np.eye(y.max() + 1)[y]
y_test = np.eye(y_test.max() + 1)[y_test]
print(X.shape, X_test.shape)

X = X.astype('float32')
X_test = X_test.astype('float32')
y = y.astype('float32')
y_test = y_test.astype('float32')

model = Model(
    Conv2D(8, kernel_size=(3, 3), input_dim=X.shape[1:]),
    Activation('relu'),
    Dense(100),
    Activation('relu'),
    Dense(y_test.shape[-1]),
    Activation('softmax')
)

loss = 'categorical_crossentropy'
history = model.fit(X, y, loss=loss, val_data=(X_test, y_test))

y_pred = model.predict(X_test)<commit_msg>fix mnist example, missing flatten layer<commit_after>import os
import sys
sys.path.insert(0, os.path.abspath('..'))

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn import metrics

import numpy as np
from aorun import datasets
from aorun.models import Model
from aorun.layers import Conv2D
from aorun.layers import Dense
from aorun.layers import Flatten
from aorun.layers import Activation

(X, y), (X_test, y_test) = datasets.load_mnist()
X = X / 127.0
X_test = X_test / 127.0
y = np.eye(y.max() + 1)[y]
y_test = np.eye(y_test.max() + 1)[y_test]
print(X.shape, X_test.shape)

X = X.astype('float32')
X_test = X_test.astype('float32')
y = y.astype('float32')
y_test = y_test.astype('float32')

model = Model(
    Conv2D(8, kernel_size=(3, 3), input_dim=X.shape[1:]),
    Flatten(),
    Activation('relu'),
    Dense(100),
    Activation('relu'),
    Dense(y_test.shape[-1]),
    Activation('softmax')
)

loss = 'categorical_crossentropy'
history = model.fit(X, y, loss=loss, val_data=(X_test, y_test))

y_pred = model.predict(X_test)
{'fraction_non_alphanumeric': 0.14151386929948284, 'fraction_numerical': 0.027268453220498354, 'mean_word_length': 4.977528089887641, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '2081880', 'n_tokens_mistral': 859, 'n_tokens_neox': 817, 'n_words': 189}