[![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
"""
```
没有合适的资源?快使用搜索试试~ 我知道了~
tensorflow_hmm-0.4.1.tar.gz
需积分: 1 0 下载量 3 浏览量
2024-03-02
13:15:30
上传
评论
收藏 7KB GZ 举报
温馨提示
共14个文件
py:6个
txt:4个
pkg-info:2个
TensorFlow是一个开放源代码的软件库,用于进行高性能数值计算。通过其灵活的架构,它允许用户轻松地部署计算工作在各种平台(CPUs、GPUs、TPUs)上,无论是在桌面、服务器还是移动设备上。TensorFlow最初由Google Brain团队(属于Google的人工智能部门)开发,并在2015年被发布到Apache 2.0开源许可证下。 TensorFlow的主要特点包括它的高度灵活性、可扩展性和可移植性。它支持从小到大的各种计算,从手机应用到复杂的机器学习系统。TensorFlow提供了一个全面的、灵活的生态系统的库、工具和社区资源,使研究人员能够推动人工智能领域的最前沿,并使开发人员能够轻松构建和部署由机器学习驱动的应用。 TensorFlow的核心是使用数据流图来表示计算。在数据流图中,节点表示在数据上执行的操作,而图中的边表示在操作之间流动的数据。这种表示法允许TensorFlow有效地执行并行计算,并且可以在不同的硬件平台上高效运行。此外,TensorFlow支持自动微分,这对于实现复杂的机器学习算法(如深度学习网络)至关重要。
资源推荐
资源详情
资源评论
收起资源包目录
tensorflow_hmm-0.4.1.tar.gz (14个子文件)
tensorflow_hmm-0.4.1
tensorflow_hmm
__init__.py 41B
hmm_layer.py 3KB
hmm.py 14KB
setup.py 446B
PKG-INFO 344B
tensorflow_hmm.egg-info
SOURCES.txt 320B
top_level.txt 15B
PKG-INFO 344B
requires.txt 13B
dependency_links.txt 1B
test
test_keras.py 0B
test_hmm.py 8KB
setup.cfg 38B
README.md 2KB
共 14 条
- 1
资源评论
程序员Chino的日记
- 粉丝: 3044
- 资源: 4万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功