def costs(data_in, outputs, Ws, Bs):
    (Z, pred) = feedforward(data_in, Ws, Bs)
    delta = []
    dj_dw = []
    loss = ((- 1) * ((outputs * np.log(pred[(- 1)])) + ((1 - outputs) * np.log((1 - pred[(- 1)])))))
    loss = np.mean(loss)
    dj_da = ((- 1) * ((outputs[(- 1)] / pred[(- 1)]) + ((1 - outputs) / (1 - pred[(- 1)]))))
    da_dz = d_sigmoid(Z[(- 1)])
    delta.append((dj_da * da_dz))
    for i in range(1, len(Ws)):
        d = (np.dot(Ws[(- i)].T, delta[(- i)]) * relu(Z[((- i) - 1)], d=True))
        delta.insert(0, np.mean(d, axis=1, keepdims=True))
    delta[(- 1)] = np.mean(delta[(- 1)])
    for i in range(1, len(pred)):
        b = []
        A = pred[((- i) - 1)].T
        for a in A:
            b.append(np.dot(delta[(- i)], [a]))
        d = np.zeros(weight_sizes[(- i)])
        for s in b:
            d += s
        d /= len(d)
        dj_dw.insert(0, d)
    return (loss, delta, dj_dw)
def costs(data_in, outputs, Ws, Bs):
    (Z, pred) = feedforward(data_in, Ws, Bs)
    delta = []
    dj_dw = []
    loss = ((- 1) * ((outputs * np.log(pred[(- 1)])) + ((1 - outputs) * np.log((1 - pred[(- 1)])))))
    loss = np.mean(loss)
    dj_da = ((- 1) * ((outputs[(- 1)] / pred[(- 1)]) + ((1 - outputs) / (1 - pred[(- 1)]))))
    da_dz = d_sigmoid(Z[(- 1)])
    delta.append((dj_da * da_dz))
    for i in range(1, len(Ws)):
        d = (np.dot(Ws[(- i)].T, delta[(- i)]) * relu(Z[((- i) - 1)], d=True))
        delta.insert(0, np.mean(d, axis=1, keepdims=True))
    delta[(- 1)] = np.mean(delta[(- 1)])
    for i in range(1, len(pred)):
        b = []
        A = pred[((- i) - 1)].T
        for a in A:
            b.append(np.dot(delta[(- i)], [a]))
        d = np.zeros(weight_sizes[(- i)])
        for s in b:
            d += s
        d /= len(d)
        dj_dw.insert(0, d)
    return (loss, delta, dj_dw)