# Export VIT model to onnx

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexport-vit-model-to-onnx%2F19492%3E%5C
**Category:** 🤗Hub\
**Created:** [June 23, 2022, 8:08am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexport-vit-model-to-onnx%2F19492 "2022-06-23T08:08:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phelan164](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@phelan164](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fphelan164)%5C
**Post date:** [June 23, 2022, 8:08am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexport-vit-model-to-onnx%2F19492%2F1 "2022-06-23T08:08:48Z")

</div>

I try to export VIT model to onnx with follow command  
`python -m transformers.onnx --model=google/vit-base-patch16-224 onnx/`  
But the output model have config

```auto
    "output": [{
        "name": "1617",
        "data_type": "TYPE_FP32",
        "dims": [2, 384],
        "label_filename": "",
        "is_shape_tensor": false
    }, {
        "name": "last_hidden_state",
        "data_type": "TYPE_FP32",
        "dims": [-1, -1, 384],
        "label_filename": "",
        "is_shape_tensor": false
    }],

```

why the output shape is 384? the input model have output shape `(cls_classifier): Linear(in_features=384, out_features=1000, bias=True)`?

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [June 23, 2022, 8:24am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexport-vit-model-to-onnx%2F19492%2F2 "2022-06-23T08:24:33Z")

</div>

cc @lewtun

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flewtun)%5C
**Post date:** [June 23, 2022, 7:07pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fexport-vit-model-to-onnx%2F19492%2F3 "2022-06-23T19:07:15Z")

</div>

Hi @phelan164 I’m not sure I can reproduce what you’re seeing - could you share how you’re obtaining the ONNX config?

Here’s what I get after exporting the model with your command:

```python
import onnx

model = onnx.load("onnx/model.onnx")
model.graph.output
# [name: "last_hidden_state"
# type {
# tensor_type {
# elem_type: 1
# shape {
# dim {
# dim_param: "batch"
# }
# dim {
# dim_param: "sequence"
# }
# dim {
# dim_value: 768
# }
# }
# }
# }
# , name: "1601"
# type {
# tensor_type {
# elem_type: 1
# shape {
# dim {
# dim_value: 2
# }
# dim {
# dim_value: 768
# }
# }
# }
# }
# ]

```

As you can see, the output dimension of the last hidden state is 768, which is what one expects for this model (no head, equivalent to `VitModel`)
