Beispiel #1
0
# Load the dev set (for tuning hyperparameters)
docs = du.load_dataset('data/ner/dev')
X_dev, y_dev = du.docs_to_windows(docs,
                                  word_to_num,
                                  tag_to_num,
                                  wsize=windowsize)

# Load the test set (dummy labels only)
docs = du.load_dataset('data/ner/test.masked')
X_test, y_test = du.docs_to_windows(docs,
                                    word_to_num,
                                    tag_to_num,
                                    wsize=windowsize)

from softmax_example import SoftmaxRegression
sr = SoftmaxRegression(wv=zeros((10, 100)), dims=(100, 5))

##
# Automatic gradient checker!
# this checks anything you add to self.grads or self.sgrads
# using the method of Assignment 1
sr.grad_check(x=5, y=4)

#from nerwindow import WindowMLP
from nerwindow_msushkov import WindowMLP
clf = WindowMLP(wv,
                windowsize=windowsize,
                dims=[None, 100, 5],
                reg=0.001,
                alpha=0.01)
clf.grad_check(X_train[0], y_train[0])  # gradient check on single point