File size: 659 Bytes
5fa1a76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Convert your datasets to the tf.data.Dataset format using the [~datasets.Dataset.to_tf_dataset] and the [DefaultDataCollator]:

from transformers import DefaultDataCollator
data_collator = DefaultDataCollator(return_tensors="tf")
tf_train_dataset = train_ds.to_tf_dataset(
     columns=["pixel_values", "label"],
     shuffle=True,
     batch_size=batch_size,
     collate_fn=data_collator,
 )
tf_eval_dataset = test_ds.to_tf_dataset(
     columns=["pixel_values", "label"],
     shuffle=True,
     batch_size=batch_size,
     collate_fn=data_collator,
 )

To compute the accuracy from the predictions and push your model to the 🤗 Hub, use Keras callbacks.