Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Passionately building something..

Abdullah Furkan Özbek afozbek

:octocat:
Passionately building something..
View GitHub Profile
@afozbek
afozbek / add-target-to-links.js
Last active Aug 16, 2019
add _blank element
View add-target-to-links.js
View train_test_split
# Datasetimizi parçalayarak test datası oluşturacağız.
# Datamızın 1/3 ünü test datası olarak oluşturuyoruz
# Yani 30 satırımızın 20 si train datası olarak ayrılacak
# Ve 10 satırımız da test datası olucak.
X_train, X_test, y_train, y_test = train_test_split(x, y, test_size = 1/3, random_state = 123, shuffle=1)
View train
history = model.fit(X_train, y_train, validation_split=0.1, epochs=10, batch_size=200,
verbose=1, shuffle=1)
View Get-Request
import requests
from PIL import Image
url = 'https://www.researchgate.net/profile/Jose_Sempere/publication/221258631/figure/fig1/AS:305526891139075@1449854695342/Handwritten-digit-2.png'
response = requests.get(url, stream = True)
img = Image.open(response.raw)
plt.imshow(img)
View assert
assert(X_train.shape[0] == y_train.shape[0]), "The number of images is not equal .."
assert(X_test.shape[0] == y_test.shape[0]), "The number of images is not equal .."
assert(X_train.shape[1:] == (28, 28)), "The dimension of the images are not 28x28"
assert(X_test.shape[1:] == (28, 28)), "The dimension of the images are not 28x28"
View show-5-images
num_of_samples = []
cols = 5 #We will select 5 random images
num_of_classes = 10 #each digit total: 10
fig, axs = plt.subplots(nrows=num_of_classes, ncols=cols,
figsize=(5, 10))
fig.tight_layout()
for i in range(cols):
for j in range(num_of_classes):
View func
def create_model():
model = Sequential()
model.add(Dense(10, input_dim = num_pixels, #num_pixels: 784
activation = 'relu'))
model.add(Dense(30, activation='relu'))
model.add(Dense(10, activation='relu'))
model.add(Dense(num_of_classes, activation='softmax'))
model.compile(Adam(lr=0.01), #lr: learning rate
loss='categorical_crossentropy', #loss function
metrics=['accuracy'])
View func
def create_model():
model = Sequential()
model.add(Dense(10, input_dim = num_pixels, #num_pixels: 784
activation = 'relu'))
model.add(Dense(30, activation='relu'))
model.add(Dense(10, activation='relu'))
model.add(Dense(num_of_classes, activation='softmax'))
model.compile(Adam(lr=0.01), #lr: learning rate
loss='categorical_crossentropy', #loss function
metrics=['accuracy'])