This file contains 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
# Neural Network config | |
CONV_FILTERS = [32, 48] | |
CONV_KERNEL_SIZES = [6, 5] | |
CONV_STRIDES = [2, 2] | |
for c, (filters, kernel_size, strides) in enumerate(zip(CONV_FILTERS, CONV_KERNEL_SIZES, CONV_STRIDES)): | |
print("index") | |
print(c) # this is the index | |
# everything else is just unpacked | |
print(filters) |
This file contains 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
# Requirements: | |
# - Python 3 | |
# - gym | |
# | |
# This is a sample script that familiarizes one with OpenAI's gym | |
# environment. | |
# | |
# It is modified from: | |
# | |
# https://github.com/vmayoral/basic_reinforcement_learning/tree/master/tutorial3 |
This file contains 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 tensorflow as tf | |
a = tf.constant([[0, 1], [2, 0], [0, 3]]) | |
b = tf.reduce_sum(a) | |
c = tf.reduce_sum(a, 0) # reduce by column | |
d = tf.reduce_sum(a, 1) # reduce by row | |
for tensor in [b, c, d]: | |
result = tf.Session().run(tensor) | |
print(result) |
This file contains 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
# note, this is for mac | |
# more: https://blog.jasonmeridth.com/posts/use-git-grep-to-replace-strings-in-files-in-your-git-repository/ | |
git grep -l 'original_text' | xargs sed -i '' -e 's/original_text/new_text/g' |
This file contains 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
source activate environment_name | |
python script.py | |
# Example: | |
# | |
# Kasim:pytorch-cifar Kasim$ python --version | |
# Python 2.7.14 | |
# Kasim:pytorch-cifar Kasim$ source activate base | |
# (base) Kasim:pytorch-cifar Kasim$ python --version | |
# P ython 3.6.5 :: Anaconda, Inc. |
This file contains 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 matplotlib.pyplot as plt | |
fig, ax = plt.subplots() | |
ax.plot(range(NUM_EPOCH), train_loss1, label="MLP") | |
ax.plot(range(NUM_EPOCH), train_loss2, label="CNN") | |
ax.legend() | |
ax.set(xlabel='Epochs', ylabel='Loss', | |
title="Training Loss (MLP vs CNN)") | |
ax.grid() |
This file contains 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
static func uniqueIdentifier() -> String { | |
let quasiUniqueString = ProcessInfo.processInfo.globallyUniqueString | |
let index = quasiUniqueString.index(quasiUniqueString.startIndex, offsetBy: 10) | |
return quasiUniqueString.substring(to: index) | |
} |
This file contains 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
var optional: String? = "Hello World" | |
if let o = optional { // Same as: optional as String! | |
print(o) | |
} | |
// Output: Hello World. | |
if let o = optional as String! { | |
print(o) | |
} | |
// Output: Hello World. |
This file contains 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
- (void)application:(UIApplication *)application | |
didReceiveLocalNotification:(UILocalNotification *)notification { | |
UIViewController *top = [[application keyWindow] rootViewController]; | |
while (top.presentedViewController != nil) { | |
top = top.presentedViewController; | |
} | |
UIAlertController *alert = |
This file contains 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
protocol X { | |
func myfunc() -> Int | |
} | |
protocol Y { | |
} | |
protocol Z { | |
} |