Config
clear_session(free_memory=True)
Resets all state generated by synalinks.
synalinks manages a global state, which it uses to implement the Functional model-building API and to uniquify autogenerated modules names.
If you are creating many models in a loop, this global state will consume
an increasing amount of memory over time, and you may want to clear it.
Calling clear_session()
releases the global state: this helps avoid
clutter from old programs and modules, especially when memory is limited.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
free_memory
|
bool
|
Whether to call Python garbage collection.
It's usually a good practice to call it to make sure
memory used by deleted objects is immediately freed.
However, it may take a few seconds to execute, so
when using |
True
|
Source code in synalinks/src/backend/common/global_state.py
api_key()
Synalinks API key.
Returns:
Type | Description |
---|---|
str
|
Synalinks API key. |
Source code in synalinks/src/backend/config.py
backend()
Publicly accessible method for determining the current backend.
Returns:
Type | Description |
---|---|
str
|
The name of the backend synalinks is currently using. like
|
Example:
Source code in synalinks/src/backend/config.py
epsilon()
Return the value of the fuzz factor used in numeric expressions.
Returns:
Type | Description |
---|---|
float
|
The epsilon value. |
Example:
Source code in synalinks/src/backend/config.py
floatx()
Return the default float type, as a string.
E.g. 'bfloat16'
, 'float16'
, 'float32'
, 'float64'
.
Returns:
Type | Description |
---|---|
str
|
The current default float type. |
Example:
Source code in synalinks/src/backend/config.py
set_api_key(key)
Set Synalinks API key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The API key value. |
required |
The API key is retrieved from the env variables at start.
Or you can setup it using the config
>>> synalinks.config.set_api_key('my-secret-api-key')
>>> synalinks.config.api_key()
'my-secret-api-key'
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
Synalinks API key. |
required |
Source code in synalinks/src/backend/config.py
set_epsilon(value)
Set the value of the fuzz factor used in numeric expressions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The new value of epsilon. |
required |
Examples:
Source code in synalinks/src/backend/config.py
set_floatx(value)
Set the default float dtype.
Note: It is not recommended to set this to "float16"
,
as this will likely cause numeric stability issues.
Instead, use float64
or float32
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The float type between |
required |
Examples:
Raises:
Type | Description |
---|---|
ValueError
|
In case of invalid value. |