[![Build Status](https://travis-ci.org/dwiel/tensorflow_hmm.svg?branch=master)](https://travis-ci.org/dwiel/tensorflow_hmm)
# tensorflow_hmm
Tensorflow and numpy implementations of the HMM viterbi and forward/backward algorithms.
See [Keras example](https://github.com/dwiel/tensorflow_hmm/blob/master/tensorflow_hmm/hmm_layer.py) for an example of how to use the Keras HMMLayer.
See test_hmm.py for usage examples. Here is an excerpt of the documentation from hmm.py for reference for now.
See also viterbi_wikipedia_example.py which replicates the viterbi example on wikipedia.
```
class HMM(object):
"""
A class for Hidden Markov Models.
The model attributes are:
- K :: the number of states
- P :: the K by K transition matrix (from state i to state j,
(i, j) in [1..K])
- p0 :: the initial distribution (defaults to starting in state 0)
"""
def __init__(self, P, p0=None):
class HMMTensorflow(HMM):
def forward_backward(self, y):
"""
runs forward backward algorithm on state probabilities y
Arguments
---------
y : np.array : shape (T, K) where T is number of timesteps and
K is the number of states
Returns
-------
(posterior, forward, backward)
posterior : list of length T of tensorflow graph nodes representing
the posterior probability of each state at each time step
forward : list of length T of tensorflow graph nodes representing
the forward probability of each state at each time step
backward : list of length T of tensorflow graph nodes representing
the backward probability of each state at each time step
"""
def viterbi_decode(self, y, nT):
"""
Runs viterbi decode on state probabilies y.
Arguments
---------
y : np.array : shape (T, K) where T is number of timesteps and
K is the number of states
nT : int : number of timesteps in y
Returns
-------
(s, pathScores)
s : list of length T of tensorflow ints : represents the most likely
state at each time step.
pathScores : list of length T of tensorflow tensor of length K
each value at (t, k) is the log likliehood score in state k at
time t. sum(pathScores[t, :]) will not necessary == 1
"""
```
程序员Chino的日记
- 粉丝: 3743
- 资源: 5万+
最新资源
- cyuyan语言的基础学习
- 录屏软件亲测可用哦,非常好用
- 前端分析-2023071100789
- STM32无源蜂鸣器播放音乐《千与千寻》
- 前端分析-2023071100789
- 计算机网络基础知识与核心技术详析
- 模电课设(GKS-18光控声光循环灯说明书).doc
- HCIA笔记一些网络历史,TCP/IP,osi七层模型等等
- 语音助手多任务音频文本共享模型(AT-AT)用于提升端到端口语理解系统性能及零样本预测能力
- 【锂电池剩余寿命预测】CNN卷积神经网络锂电池剩余寿命预测,马里兰大学锂电池数据集(Pytorch完整源码和数据)
- 康熙字典mysql数据库表
- 同时语音翻译领域中大规模语言模型的应用与突破-CLASI系统研究
- 华为认证HCIA笔记(第一二天)
- 【锂电池剩余寿命预测】GRU门控循环单元锂电池剩余寿命预测,马里兰大学锂电池数据集(Pytorch完整源码和数据)
- 【锂电池剩余寿命预测】LSTM长短期记忆神经网络锂电池剩余寿命预测,马里兰大学锂电池数据集(Pytorch完整源码和数据)
- 西南交通大学数电实验考试资料
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈