• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Aug 21st, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. int main(int argc, char **argv) {
2.
3.     const int terms = 8;
4.     Var x("x"), y("y"), i("i");
5.
6.     Param<int> width;
7.     Param<int> height;
8.     Param<float> mu;
9.     Param<float> beta;
10.     Param<float> sigma;
11.     Param<float> gamma;
12.     Param<float> tau;
13.     Param<int> order, samples;
14.     Param<double> learning_rate;
15.     RDom s(0, width, 0, height);
16.
17.     s.where(abs(sqrt(s.x * s.x + s.y * s.y)  - mu) < 3 * sigma);
18.
19. //    int n = 5; //number of features
20.     ImageParam disparities(Float(64), 2);
21.     ImageParam left_features(Float(64), 3);
22.     ImageParam right_features(Float(64), 3);
23.     ImageParam a(Float(64), 1);
24.     ImageParam b(Float(64), 1);
25.     ImageParam c(Float(64), 1);
26.     ImageParam point_tri_map(Int(32), 2);
27.
28.     Func mean;
29.     mean(x, y) = a(point_tri_map(x, y)) * x + b(point_tri_map(x, y)) * y + c(point_tri_map(x, y));
30.
31.     Func diff;
32.     diff(x, y, i) = left_features(x, y, i) - right_features(x, y, i); // for i = 0 to n
33.
34.     Func norm;
35.     RDom n_feat(0, 5);
36.     norm(x, y) = sum(abs(diff(x, y, n_feat)));
37.
38.     ImageParam d(Int(32), 2);
39.
40.     Func energy;
41.     energy(x, y) = beta * norm(x - d(x, y), y) - log (gamma + exp(- pow((d(x, y) - mean(x, y)), 2)) / (2 * sigma * sigma));
42.
43.     RDom img(0, width, 0, height);
44.     Func err;
45. //    err() = f64(0);
46.     err() = sum(energy(img.x, img.y));
47.
48.     auto d_err_d = propagate_adjoints(err);
49.
50.     Func new_d;
51.     new_d(x, y) = d(x, y) - learning_rate * d_err_d(d)(x, y);
52.
53.     Pipeline p({err, new_d});
54.     p.compile_to_static_library("energy", {disparities, a, b, c, point_tri_map, left_features, right_features, d}, "energy");
55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top