You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to decorate classes in dataclass fashion with tensorclass. From documentation, it says @tensorclass decorator helps you build custom classes that inherit the behaviour from TensorDict; it seems reasonable to assume classes decorated with tensorclass should also support indexing with key elements. However, this is not the case as shown below
btw, after operation such as th.cat, instances of classes decorated with @tensorclass seems to become vanilla thd.TensorDict, which makes it only supports indexing operation but not 'dot' operation.
btw, after operation such as th.cat, instances of classes decorated with @Tensorclass seems to become vanilla thd.TensorDict, which makes it only supports indexing operation but not 'dot' operation.
I'm happy to say that it has been fixed in the new release!
To the main issue, it's a matter of design: in tensorclass we differentiate more clearly the __getitem__ along the shape dimension and the __getattr__ on the key dimension (whereas with TensorDict these two are blended together).
Describe the bug
I tried to decorate classes in dataclass fashion with tensorclass. From documentation, it says
@tensorclass
decorator helps you build custom classes that inherit the behaviour fromTensorDict
; it seems reasonable to assume classes decorated withtensorclass
should also support indexing with key elements. However, this is not the case as shown belowTo Reproduce
Expected behavior
tc.[a"]
should have same behavior astc.a
Screenshots
n/a
System info
tensordict.__version__=="0.6.2"
Additional context
n/a
Reason and Possible fixes
n/a
Checklist
The text was updated successfully, but these errors were encountered: