Associates a string prefix with an integer counter in a TensorFlow graph. Arguments: prefix: String prefix to index. Returns: Unique integer ID. Example: ``` >>> get_uid('dense') 1 >>> get_uid('dense') 2 ```
(prefix='')
| 183 | |
| 184 | @keras_export('keras.backend.get_uid') |
| 185 | def get_uid(prefix=''): |
| 186 | """Associates a string prefix with an integer counter in a TensorFlow graph. |
| 187 | |
| 188 | Arguments: |
| 189 | prefix: String prefix to index. |
| 190 | |
| 191 | Returns: |
| 192 | Unique integer ID. |
| 193 | |
| 194 | Example: |
| 195 | |
| 196 | ``` |
| 197 | >>> get_uid('dense') |
| 198 | 1 |
| 199 | >>> get_uid('dense') |
| 200 | 2 |
| 201 | ``` |
| 202 | """ |
| 203 | graph = get_graph() |
| 204 | if graph not in PER_GRAPH_OBJECT_NAME_UIDS: |
| 205 | PER_GRAPH_OBJECT_NAME_UIDS[graph] = collections.defaultdict(int) |
| 206 | layer_name_uids = PER_GRAPH_OBJECT_NAME_UIDS[graph] |
| 207 | layer_name_uids[prefix] += 1 |
| 208 | return layer_name_uids[prefix] |
| 209 | |
| 210 | |
| 211 | @keras_export('keras.backend.reset_uids') |
nothing calls this directly
no test coverage detected