Skip to content
Snippets Groups Projects
Commit af17ad08 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

wip

parent d006f7e3
No related branches found
No related tags found
No related merge requests found
<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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment