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 torch | |
from transformers import BertTokenizer, BertModel, BertForMaskedLM | |
import logging | |
logging.basicConfig(level=logging.INFO)# OPTIONAL | |
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') | |
model = BertForMaskedLM.from_pretrained('bert-base-uncased') | |
model.eval() |
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
# -*- coding: utf-8 -*- | |
u""" | |
Beta regression for modeling rates and proportions. | |
References | |
---------- | |
Grün, Bettina, Ioannis Kosmidis, and Achim Zeileis. Extended beta regression | |
in R: Shaken, stirred, mixed, and partitioned. No. 2011-22. Working Papers in | |
Economics and Statistics, 2011. |
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
''' | |
Original implementation | |
https://github.com/clab/dynet_tutorial_examples/blob/master/tutorial_parser.ipynb | |
The code structure and variable names are similar for better reference. | |
Not for serious business, just for some comparison between PyTorch and DyNet | |
(and I still prefer PyTorch) | |
''' | |
import torch as T |
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 torch | |
from torch import nn | |
import torch.nn.functional as F | |
import torch.nn.utils | |
from torch.autograd import Variable | |
from torch.nn import Parameter, init | |
from torch.nn._functions.rnn import variable_recurrent_factory, StackedRNN | |
from torch.nn.modules.rnn import RNNCellBase | |
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence, PackedSequence | |
import numpy as np |
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 torch | |
import torch.nn as nn | |
from torch.autograd import Variable | |
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence | |
import torch.nn.functional as F | |
import numpy as np | |
import itertools | |
def flatten(l): | |
return list(itertools.chain.from_iterable(l)) |
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
sudo ldconfig /usr/local/cuda-7.0/lib64 |
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 edu.stanford.nlp.sentiment.BuildBinarizedDataset; | |
public class BinarizeTrees { | |
public static void main(String[] args) { | |
String textFile = (args.length > 1) ? args[1] : args[0]; | |
System.out.println("Generating binarized trees from file "+textFile); | |
String[] input = {"-input", textFile}; |
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 os | |
from nltk.parse import stanford | |
os.environ['STANFORD_PARSER'] = '/path/to/standford/jars' | |
os.environ['STANFORD_MODELS'] = '/path/to/standford/jars' | |
parser = stanford.StanfordParser(model_path="/location/of/the/englishPCFG.ser.gz") | |
sentences = parser.raw_parse_sents(("Hello, My name is Melroy.", "What is your name?")) | |
print sentences | |
# GUI |