Problem Description:

When python is using a custom sigmoid function, input X as a matrix, there will be a situation where’Float’ object has no attribute’exp’.

def sigmoid(inp):

return 1.0/(1 + np.exp(-inp))

It is found that it is no problem to manually generate the matrix data into this function, and then find it by looking up the numpy.mat function

numpy.mat(data, dtype=None)[source]

Interpret the input as a matrix.

Unlike matrix, asmatrix does not make a copy if the input is already a matrix or an ndarray. Equivalent to matrix(data, copy=False).

Parameters:

**data**: array_like

Input data.

**dtype**: data-type

Data-type of the output matrix.

Returns:

**mat**: matrix

data interpreted as a matrix.

The default dtype is None, so when the matrix is generated, the dtype is added to the type to solve the problem. For example, Xmat = numpy.mat(_x, dtype=float), and then Xmat was brought into the sigmoid function, no problem was found.

```
AttributeError: 'Float' object has no attribute 'exp'
```

### Read More:

- Error in Tensorflow using variables: List of Tensors when single Tensor expected
- How to Solve TypeError: type numpy.ndarray doesn‘t define __round__ method
- How to Solve TypeError: type numpy.ndarray doesn’t define __round__ method
- Error: (list) object cannot be coerced to type ‘double’
- Libtorch Error: Expected object of type Variable but found type CUDALongType for argument #2 ‘index’
- C++ BUG: [Error] invalid array assignment
- [Solved] ValueError: the indices for endog and exog are not aligned
- R language learning problem solving error in output $nodeid: $operator is invalid for atomic vectors
- RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future rel
- How to Fix Error return arrays must be of arraytype
- The loop of life and death occurs when the El table component of element UI is bidirectional bound
- Win10 ImportError: cannot import name NUMPY_MKL
- Find malloc_error_Root cause method of break error
- DataTables warning encountered using DataTables: table id = DataTables_Table_0 – Ajax error. For more information ab
- A mistake about implicitly providing default constructors
- QT solves error: use of deleted function and is private within this context
- AUC Error – ValueError: Data is not binary and pos_label is not specified
- JSON parse error: Can not deserialize instance of java.lang.String out of START_OBJECT token
- Abnormal [System.InvalidOperationException: custom type mapping for ‘xxx’ is not specified or is not a solution
- How to Fix Node SASS Error in Vue + webpack project after nodejs upgrade