Skip to content

Instantly share code, notes, and snippets.

View rasoolims's full-sized avatar

Mohammad Sadegh Rasooli rasoolims

View GitHub Profile
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
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
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
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):
@rasoolims
rasoolims / bible2giza_files.py
Last active March 22, 2017 23:23
Convert Bible xml files from https://github.com/christos-c/bible-corpus/ to aligned files for all pairs of languages (src.target)
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'
@rasoolims
rasoolims / binary_search.py
Created October 6, 2016 23:53
binary search
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
@rasoolims
rasoolims / kth_item.py
Created October 6, 2016 23:53
kth_item.py
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:
@rasoolims
rasoolims / sort.py
Created October 6, 2016 23:52
sort
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])
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");
@rasoolims
rasoolims / Adam.java
Last active August 17, 2016 16:32
Adam algorithm with averaging
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.