Skip to content

Instantly share code, notes, and snippets.

from fastText import load_model
model = load_model('official_fasttext_wiki_200_model')
def find_ngrams(string, n):
ngrams = zip(*[string[i:] for i in range(n)])
ngrams = [''.join(_) for _ in ngrams]
return ngrams
string = 'грёзоблаженствующий'
@eph2795
eph2795 / cartpole.py
Created February 18, 2017 19:50
CartPole
import gym
from tqdm import tqdm_notebook
import numpy as np
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
def get_random_policy():
return np.random.choice(n_actions, tuple(bins))
@eph2795
eph2795 / genetic.py
Last active February 17, 2017 08:19
Frozenlake8x8-v0
import gym
import numpy as np
import matplotlib.pyplot as plt
def get_random_policy():
"""
Build a numpy array representing agent policy.
This array must have one element per each of 16 environment states.
Element must be an integer from 0 to 3, representing action
to take from that state.