Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Is it possible to use a transducer here instead of reduce?
- (ns anny.forwardprop
- (:require [clojure.core.matrix :as m]
- [anny.utility :as u]
- [anny.network :as n])
- (:use [clojure.core.matrix.operators]))
- (defn sum-weighted-values
- "computes the propagation for one layer given the
- input and weights for that layer this is often used
- as a part of forward propagiton or classifying"
- [input weight-layer]
- (m/inner-product (m/transpose input) weight-layer)) ;;returns a new matrix
- (defn prop-function
- "sums the weighted inputs for a node and applies
- the activation function"
- [activation-function]
- (comp
- (fn [x] (m/matrix x))
- (fn [x] (mapv activation-function x)) ;;; ideally this comp could be changed to a transducer
- sum-weighted-values)) ;;; buit im confused how with when usuing m/matrix and
- ;;; sum-weighted values as they both return a definite
- ;;;structure
- (defn forward-prop
- "foward propagiotn to finde output of network"
- [net input]
- (let [weights (:weights net)
- act (:activation-function net)
- f (prop-function act)]
- (reduce #(f %1 %2) input weights))) ;;here is what i want to change input
Advertisement
Add Comment
Please, Sign In to add comment