Published
Edited
May 15, 2019
Importers
1 star
Insert cell
Insert cell
Insert cell
tensor = f => ({
meta: () => { const t = tf.tidy( f ); t.dispose(); return t },
data: () => { const t = tf.tidy( f ); return t.data().then( d => { t.dispose(); return d; } ) },
over: (that) => { const t = tf.tidy( f ); if(that) that.dispose(); return t },
view: (that,name) => { const t = tf.tidy( f ); if(that) that.value.dispose(); return pt( t , {name:name} ) }
})
Insert cell
Insert cell
Insert cell
now, tf.memory().numTensors
Insert cell
Insert cell
leak_button, tf.ones([4,4])
Insert cell
Insert cell
Insert cell
tensor( () => tf.ones([4,4]) ).meta()
Insert cell
Insert cell
tf.ones([4,4]).dispose()
Insert cell
Insert cell
tensor( () => tf.ones([4,4]) ).data()
Insert cell
Insert cell
reference = tensor( () => tf.ones([4,4]) ).over(this)
Insert cell
Insert cell
pt(reference)
Insert cell
Insert cell
viewof t = tensor( () => tf.ones([4,4]) ).view(this)
Insert cell
t
Insert cell
Insert cell
viewof just_a_tensor = tensor( () => tf.ones([4,4]) ).view(this,"just_a_tensor")
Insert cell
Insert cell
now, tf.memory().numTensors
Insert cell
Insert cell
no_leak_button, tensor( () => tf.ones([4,4]) ).meta()
Insert cell
no_leak_button, tensor( () => tf.ones([4,4]) ).data()
Insert cell
ref = no_leak_button, tensor( () => tf.ones([4,4]) ).over(this)
Insert cell
viewof z = no_leak_button, tensor( () => tf.ones([4,4]) ).view(this)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more