Skip to content

Question: mean aggregation in Encoder #9

@yichengchen24

Description

@yichengchen24

Thanks for the excellent work!

However, I have a question about the mean aggregation operation in Encoder: why divide by the length of the chunked sentence len(chunked_instances[index]) instead of the number that the sentence is chunked to?

The corresponding code is

# aggregate the embeddings
embeddings = np.zeros((len(sentences), self.hidden_size))
for i, index in enumerate(chunked_indices):
    if aggregate_method == 'mean':
        embeddings[index] += chunked_embeddings[i] / len(chunked_instances[index])
    elif aggregate_method == 'sum':
        embeddings[index] += chunked_embeddings[i]
    elif aggregate_method == 'max':
        embeddings[index] = np.maximum(embeddings[index], chunked_embeddings[i])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions