Skip to content

Commit d37441d

Browse files
author
dmitrinesterenko
committed
Merge master
2 parents 412b0db + 34feb15 commit d37441d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

assignment3/rnn.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
import os
33
import numpy as np
4+
#import matplotlib.pyplot as plt
45
import math
56
import time
67
import itertools
@@ -187,17 +188,19 @@ def add_model(self, node):
187188
node_tensors[node] = curr_node_tensor
188189
return node_tensors
189190

190-
191191
def add_projections(self, node_tensors):
192192
"""Add projections to the composition vectors to compute the raw sentiment scores
193193
194194
Hint: Reuse the "Projection" variable_scope here
195195
Args:
196196
node_tensors: tensor(?, embed_size)
197+
<<<<<<< HEAD
197198
When we are evaluating just on the root node then the first
198199
dimension would be 1, if we are looking through a hierarchy of terms in a
199200
sentence then that would be equal to the number of words we want to include i.e.
200201
5
202+
=======
203+
>>>>>>> master
201204
Returns:
202205
output: tensor(?, label_size)
203206
"""
@@ -339,6 +342,7 @@ def run_epoch(self, new_model = False, verbose=50):
339342
if i == 0: # this is GLORIOUS :(
340343
self.add_model_vars()
341344
# Define training operations in the graph
345+
342346
tree = self.train_data[step]
343347
logits = self.inference(tree)
344348
labels = [l for l in tree.labels if l!=2]
@@ -495,5 +499,13 @@ def test_RNN():
495499
test_acc = np.equal(predictions, labels).mean()
496500
print('Test acc: {}'.format(test_acc))
497501

502+
#plt.plot(stats['loss_history'])
503+
#plt.title('Loss history')
504+
#plt.xlabel('Iteration')
505+
#plt.ylabel('Loss')
506+
#plt.savefig("loss_history.png")
507+
#plt.show()
508+
509+
498510
if __name__ == "__main__":
499511
test_RNN()

assignment3/tree.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def get_words(self):
8181
def leftTraverse(node, nodeFn=None, args=None):
8282
"""
8383
Recursive function traverses tree
84+
<<<<<<< HEAD
8485
from left to right.
8586
Calls nodeFn at each node
8687
"""
@@ -149,7 +150,7 @@ def simplified_data(num_train, num_dev, num_test):
149150
rndstate = random.getstate()
150151
random.seed(0)
151152
trees = loadTrees('train') + loadTrees('dev') + loadTrees('test')
152-
153+
153154
#filter extreme trees
154155
pos_trees = [t for t in trees if t.root.label==4]
155156
neg_trees = [t for t in trees if t.root.label==0]

assignment3/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def construct(self, words):
2222
self.add_word(word)
2323
self.total_words = float(sum(self.word_freq.values()))
2424
print('{} total words with {} uniques'.format(self.total_words, len(self.word_freq)))
25-
2625
def encode(self, word):
2726
if word not in self.word_to_index:
2827
word = self.unknown

0 commit comments

Comments
 (0)