Exemple #1
0
 def basisf(self, x, s, e):
     cpstart = tf.cast(tf.less_equal(s, x), tf.float32)
     cpend = tf.cast(tf.greater(e, x), tf.float32)
     if self.order == 1:
         output = self.magnitude * (0 * (1 - cpstart) + (x - s) * cpstart * cpend + (e - s) * (1 - cpend))
     else:
         output = self.magnitude * (0 * (1 - cpstart) + 0.5 * (x - s)**2 * cpstart
                                  * cpend + ((e - s) * (x - e) + 0.5 * (e - s)**2) * (1 - cpend))
     
     return tf.cast(output, tf.float32)
     
     self.built = True
Exemple #2
0
    def build(self, input_shape):

        N = self.input_length
        ps = self.pulse_sec
        self.t = tf.range(0, N - 1, delta=N / ps, dtype=tf.float32)
        self.t = tf.reshape(self.t, [self.t.shape[0], 1])
        self.t = tf.broadcast_to(self.t, [self.t.shape[0], 1])
        self.t = tf.cast(self.t, tf.int64)

        self.built = True
Exemple #3
0
def castIntSoftMax(x):
    def grad(dy):
        return dy

    return tf.cast(x, tf.int64), grad