Spaces:
Running
Running
Update script.js
Browse files
script.js
CHANGED
|
@@ -21,6 +21,10 @@ var rand_truncated_normal = function(low, high) {
|
|
| 21 |
return r;
|
| 22 |
}
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
|
| 26 |
var char2idx = {'\x00': 0, ' ': 1, '!': 2, '"': 3, '#': 4, "'": 5, '(': 6, ')': 7, ',': 8, '-': 9, '.': 10, '0': 11, '1': 12, '2': 13, '3': 14, '4': 15, '5': 16, '6': 17, '7': 18, '8': 19, '9': 20, ':': 21, ';': 22, '?': 23, 'A': 24, 'B': 25, 'C': 26, 'D': 27, 'E': 28, 'F': 29, 'G': 30, 'H': 31, 'I': 32, 'J': 33, 'K': 34, 'L': 35, 'M': 36, 'N': 37, 'O': 38, 'P': 39, 'R': 40, 'S': 41, 'T': 42, 'U': 43, 'V': 44, 'W': 45, 'Y': 46, 'a': 47, 'b': 48, 'c': 49, 'd': 50, 'e': 51, 'f': 52, 'g': 53, 'h': 54, 'i': 55, 'j': 56, 'k': 57, 'l': 58, 'm': 59, 'n': 60, 'o': 61, 'p': 62, 'q': 63, 'r': 64, 's': 65, 't': 66, 'u': 67, 'v': 68, 'w': 69, 'x': 70, 'y': 71, 'z': 72};
|
|
@@ -143,7 +147,7 @@ var dojob = function(run_id) {
|
|
| 143 |
tf.dispose(gru0_hx_);
|
| 144 |
const att_inp = tf.concat([att_context, input, out_0], 1);
|
| 145 |
const att_params = tf.add(tf.matMul(att_inp, att_w), att_b);
|
| 146 |
-
[alpha,beta,kappa] = tf.split(
|
| 147 |
att_location_ = att_location;
|
| 148 |
att_location = tf.add(att_location, tf.div(kappa, 25.));
|
| 149 |
tf.dispose(att_location_)
|
|
|
|
| 21 |
return r;
|
| 22 |
}
|
| 23 |
|
| 24 |
+
var softplus = function(x) {
|
| 25 |
+
const m = tf.maximum(x, 0.0);
|
| 26 |
+
return tf.add(m, tf.log(tf.add(tf.exp(-m), tf.exp(x-m))));
|
| 27 |
+
}
|
| 28 |
|
| 29 |
|
| 30 |
var char2idx = {'\x00': 0, ' ': 1, '!': 2, '"': 3, '#': 4, "'": 5, '(': 6, ')': 7, ',': 8, '-': 9, '.': 10, '0': 11, '1': 12, '2': 13, '3': 14, '4': 15, '5': 16, '6': 17, '7': 18, '8': 19, '9': 20, ':': 21, ';': 22, '?': 23, 'A': 24, 'B': 25, 'C': 26, 'D': 27, 'E': 28, 'F': 29, 'G': 30, 'H': 31, 'I': 32, 'J': 33, 'K': 34, 'L': 35, 'M': 36, 'N': 37, 'O': 38, 'P': 39, 'R': 40, 'S': 41, 'T': 42, 'U': 43, 'V': 44, 'W': 45, 'Y': 46, 'a': 47, 'b': 48, 'c': 49, 'd': 50, 'e': 51, 'f': 52, 'g': 53, 'h': 54, 'i': 55, 'j': 56, 'k': 57, 'l': 58, 'm': 59, 'n': 60, 'o': 61, 'p': 62, 'q': 63, 'r': 64, 's': 65, 't': 66, 'u': 67, 'v': 68, 'w': 69, 'x': 70, 'y': 71, 'z': 72};
|
|
|
|
| 147 |
tf.dispose(gru0_hx_);
|
| 148 |
const att_inp = tf.concat([att_context, input, out_0], 1);
|
| 149 |
const att_params = tf.add(tf.matMul(att_inp, att_w), att_b);
|
| 150 |
+
[alpha,beta,kappa] = tf.split(softplus(att_params), 3, 1);
|
| 151 |
att_location_ = att_location;
|
| 152 |
att_location = tf.add(att_location, tf.div(kappa, 25.));
|
| 153 |
tf.dispose(att_location_)
|