Chapter 13 : TypeError in cell #102
- 主要語言
- Jupyter Notebook
- 星號
- 30k
- 分支
- 13.1k
- PR 合併指標
- 30 天內沒有已合併 PR
描述
Hi,
Executing the cell 102 of the chapter 13 handbook raises TypeError Exception (see traceback below). The workaround i used is to change `value=[x]` to `value=[*x]` (and the same for `y`) as the values returned are arrays (`[15.]`) and not simple values.
We could also be using directly the `filepath_dataset` created earlier and parse it "the good way", reshaping `X_train`, or else.. ?
> ```
> ---------------------------------------------------------------------------
> TypeError Traceback (most recent call last)
> in
> 2 for x, y in zip(X_train[:, 1:2], y_train):
> 3 example = Example(features=Features(feature={
> ----> 4 "housing_median_age": Feature(float_list=FloatList(value=[x])),
> 5 "median_house_value": Feature(float_list=FloatList(value=[y]))
> 6 }))
>
> ~\anaconda3\lib\site-packages\google\protobuf\internal\python_message.py in init(self, **kwargs)
> 551 field_value = [_GetIntegerEnumValue(field.enum_type, val)
> 552 for val in field_value]
> --> 553 copy.extend(field_value)
> 554 self._fields[field] = copy
> 555 elif field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
>
> ~\anaconda3\lib\site-packages\google\protobuf\internal\containers.py in extend(self, elem_seq)
> 280 raise
> 281
> --> 282 new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
> 283 if new_values:
> 284 self._values.extend(new_values)
>
> ~\anaconda3\lib\site-packages\google\protobuf\internal\containers.py in (.0)
> 280 raise
> 281
> --> 282 new_values = [self._type_checker.CheckValue(elem) for elem in elem_seq_iter]
> 283 if new_values:
> 284 self._values.extend(new_values)
>
> ~\anaconda3\lib\site-packages\google\protobuf\internal\type_checkers.py in CheckValue(self, proposed_value)
> 283 message = ('%.1024r has type %s, but expected one of: numbers.Real' %
> 284 (proposed_value, type(proposed_value)))
> --> 285 raise TypeError(message)
> 286 converted_value = float(proposed_value)
> 287 # This inf rounding matches the C++ proto SafeDoubleToFloat logic.
>
> TypeError: array([15.]) has type , but expected one of: numbers.Real
>
> ```
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。