Skip to content

Instantly share code, notes, and snippets.

View ogyalcin's full-sized avatar

Orhan Yalcin ogyalcin

View GitHub Profile
@ogyalcin
ogyalcin / preparing_mnist.py
Created August 19, 2018 19:12
Reshaping and Normalizing the MNIST Images
# Reshaping the array to 4-dims so that it can work with the Keras API
x_train = x_train.reshape(x_train.shape[0], 28, 28, 1)
x_test = x_test.reshape(x_test.shape[0], 28, 28, 1)
input_shape = (28, 28, 1)
# Making sure that the values are float so that we can get decimal points after division
x_train = x_train.astype('float32')
x_test = x_test.astype('float32')
# Normalizing the RGB codes by dividing it to the max RGB value.
x_train /= 255
x_test /= 255
import glob # The glob module is used for Unix style pathname pattern expansion.
import imageio # The library that provides an easy interface to read and write a wide range of image data
anim_file = 'dcgan.gif'
with imageio.get_writer(anim_file, mode='I') as writer:
filenames = glob.glob('image*.png')
filenames = sorted(filenames)
for filename in filenames:
image = imageio.imread(filename)
def convert_data_to_examples(train, test, DATA_COLUMN, LABEL_COLUMN):
train_InputExamples = train.apply(lambda x: InputExample(guid=None, # Globally unique ID for bookkeeping, unused in this case
text_a = x[DATA_COLUMN],
text_b = None,
label = x[LABEL_COLUMN]), axis = 1)
validation_InputExamples = test.apply(lambda x: InputExample(guid=None, # Globally unique ID for bookkeeping, unused in this case
text_a = x[DATA_COLUMN],
text_b = None,
label = x[LABEL_COLUMN]), axis = 1)
Model Size Top-1 Accuracy Top-5 Accuracy Parameters Depth
Xception 88 MB 0.79 0.945 22,910,480 126
VGG16 528 MB 0.713 0.901 138,357,544 23
VGG19 549 MB 0.713 0.9 143,667,240 26
ResNet50 98 MB 0.749 0.921 25,636,712 -
ResNet101 171 MB 0.764 0.928 44,707,176 -
ResNet152 232 MB 0.766 0.931 60,419,944 -
ResNet50V2 98 MB 0.76 0.93 25,613,800 -
ResNet101V2 171 MB 0.772 0.938 44,675,560 -
ResNet152V2 232 MB 0.78 0.942 60,380,648 -
# tf.function annotation causes the function
# to be "compiled" as part of the training
@tf.function
def train_step(images):
# 1 - Create a random noise to feed it into the model
# for the image generation
noise = tf.random.normal([BATCH_SIZE, noise_dim])
# 2 - Generate images and calculate loss values
x_train = x_train[…, tf.newaxis]
x_test = x_test[…, tf.newaxis]
@ogyalcin
ogyalcin / rnn_1.py
Last active December 27, 2021 13:22
import requests,json,numpy as np,pandas as pd
# https://docs.coinranking.com/
def hist_price_dl(coin_id=1335,timeframe = "5y",coinID = "Qwsogvtv82FCd", APIKey="YOUR-COINRANKING-API-KEY"):
'''It accepts coin_id, timeframe, and currency parameters to clean the historic coin data taken from COINRANKING.COM
It returns a Pandas Series with daily mean values of the selected coin in which the date is set as the index'''
r = requests.get("https://api.coinranking.com/v2/coin/" + coinID + "/history?timePeriod=" + timeframe + "&x-access-token="+APIKey)
coin = json.loads(r.text)['data']['history'] # Reading in json and cleaning the irrelevant parts
df = pd.DataFrame(coin)
Property Symbolic AI Subsymbolic AI
Knowledge Coding Easy | Coded as Rules and Relations Easy | Coded in Networks
Theoretical Knowledge Acquisition Easy Difficult
New Knowledge Insertion Easy Difficult
Result Explanation Easily Explained Difficult | Usually Opaque Models
Development Difficult | Manually Entering Rules Difficult | Can be Long
Training Difficult Easy
Approximate or Incomplete Information Processing Cannot Adopt by Itself Can Deal
Managing and Maintaining Difficult Easy
Processing Mode Sequential and Slow Parallel and Fast
def price_matrix_creator(data, seq_len=30):
'''
It converts the series into a nested list where every item of the list contains historic prices of 30 days
'''
price_matrix = []
for index in range(len(data)-seq_len+1):
price_matrix.append(data[index:index+seq_len])
return price_matrix
def normalize_windows(window_data):
@ogyalcin
ogyalcin / Add_Existing_Project_To_Git.md
Created August 31, 2021 09:01 — forked from alexpchin/Add_Existing_Project_To_Git.md
Add Existing Project To Git Repo

#Adding an existing project to GitHub using the command line

Simple steps to add existing project to Github.

1. Create a new repository on GitHub.

In Terminal, change the current working directory to your local project.

##2. Initialize the local directory as a Git repository.

git init