8 | ||| N-layer multi-layer perceptron with a specified activation function,
9 | ||| and flag for whether the last layer should have it
25 | = composePara (composePara affinePara activation) (multiLayerPerceptron (S k) activation {lastLayerActivation = lastLayerActivation})
28 | -- public export
29 | -- threeLayerPerceptron : {inputSize, outputSize : Nat} ->
30 | -- AllConsistent [inName, outName] [Vect outputSize, Vect inputSize] =>
31 | -- Tensor [inputSize] [inName] Double -\-> Tensor [outputSize] [outName] Double
32 | -- threeLayerPerceptron =
33 | -- let hiddenDimension1 = inputSize * 10
34 | -- hiddenDimension2 = inputSize * 10
35 | -- in affinePara
36 | -- \>> trivialParam Tensor.sigmoid
37 | -- \>> affinePara {x=Vect hiddenDimension1}
38 | -- \>> trivialParam Tensor.sigmoid
39 | -- \>> affinePara {x=Vect hiddenDimension2}
45 | -- public export
46 | -- inputTensor : Tensor [3] Double
47 | -- inputTensor = ># [1, 2, 3]
48 | --
49 | --
50 | -- public export
51 | -- outputTensor : IO (Tensor [2] Double)
52 | -- outputTensor = do
53 | -- let pr = randomRIO {io=IO} {a=(Param (trivialParam Tensor.sigmoid) inputTensor)}
54 | -- ?asdfasdf
56 | {-
57 | public export
58 | mlpNonDependentPara : {a : Type} -> Num a =>
59 | {ieva : Cont} ->
60 | (allAlg : AllAlgebra [ieva] a) =>
61 | (allAppl : All TensorMonoid [ieva]) =>
62 | (numLayers : Nat) ->
63 | (activation : CTensor [ieva] a -> CTensor [ieva] a) ->
64 | {default False lastLayerActivation : Bool} ->
65 | IsNotDependent (multiLayerPerceptron numLayers (trivialParam activation) {lastLayerActivation = lastLayerActivation})
66 | mlpNonDependentPara 0 activation = ?oqwi -- MkNonDep () (\t, _ => t)
67 | mlpNonDependentPara 1 activation {lastLayerActivation = False}
68 | = MkNonDep (AffineLayerParams ieva ieva a)
69 | (\x, p => (Run (multiLayerPerceptron 1 (trivialParam activation) {lastLayerActivation = False})) x p)
70 | mlpNonDependentPara 1 activation {lastLayerActivation = True} = ?wiii_1 -- MkNonDep ?ppp ?fff
71 | mlpNonDependentPara (S k) activation = ?wiii_11 -- MkNonDep ?ppp ?fff
72 | -- = MkNonDep ?ppp ?fff
76 | public export
77 | simpleNLayerNet : {features : Nat} -> (n : Nat) ->
78 | Tensor [features] Double -\-> Tensor [features] Double
79 | simpleNLayerNet n = multiLayerPerceptron n (trivialParam sigmoid)
82 | public export
83 | exampleInput : Tensor [2] Double
84 | exampleInput = ># [1, 5]
86 | public export
87 | exampleParam : Tensor [2, 2] Double
88 | exampleParam = ># [ [0.4, 0.2]
89 | , [0.7, -3]]
91 | public export
92 | exampleBias : Tensor [2] Double
93 | exampleBias = ># [0, 0]
95 | public export
96 | layerParam : AffineLayerParams (Vect 2) (Vect 2) Double
97 | layerParam = MkParams exampleParam exampleBias
99 | public export
100 | exampleOutput : Tensor [2] Double
101 | exampleOutput = Run (simpleNLayerNet 2) exampleInput
102 | ((layerParam ** ()) ** layerParam)
103 | -}