Create train.py
Browse files
train.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 2 |
+
|
| 3 |
+
def main():
|
| 4 |
+
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
|
| 5 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
| 6 |
+
"bert-base-uncased", num_labels=3
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
text = "pick up the object"
|
| 10 |
+
inputs = tokenizer(text, return_tensors="pt")
|
| 11 |
+
|
| 12 |
+
outputs = model(**inputs)
|
| 13 |
+
print(outputs.logits)
|
| 14 |
+
|
| 15 |
+
if __name__ == "__main__":
|
| 16 |
+
main()
|