Remove trailing whitespace in dnn

This commit is contained in:
Marcus Asteborg 2023-06-22 05:27:54 -07:00
parent 26ab10d0c8
commit f36685fc97
No known key found for this signature in database
GPG key ID: F69798291D4CE42A
37 changed files with 231 additions and 246 deletions

View file

@ -3,7 +3,7 @@ Modification of Tensorflow's Embedding Layer:
1. Not restricted to be the first layer of a model
2. Differentiable (allows non-integer lookups)
- For non integer lookup, this layer linearly interpolates between the adjacent embeddings in the following way to preserver gradient flow
- E = (1 - frac(x))*embed(floor(x)) + frac(x)*embed(ceil(x))
- E = (1 - frac(x))*embed(floor(x)) + frac(x)*embed(ceil(x))
"""
import tensorflow as tf
@ -26,13 +26,13 @@ class diff_Embed(Layer):
self.pcm_init = pcm_init
self.initializer = initializer
def build(self, input_shape):
def build(self, input_shape):
w_init = tf.random_normal_initializer()
if self.pcm_init:
if self.pcm_init:
w_init = self.initializer
self.w = tf.Variable(initial_value=w_init(shape=(self.dict_size, self.units),dtype='float32'),trainable=True)
def call(self, inputs):
def call(self, inputs):
alpha = inputs - tf.math.floor(inputs)
alpha = tf.expand_dims(alpha,axis = -1)
alpha = tf.tile(alpha,[1,1,1,self.units])