Skip to content

Commit 6323421

Browse files
authored
Merge branch 'development' into example-simple
2 parents 2a3e251 + adf4bf4 commit 6323421

File tree

15 files changed

+216536
-216518
lines changed

15 files changed

+216536
-216518
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ jobs:
6969
pip list
7070
7171
- name: Install graphviz
72-
uses: ts-graphviz/setup-graphviz@v1
72+
uses: ts-graphviz/setup-graphviz@v2
73+
with:
74+
# Skip to run brew update command on macOS.
75+
macos-skip-brew-update: 'true' # default false
7376

7477
- name: Test interface ACT-R
7578
run: |
@@ -85,7 +88,6 @@ jobs:
8588
python -m pytest -v -m "neuroml" tests/
8689
8790
- name: Test interface TensorFlow
88-
if: ${{ matrix.python-version != '3.11'}}
8991
run: |
9092
python -m pip install .[tensorflow]
9193
dot -V

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,5 @@ examples/TensorFlow/Keras/keras_to_MDF
308308
/examples/TensorFlow/Keras/MNIST/keras_to_MDF.1
309309
/examples/TensorFlow/Keras/IRIS/keras_to_MDF.1
310310
/checkout_pngs.sh
311+
/examples/TensorFlow/Keras/IRIS/keras_model_on_iris.keras
312+
/examples/TensorFlow/Keras/MNIST/kr_N_model.keras

examples/TensorFlow/Keras/IRIS/keras_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282

8383

8484
# Saving model in h5 for Ploting Nuetron visual
85-
model.save("keras_model_on_iris.h5")
85+
model.save("keras_model_on_iris.keras")
8686

8787

8888
# predict example for index 0
-114 KB
Binary file not shown.

examples/TensorFlow/Keras/IRIS/keras_to_MDF.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
from modelspec.utils import _val_info
1212
from modeci_mdf.execution_engine import EvaluableGraph
1313

14+
exec(open("./keras_model.py").read())
15+
1416
# load the keras model
15-
model = tf.keras.models.load_model("keras_model_on_iris.h5")
17+
# model = tf.keras.models.load_model("keras_model_on_iris.keras")
1618

1719
# get the test data from iris dataset
1820
iris = load_iris()

examples/TensorFlow/Keras/MNIST/keras_model.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,47 +35,47 @@
3535

3636
# Build Model
3737
print("Building the Model")
38-
kr_model = tf.keras.models.Sequential()
39-
kr_model.add(tf.keras.layers.Flatten()) # input layer
38+
model = tf.keras.models.Sequential()
39+
model.add(tf.keras.layers.Flatten()) # input layer
4040

41-
kr_model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu)) # hidden layers
42-
kr_model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
43-
kr_model.add(tf.keras.layers.Dense(10, activation=tf.nn.softmax)) # output layer
41+
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu)) # hidden layers
42+
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
43+
model.add(tf.keras.layers.Dense(10, activation=tf.nn.softmax)) # output layer
4444

4545
# Compile Model
4646
print("Compiling the model")
47-
kr_model.compile(
47+
model.compile(
4848
optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"]
4949
)
5050

5151
# train the model
5252
print("Training the Model")
53-
kr_model.fit(x_train, y_train, epochs=3)
53+
model.fit(x_train, y_train, epochs=3)
5454

5555
# loadthe model above
5656
# new_model = tf.keras.models.load_model("num_reader.model")
5757

5858

5959
# check if the model actually generalize the data.
6060
print("Accuracy of our model is:")
61-
val_loss, val_acc = kr_model.evaluate(x_test, y_test)
61+
val_loss, val_acc = model.evaluate(x_test, y_test)
6262
print(val_loss, val_acc)
6363

6464
# Print summary
65-
kr_model.summary()
65+
model.summary()
6666

6767
# plot the model
6868
print("Plotting the model")
69-
plot_model(kr_model, to_file="model_plot.png", show_shapes=True, show_layer_names=True)
69+
plot_model(model, to_file="model_plot.png", show_shapes=True, show_layer_names=True)
7070

7171

7272
# Saving model in h5 for Ploting Nuetron visual
73-
kr_model.save("kr_N_model.h5")
73+
model.save("kr_N_model.keras")
7474

7575

7676
# predict example for index 0
7777
print("Predict value at index 0:")
78-
predictions = kr_model.predict([x_test])
78+
predictions = model.predict([x_test])
7979
print("The predicted number at index 0 is", np.argmax(predictions[0]))
8080

8181
# print the actual value at that index
-1.5 KB
Loading

examples/TensorFlow/Keras/MNIST/keras_to_MDF.json

Lines changed: 109183 additions & 109183 deletions
Large diffs are not rendered by default.
-69.1 KB
Loading

examples/TensorFlow/Keras/MNIST/keras_to_MDF.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
import sys
2+
13
import numpy as np
24
import tensorflow as tf
35

46
from modeci_mdf.interfaces.keras import keras_to_mdf
57
from modelspec.utils import _val_info
68
from modeci_mdf.execution_engine import EvaluableGraph
79

10+
exec(open("./keras_model.py").read())
11+
812
# load the keras model
9-
model = tf.keras.models.load_model("kr_N_model.h5")
13+
# model = tf.keras.models.load_model("kr_N_model.keras")
1014

1115
# get 20 of the test images from the mnnist test dataset
1216
_, (x_test, y_test) = tf.keras.datasets.mnist.load_data()

0 commit comments

Comments
 (0)