Esempio n. 1
0
 def __init__(self) -> None:
     self.model: Sequential = Sequential()
     self.model.add(Conv2D(filters=6, kernel_size=(5, 5),
                           activation="relu"))
     self.model.add(MaxPool2D(pool_size=(2, 2)))
     self.model.add(
         Conv2D(filters=16, kernel_size=(5, 5), activation="relu"))
     self.model.add(MaxPool2D(pool_size=(2, 2)))
     self.model.add(Flatten())
     self.model.add(FC(units=120, activation="relu"))
     self.model.add(FC(units=84, activation="relu"))
Esempio n. 2
0
from dnet import datasets
from dnet.archs import LeNet5
from dnet.layers import FC

(x_train, y_train), (x_val, y_val) = datasets.tiny_mnist(flatten=False,
                                                         one_hot_encoding=True)

model = LeNet5()()
model.add(FC(units=10, activation="softmax"))
model.compile(loss="categorical_crossentropy",
              optimizer="adam",
              lr=1e-03,
              bs=512)
model.fit(inputs=x_train,
          targets=y_train,
          epochs=10,
          validation_data=(x_val, y_val))

model.plot_losses()
model.plot_accuracy()
Esempio n. 3
0
from dnet import datasets
from dnet.layers import Conv2D, MaxPool2D, Flatten, FC
from dnet.models import Sequential

(x_train, y_train), (x_val, y_val) = datasets.tiny_mnist(flatten=False,
                                                         one_hot_encoding=True)

model = Sequential([
    Conv2D(filters=6, kernel_size=(5, 5), activation="relu"),
    MaxPool2D(pool_size=(2, 2)),
    Conv2D(filters=16, kernel_size=(5, 5), activation="relu"),
    MaxPool2D(pool_size=(2, 2)),
    Flatten(),
    FC(units=120, activation="relu"),
    FC(units=84, activation="relu"),
    FC(units=10, activation="softmax")
])
model.compile(loss="categorical_crossentropy",
              optimizer="adam",
              lr=1e-03,
              bs=512)
model.fit(inputs=x_train,
          targets=y_train,
          epochs=10,
          validation_data=(x_val, y_val))

model.plot_losses()
model.plot_accuracy()
Esempio n. 4
0
 def __init__(self) -> None:
     self.model: Sequential = Sequential()
     self.model.add(
         Conv2D(filters=64,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(
         Conv2D(filters=64,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(MaxPool2D(pool_size=(2, 2)))
     self.model.add(
         Conv2D(filters=128,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(
         Conv2D(filters=128,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(MaxPool2D(pool_size=(2, 2)))
     self.model.add(
         Conv2D(filters=256,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(
         Conv2D(filters=256,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(
         Conv2D(filters=256,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(MaxPool2D(pool_size=(2, 2)))
     self.model.add(
         Conv2D(filters=512,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(
         Conv2D(filters=512,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(
         Conv2D(filters=512,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(MaxPool2D(pool_size=(2, 2)))
     self.model.add(
         Conv2D(filters=512,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(
         Conv2D(filters=512,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(
         Conv2D(filters=512,
                kernel_size=(3, 3),
                padding="same",
                activation="relu"))
     self.model.add(MaxPool2D(pool_size=(2, 2)))
     self.model.add(Flatten())
     self.model.add(FC(units=4096, activation="relu"))
     self.model.add(FC(units=4096, activation="relu"))
Esempio n. 5
0
from dnet import datasets
from dnet.layers import FC
from dnet.models import Sequential

(x_train, y_train), (x_val, y_val) = datasets.tiny_mnist(flatten=True, one_hot_encoding=True)

model = Sequential()
model.add(FC(units=500, activation="relu"))
model.add(FC(units=50, activation="relu"))
model.add(FC(units=10, activation="softmax"))
model.compile(loss="categorical_crossentropy", optimizer="rmsprop", lr=1e-03, bs=512)
model.fit(inputs=x_train, targets=y_train, epochs=20, validation_data=(x_val, y_val))

model.plot_losses()
model.plot_accuracy()