Model class to store pytorch model.
%load_ext autoreload
%autoreload 2

class Sequential[source]

Sequential(model=None)

model = Sequential()
model.add(Dense(2, x.shape[1], activation='relu'))
model.add(Dense(2, activation='relu'))
model.add(Dense(len(set(y))))
model.add(Activation('softmax'))

model.compile(ce4softmax)
bs = 50
model.lr_find(x, y, bs=bs)
Min numerical gradient: 6.31E-07
Min loss divided by 10: 1.91E-01
model.fit(x, y, bs, epochs=3, lr=1e-1)
epoch train_loss valid_loss time
0 1.118083 1.098731 00:00
1 1.106743 1.112724 00:00
2 1.104552 1.116109 00:00
preds = model.predict(x[:2])
preds
array([[0.306072, 0.39727 , 0.296658],
       [0.306072, 0.39727 , 0.296658]], dtype=float32)

As can be seen the sum of the probabilities are 1.

preds.sum(axis=-1, keepdims=True)
array([[1.],
       [1.]], dtype=float32)