Skip to content

Commit

Permalink
That was what was needed for softmax in keras
Browse files Browse the repository at this point in the history
  • Loading branch information
pobonomo committed Dec 4, 2024
1 parent 172c02a commit 065c888
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions notebooks/adversarial/adversarial_keras.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
" tf.keras.layers.InputLayer((28 * 28,)),\n",
" tf.keras.layers.Dense(50, activation=\"relu\"),\n",
" tf.keras.layers.Dense(50, activation=\"relu\"),\n",
" tf.keras.layers.Dense(10),\n",
" tf.keras.layers.Dense(10, activation=\"softmax\"),\n",
" ]\n",
")"
]
Expand Down Expand Up @@ -257,7 +257,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.11.10"
},
"license": {
"full_text": "# Copyright © 2023 Gurobi Optimization, LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# =============================================================================="
Expand Down
2 changes: 1 addition & 1 deletion src/gurobi_ml/keras/keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, gp_model, predictor, input_vars, output_vars=None, **kwargs):
if isinstance(step, keras.layers.Dense):
config = step.get_config()
activation = config["activation"]
if activation not in ("relu", "linear"):
if activation not in ("relu", "softmax", "linear"):
raise NoModel(predictor, f"Unsupported activation {activation}")
elif isinstance(step, keras.layers.ReLU):
if step.negative_slope != 0.0:
Expand Down

0 comments on commit 065c888

Please sign in to comment.