Пример #1
0
# value definition
tree_matrix = np.asarray([
    [3, 1, 2],
    [4, 0, 3],
], dtype=np.int32)
phrase_number = tree_matrix.shape[0]

labels = np.asarray([2, 4, 2, 4, 4], dtype=np.int32)

x = T.imatrix('x')
y = T.ivector('y')

classifier = RNTN(
    x,
    y,
    vocab_size=5,
    embed_dim=3,
    label_n=5,
)

x_input = np.asarray([[1, -1, -1], [2, -1, -1], [3, 1, 2]], dtype=np.int32)
y_input = labels[1:4]

original_embedding = classifier.embedding.get_value()

classifier.update_embedding(x_input)

new_embedding = classifier.embedding.get_value()

assert_matrix_neq(original_embedding, new_embedding, "update_embeding")