Spaces:
Runtime error
Runtime error
Download modelutil.py from crobbi/MNIST-Digit-Classifier: direct link, hf CLI and curl.
- Browser
- Download file 947 Bytes
-
https://huggingface.co/spaces/crobbi/MNIST-Digit-Classifier/resolve/refs%2Fpr%2F1/modelutil.py
- Command line
-
hf download hf://spaces/crobbi/MNIST-Digit-Classifier@refs/pr/1/modelutil.py
-
curl -L -o modelutil.py https://huggingface.co/spaces/crobbi/MNIST-Digit-Classifier/resolve/refs%2Fpr%2F1/modelutil.py
947 Bytes
| import tensorflow as tf | |
| def create_model(): | |
| LAYERS = [tf.keras.layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1), name="convlayer1"), | |
| tf.keras.layers.Conv2D(64, (3, 3), activation='relu', name="convlayer2"), | |
| tf.keras.layers.Flatten(input_shape=[28,28], name="inputlayer"), | |
| tf.keras.layers.Dense(300, activation='relu', name="hiddenlayer1"), | |
| tf.keras.layers.Dense(100, activation='relu', name="hiddenlayer2"), | |
| tf.keras.layers.Dense(10, activation='softmax', name="outputlayer")] | |
| model = tf.keras.models.Sequential(LAYERS) | |
| model.load_weights('./checkpoint') | |
| # LOSS_FUNCTION = tf.keras.losses.SparseCategoricalCrossentropy() # HERE | |
| # OPTIMIZER = tf.keras.optimizers.legacy.Adam() | |
| # METRICS = ["accuracy"] | |
| # model.compile(loss=LOSS_FUNCTION, | |
| # optimizer=OPTIMIZER, | |
| # metrics=METRICS) | |
| return model | |