Skip to content

Instantly share code, notes, and snippets.

View mmuratarat's full-sized avatar
😃

Mustafa Murat Arat mmuratarat

😃
View GitHub Profile
@mmuratarat
mmuratarat / gist:1b1f879fdf58c976fe0a9d253bd477ba
Last active December 6, 2023 07:01
Turkish official holidays for the years 2020, 2021, 2022, 2023
import datetime
holidays = {datetime.date(2020, 1, 1): 'Yeni Yıl',
datetime.date(2020, 4, 23): "Ulusal Egemenlik ve Çocuk Bayramı",
datetime.date(2020, 5, 1): 'İşçi ve Emekçiler Bayramı',
datetime.date(2020, 5, 19): "Atatürk'ü Anma, Gençlik ve Spor Bayramı",
datetime.date(2020, 5, 23): 'Ramazan Bayramı Arife Günü',
datetime.date(2020, 5, 24): 'Ramazan Bayramı',
datetime.date(2020, 5, 25): 'Ramazan Bayramı ',
datetime.date(2020, 5, 26): 'Ramazan Bayramı ',
import re
def tr_upper(self):
self = re.sub(r"i", "İ", self)
self = re.sub(r"ı", "I", self)
self = re.sub(r"ç", "Ç", self)
self = re.sub(r"ş", "Ş", self)
self = re.sub(r"ü", "Ü", self)
self = re.sub(r"ğ", "Ğ", self)
self = re.sub(r"â", "a", self)
@mmuratarat
mmuratarat / reproducibility.txt
Created October 8, 2023 18:30
reproducibility
def seed_everything(seed: int):
import random, os
import numpy as np
import torch
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
@mmuratarat
mmuratarat / gist:eff84ecb11b32cb9db6d4badf92e7c1b
Last active September 19, 2023 17:19
Expanding contractions
contractions_dict = { "ain’t": "are not", "’s":" is", "aren’t": "are not", "can’t": "cannot", "can’t’ve": "cannot have", "‘cause": "because",
"could’ve": "could have", "couldn’t": "could not", "couldn’t’ve": "could not have", "didn’t": "did not", "doesn’t": "does not",
"don’t": "do not", "hadn’t": "had not", "hadn’t’ve": "had not have", "hasn’t": "has not", "haven’t": "have not", "he’d": "he would",
"he’d’ve": "he would have", "he’ll": "he will", "he’ll’ve": "he will have", "how’d": "how did", "how’d’y": "how do you", "how’ll": "how will",
"I’d": "I would", "I’d’ve": "I would have", "I’ll": "I will", "I’ll’ve": "I will have", "I’m": "I am", "I’ve": "I have", "isn’t": "is not",
"it’d": "it would", "it’d’ve": "it would have", "it’ll": "it will", "it’ll’ve": "it will have", "let’s": "let us", "ma’am": "madam",
"mayn’t": "may not", "might’ve": "might have", "mightn’t": "might not", "m
@mmuratarat
mmuratarat / gist:4e607b1cd08c8a35c06a77c0bfbabb0b
Created September 10, 2023 19:02
Turkish cities in a Python List
# # Turkish Cities
cities = ["Adana","Adiyaman","Afyon","Agri","Aksaray","Amasya","Ankara","Antalya","Ardahan","Artvin","Aydin","Balikesir","Bartin","Batman","Bayburt","Bilecik","Bingol","Bitlis","Bolu","Burdur","Bursa","Canakkale","Cankiri","Corum","Denizli","Diyarbakir","Duzce","Edirne","Elazig","Erzincan","Erzurum","Eskisehir","Gaziantep","Giresun","Gumushane","Hakkari","Hatay","Igdir","Isparta","Istanbul","Izmir","Kahramanmaras","Karabuk","Karaman","Kars","Kastamonu","Kayseri","Kilis","Kirikkale","Kirklareli","Kirsehir","Kocaeli","Konya","Kutahya","Malatya","Manisa","Mardin","Mersin","Mugla","Mus","Nevsehir","Nigde","Ordu","Osmaniye","Rize","Sakarya","Samsun","Sanliurfa","Siirt","Sinop","Sirnak","Sivas","Tekirdag","Tokat","Trabzon","Tunceli","Usak","Van","Yalova","Yozgat","Zonguldak"]
# # Turkish Cities Uppercase
cities_upper = ['ADANA', 'ADIYAMAN', 'AFYON', 'AGRI', 'AKSARAY', 'AMASYA', 'ANKARA', 'ANTALYA', 'ARDAHAN', 'ARTVIN', 'AYDIN', 'BALIKESIR', 'BARTIN', 'BATMAN', 'BAYBURT', 'BILECIK', 'BINGOL', '
file_name multi_hot_encoding Labels Categories
----------------------------------------------------------------------------------------------------
0.png [1, 0, 0, 0, 0] [1] [Desert]
10.png [1, 1, 0, 0, 1] [1, 2] [Desert, Mountains]
47.png [1, 0, 0, 1, 1] [1, 4, 5] [Desert, Sunset, Trees]
import matplotlib.pyplot as plt
import numpy as np
from math import ceil
def multi_convolution2d(input, filter, strides=(1, 1), padding='SAME'):
#This is for multiple filter
if not len(filter.shape) == 4:
raise ValueError("The size of filter should be (filter_height, filter_width, filter_depth, number_of_filters)")
if not len(input.shape) == 3:
import matplotlib.pyplot as plt
import numpy as np
from math import ceil
def convolution2d(input, filter, bias=0, strides=(1, 1), padding='SAME'):
#This is only for using one filter
if not len(filter.shape) == 3:
raise ValueError("The size of the filter should be (filter_height, filter_width, filter_depth)")
if not len(input.shape) == 3:
reset_graph()
n_epochs = 1000
learning_rate = 0.01
epsilon = 1e-7
X = tf.constant(inputs, dtype = tf.float32, name = "x")
y = tf.constant(output, dtype = tf.float32, name = "y")
theta = tf.Variable(tf.random_uniform([n,1], -1.0, 1.0), name ="theta")
logits = tf.matmul(X, theta, name="logits")
#predictions = 1/(1+ tf.exp(-logits))
reset_graph()
n_epochs = 1000
learning_rate = 0.01
X = tf.constant(inputs, dtype = tf.float32, name = "x")
y = tf.constant(output, dtype = tf.float32, name = "y")
theta = tf.Variable(tf.random_uniform([n,1], -1.0, 1.0), name ="theta")
logits = tf.matmul(X, theta, name="logits")
#predictions = 1/(1+ tf.exp(-logits))
predictions = tf.sigmoid(logits)