Method
createCustomLossFunctionWithSourceCode POST
Copy POST

Registers a new custom loss function which can be used as an objective function during model training.

Arguments:

REQUIRED KEY TYPE DESCRIPTION
Yes name str A name for the loss, unique per organization. Must be 50 characters or fewer, and can contain only underscores, numbers, and uppercase alphabets.
Yes lossFunctionType str The category of problems that this loss would be applicable to, e.g. REGRESSION_DL_TF, CLASSIFICATION_DL_TF, etc.
Yes lossFunctionName str The name of the function whose full source code is passed in loss_function_source_code.
Yes lossFunctionSourceCode str Python source code string of the function.
Note: The arguments for the API methods follow camelCase but for Python SDK underscore_case is followed.

Response:

KEY TYPE DESCRIPTION
success Boolean true if the call succeeded, false if there was an error
result CustomLossFunction
KEY TYPE Description
notebookId str The unique identifier of the notebook used to create/edit the loss function.
name str Name assigned to the custom loss function.
createdAt str When the loss function was created.
lossFunctionName str The name of the function defined in the source code.
lossFunctionType str The category of problems that this loss would be applicable to, e.g. regression, multi-label classification, etc.
codeSource CodeSource Information about the source code of the loss function.
KEY TYPE Description
sourceType str The type of the source, one of TEXT, PYTHON, FILE_UPLOAD, or APPLICATION_CONNECTOR
sourceCode str If the type of the source is TEXT, the raw text of the function
applicationConnectorId str The Application Connector to fetch the code from
applicationConnectorInfo str Args passed to the application connector to fetch the code
packageRequirements list The pip package dependencies required to run the code
status str The status of the code and validations
error str If the status is failed, an error message describing what went wrong
publishingMsg dict Warnings in the source code
moduleDependencies list The list of internal modules dependencies required to run the code

Exceptions:

TYPE WHEN
InvalidEnumParameterError

An invalid value is passed for lossFunctionType.

InvalidParameterError

If either loss function name or type or the passed function is invalid/incompatible.

AlreadyExistsError

If the loss function with the same name already exists in the organization.

Language: