aws / aws/sagemaker-scikit-learn-container
Batch size bug with batch of one using aws_sagemaker.invoke_endpoint
- Dominant language
- Python
- Stars
- 188
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
I have a trained sklearn model deployed as a sagemaker endpoint that I want to invoke from the aurora postgres extenstion using `aws_sagemaker.invoke_endpoint`. Invoking works correctly as long as each batch has more than one sample but if the batch has one sample it returns a 500 with the error `ValueError: Expected 2D array, got 1D array instead`.
For example if there are 100 samples and I call the postgres extention with a `max_batch_size` of 10 like below it will score 10 batches without issue. If there were 101 samples it would score 10 batches successfully and then blow up on the 11th.
```sql
SELECT
s.id
, aws_sagemaker.invoke_endpoint(
'model-v3-2022-10-04-17-20-24'
, 10
, ARRAY [s.feat_1, s.feat_2, s.feat_3, s.feat_4])::DECIMAL(16, 2) predicted_output
FROM
_samples s;
```
I saw issue #15 had a similar problem invoking from the api but I'm not sure how I can pass in an extra line when invoking the endpoint.
Contributor guide
Assessment
This issue has not been assessed yet.