Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I generate the feature columns to feed to the TabNetClassifier from numpy matrix? #18

Open
yxu02 opened this issue Feb 27, 2021 · 1 comment

Comments

@yxu02
Copy link

yxu02 commented Feb 27, 2021

All the examples used tensorflow out-of-box dataset, which are in tensorflow dataset format.

I'd like to give tabnet a try but I have to use numpy matrix. Even though I converted numpy matrix to tensor via from_tensor_slices, it still didn't work coz I don't have the mapping between my tensor and the feature_columns. Please advise.

@csetraynor
Copy link

csetraynor commented Aug 5, 2021

Hello,

I faced similar issue and I tried the following and it runed, but I'm unsure is correct. I've followed the example and create a dictionary. But from a numpy matrix it needs to be transpose to match tensor dimnesions. It would be great if the devs can have a look and double-check this is correct. Thanks,

col_names = ['a', 'b', 'c'] ## <--- feature colnames here
features_train = tf.cast(X_train, tf.float32)
labels_train = tf.cast(y_train, tf.float32)
x_train = dict(zip(col_names, tf.transpose( features_train )))
dataset_train = tf.data.Dataset.from_tensor_slices((x_train, labels_train)).batch(BATCH_SIZE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants