Skip to content

Commit ea68716

Browse files
committed
[ version ] bump version, update doc
1 parent 7f49cb1 commit ea68716

File tree

3 files changed

+22
-33
lines changed

3 files changed

+22
-33
lines changed

README.md

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# HashedExpression
22
[![wercker status](https://app.wercker.com/status/fce29884fa47e4258f62240000f1e368/m/master "wercker status")](https://app.wercker.com/project/byKey/fce29884fa47e4258f62240000f1e368)
33

4-
Type-safe modelling DSL, symbolic transformation, and code generation for solving optimization problems.
4+
Haskell-embeded Algebraic Modeling Language with type-safety, symbolic transformation and C-code generation
55

66

77
## Features
@@ -86,12 +86,8 @@ ex1_linearRegression =
8686
values =
8787
[ x :-> VFile (TXT "x.txt"),
8888
y :-> VFile (TXT "y.txt")
89-
],
90-
workingDir = "examples" </> "LinearRegression"
89+
]
9190
}
92-
93-
ex1 :: IO ()
94-
ex1 = proceed ex1_linearRegression CSimpleConfig {output = OutputText}
9591
```
9692
(`(*.)` is scaling )
9793

@@ -126,12 +122,8 @@ ex2_logisticRegression =
126122
values =
127123
[ x :-> VFile (TXT "x_expanded.txt"),
128124
y :-> VFile (TXT "y.txt")
129-
],
130-
workingDir = "examples" </> "LogisticRegression"
125+
]
131126
}
132-
133-
ex2 :: IO ()
134-
ex2 = proceed ex2_logisticRegression CSimpleConfig {output = OutputText}
135127
```
136128

137129
( `(**)` is matrix multiplication, `(<.>)` is dot product, `project (range @1 @27, at @0) theta` is the typed version of `theta[1:27,0]` )
@@ -144,33 +136,36 @@ ex2 = proceed ex2_logisticRegression CSimpleConfig {output = OutputText}
144136
Model is in [app/Examples/Brain.hs](app/Examples/Brain.hs), data is in [examples/Brain](examples/Brain)
145137

146138
```haskell
147-
brain_reconstructFromMRI :: OptimizationProblem
148-
brain_reconstructFromMRI =
139+
brainReconstructFromMRI :: OptimizationProblem
140+
brainReconstructFromMRI =
149141
let -- variables
150142
x = variable2D @128 @128 "x"
143+
--- bound
144+
xLowerBound = bound2D @128 @128 "x_lb"
145+
xUpperBound = bound2D @128 @128 "x_ub"
151146
-- parameters
152147
im = param2D @128 @128 "im"
153148
re = param2D @128 @128 "re"
154149
mask = param2D @128 @128 "mask"
155150
-- regularization
151+
regularization = norm2square (rotate (0, 1) x - x) + norm2square (rotate (1, 0) x - x)
156152
lambda = 3000
157-
regularization = lambda * (norm2square (rotate (0, 1) x - x) + norm2square (rotate (1, 0) x - x))
158153
in OptimizationProblem
159-
{ objective = norm2square ((mask +: 0) * (ft (x +: 0) - (re +: im))) + regularization,
154+
{ objective =
155+
norm2square ((mask +: 0) * (ft (x +: 0) - (re +: im)))
156+
+ lambda * regularization,
160157
constraints =
161-
[ x .<= VFile (HDF5 "bound.h5" "ub"),
162-
x .>= VFile (HDF5 "bound.h5" "lb")
158+
[ x .<= xUpperBound,
159+
x .>= xLowerBound
163160
],
164161
values =
165162
[ im :-> VFile (HDF5 "kspace.h5" "im"),
166163
re :-> VFile (HDF5 "kspace.h5" "re"),
167-
mask :-> VFile (HDF5 "mask.h5" "mask")
168-
],
169-
workingDir = "examples" </> "Brain"
164+
mask :-> VFile (HDF5 "mask.h5" "mask"),
165+
xLowerBound :-> VFile (HDF5 "bound.h5" "lb"),
166+
xUpperBound :-> VFile (HDF5 "bound.h5" "ub")
167+
]
170168
}
171-
172-
brain :: IO ()
173-
brain = proceed brain_reconstructFromMRI CSimpleConfig {output = OutputHDF5}
174169
```
175170

176171
<img src="docs/images/brain_before.png" width="450px"/>
@@ -190,7 +185,7 @@ prependColumn ::
190185
(Injectable 0 (m - 1) m m, Injectable 1 n n (n + 1)) =>
191186
Double ->
192187
TypedExpr '[m, n] R ->
193-
TypedExpr (D2 m (n + 1)) R
188+
TypedExpr '[m, n + 1] R
194189
prependColumn v exp = inject (range @0 @(m - 1), range @1 @n) exp (constant2D @m @(n + 1) v)
195190

196191
ex4_neuralNetwork :: OptimizationProblem
@@ -216,12 +211,8 @@ ex4_neuralNetwork =
216211
values =
217212
[ x :-> VFile (HDF5 "data.h5" "x"),
218213
y :-> VFile (HDF5 "data.h5" "y")
219-
],
220-
workingDir = "examples" </> "NeuralNetwork"
214+
]
221215
}
222-
223-
ex4 :: IO ()
224-
ex4 = proceed ex4_neuralNetwork CSimpleConfig {output = OutputHDF5, maxIteration = Just 400}
225216
```
226217

227218
<img src="docs/images/nn_before.png" width="450px"/>

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.9
1+
0.0.10

app/Examples/Brain.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ brainReconstructFromMRI =
1717
re = param2D @128 @128 "re"
1818
mask = param2D @128 @128 "mask"
1919
-- regularization
20-
regularization =
21-
norm2square (rotate (0, 1) x - x)
22-
+ norm2square (rotate (1, 0) x - x)
20+
regularization = norm2square (rotate (0, 1) x - x) + norm2square (rotate (1, 0) x - x)
2321
lambda = 3000
2422
in OptimizationProblem
2523
{ objective =

0 commit comments

Comments
 (0)