# 向后传递

`feedforward()`实现向后传递的功能。

向后传递的公式：

$$
a' = \sigma (w a + b)  \\
\sigma(z) = \frac{1}{1+\exp(-z)}
$$

w和b为某个神经上的参数，a为上层的输出，a'为这个神经元的输出。

```python
def feedforward(self, a):
    """Return the output of the network if "a" is input."""
    for b, w in zip(self.biases, self.weights):
        a = sigmoid(np.dot(w, a)+b)
    return a

def sigmoid(z):
    return 1.0/(1.0+np.exp(-z))
```

sigmoid函数用于实现$$\sigma(z)$$，需注意的是入参z是一个向量。\
sigmoid函数是对整个向量计算的。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://windmising.gitbook.io/nielsen-nndl/introduction/shi-xian-shu-zi-fen-lei-de-shen-jing-wang-luo/3.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
