Skip to content

Commit

Permalink
update slides and scripts tensorflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mariojmdavid committed Jan 18, 2024
1 parent 477fc5d commit f82e102
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
10 changes: 9 additions & 1 deletion docs/udocker/udocker-04.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,22 @@ ssh into your favorite HPC system's head node (user interface host), install udo
mkdir udocker-tutorial
cd udocker-tutorial
export UDOCKER_DIR=$HOME/udocker-tutorial/.udocker
udocker version
```

I assume that the compute/worker nodes mount your $HOME directory or, you can do this in some directory mounted in the compute/worker nodes.
Check that the `UDOCKER_DIR=$HOME/udocker-tutorial/.udocker` was created

```bash
echo $UDOCKER_DIR
ls -al $UDOCKER_DIR
```

---

## In the beginning - II

I assume that the compute/worker nodes mount your $HOME directory or, you can do this in some directory mounted in the compute/worker nodes.

Git pull the repository to get needed input files, in particular for the tensorflow/keras application:

```bash
Expand Down
2 changes: 1 addition & 1 deletion udocker-files/run-keras.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ source udockervenv/bin/activate
export UDOCKER_DIR=$TUT_DIR/.udocker

echo "###############################"
udocker run -v $TUT_DIR/tensorflow:/home/user -w /home/user tf_gpu python3 keras_example_small.py
udocker run -v $TUT_DIR/tensorflow:/home/user -w /home/user tf_gpu python3 keras_2_small.py
20 changes: 20 additions & 0 deletions udocker-files/tensorflow/keras_2_small.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import tensorflow as tf

mnist = tf.keras.datasets.mnist

(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation='softmax')
])

model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])

model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test, y_test, verbose=2)

0 comments on commit f82e102

Please sign in to comment.