I was using https://docs.edgeimpulse.com/reference/trainkerasjob to train my Classifier. However, when I try to train the Keras model, I get the error, “Number of new classes and neurons should be a positive number!”
I matched all the API settings (for the training script) to the payloads from the Chrome browser of a working project. However, it’s still not working. I’ll paste the code I used to train the model below. I’ve also tried adding a dense layer at the end to serve as an output layer, but that didn’t work. I’ve checked and the impulse blocks are also matched.
My Project ID is 337137.
As a side question, if I run the create impulse API script twice, will the blocks be overwritten? Because I am not allowed to delete the learning blocks. So if they do not overwrite, then I have to create a new project every time I test the API (because the API creates another learning block with the same ID and all that).
import requests
url = "https://studio.edgeimpulse.com/v1/api/337137/jobs/train/keras/5"
payload = {
"augmentationPolicySpectrogram": {
"enabled": False,
"gaussianNoise": "high",
"freqMasking": "none",
"timeMasking": "low",
"warping": False
},
"akidaEdgeLearningConfig": { "enabled": False },
"mode": "visual",
"visualLayers": [{
"type": "reshape",
"columns": 13
}, {
"type": "conv1d",
"neurons": 8,
"kernelSize": 3,
"stack": 1
}, {
"type": "dropout",
"dropoutRate": 0.25
}, {
"type": "conv1d",
"neurons": 16,
"kernelSize": 3,
"stack": 1
}, {
"type": "dropout",
"dropoutRate": 0.25
}, { "type": "flatten" }],
"trainingCycles": 5,
"learningRate": 0.005,
"profileInt8": False,
"augmentationPolicyImage": "none",
"autoClassWeights": False,
"trainTestSplit": 0.2
}
headers = {
"accept": "application/json",
"content-type": "application/json",
"x-api-key": "ei_128ba30ff7c8b8879d5e2b7e1ba07b0c6b02a8d60c227cf25c6a65645550643a"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
Please let me know if you have any other questions!