Skip to content

Commit

Permalink
feat(tf): improve the activation setting in tebd (deepmodeling#3971)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added logging to notify users when multiple neurons are used with a
"linear" activation function, equivalent to a single linear layer.

- **Configuration Updates**
- Introduced `"activation_function": "linear"` in various neural network
configuration files (`input.json`).
- Added `"activation_function": "tanh"` in the `input.json` file for
water model configuration.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
iProzd authored and Mathieu Taillefumier committed Sep 18, 2024
1 parent 366a341 commit d71ce3e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions deepmd/tf/utils/type_embed.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import logging
import re
from typing import (
List,
Expand Down Expand Up @@ -33,6 +34,8 @@
check_version_compatibility,
)

log = logging.getLogger(__name__)


def embed_atom_type(
ntypes: int,
Expand Down Expand Up @@ -131,6 +134,11 @@ def __init__(
self.filter_precision = get_precision(precision)
self.filter_activation_fn_name = str(activation_function)
self.filter_activation_fn = get_activation_func(activation_function)
if len(neuron) > 1 and self.filter_activation_fn_name == "linear":
log.warning(
"Multi-layer type embedding is being used with a 'linear' activation function. "
"This is equivalent to a single linear layer. Please ensure this is intentional."
)
self.trainable = trainable
self.uniform_seed = uniform_seed
self.type_embedding_net_variables = None
Expand Down
1 change: 1 addition & 0 deletions examples/dprc/generalized_force/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"neuron": [
8
],
"activation_function": "linear",
"precision": "float32"
},
"descriptor": {
Expand Down
1 change: 1 addition & 0 deletions examples/dprc/normal/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"neuron": [
8
],
"activation_function": "linear",
"precision": "float32"
},
"descriptor": {
Expand Down
1 change: 1 addition & 0 deletions examples/dprc/pairwise/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"neuron": [
8
],
"activation_function": "linear",
"precision": "float32"
},
"qm_model": {
Expand Down
1 change: 1 addition & 0 deletions examples/water/se_e2_a_tebd/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
4,
8
],
"activation_function": "tanh",
"resnet_dt": false,
"precision": "float64",
"seed": 1
Expand Down

0 comments on commit d71ce3e

Please sign in to comment.