|
24 | 24 | "## Step 1 - Requirements\n", |
25 | 25 | "To run this notebook, you will need the following packages already installed:\n", |
26 | 26 | "* SparseML and SparseZoo;\n", |
27 | | - "* Tensorflow >=2.2, which includes Keras and TensorBoard;\n", |
| 27 | + "* Tensorflow >=2.1, which includes Keras and TensorBoard;\n", |
28 | 28 | "* keras2onnx.\n", |
29 | 29 | "\n", |
30 | 30 | "You can install any package that is not already present via `pip`." |
|
60 | 60 | "outputs": [], |
61 | 61 | "source": [ |
62 | 62 | "import os\n", |
63 | | - "from tensorflow import keras\n", |
| 63 | + "from sparseml.keras.utils import keras\n", |
64 | 64 | "from sparsezoo.models import Zoo\n", |
65 | 65 | "\n", |
66 | 66 | "# Root directory for the notebook artifacts\n", |
|
122 | 122 | "metadata": {}, |
123 | 123 | "outputs": [], |
124 | 124 | "source": [ |
| 125 | + "import numpy\n", |
| 126 | + "\n", |
125 | 127 | "# Number of classes\n", |
126 | 128 | "num_classes = 10\n", |
127 | 129 | "\n", |
|
132 | 134 | "x_train = x_train.astype('float32') / 255\n", |
133 | 135 | "x_test = x_test.astype('float32') / 255\n", |
134 | 136 | "\n", |
| 137 | + "# Add batch dimension (for older TF versions)\n", |
| 138 | + "x_train = numpy.expand_dims(x_train, -1)\n", |
| 139 | + "x_test = numpy.expand_dims(x_test, -1)\n", |
| 140 | + "\n", |
135 | 141 | "y_train = keras.utils.to_categorical(y_train, num_classes)\n", |
136 | 142 | "y_test = keras.utils.to_categorical(y_test, num_classes)\n", |
137 | 143 | "\n", |
|
418 | 424 | ], |
419 | 425 | "metadata": { |
420 | 426 | "kernelspec": { |
421 | | - "display_name": "Python (pypi_sparseml)", |
| 427 | + "display_name": "Python (keras_pruning)", |
422 | 428 | "language": "python", |
423 | | - "name": "pypi_sparseml" |
| 429 | + "name": "keras_pruning" |
424 | 430 | }, |
425 | 431 | "language_info": { |
426 | 432 | "codemirror_mode": { |
|
0 commit comments