Skip to content

Commit bee4252

Browse files
authored
Move model to device and don't use deprecated use_inf_as_na (#104)
This PR includes fixes for: - running `examples/tutorial.py` on a cuda device - suppressing these countless warnings introduced by pandas-dev/pandas#51684: ``` /home/akihiro/work/github.com/pyg-team/pytorch-frame/torch_frame/data/stats.py:60: FutureWarning: use_inf_as_na option is deprecated and will be removed in a future version. Convert inf values to NaN before operating instead. ```
1 parent 4b18ac8 commit bee4252

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

examples/tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def forward(self, tf: TensorFrame) -> Tensor:
217217
num_layers=args.num_layers,
218218
col_stats=dataset.col_stats,
219219
col_names_dict=train_tensor_frame.col_names_dict,
220-
)
220+
).to(device)
221221

222222
optimizer = torch.optim.Adam(model.parameters(), lr=args.lr)
223223

torch_frame/data/stats.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@ def compute_col_stats(
5757
) -> Dict[StatType, Any]:
5858

5959
if stype == torch_frame.numerical:
60-
with pd.option_context('mode.use_inf_as_na', True):
61-
ser = ser.dropna()
62-
else:
63-
ser = ser.dropna()
60+
ser = ser.mask(ser.isin([np.inf, -np.inf]), np.nan)
61+
62+
ser = ser.dropna()
6463

6564
return {
6665
stat_type: stat_type.compute(ser)

0 commit comments

Comments
 (0)