def cwt(wav, widthCwt, wavelet):
length = wav.shape[0]
wav = tf.to_float(wav)
wav = tf.reshape(wav, [1,length,1,1])
# While loop functions
def body(i, m):
v = conv1DWavelet(wav, i, wavelet)
v = tf.reshape(v, [length, 1])
m = tf.concat([m,v], 1)
return [1 + i, m]
def cond_(i, m):
return tf.less_equal(i, widthCwt)
# Initialize and run while loop
emptyCwtMatrix = tf.zeros([length, 0], dtype='float32')
i = tf.constant(1)
_, result = tf.while_loop(
cond_,
body,
[i, emptyCwtMatrix],
shape_invariants=[i.get_shape(), tf.TensorShape([length, None])],
back_prop=False,
parallel_iterations=1024,
)
result = tf.transpose(result)
return result
# ------------------------------------------------------
# wavelets
评论列表
文章目录