This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Deep Learning Türkiye topluluğu için Mert Çobanoğlu tarafından hazırlanmıştır. | |
Amaç: Keras ile nesne tanıma. | |
Algoritma: Evrişimli Sinir Ağları (Convolutional Neural Networks) | |
Ek: Çalışma ile ilgili rehber README.md dosyasında belirtilmiştir. | |
""" | |
from keras.applications.resnet50 import ResNet50 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import keras | |
import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model_and = keras.Sequential() | |
model_and.add(keras.layers.Dense(units=2, input_shape=[2])) | |
model_and.add(keras.layers.Dense(units=1)) | |
model_and.compile(optimizer="sgd", loss="mean_squared_error", metrics=["accuracy"]) | |
model_and.fit(xs_and, ys_and, epochs=300, verbose=0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xs_and = np.array([[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]], dtype = float) | |
ys_and = np.array([[0.0], [0.0], [0.0], [1.0]], dtype = float) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model_and.predict(np.array([[0.0, 0.0]])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pred_zero_zero = np.array([[0.0,0.0]]) # Expecting False | |
pred_zero_one = np.array([[0.0,1.0]]) | |
pred_one_zero = np.array([[1.0,0.0]]) | |
pred_one_one = np.array([[1.0,1.0]]) | |
predictions = [pred_zero_zero, pred_zero_one, pred_one_zero, pred_one_one] | |
for pred in predictions: | |
print(model_and.predict(pred)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prediction_and(pred): | |
x = model_and.predict(pred) | |
print(x) | |
if x > 0.5: | |
print("Bu doğru\n") | |
else: | |
print("Bu yanlış\n") | |
for pred in predictions: | |
prediction_and(pred) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first_layer_weights_and = model_and.layers[0].get_weights()[0] | |
first_layer_biases_and = model_and.layers[0].get_weights()[1] | |
print(first_layer_weights_and) | |
print(first_layer_biases_and) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first_layer_weights_and = model_and.layers[0].get_weights()[0] | |
first_layer_biases_and = model_and.layers[0].get_weights()[1] | |
print("ilk katman ağırlıkları") | |
print(first_layer_weights_and) | |
print("\nilk katman yanlılıkları") | |
print(first_layer_biases_and) | |
second_layer_weights_and = model_and.layers[1].get_weights()[0] | |
second_layer_biases_and = model_and.layers[1].get_weights()[1] | |
print("\nçıkış katmanı ağırlıkları") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Wed Apr 3 00:47:42 2019 | |
@author: coban | |
""" | |
import pandas as pd | |
import numpy as np | |