Skip to content

Instantly share code, notes, and snippets.

View cobanov's full-sized avatar
🦊
Focusing

Mert Cobanov cobanov

🦊
Focusing
View GitHub Profile
# -*- 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
import keras
import numpy as np
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)
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)
model_and.predict(np.array([[0.0, 0.0]]))
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))
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)
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)
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ı")
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 3 00:47:42 2019
@author: coban
"""
import pandas as pd
import numpy as np