print posteriorRestrictionToObjectsAndAdjectivesForSent([0, 1, 1], True, 0, 1) print posteriorRestrictionToObjectsAndAdjectivesForSent([1, 0, 1], True, 1, 0) def sigma(x): return 1 / (1 + exp(-x)) alpha1 = 1.7 alpha2 = -0.3 u = 0 c = 0 logAvg = -0.6931471805599453 correct = .5 for epoch in range(200): for point in prepareNgramData.dataset(): adj1 = point["AdjNum1"] adj2 = point["AdjNum2"] pmi1 = point["PMI1"] pmi2 = point["PMI2"] utilityLoss12 = posteriorRestrictionToObjectsAndAdjectivesForSent( [adj1, adj2, 1], True, adj1, adj2) utilityLoss21 = posteriorRestrictionToObjectsAndAdjectivesForSent( [adj2, adj1, 1], True, adj2, adj1) print[ utilityLoss12, utilityLoss21, "AGR", agreement[adj1], agreement[adj2] ] if (utilityLoss12 > utilityLoss21) != (agreement[adj1] < agreement[adj2]): print["ERROR", agreement[adj1], agreement[adj2]]
return sum(map(lambda x: x[0] * x[1], zip(surprisals, probabilities))) # print "PROBABILITIES "+str(eventsForS1) # return sum(map(lambda x:x * log(x), eventsForS1)) #print posteriorRestrictionToObjectsAndAdjectivesForSent([0,1,1], True, 0, 1) #print posteriorRestrictionToObjectsAndAdjectivesForSent([1,0,1], True, 1, 0) def sigma(x): return 1 / (1 + exp(-x)) #dataset_size = sum(1 for _ in prepareNgramData.dataset()) dataiter = prepareNgramData.dataset() dataset = [x for x in dataiter] u = 0 c = 0 logAvg = -0.6931471805599453 correct = .5 #for epoch in range(200): def guide(dataset): # register the two variational parameters with Pyro mu1 = pyro.param("mu1", Variable(torch.Tensor([(0.0)]), requires_grad=True)) mu2 = pyro.param("mu2", Variable(torch.Tensor([(0.0)]), requires_grad=True))