{"id":13454785,"url":"https://github.com/dwiel/tensorflow_hmm","last_synced_at":"2026-01-14T09:38:28.792Z","repository":{"id":57474151,"uuid":"53764752","full_name":"dwiel/tensorflow_hmm","owner":"dwiel","description":"A tensorflow implementation of an HMM layer","archived":false,"fork":false,"pushed_at":"2018-01-23T18:11:27.000Z","size":1023,"stargazers_count":284,"open_issues_count":4,"forks_count":80,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-11-28T03:41:41.013Z","etag":null,"topics":["hmm","tensorflow","tensorflow-hmm","viterbi"],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dwiel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-13T03:00:15.000Z","updated_at":"2025-08-23T12:07:14.000Z","dependencies_parsed_at":"2022-09-12T19:40:19.608Z","dependency_job_id":null,"html_url":"https://github.com/dwiel/tensorflow_hmm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dwiel/tensorflow_hmm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwiel%2Ftensorflow_hmm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwiel%2Ftensorflow_hmm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwiel%2Ftensorflow_hmm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwiel%2Ftensorflow_hmm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dwiel","download_url":"https://codeload.github.com/dwiel/tensorflow_hmm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwiel%2Ftensorflow_hmm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28416120,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hmm","tensorflow","tensorflow-hmm","viterbi"],"created_at":"2024-07-31T08:00:57.932Z","updated_at":"2026-01-14T09:38:28.777Z","avatar_url":"https://github.com/dwiel.png","language":"Jupyter Notebook","funding_links":[],"categories":["Models/Projects","Jupyter Notebook","模型项目"],"sub_categories":["微信群"],"readme":"[![Build Status](https://travis-ci.org/dwiel/tensorflow_hmm.svg?branch=master)](https://travis-ci.org/dwiel/tensorflow_hmm)\n\n# tensorflow_hmm\nTensorflow and numpy implementations of the HMM viterbi and forward/backward algorithms.\n\nSee [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.\n\nSee [test_hmm.py](https://github.com/dwiel/tensorflow_hmm/blob/master/test/test_hmm.py) for usage examples.  Here is an excerpt of the documentation from hmm.py for reference for now.\n\nSee also viterbi_wikipedia_example.py which replicates the viterbi example on wikipedia.\n\n```\nclass HMM(object):\n    \"\"\"\n    A class for Hidden Markov Models.\n\n    The model attributes are:\n    - K :: the number of states\n    - P :: the K by K transition matrix (from state i to state j,\n        (i, j) in [1..K])\n    - p0 :: the initial distribution (defaults to starting in state 0)\n    \"\"\"\n\n    def __init__(self, P, p0=None):\n\nclass HMMTensorflow(HMM):\n      def forward_backward(self, y):\n          \"\"\"\n          runs forward backward algorithm on state probabilities y\n      \n          Arguments\n          ---------\n          y : np.array : shape (T, K) where T is number of timesteps and\n              K is the number of states\n      \n          Returns\n          -------\n          (posterior, forward, backward)\n          posterior : list of length T of tensorflow graph nodes representing\n              the posterior probability of each state at each time step\n          forward : list of length T of tensorflow graph nodes representing\n              the forward probability of each state at each time step\n          backward : list of length T of tensorflow graph nodes representing\n              the backward probability of each state at each time step\n          \"\"\"\n      \n      \n      def viterbi_decode(self, y, nT):\n          \"\"\"\n          Runs viterbi decode on state probabilies y.\n      \n          Arguments\n          ---------\n          y : np.array : shape (T, K) where T is number of timesteps and\n              K is the number of states\n          nT : int : number of timesteps in y\n      \n          Returns\n          -------\n          (s, pathScores)\n          s : list of length T of tensorflow ints : represents the most likely\n              state at each time step.\n          pathScores : list of length T of tensorflow tensor of length K\n              each value at (t, k) is the log likliehood score in state k at\n              time t.  sum(pathScores[t, :]) will not necessary == 1\n          \"\"\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwiel%2Ftensorflow_hmm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwiel%2Ftensorflow_hmm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwiel%2Ftensorflow_hmm/lists"}