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
| class PageRank(val connections: Map<String, List<String>>) { | |
| private val reversed: Map<String, List<String>> = connections | |
| .flatMap { (k, v) -> v.map { it to k } } | |
| .groupBy { it.first } | |
| .mapValues { (_, v) -> v.map { it.second } } | |
| private var pageRank: Map<String, Double> = connections.mapValues { (_, _) -> 0.0 } | |
| private fun partialSum(point: String): Double { |
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
| # This script is designed to work with ubuntu 16.04 LTS | |
| # with keras 1.2.2 and the latest Pytorch with CUDA 8 support | |
| ########################################################################## | |
| #This is used to install CUDA 8 driver for Tesla K80 | |
| ########################################################################## | |
| #!/bin/bash | |
| echo "Checking for CUDA and installing." | |
| # Check for CUDA and try to install. | |
| if ! dpkg-query -W cuda-8-0; then |
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 torch | |
| import torch.nn as nn | |
| from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence | |
| seqs = ['gigantic_string','tiny_str','medium_str'] | |
| # make <pad> idx 0 | |
| vocab = ['<pad>'] + sorted(set(''.join(seqs))) | |
| # make model |
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
| # Author: Luke Schoen 2017 | |
| import pandas as pd | |
| import numpy as np | |
| import functools | |
| # Create DataFrame | |
| # df = pd.DataFrame(np.random.randn(10,2)) | |
| # Populate with NaN values | |
| df = pd.DataFrame({'col1': ['1.111', '2.111', '3.111', '4.111'], 'col2': ['4.111', '5.111', np.NaN, '7.111'], 'col3': ['8', '9', np.NaN, np.NaN], 'col4': ['12', '13', '14', '15']}) |
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 torch | |
| import torch.nn as nn | |
| import numpy as np | |
| import torch.optim as optim | |
| from torch.autograd import Variable | |
| # (1, 0) => target labels 0+2 | |
| # (0, 1) => target labels 1 | |
| # (1, 1) => target labels 3 | |
| train = [] |
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 numpy as np | |
| from sklearn.model_selection import train_test_split | |
| import torch | |
| import torch.nn as nn | |
| from torch.autograd import Variable | |
| np.random.seed(1337) | |
| MAX_LEN = 30 |
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
| """ Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """ | |
| import numpy as np | |
| import cPickle as pickle | |
| import gym | |
| # hyperparameters | |
| H = 200 # number of hidden layer neurons | |
| batch_size = 10 # every how many episodes to do a param update? | |
| learning_rate = 1e-4 | |
| gamma = 0.99 # discount factor for reward |
NewerOlder