6bc6978ad31c2adda4540f059340dc61ce4fde3c,src/spn/experiments/RandomSPNs/train_mnist.py,,,#,65
Before Change
if __name__ == "__main__":
//rg = region_graph.RegionGraph(range(28 * 28))
rg = region_graph.RegionGraph(range(3 * 3))
for _ in range(0, 2):
rg.random_split(2, 2)
args = RAT_SPN.SpnArgs()
args.normalized_sums = True
spn = RAT_SPN.RatSpn(10, region_graph=rg, name="obj-spn", args=args)
print("num_params", spn.num_params())
sess = tf.Session()
sess.run(tf.global_variables_initializer())
dummy_input = np.random.normal(0.0, 1.2, [10, 9])
input_ph = tf.placeholder(tf.float32, [10, 9])
output_tensor = spn.forward(input_ph)
tf_output = sess.run(output_tensor, feed_dict={input_ph: dummy_input})
output_nodes = spn.get_simple_spn(sess)
simple_output = []
for node in output_nodes:
simple_output.append(inference.likelihood(node, dummy_input))
simple_output = np.stack(simple_output)
relative_error = simple_output / np.exp(tf_output)
print(np.average(relative_error) - 1)
// (train_im, train_labels), _ = load_mnist()
After Change
train_spn(spn, train_im, train_labels, num_epochs=3, sess=sess)
// dummy_input = np.random.normal(0.0, 1.2, [10, 9])
dummy_input = train_im[:5]
input_ph = tf.placeholder(tf.float32, dummy_input.shape)
output_tensor = spn.forward(input_ph)
tf_output = sess.run(output_tensor, feed_dict={input_ph: dummy_input})
output_nodes = spn.get_simple_spn(sess)
simple_output = []
for node in output_nodes:
simple_output.append(inference.log_likelihood(node, dummy_input)[:, 0])
// graphics.plot_spn2(output_nodes[0])
// graphics.plot_spn_to_svg(output_nodes[0])
simple_output = np.stack(simple_output, axis=-1)
print(tf_output, simple_output)
simple_output = softmax(simple_output, axis=1)
tf_output = softmax(tf_output, axis=1) + 1e-100
print(tf_output, simple_output)
relative_error = np.abs(simple_output / tf_output - 1)
print(np.average(relative_error))
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 8
Instances
Project Name: SPFlow/SPFlow
Commit Name: 6bc6978ad31c2adda4540f059340dc61ce4fde3c
Time: 2018-09-11
Author: stelzner@cs.tu-darmstadt.de
File Name: src/spn/experiments/RandomSPNs/train_mnist.py
Class Name:
Method Name:
Project Name: SPFlow/SPFlow
Commit Name: 6bc6978ad31c2adda4540f059340dc61ce4fde3c
Time: 2018-09-11
Author: stelzner@cs.tu-darmstadt.de
File Name: src/spn/experiments/RandomSPNs/train_mnist.py
Class Name:
Method Name:
Project Name: SPFlow/SPFlow
Commit Name: e83c4ba2424b141f626e8fc911286b7996649c62
Time: 2018-07-16
Author: stelzner@cs.tu-darmstadt.de
File Name: src/spn/experiments/RandomSPNs/train_mnist.py
Class Name:
Method Name:
Project Name: nipy/dipy
Commit Name: cc6478df56ca665559724b3ee49146a97fa7810d
Time: 2020-10-09
Author: grlee77@gmail.com
File Name: dipy/denoise/gibbs.py
Class Name:
Method Name: _gibbs_removal_1d