Aksquare Docs
Aksquare is a deep learning library built by scoopml to build deep learning to build neural networks with few lines of code.

Installing Aksquare

1
pip3 install aksquare
Copied!

Example program to play with Aksquare

1
from typing import List
2
​
3
import numpy as np
4
​
5
from aksquare.train import train
6
from aksquare.nn import NeuralNet
7
from aksquare.layers import Linear, Tanh
8
from aksquare.optim import SGD
9
​
10
def fizz_buzz_encode(x: int) -> List[int]:
11
if x % 15 == 0:
12
return [0, 0, 0, 1]
13
elif x % 5 == 0:
14
return [0, 0, 1, 0]
15
elif x % 3 == 0:
16
return [0, 1, 0, 0]
17
else:
18
return [1, 0, 0, 0]
19
​
20
​
21
def binary_encode(x: int) -> List[int]:
22
"""
23
10 digit binary encoding of x
24
"""
25
return [x >> i & 1 for i in range(10)]
26
​
27
inputs = np.array([
28
binary_encode(x)
29
for x in range(101, 1024)
30
])
31
​
32
targets = np.array([
33
fizz_buzz_encode(x)
34
for x in range(101, 1024)
35
])
36
​
37
net = NeuralNet([
38
Linear(input_size=10, output_size=50),
39
Tanh(),
40
Linear(input_size=50, output_size=4)
41
])
42
​
43
train(net,
44
inputs,
45
targets,
46
num_epochs=5000,
47
optimizer=SGD(lr=0.001))
48
​
49
for x in range(1, 101):
50
predicted = net.forward(binary_encode(x))
51
predicted_idx = np.argmax(predicted)
52
actual_idx = np.argmax(fizz_buzz_encode(x))
53
labels = [str(x), "fizz", "buzz", "fizzbuzz"]
54
print(x, labels[predicted_idx], labels[actual_idx])
Copied!

Development of Aksquare is in progress