Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- X = T.fmatrix('X')
- y = T.fmatrix('y')
- cosines = theano.shared(cosine_sims.astype('float32'))
- indx1 = theano.shared(indx1.astype('float32'))
- indx2 = theano.shared(indx2.astype('float32'))
- w = theano.shared(np.random.uniform(-1./m, 1./m, size=(m, n)).astype('float32'))
- b = theano.shared(np.zeros(shape=n,).astype('float32'))
- p = T.nnet.softmax(X.dot(w) + b[None, :])
- L1 = T.mean(-T.sum(y * T.log(p)))
- L2 = T.sum(w**2)
- L3 = T.sum((w[indx1, :] - w[indx2, :]) ** 2)
- #L3 = T.mean(((w[:, None, :] - w[None, :, :])**2) * cosines[:, :, None])
- alpha1 = T.fscalar()
- alpha2 = T.fscalar()
- L = L1 + alpha1*L2 + alpha2*L3
- TypeErrorTraceback (most recent call last)
- <ipython-input-38-b3aea550ace2> in <module>()
- 14 L1 = T.mean(-T.sum(y * T.log(p)))
- 15 L2 = T.sum(w**2)
- ---> 16 L3 = T.sum((w[indx1, :] - w[indx2, :]) ** 2)
- 17
- 18 #L3 = T.mean(((w[:, None, :] - w[None, :, :])**2) * cosines[:, :, None])
- /opt/jupyter-notebook/.local/lib/python2.7/site-packages/theano/tensor/var.pyc in __getitem__(self, args)
- 501 TensorVariable, TensorConstant,
- 502 theano.tensor.sharedvar.TensorSharedVariable))):
- --> 503 return self.take(args[axis], axis)
- 504 else:
- 505 return theano.tensor.subtensor.advanced_subtensor(self, *args)
- /opt/jupyter-notebook/.local/lib/python2.7/site-packages/theano/tensor/var.pyc in take(self, indices, axis, mode)
- 533
- 534 def take(self, indices, axis=None, mode='raise'):
- --> 535 return theano.tensor.subtensor.take(self, indices, axis, mode)
- 536
- 537 # COPYING
- /opt/jupyter-notebook/.local/lib/python2.7/site-packages/theano/tensor/subtensor.pyc in take(a, indices, axis, mode)
- 2368 return advanced_subtensor1(a.flatten(), indices)
- 2369 elif axis == 0:
- -> 2370 return advanced_subtensor1(a, indices)
- 2371 else:
- 2372 if axis < 0:
- /opt/jupyter-notebook/.local/lib/python2.7/site-packages/theano/gof/op.pyc in __call__(self, *inputs, **kwargs)
- 609 """
- 610 return_list = kwargs.pop('return_list', False)
- --> 611 node = self.make_node(*inputs, **kwargs)
- 612
- 613 if config.compute_test_value != 'off':
- /opt/jupyter-notebook/.local/lib/python2.7/site-packages/theano/tensor/subtensor.pyc in make_node(self, x, ilist)
- 1685 ilist_ = theano.tensor.as_tensor_variable(ilist)
- 1686 if ilist_.type.dtype[:3] not in ('int', 'uin'):
- -> 1687 raise TypeError('index must be integers')
- 1688 if ilist_.type.ndim != 1:
- 1689 raise TypeError('index must be vector')
- TypeError: index must be integers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement