---
title: "Keras settings"
method: POST
path: "/api/{projectId}/training/keras/{learnId}"
tags: ["Learn"]
---

# Keras settings

`POST /api/{projectId}/training/keras/{learnId}`

## Request

- Base URL: `https://studio.edgeimpulse.com/v1`
- URL: `https://studio.edgeimpulse.com/v1/api/{projectId}/training/keras/{learnId}`
- Auth: one of:
  - API key in header `x-api-key`
  - API key in cookie `jwt`
  - API key in header `x-jwt-token`
  - OAuth 2
    - Authorization code: `/v1/oauth/authorize`
    - Client credentials
    - Implicit: `/v1/oauth/authorize`
    - Password
    - Token URL: `/v1/oauth/token`
- TypeScript: <https://skmtc.dev/edgeimpulse/apis/edge-impulse-api/docs/api/:projectId/training/keras/:learnId/post.ts> (a function with typed inputs; its response is checked against the schema)

Configure the Keras block, such as its minimum confidence score. Use the impulse blocks to find the learnId.

## Path parameters

- `projectId` integer, required
- `learnId` integer, required

## Request body

- SetKerasParameterRequest: Only fields defined in this object are set
  - `mode` 'expert' | 'visual': Whether to use visual or expert mode.
  - `minimumConfidenceRating` number: DEPRECATED, use "setImpulseThresholds" instead. Minimum confidence score, if the neural network scores a sample below this threshold it will be flagged as uncertain.
  - `selectedModelType` 'int8' | 'float32' | 'akida' | 'requiresRetrain'
  - `script` string: Raw Keras script (only used in expert mode)
  - `visualLayers` KerasVisualLayer[]: The visual layers for the neural network (only in visual mode).
    - `type` 'dense' | 'conv1d' | 'conv2d' | 'reshape' | 'flatten' | 'dropout' | 'batchNormalization' | 'transfer_mobilenetv2_a35' | 'transfer_mobilenetv2_a1' | 'transfer_mobilenetv2_a05' | 'transfer_mobilenetv2_160_a1' | 'transfer_mobilenetv2_160_a75' | 'transfer_mobilenetv2_160_a5' | 'transfer_mobilenetv2_160_a35' | 'transfer_mobilenetv1_a25_d100' | 'transfer_mobilenetv1_a2_d100' | 'transfer_mobilenetv1_a1_d100' | 'transfer_kws_mobilenetv1_a1_d100' | 'transfer_kws_mobilenetv2_a35_d100' | 'transfer_kws_syntiant_ndp10x' | 'transfer_kws_conv2d_tiny' | 'object_ssd_mobilenet_v2_fpnlite_320x320' | 'fomo_mobilenet_v2_a01' | 'fomo_mobilenet_v2_a35' | 'transfer_organization' | 'transfer_akidanet_imagenet_160_a100' | 'transfer_akidanet_imagenet_160_a50' | 'transfer_akidanet_imagenet_160_a25' | 'transfer_akidanet_imagenet_224_a100' | 'transfer_akidanet_imagenet_224_a50' | 'transfer_akidanet_imagenet_224_a25' | 'fomo_akidanet_a50' | 'fomo_ad_gmm' | 'fomo_ad_patchcore', required
    - `neurons` integer: Number of neurons or filters in this layer (only for dense, conv1d, conv2d) or in the final conv2d layer (only for transfer layers)
    - `kernelSize` integer: Kernel size for the convolutional layers (only for conv1d, conv2d)
    - `dropoutRate` number: Fraction of input units to drop (only for dropout) or in the final layer dropout (only for transfer layers)
    - `columns` integer: Number of columns for the reshape operation (only for reshape)
    - `stack` integer: Number of convolutional layers before the pooling layer (only for conv1d, conv2d)
    - `enabled` boolean
    - `organizationModelId` integer: Custom transfer learning model ID (when type is set to transfer_organization)
  - `trainingCycles` integer: Number of training cycles (only in visual mode).
  - `learningRate` number: Learning rate (between 0 and 1) (only in visual mode).
  - `batchSize` number: Batch size used during training (only in visual mode).
  - `trainTestSplit` number: Train/test split (between 0 and 1)
  - `autoClassWeights` boolean: Whether to automatically balance class weights, use this for skewed datasets.
  - `useLearnedOptimizer` boolean: Use learned optimizer and ignore learning rate.
  - `augmentationPolicyImage` 'none' | 'all': The data augmentation policy to use with image input
  - `augmentationPolicySpectrogram` AugmentationPolicySpectrogram
    - `enabled` boolean, required: True if spectrogram augmentation is enabled. Other properties will be ignored if this is false.
    - `warping` boolean: True if warping along the time axis is enabled.
    - `freqMasking` 'none' | 'low' | 'high': The amount of frequency masking to apply.
    - `timeMasking` 'none' | 'low' | 'high': The amount of time masking to apply.
    - `gaussianNoise` 'none' | 'low' | 'high': The amount of Gaussian noise to add.
  - `profileInt8` boolean: Whether to profile the i8 model (might take a very long time)
  - `skipEmbeddingsAndMemory` boolean: If set, skips creating embeddings and measuring memory (used in tests)
  - `akidaEdgeLearningConfig` AkidaEdgeLearningConfig
    - `enabled` boolean, required: True if Akida Edge Learning model creation is enabled. Other properties will be ignored if this is false.
    - `additionalClasses` number: Number of additional classes that will be added to the Edge Learning model.
    - `neuronsPerClass` number: Number of neurons in each class on the last layer in the Edge Learning model.
  - `customValidationMetadataKey` string: If the 'custom validation split' experiment is enabled, this metadata key is used to prevent group data leakage between train and validation datasets.
  - `showAdvancedTrainingSettings` boolean: Whether the 'Advanced training settings' UI element should be expanded.
  - `showAugmentationTrainingSettings` boolean: Whether the 'Augmentation training settings' UI element should be expanded.
  - `customParameters` object: Training parameters, this list depends on the list of parameters that the model exposes.
  - `anomalyCapacity` 'low' | 'medium' | 'high': Capacity level for visual anomaly detection. Determines which set of default configurations to use. The higher capacity, the higher number of (Gaussian) components, and the more adapted the model becomes to the original distribution
  - `lastShownModelVariant` 'int8' | 'float32' | 'akida'
  - `blockParameters` union: Training parameters specific to the type of the learn block. Parameters may be adjusted depending on the model defined in the visual layers. Used for our built-in blocks.
    - BlockParamsVisualAnomalyPatchcore
      - `backbone` string: The backbone to use for feature extraction
      - `numLayers` integer: The number of layers in the feature extractor (1-3)
      - `poolSize` integer: The pool size for the feature extractor
      - `samplingRatio` number: The sampling ratio for the coreset, used for anomaly scoring
      - `numNearestNeighbors` integer: The number of nearest neighbors to consider, used for anomaly scoring
    - BlockParamsVisualAnomalyGmm
      - `backbone` string: The backbone to use for feature extraction
  - `trainingProcessor` 'cpu' | 'gpu': Training processor selection for an impulse.
  - `kFoldsValidationConfig` KFoldsValidationConfig: K-fold cross-validation configuration. Leave undefined to disable k-fold cross validation (default behavior). If configured, a pre-training k-fold cross-validation step will occur. Training data will be partitioned into k subsets (stratified by existing project config), and k models will be trained (one for each subset). Once finished, a final model will be retrained with no validation set. The number of training epochs will be calculated by taking the median average of the best epochs from the prior k runs.
    - `numFolds` number, required: Number of "k" folds
    - `includeFinalTrainingRun` boolean: Optional flag for activating the final training run, performed on the entire training dataset after the k fold runs complete (defaults to off).
    - `extraEpochs` number: Number of additional training epochs. The final model will be trained on the median epoch count from the previous k runs + extraEpochs.
  - `assertGpuUsagePercentage` number, nullable: EXPERIMENTAL. When set, max GPU utilization will be checked against this threshold after training. Used for testing purposes.

## Response `200`

OK

- GenericApiResponse
  - `success` boolean, required: Whether the operation succeeded
  - `error` string: Optional error description (set if 'success' was false)

---

[API](https://skmtc.dev/edgeimpulse/apis/edge-impulse-api.md) - [All operations](https://skmtc.dev/edgeimpulse/apis/edge-impulse-api/llms.txt) - [OpenAPI document](https://skmtc.dev/edgeimpulse/apis/edge-impulse-api/revisions/e2a976d38427?raw)
