Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-736: minor bug fixes #832

Merged
merged 2 commits into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions flair/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,22 @@ def __init__(

for row in csv_reader:

# test if format is OK
wrong_format = False
for text_column in self.text_columns:
if text_column >= len(row):
wrong_format = True

# test if at least one label given
has_label = False
for column in self.column_name_map:
if self.column_name_map[column].startswith("label") and row[column]:
has_label = True
break

if wrong_format or not has_label:
continue

if self.in_memory:

text = " || ".join(
Expand Down
2 changes: 1 addition & 1 deletion flair/models/language_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_representation(self, strings: List[str], chars_per_chunk: int = 512):
prediction, rnn_output, hidden = self.forward(batch, hidden)
rnn_output = rnn_output.detach()

output_parts.append(rnn_output)
output_parts.append(rnn_output.to("cpu"))

# concatenate all chunks to make final output
output = torch.cat(output_parts)
Expand Down