From af17ad08f166af95d44bea899ff6f51a0524c99e Mon Sep 17 00:00:00 2001 From: Neil Gershenfeld <gersh@cba.mit.edu> Date: Sun, 18 Nov 2018 09:11:10 -0500 Subject: [PATCH] wip --- TensorFlow/tfpi.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 TensorFlow/tfpi.html diff --git a/TensorFlow/tfpi.html b/TensorFlow/tfpi.html new file mode 100644 index 0000000..94a661d --- /dev/null +++ b/TensorFlow/tfpi.html @@ -0,0 +1,25 @@ +<html> +<body> +<script src=tf.min.js></script> +<script> +// +// tfpi.html +// Neil Gershenfeld 11/18/18 +// TensorFlow.js pi calculation benchmark +// pi = 3.14159265358979323846 +// +const points = 1e7 +const a = tf.scalar(0.5) +const b = tf.scalar(0.75) +const c = tf.scalar(0.25) +const tstart = Date.now()/1000 +const index = tf.range(1,points) +const sum = tf.sum(tf.div(a,tf.mul(index.sub(b),index.sub(c)))) +const tend = Date.now()/1000 +const mflops = points*5.0*1e-6/(tend-tstart); +document.write('pi: '+sum.toString()) +document.write('<br>') +document.write('time: '+(tend-tstart).toFixed(1)+'s') +document.write('<br>') +document.write('estimated MFlops: '+mflops) +</script> -- GitLab