Repository: Lightning-Universe/lightning-flash

Issue:
Cannot run on iris dataset
## 🐛 Bug

Cannot run on iris dataset

### To Reproduce

Run the code sample. CSV file is attached
[iris.csv](https://github.com/PyTorchLightning/lightning-flash/files/7967078/iris.csv)

Error message:
```
Num classes: 3
GPU available: False, used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
/Users/minh.chau/miniconda3/envs/chem/lib/python3.7/site-packages/pytorch_lightning/trainer/configuration_validator.py:122: UserWarning: You defined a `validation_step` but have no `val_dataloader`. Skipping val loop.
  rank_zero_warn("You defined a `validation_step` but have no `val_dataloader`. Skipping val loop.")

  | Name          | Type       | Params
---------------------------------------------
0 | model         | TabNet     | 5.9 K 
1 | train_metrics | ModuleDict | 0     
2 | val_metrics   | ModuleDict | 0     
3 | test_metrics  | ModuleDict | 0     
---------------------------------------------
5.9 K     Trainable params
0         Non-trainable params
5.9 K     Total params
0.024     Total estimated model params size (MB)
......many lines later.............
    return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
IndexError: Target 3 is out of bounds.
```

#### Code sample
```python
import pandas as pd
t=pd.read_csv("iris.csv")

datamodule = TabularClassificationData.from_csv(
    numerical_fields=["sepal.length","sepal.width","petal.length","petal.width"],
    target_fields="variety",
    train_file="iris.csv",
    val_split=0.3,
    batch_size=4
)
print(f"Num classes: {datamodule.num_classes}")
model = TabularClassifier.from_data(datamodule)
```

### Expected behavior

A model is created as expected

### Environment

 - PyTorch Version (e.g., 1.0): 1.9.0
 - OS (e.g., Linux): MacOS
 - How you installed PyTorch (`conda`, `pip`, source): conda
 - Python version: 3.7
 - CUDA/cuDNN version: No
 - GPU models and configuration: No


Discussion:

Resolving patch:
diff --git a/flash/tabular/input.py b/flash/tabular/input.py
--- a/flash/tabular/input.py
+++ b/flash/tabular/input.py
@@ -120,8 +120,8 @@ def preprocess(
         num_vars = _to_num_vars_numpy(df, parameters["numerical_fields"])
 
         num_samples = len(df)
-        cat_vars = np.stack(cat_vars, 1) if len(cat_vars) else np.zeros((num_samples, 0))
-        num_vars = np.stack(num_vars, 1) if len(num_vars) else np.zeros((num_samples, 0))
+        cat_vars = np.stack(cat_vars, 1) if len(cat_vars) else np.zeros((num_samples, 0), dtype=np.int64)
+        num_vars = np.stack(num_vars, 1) if len(num_vars) else np.zeros((num_samples, 0), dtype=np.float32)
 
         return cat_vars, num_vars
 


Test patch:
diff --git a/tests/tabular/classification/test_data_model_integration.py b/tests/tabular/classification/test_data_model_integration.py
--- a/tests/tabular/classification/test_data_model_integration.py
+++ b/tests/tabular/classification/test_data_model_integration.py
@@ -32,16 +32,25 @@
 
 @pytest.mark.skipif(not _TABULAR_TESTING, reason="tabular libraries aren't installed.")
 @pytest.mark.parametrize(
-    "backbone", ["tabnet", "tabtransformer", "fttransformer", "autoint", "node", "category_embedding"]
+    "backbone,fields",
+    [
+        ("tabnet", {"categorical_fields": ["category"], "numerical_fields": ["scalar_a", "scalar_b"]}),
+        ("tabtransformer", {"categorical_fields": ["category"], "numerical_fields": ["scalar_a", "scalar_b"]}),
+        ("fttransformer", {"categorical_fields": ["category"], "numerical_fields": ["scalar_a", "scalar_b"]}),
+        ("autoint", {"categorical_fields": ["category"], "numerical_fields": ["scalar_a", "scalar_b"]}),
+        ("node", {"categorical_fields": ["category"], "numerical_fields": ["scalar_a", "scalar_b"]}),
+        ("category_embedding", {"categorical_fields": ["category"], "numerical_fields": ["scalar_a", "scalar_b"]}),
+        # No categorical / numerical fields
+        ("tabnet", {"categorical_fields": ["category"]}),
+        ("tabnet", {"numerical_fields": ["scalar_a", "scalar_b"]}),
+    ],
 )
-def test_classification(backbone, tmpdir):
-
+def test_classification(backbone, fields, tmpdir):
     train_data_frame = TEST_DF_1.copy()
     val_data_frame = TEST_DF_1.copy()
     test_data_frame = TEST_DF_1.copy()
     data = TabularClassificationData.from_data_frame(
-        categorical_fields=["category"],
-        numerical_fields=["scalar_a", "scalar_b"],
+        **fields,
         target_fields="label",
         train_data_frame=train_data_frame,
         val_data_frame=val_data_frame,
diff --git a/tests/tabular/regression/test_data_model_integration.py b/tests/tabular/regression/test_data_model_integration.py
--- a/tests/tabular/regression/test_data_model_integration.py
+++ b/tests/tabular/regression/test_data_model_integration.py
@@ -32,16 +32,25 @@
 
 @pytest.mark.skipif(not _TABULAR_TESTING, reason="tabular libraries aren't installed.")
 @pytest.mark.parametrize(
-    "backbone", ["tabnet", "tabtransformer", "fttransformer", "autoint", "node", "category_embedding"]
+    "backbone,fields",
+    [
+        ("tabnet", {"categorical_fields": ["category"], "numerical_fields": ["scalar_a", "scalar_b"]}),
+        ("tabtransformer", {"categorical_fields": ["category"], "numerical_fields": ["scalar_a", "scalar_b"]}),
+        ("fttransformer", {"categorical_fields": ["category"], "numerical_fields": ["scalar_a", "scalar_b"]}),
+        ("autoint", {"categorical_fields": ["category"], "numerical_fields": ["scalar_a", "scalar_b"]}),
+        ("node", {"categorical_fields": ["category"], "numerical_fields": ["scalar_a", "scalar_b"]}),
+        ("category_embedding", {"categorical_fields": ["category"], "numerical_fields": ["scalar_a", "scalar_b"]}),
+        # No categorical / numerical fields
+        ("tabnet", {"categorical_fields": ["category"]}),
+        ("tabnet", {"numerical_fields": ["scalar_a", "scalar_b"]}),
+    ],
 )
-def test_regression(backbone, tmpdir):
-
+def test_regression(backbone, fields, tmpdir):
     train_data_frame = TEST_DF_1.copy()
     val_data_frame = TEST_DF_1.copy()
     test_data_frame = TEST_DF_1.copy()
     data = TabularRegressionData.from_data_frame(
-        categorical_fields=["category"],
-        numerical_fields=["scalar_a", "scalar_b"],
+        **fields,
         target_field="label",
         train_data_frame=train_data_frame,
         val_data_frame=val_data_frame,