GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — machine_learning_examples/hmm_class/tf_scan3.py at master · evalcoding/machine_learning_examples

Expand file tree

/

tf_scan3.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
43 lines (35 loc) · 1.18 KB
/

tf_scan3.py

Copy path

File metadata and controls

43 lines (35 loc) · 1.18 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# https://deeplearningcourses.com/c/unsupervised-machine-learning-hidden-markov-models-in-python
# https://udemy.com/unsupervised-machine-learning-hidden-markov-models-in-python
# https://lazyprogrammer.me
# tensorflow scan example - low pass filter
from __future__ import print_function, division
from builtins import range
# Note: you may need to update your version of future
# sudo pip install -U future
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
# original sequence is a noisy sine wave
original = np.sin(np.linspace(0, 3*np.pi, 300))
X = 2*np.random.randn(300) + original
plt.plot(X)
plt.title("original")
plt.show()
# set up placeholders
decay = tf.placeholder(tf.float32, shape=(), name='decay')
sequence = tf.placeholder(tf.float32, shape=(None,), name='sequence')
# the recurrence function and loop
def recurrence(last, x):
return (1.0-decay)*x + decay*last
lpf = tf.scan(
fn=recurrence,
elems=sequence,
initializer=0.0, # sequence[0] to use the first value of the sequence
)
# run it!
with tf.Session() as session:
Y = session.run(lpf, feed_dict={sequence: X, decay: 0.97})
plt.plot(Y)
plt.plot(original)
plt.title("filtered")
plt.show()
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.