Getting Input Dimension from Tensorflow
I have this code:
def transform(feature,target):
return feature,target
def frame_tensor(feature,target,batch_size=2024,shuffle=True):
df = tf.data.Dataset.from_tensor_slices((feature,target))
df = df.map(transform)
if shuffle:
df = df.shuffle(1024)
df = df.batch(batch_size).cache().prefetch(tf.data.experimental.AUTOTUNE)
gc.collect()
return df
Now, let's say I write:
dt = frame_tensor()
I want to build my embedding model and train my dataset. In the embedding model, I will need the input dimension. When training the dataset, I will need both the train and validation dataset.
My questions are:
(1) How should I get the input dimension for the embedding model? Is it by writing feature.shape[1]? tf.shape(dt) gives me an error message.
(2) What is my train dataset? Is it dt, or should I split the feature dataset to get the train dataset?
(3) Should I use model.fit() or model.fit_generator? Is there any other I can use?
(4) Is there anything I need to know apart from these (I am having a hard time wrapping my head around tpu)
Thanks.
Topic tpu cnn tensorflow deep-learning machine-learning
Category Data Science