tx · 4mYq43JfanRZQyBETXNzpVZnazq9HeDF1xkokwGuKXa5 3N3n75UqB8G1GKmXFr4zPhKCjGcqJPRSuJY: -0.01000000 Waves 2024.04.28 12:46 [3082542] smart account 3N3n75UqB8G1GKmXFr4zPhKCjGcqJPRSuJY > SELF 0.00000000 Waves
{ "type": 13, "id": "4mYq43JfanRZQyBETXNzpVZnazq9HeDF1xkokwGuKXa5", "fee": 1000000, "feeAssetId": null, "timestamp": 1714297558509, "version": 2, "chainId": 84, "sender": "3N3n75UqB8G1GKmXFr4zPhKCjGcqJPRSuJY", "senderPublicKey": "2AWdnJuBMzufXSjTvzVcawBQQhnhF1iXR6QNVgwn33oc", "proofs": [ "5FyYDx64RL6qRhvuBaExaKJCPugv5pq8K7QGTiMYYWZsxV4Dfe3721BYqoNapv66HkVdEQtgBEMbQT7s8KQVun9Z" ], "script": "base64:AAIFAAAAAAAAAAgIAhIECgIBAQAAAAcAAAAADWxheWVyMVdlaWdodHMJAARMAAAAAgkABEwAAAACAAAAAAAACSmwCQAETAAAAAIAAAAAAAAJKp0FAAAAA25pbAkABEwAAAACCQAETAAAAAIAAAAAAAAGUfUJAARMAAAAAgAAAAAAAAZSLQUAAAADbmlsBQAAAANuaWwAAAAADGxheWVyMUJpYXNlcwkABEwAAAACAP///////AwWCQAETAAAAAIA///////2TQsFAAAAA25pbAAAAAANbGF5ZXIyV2VpZ2h0cwkABEwAAAACCQAETAAAAAIAAAAAAAAMtcUJAARMAAAAAgD///////JPiwUAAAADbmlsBQAAAANuaWwAAAAADGxheWVyMkJpYXNlcwkABEwAAAACAP//////+i8FBQAAAANuaWwBAAAAB3NpZ21vaWQAAAACAAAAAXoAAAALZGVidWdQcmVmaXgEAAAAAWUAAAAAAAApekkEAAAABGJhc2UAAAAAAAAPQkAEAAAACXBvc2l0aXZlWgMJAABmAAAAAgAAAAAAAAAAAAUAAAABegkBAAAAAS0AAAABBQAAAAF6BQAAAAF6BAAAAAdleHBQYXJ0CQAAawAAAAMFAA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dEw48=", "height": 3082542, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: JCkBbNxDPwS9TmpCQ9srGadxFoSNr8BhMnsUqjfEDxmf Next: 6V35pBudomPg2sNkERM1SV5yreXyCvfUjZxcnWEAwv9b Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let layer1Weights = [[ | |
4 | + | let layer1Weights = [[600496, 600733], [414197, 414253]] | |
5 | 5 | ||
6 | - | let layer1Biases = [-259050, - | |
6 | + | let layer1Biases = [-259050, -635637] | |
7 | 7 | ||
8 | - | let layer2Weights = [[ | |
8 | + | let layer2Weights = [[832965, -897141]] | |
9 | 9 | ||
10 | 10 | let layer2Biases = [-381179] | |
11 | 11 | ||
12 | - | func exp_approx (x) = { | |
13 | - | let scale = 100000 | |
14 | - | if (((-6 * scale) > x)) | |
15 | - | then 1 | |
16 | - | else if ((x > (6 * scale))) | |
17 | - | then scale | |
18 | - | else { | |
19 | - | let coefficients = [$Tuple2(60000, (scale - 1)), $Tuple2(50000, (scale - 2)), $Tuple2(40000, (scale - 3)), $Tuple2(30000, (scale - 10)), $Tuple2(20000, (scale - 20)), $Tuple2(10000, (scale - 30)), $Tuple2(0, scale), $Tuple2(-10000, (scale + 30)), $Tuple2(-20000, (scale + 20)), $Tuple2(-30000, (scale + 10)), $Tuple2(-40000, (scale + 3)), $Tuple2(-50000, (scale + 2)), $Tuple2(-60000, (scale + 1))] | |
20 | - | let index = ((x + 60000) / 10000) | |
21 | - | let $t0926968 = coefficients[index] | |
22 | - | let coefficient = $t0926968._1 | |
23 | - | let y = $t0926968._2 | |
24 | - | y | |
25 | - | } | |
26 | - | } | |
27 | - | ||
28 | - | ||
29 | 12 | func sigmoid (z,debugPrefix) = { | |
30 | - | let base = 100000 | |
13 | + | let e = 2718281 | |
14 | + | let base = 1000000 | |
31 | 15 | let positiveZ = if ((0 > z)) | |
32 | 16 | then -(z) | |
33 | 17 | else z | |
34 | - | let | |
35 | - | let sigValue = (base | |
36 | - | $Tuple2([IntegerEntry((debugPrefix + "positiveZ"), positiveZ), IntegerEntry((debugPrefix + " | |
18 | + | let expPart = fraction(e, base, positiveZ) | |
19 | + | let sigValue = fraction(base, (base + expPart), base) | |
20 | + | $Tuple2([IntegerEntry((debugPrefix + "positiveZ"), positiveZ), IntegerEntry((debugPrefix + "expPart"), expPart), IntegerEntry((debugPrefix + "sigValue"), sigValue)], sigValue) | |
37 | 21 | } | |
38 | 22 | ||
39 | 23 | ||
40 | 24 | func forwardPassLayer1 (input,weights,biases,debugPrefix) = { | |
41 | - | let sum0 = (((input[0] * weights[0][0]) + (input[1] * weights[0][1])) + (biases[0] * 100000)) | |
42 | - | let sum1 = (((input[0] * weights[1][0]) + (input[1] * weights[1][1])) + (biases[1] * 100000)) | |
43 | - | let $t018331886 = sigmoid(sum0, "Layer1N0") | |
44 | - | let debugEntries0 = $t018331886._1 | |
45 | - | let sig0 = $t018331886._2 | |
46 | - | let $t018911944 = sigmoid(sum1, "Layer1N1") | |
47 | - | let debugEntries1 = $t018911944._1 | |
48 | - | let sig1 = $t018911944._2 | |
49 | - | let debugInfo = (debugEntries0 ++ debugEntries1) | |
50 | - | let output = [sig0, sig1] | |
51 | - | $Tuple2(debugInfo, output) | |
25 | + | let sum0 = ((fraction(input[0], weights[0][0], 1000000) + fraction(input[1], weights[0][1], 1000000)) + biases[0]) | |
26 | + | let sum1 = ((fraction(input[0], weights[1][0], 1000000) + fraction(input[1], weights[1][1], 1000000)) + biases[1]) | |
27 | + | let $t010791125 = sigmoid(sum0, "Layer1N0") | |
28 | + | let debug0 = $t010791125._1 | |
29 | + | let sig0 = $t010791125._2 | |
30 | + | let $t011301176 = sigmoid(sum1, "Layer1N1") | |
31 | + | let debug1 = $t011301176._1 | |
32 | + | let sig1 = $t011301176._2 | |
33 | + | $Tuple2([sig0, sig1], (debug0 ++ debug1)) | |
52 | 34 | } | |
53 | 35 | ||
54 | 36 | ||
55 | 37 | func forwardPassLayer2 (input,weights,biases,debugPrefix) = { | |
56 | - | let sum0 = (((input[0] * weights[0][0]) + (input[1] * weights[0][1])) + (biases[0] * 100000)) | |
57 | - | let $t022542307 = sigmoid(sum0, "Layer2N0") | |
58 | - | let debugEntries0 = $t022542307._1 | |
59 | - | let sig0 = $t022542307._2 | |
60 | - | let debugInfo = debugEntries0 | |
61 | - | let output = sig0 | |
62 | - | $Tuple2(debugInfo, output) | |
38 | + | let sum0 = ((fraction(input[0], weights[0][0], 1000000) + fraction(input[1], weights[0][1], 1000000)) + biases[0]) | |
39 | + | let $t014451491 = sigmoid(sum0, "Layer2N0") | |
40 | + | let debug0 = $t014451491._1 | |
41 | + | let sig0 = $t014451491._2 | |
42 | + | $Tuple2(sig0, debug0) | |
63 | 43 | } | |
64 | 44 | ||
65 | 45 | ||
72 | 52 | then 1000000 | |
73 | 53 | else 0 | |
74 | 54 | let inputs = [scaledInput1, scaledInput2] | |
75 | - | let $ | |
76 | - | let | |
77 | - | let | |
78 | - | let $ | |
79 | - | let | |
80 | - | let | |
55 | + | let $t017421840 = forwardPassLayer1(inputs, layer1Weights, layer1Biases, "Layer1") | |
56 | + | let layer1Output = $t017421840._1 | |
57 | + | let debugLayer1 = $t017421840._2 | |
58 | + | let $t018451949 = forwardPassLayer2(layer1Output, layer2Weights, layer2Biases, "Layer2") | |
59 | + | let layer2Output = $t018451949._1 | |
60 | + | let debugLayer2 = $t018451949._2 | |
81 | 61 | (([IntegerEntry("result", layer2Output)] ++ debugLayer1) ++ debugLayer2) | |
82 | 62 | } | |
83 | 63 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let layer1Weights = [[ | |
4 | + | let layer1Weights = [[600496, 600733], [414197, 414253]] | |
5 | 5 | ||
6 | - | let layer1Biases = [-259050, - | |
6 | + | let layer1Biases = [-259050, -635637] | |
7 | 7 | ||
8 | - | let layer2Weights = [[ | |
8 | + | let layer2Weights = [[832965, -897141]] | |
9 | 9 | ||
10 | 10 | let layer2Biases = [-381179] | |
11 | 11 | ||
12 | - | func exp_approx (x) = { | |
13 | - | let scale = 100000 | |
14 | - | if (((-6 * scale) > x)) | |
15 | - | then 1 | |
16 | - | else if ((x > (6 * scale))) | |
17 | - | then scale | |
18 | - | else { | |
19 | - | let coefficients = [$Tuple2(60000, (scale - 1)), $Tuple2(50000, (scale - 2)), $Tuple2(40000, (scale - 3)), $Tuple2(30000, (scale - 10)), $Tuple2(20000, (scale - 20)), $Tuple2(10000, (scale - 30)), $Tuple2(0, scale), $Tuple2(-10000, (scale + 30)), $Tuple2(-20000, (scale + 20)), $Tuple2(-30000, (scale + 10)), $Tuple2(-40000, (scale + 3)), $Tuple2(-50000, (scale + 2)), $Tuple2(-60000, (scale + 1))] | |
20 | - | let index = ((x + 60000) / 10000) | |
21 | - | let $t0926968 = coefficients[index] | |
22 | - | let coefficient = $t0926968._1 | |
23 | - | let y = $t0926968._2 | |
24 | - | y | |
25 | - | } | |
26 | - | } | |
27 | - | ||
28 | - | ||
29 | 12 | func sigmoid (z,debugPrefix) = { | |
30 | - | let base = 100000 | |
13 | + | let e = 2718281 | |
14 | + | let base = 1000000 | |
31 | 15 | let positiveZ = if ((0 > z)) | |
32 | 16 | then -(z) | |
33 | 17 | else z | |
34 | - | let | |
35 | - | let sigValue = (base | |
36 | - | $Tuple2([IntegerEntry((debugPrefix + "positiveZ"), positiveZ), IntegerEntry((debugPrefix + " | |
18 | + | let expPart = fraction(e, base, positiveZ) | |
19 | + | let sigValue = fraction(base, (base + expPart), base) | |
20 | + | $Tuple2([IntegerEntry((debugPrefix + "positiveZ"), positiveZ), IntegerEntry((debugPrefix + "expPart"), expPart), IntegerEntry((debugPrefix + "sigValue"), sigValue)], sigValue) | |
37 | 21 | } | |
38 | 22 | ||
39 | 23 | ||
40 | 24 | func forwardPassLayer1 (input,weights,biases,debugPrefix) = { | |
41 | - | let sum0 = (((input[0] * weights[0][0]) + (input[1] * weights[0][1])) + (biases[0] * 100000)) | |
42 | - | let sum1 = (((input[0] * weights[1][0]) + (input[1] * weights[1][1])) + (biases[1] * 100000)) | |
43 | - | let $t018331886 = sigmoid(sum0, "Layer1N0") | |
44 | - | let debugEntries0 = $t018331886._1 | |
45 | - | let sig0 = $t018331886._2 | |
46 | - | let $t018911944 = sigmoid(sum1, "Layer1N1") | |
47 | - | let debugEntries1 = $t018911944._1 | |
48 | - | let sig1 = $t018911944._2 | |
49 | - | let debugInfo = (debugEntries0 ++ debugEntries1) | |
50 | - | let output = [sig0, sig1] | |
51 | - | $Tuple2(debugInfo, output) | |
25 | + | let sum0 = ((fraction(input[0], weights[0][0], 1000000) + fraction(input[1], weights[0][1], 1000000)) + biases[0]) | |
26 | + | let sum1 = ((fraction(input[0], weights[1][0], 1000000) + fraction(input[1], weights[1][1], 1000000)) + biases[1]) | |
27 | + | let $t010791125 = sigmoid(sum0, "Layer1N0") | |
28 | + | let debug0 = $t010791125._1 | |
29 | + | let sig0 = $t010791125._2 | |
30 | + | let $t011301176 = sigmoid(sum1, "Layer1N1") | |
31 | + | let debug1 = $t011301176._1 | |
32 | + | let sig1 = $t011301176._2 | |
33 | + | $Tuple2([sig0, sig1], (debug0 ++ debug1)) | |
52 | 34 | } | |
53 | 35 | ||
54 | 36 | ||
55 | 37 | func forwardPassLayer2 (input,weights,biases,debugPrefix) = { | |
56 | - | let sum0 = (((input[0] * weights[0][0]) + (input[1] * weights[0][1])) + (biases[0] * 100000)) | |
57 | - | let $t022542307 = sigmoid(sum0, "Layer2N0") | |
58 | - | let debugEntries0 = $t022542307._1 | |
59 | - | let sig0 = $t022542307._2 | |
60 | - | let debugInfo = debugEntries0 | |
61 | - | let output = sig0 | |
62 | - | $Tuple2(debugInfo, output) | |
38 | + | let sum0 = ((fraction(input[0], weights[0][0], 1000000) + fraction(input[1], weights[0][1], 1000000)) + biases[0]) | |
39 | + | let $t014451491 = sigmoid(sum0, "Layer2N0") | |
40 | + | let debug0 = $t014451491._1 | |
41 | + | let sig0 = $t014451491._2 | |
42 | + | $Tuple2(sig0, debug0) | |
63 | 43 | } | |
64 | 44 | ||
65 | 45 | ||
66 | 46 | @Callable(i) | |
67 | 47 | func predict (input1,input2) = { | |
68 | 48 | let scaledInput1 = if ((input1 == 1)) | |
69 | 49 | then 1000000 | |
70 | 50 | else 0 | |
71 | 51 | let scaledInput2 = if ((input2 == 1)) | |
72 | 52 | then 1000000 | |
73 | 53 | else 0 | |
74 | 54 | let inputs = [scaledInput1, scaledInput2] | |
75 | - | let $ | |
76 | - | let | |
77 | - | let | |
78 | - | let $ | |
79 | - | let | |
80 | - | let | |
55 | + | let $t017421840 = forwardPassLayer1(inputs, layer1Weights, layer1Biases, "Layer1") | |
56 | + | let layer1Output = $t017421840._1 | |
57 | + | let debugLayer1 = $t017421840._2 | |
58 | + | let $t018451949 = forwardPassLayer2(layer1Output, layer2Weights, layer2Biases, "Layer2") | |
59 | + | let layer2Output = $t018451949._1 | |
60 | + | let debugLayer2 = $t018451949._2 | |
81 | 61 | (([IntegerEntry("result", layer2Output)] ++ debugLayer1) ++ debugLayer2) | |
82 | 62 | } | |
83 | 63 | ||
84 | 64 |
github/deemru/w8io/026f985 41.12 ms ◑