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
How to manually setup flake8 as PyCharm external tool | |
File / Settings / Tools / External Tools / Add | |
Name: Flake8 | |
Program: $PyInterpreterDirectory$/python | |
Parameters: -m flake8 --max-complexity 10 --ignore E501 $FilePath$ | |
Working directory: $ProjectFileDir$ | |
Output Filters / Add | |
Name: Filter 1 |
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
# Ref: https://github.com/ericjang/genadv_tutorial/blob/master/genadv1.ipynb | |
learning_rate = tf.train.exponential_decay( | |
0.001, # Base learning rate. | |
batch, # Current index into the dataset. | |
TRAIN_ITERS // 4, # Decay step - this decays 4 times throughout training process. | |
0.95, # Decay rate. | |
staircase=True) |
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 get_from_json_dict(json_dict, keys, default_dict=None): | |
for index, key in enumerate(keys): | |
if isinstance(json_dict, dict) and isinstance(key, str): # check if you have a `dict` and `str` in hand | |
# get item of the key from json_dict, if key is Bad, get item from default_dict, or get None | |
json_dict = json_dict.get(key, default_dict[key] if default_dict else None) | |
if default_dict: | |
default_dict = default_dict[key] # reducing default dict | |
continue | |
if isinstance(json_dict, list) and isinstance(key, int): # check if you have a `list` and `int` in hand |
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
# get only the first element | |
checkout_curse = reduce(lambda curses_dict, key: dict.get(key), [curses_dict, "curses", "names", 0]) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2016-11-01T17:33:15.254949", | |
"start_time": "2016-11-01T17:33:12.700730" | |
}, |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 pickle # pickle is py2 equivalent of cPickle | |
# if a Py2 cPickle object shows UnicodeError in Py3 | |
with open(picklefile, 'rb') as f | |
d = pickle.load(f, encoding='latin1') |
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 requests | |
url = "http://www.matthewzeiler.com/pubs/arxive2013/eccv2014.pdf" | |
r = requests.get(url) | |
pdffile = r.url.split('/')[-1] | |
with open(pdffile, 'wb') as pdf: | |
pdf.write(r.content) |
NewerOlder