-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SoftmaxSampling should produce the same output dtype as the input (#154)
* softmax sampling should keep input col dtype * rename old variable
- Loading branch information
1 parent
f1e2bf5
commit 572dbf1
Showing
3 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pandas as pd | ||
|
||
from merlin.schema import ColumnSchema, Schema | ||
from merlin.systems.dag.ops.softmax_sampling import SoftmaxSampling | ||
from nvtabular import ColumnSelector | ||
|
||
|
||
def test_softmax_output_dtype_keeps_input_dtype(): | ||
# We expect the method to: | ||
# * change the output name to `ordered_ids` | ||
# * change is_list to True | ||
# * change is_ragged to True | ||
# * Not change the output dtype | ||
|
||
s = SoftmaxSampling("rel_col", _input_col="input_col") | ||
|
||
input_col_schema = Schema( | ||
[ | ||
ColumnSchema(name="rel_col"), | ||
ColumnSchema(name="input_col", dtype=pd.StringDtype, is_list=False, is_ragged=False), | ||
] | ||
) | ||
|
||
expected = Schema( | ||
[ColumnSchema(name="ordered_ids", dtype=pd.StringDtype, is_list=True, is_ragged=True)] | ||
) | ||
actual = s.compute_output_schema(input_col_schema, ColumnSelector(["ordered_ids"])) | ||
|
||
assert actual == expected |