Skip to content

Instantly share code, notes, and snippets.

@franckjay
Created December 30, 2020 23:17
Show Gist options
  • Save franckjay/6c3eba31d389ab5f80105f947c47668c to your computer and use it in GitHub Desktop.
Save franckjay/6c3eba31d389ab5f80105f947c47668c to your computer and use it in GitHub Desktop.
Build a Sparse Tenor
indices = torch.LongTensor(
train[[user_id_col, item_id_col]].values
)
values = torch.ones(indices.shape[0])
torch.sparse.FloatTensor(indices.t(), values)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment