Fixes TypeError: torch.Size() takes an iterable of 'int' (item 1 is '…#729
Open
Rajathbharadwaj wants to merge 1 commit intoNVIDIA-Merlin:mainfrom
Open
Fixes TypeError: torch.Size() takes an iterable of 'int' (item 1 is '…#729Rajathbharadwaj wants to merge 1 commit intoNVIDIA-Merlin:mainfrom
Rajathbharadwaj wants to merge 1 commit intoNVIDIA-Merlin:mainfrom
Conversation
…NoneType') Error When using Transformer4Rec, whilst creating the `tabular_inputs` from `tr.TabularSequenceFeatures.from_schema`, it throws an TypeError. After a bit of inspect, the following changes solved the issue.
|
Pull requests from external contributors require approval from a |
Contributor
|
@Rajathbharadwaj hello. thanks for the PR. Can you please first provide a reproducible example with a toy dataset of your error? |
Author
|
Hey @rnyak, definitely. Following the Advanced NVTabular Workflow import os
from merlin.datasets.entertainment import get_movielens
input_path = os.environ.get("INPUT_DATA_DIR", os.path.expanduser("~/merlin-framework/movielens/"))
get_movielens(variant="ml-1m", path=input_path); #noqa
from merlin.core.dispatch import get_lib
data = get_lib().read_parquet(f'{input_path}ml-1m/train.parquet').sample(frac=1)
train = data.iloc[:600_000]
valid = data.iloc[600_000:]
movies = get_lib().read_parquet(f'{input_path}ml-1m/movies_converted.parquet')
import nvtabular as nvt
from merlin.schema.tags import Tags
train_ds = nvt.Dataset(train, npartitions=2)
valid_ds = nvt.Dataset(valid)
train_ds, valid_ds
train_ds.shuffle_by_keys('userId')
valid_ds.shuffle_by_keys('userId')
genres = ['movieId'] >> nvt.ops.JoinExternal(movies, on='movieId', columns_ext=['movieId', 'genres'])
genres = genres >> nvt.ops.Categorify(freq_threshold=10)
def rating_to_binary(col):
return col > 3
binary_rating = ['rating'] >> nvt.ops.LambdaOp(rating_to_binary) >> nvt.ops.Rename(name='binary_rating')
userId = ['userId'] >> nvt.ops.Categorify() >> nvt.ops.AddTags(tags=[Tags.USER_ID, Tags.CATEGORICAL, Tags.USER])
movieId = ['movieId'] >> nvt.ops.Categorify() >> nvt.ops.AddTags(tags=[Tags.ITEM_ID, Tags.CATEGORICAL, Tags.ITEM])
binary_rating = binary_rating >> nvt.ops.AddTags(tags=[Tags.TARGET, Tags.BINARY_CLASSIFICATION])
workflow = nvt.Workflow(userId + movieId + genres + binary_rating)
train_transformed = workflow.fit_transform(train_ds)
valid_transformed = workflow.transform(valid_ds)
valid_transformed.compute().head()
train_transformed.schema
# Issue after running this code
from transformers4rec.torch import TabularSequenceFeatures
tabular_inputs = TabularSequenceFeatures.from_schema(
train_transformed.schema,
embedding_dim_default=128,
max_sequence_length=20,
d_output=100,
aggregation="concat",
masking="clm"
)It throws the following error After a bit of inspection, I found that the parameter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes TypeError: torch.Size() takes an iterable of 'int' (item 1 is 'NoneType') Error.
When using Transformer4Rec, whilst creating the
tabular_inputsfromtr.TabularSequenceFeatures.from_schema, it throws a TypeError. After a bit of inspection, the following changes solved the issue.Fixes #728
Goals ⚽
Implementation Details 🚧
Testing Details 🔍