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
2020-04-07 14:56:15.927070 Epoch Step: 50 Loss: 10.338213 Tokens per Sec: 3368.013480 | |
2020-04-07 14:57:20.718592 Epoch Step: 100 Loss: 10.167365 Tokens per Sec: 7114.368865 | |
2020-04-07 14:58:23.048797 Epoch Step: 150 Loss: 10.049715 Tokens per Sec: 7365.751670 | |
2020-04-07 14:59:27.724888 Epoch Step: 200 Loss: 10.009823 Tokens per Sec: 7001.795763 | |
2020-04-07 15:00:33.312455 Epoch Step: 250 Loss: 10.029766 Tokens per Sec: 7038.528239 | |
2020-04-07 15:01:37.124237 Epoch Step: 300 Loss: 9.958084 Tokens per Sec: 7132.142970 | |
2020-04-07 15:02:41.631392 Epoch Step: 350 Loss: 10.029122 Tokens per Sec: 7037.992992 | |
2020-04-07 15:03:47.031098 Epoch Step: 400 Loss: 10.011264 Tokens per Sec: 6991.174433 | |
2020-04-07 15:04:50.035835 Epoch Step: 450 Loss: 9.939527 Tokens per Sec: 7247.814263 | |
2020-04-07 15:05:54.265058 Epoch Step: 500 Loss: 10.037009 Tokens per Sec: 7080.542676 |
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
class avg_perceptron: | |
def __init__(self,model_path='',label_path=''): | |
self.avg_weights=self.load_model(model_path) | |
self.labels=self.load_labels(label_path) | |
self.weights=defaultdict(int) | |
self.iteration=1 | |
def update_weight(self,feature,update): | |
self.weights[feature]+=update | |
self.avg_weights[feature]+=iteration*update |
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 dynet as dynet | |
import random | |
import matplotlib.pyplot as plt | |
import numpy as np | |
class Network: | |
def __init__(self, vocab, properties): | |
self.properties = properties | |
self.vocab = vocab |
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
from dynet import * | |
from depModel import DepModel | |
import random, time | |
import numpy as np | |
init() | |
class NNModel(DepModel): | |
def __init__(self, words, pos_tags, labels, options): |
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 re,os,sys,codecs,traceback | |
from xml.dom import minidom | |
''' | |
The input folder is the folder with Bible xml files from https://github.com/christos-c/bible-corpus/ | |
The output folder contains aligned files for all pairs of languages (src.target) | |
It merges English and English-Web files. | |
''' | |
if len(sys.argv)<3: | |
print 'input_folder output_folder' |
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
arr = [1,2,3,4,5,6,8,9,10,12,13,15] | |
def binary_search(a, v): | |
s = 0 | |
e = len(a) - 1 | |
mid = (s+e)/2 | |
while s <= e: | |
if a[mid] == v: | |
return mid |
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 time, random | |
def partition(myList, start, end): | |
pivot = myList[start] | |
left = start+1 | |
right = end | |
done = False | |
while not done: | |
while left <= right and myList[left] <= pivot: |
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 time | |
def merge (a, b): | |
p1 = 0 | |
p2 = 0 | |
res = list() | |
while p1<len(a) and p2<len(b): | |
if a[p1]<b[p2]: | |
res.append(a[p1]) |
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
private String trainWithAdam(List<String> trainSentencesInCONLLFormat, | |
IndexMap indexMap, HashSet<String> labelSet, | |
int numberOfTrainingIterations, | |
String modelDir, int numOfFeatures, String taskType, int batchSize) | |
throws Exception { | |
System.out.println("Training for task "+taskType); | |
DecimalFormat format = new DecimalFormat("##.00"); | |
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
package ml; | |
import java.io.*; | |
import java.text.SimpleDateFormat; | |
import java.util.*; | |
import java.util.zip.GZIPInputStream; | |
import java.util.zip.GZIPOutputStream; | |
/** | |
* Created by Mohammad Sadegh Rasooli. |
NewerOlder