Exemplo n.º 1
0
import time
import pickle
import numpy as np
from layers import Dense, Flatten, Conv2D, MaxPooling2D
from loss import binary_crossentropy
from model import Linear
from activation import Sigmoid
from optimizer import gradient_descent

start_time = time.time()
image = np.random.rand(64, 64)

model = Linear()
model.add(Conv2D(64, input_shape=(64, 64)))
model.add(MaxPooling2D((2, 2)))
model.add(Conv2D(128))
model.add(MaxPooling2D((2, 2)))
model.add(Flatten())
model.add(Dense(128))
model.add(Dense(64))
model.add(Dense(1, activation=Sigmoid, normalize_signal=False))
model.summary()

model.eval(image)
input_data = open("input_data.pickle", "rb")
input_data = np.array(pickle.load(input_data)) / 255.0

label = open("label.pickle", "rb")
label = np.expand_dims(np.array(pickle.load(label)), axis=1)
model.compile(optimizer=gradient_descent, loss=binary_crossentropy)
model.fit(input_data, label, epochs=20, batch_size=16)
Exemplo n.º 2
0
import time
from layers import Dense, Flatten, Conv2D
from model import Linear
import numpy as np

start_time = time.time()
image = np.random.rand(64, 64)

model = Linear()
model.add(Conv2D(64))
model.add(Flatten())
model.add(Dense(512))
model.add(Dense(256))
model.add(Dense(64))
model.summary()

print(model.eval(image))
end_time = time.time()
print(f"Total execution time::  {end_time - start_time}")