   (let [e-count (count entries)]
     (loop [curr-net start-net
            entry-i 0
-           curr-delta-w (get-initial-delta-w curr-net)]
+           curr-delta-w (get-initial-delta-w curr-net)
+           curr-delta-b (get-initial-delta-b curr-net)]
       (if (>= entry-i e-count)
         curr-net
         (let [entry (nth entries entry-i)
-              step-result (backprop-step curr-net entry e-count t-opts curr-delta-w)
-              [new-net new-delta-w] step-result]
-          (recur new-net
-                 (inc entry-i)
-                 new-delta-w))))))
+              step-result (backprop-step curr-net entry e-count t-opts curr-delta-w curr-delta-b)
+              [new-net new-delta-w new-delta-b] step-result]
+          (recur new-net (inc entry-i) new-delta-w new-delta-b))))))
 
 (defn train
   "Trains given network on a dataset during multiple epochs.

       deltas-vecs
       forward-vecs
       prev-delta-w)

     (map
       #(backprop-delta-layer-biases t-opts %1)
       deltas-vecs)]))

(defn backprop-step
  "Performs forward & backward pass, tunes network weights & biases.
  Returns new network and weights deltas."
  [net entry e-count t-opts prev-delta-w]
  (let [results (backprop-step-delta net entry e-count t-opts prev-delta-w)
        [delta-weights delta-biases] results
        new-layers (map
                     (fn [{:keys [edges-matrix edges-mask biases] :as layer} delta-w delta-b]
                       (let [delta-w (m/mul delta-w edges-mask)
                             new-edges-matrix (m/add delta-w edges-matrix)
                             new-biases (m/add! delta-b biases)]
                         (assoc layer :edges-matrix new-edges-matrix
                                      :biases new-biases)))
                     (:layers net)
                     delta-weights
                     delta-biases)]
    [(assoc net :layers (vec new-layers))
     delta-weights]))

(defn calc-cost
  "Performs forward pass, calculates cost of out layer for each entry.


(defmethod forward ::relu
  [_ in-vec]
  (m/emap #(if (pos? %) % 0.0) in-vec))

(defmethod derivative ::relu
  [_ out-vec]
  (m/emap #(if (pos? %) 1.0 0.0) out-vec))

;; Softmax output layer with log-likehood loss

