C3W2- Exercise 10 in Notebook error

Error-

can only join an iterable

for this line :

predictor.predict([
{“features”: [review]}
])

Error stack:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-59-396170bb44b0> in <module>
      1 predictor.predict([
----> 2         {"features": [review]}
      3     ])

/opt/conda/lib/python3.7/site-packages/sagemaker/predictor.py in predict(self, data, initial_args, target_model, target_variant, inference_id)
    132 
    133         request_args = self._create_request_args(
--> 134             data, initial_args, target_model, target_variant, inference_id
    135         )
    136         response = self.sagemaker_session.sagemaker_runtime_client.invoke_endpoint(**request_args)

/opt/conda/lib/python3.7/site-packages/sagemaker/predictor.py in _create_request_args(self, data, initial_args, target_model, target_variant, inference_id)
    161 
    162         if "Accept" not in args:
--> 163             args["Accept"] = ", ".join(self.accept)
    164 
    165         if target_model:

TypeError: can only join an iterable

Hello @bagyaboy,

Do you mean C3W3? If that please check the SentimentPredictor class was created correctly.

Best regards,

Yes, My bad! It’s C3W3 and I am still getting the same error. I double checked that the Predictor class was created correctly as I forgot to add () after JSONSerializer. Thanks

2 Likes