Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View afozbek's full-sized 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 August 16, 2019 09:32
add _blank element
# 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)
@afozbek
afozbek / train
Created January 28, 2019 20:24
medium
history = model.fit(X_train, y_train, validation_split=0.1, epochs=10, batch_size=200,
verbose=1, shuffle=1)
@afozbek
afozbek / Get-Request
Last active January 28, 2019 20:18
medium
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)
@afozbek
afozbek / assert
Created January 28, 2019 07:58
medium
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"
@afozbek
afozbek / show-5-images
Created January 28, 2019 07:54
medium
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):
@afozbek
afozbek / func
Created January 28, 2019 07:51
med
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'])
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'])