Instructions to use SaiGaneshanM/bert-classifier_FOR_FRAUD_AND_NORMAL_HACK with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TF-Keras
How to use SaiGaneshanM/bert-classifier_FOR_FRAUD_AND_NORMAL_HACK with TF-Keras:
# Note: 'keras<3.x' or 'tf_keras' must be installed (legacy), and from_pretrained_keras was removed in huggingface_hub 1.0. # See https://github.com/keras-team/tf-keras for more details. # !pip install "huggingface_hub<1.0" tf_keras from huggingface_hub import from_pretrained_keras model = from_pretrained_keras("SaiGaneshanM/bert-classifier_FOR_FRAUD_AND_NORMAL_HACK") - Notebooks
- Google Colab
- Kaggle
Download model.py from SaiGaneshanM/bert-classifier_FOR_FRAUD_AND_NORMAL_HACK: direct link, hf CLI and curl.
- Browser
- Download file 798 Bytes
-
https://huggingface.co/SaiGaneshanM/bert-classifier_FOR_FRAUD_AND_NORMAL_HACK/resolve/main/model.py
- Command line
-
hf download hf://SaiGaneshanM/bert-classifier_FOR_FRAUD_AND_NORMAL_HACK/model.py
-
curl -L -o model.py https://huggingface.co/SaiGaneshanM/bert-classifier_FOR_FRAUD_AND_NORMAL_HACK/resolve/main/model.py
798 Bytes
| from transformers import TFAutoModel | |
| from tensorflow import keras | |
| import tensorflow as tf | |
| class BERTForClassification(keras.Model): | |
| def __init__(self, bert_model, num_classes): | |
| super(BERTForClassification, self).__init__() | |
| self.bert = bert_model | |
| self.dropout = keras.layers.Dropout(0.3) | |
| self.classifier = keras.layers.Dense(num_classes, activation="softmax") | |
| def call(self, inputs, training=False): | |
| x = self.bert(inputs)[1] # Pooler output | |
| x = self.dropout(x, training=training) | |
| return self.classifier(x) | |
| # Load the model | |
| def load_model(): | |
| bert_model = TFAutoModel.from_pretrained("bert-base-uncased") | |
| model = BERTForClassification(bert_model, num_classes=2) | |
| model.load_weights("my_model_weights.h5") | |
| return model | |