regisss HF staff commited on
Commit
9db566f
1 Parent(s): 7a0b241

Change usage section

Browse files
Files changed (1) hide show
  1. README.md +26 -17
README.md CHANGED
@@ -23,21 +23,30 @@ This enables to specify:
23
  ## Usage
24
 
25
  The model is instantiated the same way as in the Transformers library.
26
- The only difference is that there are a few new training arguments specific to HPUs:
27
-
28
- ```
29
- from optimum.habana import GaudiTrainer, GaudiTrainingArguments
30
- from transformers import SwinForImageClassification
31
- model = SwinForImageClassification.from_pretrained('microsoft/swin-base-patch4-window7-224-in22k')
32
- args = GaudiTrainingArguments(
33
- output_dir="/tmp/output_dir",
34
- use_habana=True,
35
- use_lazy_mode=True,
36
- gaudi_config_name="Habana/swin",
37
- )
38
- trainer = GaudiTrainer(
39
- model=model,
40
- args=args,
41
- )
42
- trainer.train()
 
 
 
 
 
 
 
43
  ```
 
 
 
23
  ## Usage
24
 
25
  The model is instantiated the same way as in the Transformers library.
26
+ The only difference is that there are a few new training arguments specific to HPUs.
27
+
28
+ [Here](https://github.com/huggingface/optimum-habana/blob/main/examples/image-classification/run_image_classification.py) is an image classification example script to fine-tune a model. You can run it with Swin with the following command:
29
+ ```bash
30
+ python run_image_classification.py \
31
+ --model_name_or_path microsoft/swin-base-patch4-window7-224 \
32
+ --dataset_name cifar10 \
33
+ --output_dir /tmp/outputs/ \
34
+ --remove_unused_columns False \
35
+ --do_train \
36
+ --do_eval \
37
+ --learning_rate 2e-5 \
38
+ --num_train_epochs 5 \
39
+ --per_device_train_batch_size 32 \
40
+ --per_device_eval_batch_size 32 \
41
+ --evaluation_strategy epoch \
42
+ --save_strategy epoch \
43
+ --load_best_model_at_end True \
44
+ --save_total_limit 3 \
45
+ --seed 1337 \
46
+ --use_habana \
47
+ --use_lazy_mode \
48
+ --gaudi_config_name Habana/swin \
49
+ --throughput_warmup_steps 2
50
  ```
51
+
52
+ Check the [documentation](https://huggingface.co/docs/optimum/habana/index) out for more advanced usage and examples.