
具有时间相关性



[b个波形, 采样100个seq时间点, 对应每个时间点的feature]


最简单的one_hot encoding



意思相近的单词在向量空间上相关性距离越小 表示方式越好
Embedding Layer
In [2]: from tensorflow.keras import layers
In [3]: import tensorflow as tf
In [6]: x = tf.range(5)
In [7]: x = tf.random.shuffle(x)
In [8]: net = layers.Embedding(10, 4) # 网络最多10个单词,每个单词用一个长度为4的vector表示
In [9]: net(x) # x为5个单词,则对应[5, 4]
Out[9]:
<tf.Tensor: shape=(5, 4), dtype=float32, numpy=
array([[-0.04134145, 0.02167301, -0.00487036, -0.03129961],
[-0.00446678, 0.0411575 , -0.0083902 , -0.04393339],
[-0.04771481, 0.03433364, 0.03229776, 0.01344705],
[ 0.03182409, -0.04264296, -0.02120506, 0.00117933],
[-0.00085657, -0.04112577, 0.04295324, -0.02037839]],
dtype=float32)>
In [10]: net.trainable
Out[10]: True
In [11]: net.trainable_variables # trainable
Out[11]:
[<tf.Variable 'embedding/embeddings:0' shape=(10, 4) dtype=float32, numpy=
array([[-0.00446678, 0.0411575 , -0.0083902 , -0.04393339],
[-0.00085657, -0.04112577, 0.04295324, -0.02037839],
[-0.04134145, 0.02167301, -0.00487036, -0.03129961],
[ 0.03182409, -0.04264296, -0.02120506, 0.00117933],
[-0.04771481, 0.03433364, 0.03229776, 0.01344705],
[ 0.00809318, 0.00439113, -0.02471092, 0.01798195],
[ 0.02877717, 0.02287935, -0.04870056, -0.01806825],
[-0.00918406, 0.03466691, 0.04272464, -0.03204942],
[ 0.03497279, 0.03022062, -0.00239567, 0.00312829],
[-0.04340002, -0.04850687, -0.02064794, -0.03603333]],
dtype=float32)>]
最后
以上就是哭泣奇迹最近收集整理的关于序列表示方法的全部内容,更多相关序列表示方法内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复