Skip to content

Commit

Permalink
Modified.
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntan committed Jul 3, 2013
1 parent fc50f5a commit 5c35196
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 804 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ nosetests.xml
.mr.developer.cfg
.project
.pydevproject

*.data
*.pickle
11 changes: 7 additions & 4 deletions crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ def __init__(self,feature_functions,labels,sigma=10,transition_feature=True):
self.theta = np.random.randn(len(self.ft_fun))

self.label_id = { l:i for i,l in enumerate(self.labels) }
v = sigma ** 2
v2 = v * 2
self.regulariser = lambda w: np.sum(w ** 2) / v2
self.regulariser_deriv = lambda w:np.sum(w) / v
self.v = sigma ** 2
self.v2 = self.v * 2

def regulariser(self,w):
return np.sum(w ** 2) /self.v2
def regulariser_deriv(self,w):
return np.sum(w) / self.v

def all_features(self,x_vec):
"""
Expand Down
Binary file removed model.pickle
Binary file not shown.
Loading

0 comments on commit 5c35196

Please sign in to comment.