【tensorflow】学习笔记

1、tensorflow中dynamic_rnn和rnn有什么区别?

  •    在tensorflow中没有找到rnn这个方法难道是废弃掉了?

    rnn是静态图,比如有10个时间序列,那么它将全部展开,并且存储这十个图,

    dynamic_rnn是动态的,不会全部存储这些图

    dynamic_rnn对于不同的时间步的batch可以是长度不同的数据,它会根据不同的迭代进行对齐

  • dynamic_rnn与static_rnn区别

1、输入输出的结构不一样

    dynamic_rnn的输入[batch, n_steps, input],  输出对应 [batch, n_steps, output]

    static_rnn的输入[n_steps, batch, input], 输出对应[n_steps, batch, input]

2、sparse_softmax_cross_entropy_with_logits vs softmax_cross_entropy_with_logits

    二者在tensorflow中的效果都是一样的,先对输出结果进行softmax,然后求交叉熵,不同的一点就是 输入labels的形式,

    在sparse_softmax_cross_entropy_with_logits中,labels的维度是[batch_size], 就是batch_size个整数组成的一位向量,每一个整数代表样本的类别,

    而在softmax_cross_entropy_with_logits中,labels的维度是[batch_size, num_classes], 也就是每一个样本都以one-hot形式编码

    共同点:

    输入都需要unscaled logits,因为tensorflow内部机制会将其进行归一化操作以提高效率

    参考:https://blog.csdn.net/yc461515457/article/details/77861695

3、tensorflow.contrib.learn.preprocessing.VocabularyProcessor

    一个建立字典,并获取索引有用的函数

原文地址:https://www.cnblogs.com/zhaopAC/p/10083329.html