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 random | |
| import torch | |
| num_examples = 128 | |
| message_length = 32 | |
| def dataset(num_examples): | |
| """Returns a list of 'num_examples' pairs of the form (encrypted, original). | |
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
| from pymongo import MongoClient | |
| try: | |
| client = MongoClient('localhost') | |
| db = client.searchfollow | |
| except: | |
| print("Could not connect to MongoDB") | |
| call = db.command("dbstats") |
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
| [ | |
| { | |
| "url": "http://money.cnn.com", | |
| "rss": "http://rss.cnn.com/rss/money_topstories.rss" | |
| }, | |
| { | |
| "url": "http://thehill.com", | |
| "rss": "http://thehill.com/rss/syndicator/19110" | |
| }, | |
| { |
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.
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 keras | |
| import numpy as np | |
| timesteps = 60 | |
| input_dim = 64 | |
| samples = 10000 | |
| batch_size = 128 | |
| output_dim = 64 | |
| # Test data. |
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
| #!/usr/bin/python | |
| import os, sys, gzip | |
| from StringIO import StringIO | |
| from datetime import datetime | |
| def readByte(f): | |
| return ord(f.read(1)) | |
| def readInt(f): | |
| l = 0 |
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
| cimport cython | |
| import numpy as np | |
| cimport numpy as np | |
| from sklearn.metrics import f1_score | |
| @cython.boundscheck(False) | |
| @cython.wraparound(False) | |
| def f1_opt(np.ndarray[long, ndim=1] label, np.ndarray[double, ndim=1] preds): |
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
| """akmtdfgen: A Keras multithreaded dataframe generator. | |
| Works with Python 2.7 and Keras 2.x. | |
| For Python 3.x, need to fiddle with the threadsafe generator code. | |
| Test the generator_from_df() functions by running this file: | |
| python akmtdfgen.py |