def load_from_theano_model(cls, model, word2id): return RNTN(embedding=model.embedding.get_value(), rntn_layer=RNTNLayer(model.rntn_layer.V.get_value(), model.rntn_layer.W.get_value()), logreg_layer=LogisticRegression( model.logreg_layer.W.get_value(), model.logreg_layer.b.get_value()), word2id=word2id)
def __init__(self, params): self.e_layer = WordEmbeddingLayer(embeddings=params.embeddings) self.c_layers = [] for i in range(params.conv_layer_n): self.c_layers.append( ConvFoldingPoolLayer(params.ks[i], params.fold[i], W=params.W[i], b=params.b[i])) self.l_layer = LogisticRegression(params.logreg_W, params.logreg_b)
from logreg import LogisticRegression as TheanoLogisticRegression from test_util import assert_matrix_eq ######################### # NUMPY PART ######################### # 5 labels and 10 inputs W = np.random.rand(10, 5) b = np.random.rand(5) x = np.random.rand(3, 10) y = np.asarray(np.random.randint(5, size=3), dtype=np.int32) np_l = LogisticRegression(W, b) ######################### # THEANO PART ######################### x_symbol = theano.tensor.dmatrix('x') y_symbol = theano.tensor.ivector('y') th_l = TheanoLogisticRegression(rng=np.random.RandomState(1234), input=x_symbol, n_in=10, n_out=5, W=theano.shared(value=W, name="W"), b=theano.shared(value=b, name="b"))