Object-Oriented for the CVM (Continued), and an Oops!

Object-Oriented for the CVM (Continued), and an Oops!

Why Shifting to the Object-Oriented Coding Approach REALLY IS Important:

 

Well, I hate having to admit it. Mud on my face; all that. But I made a pretty significant Whoops! back this last winter when I posted a “Verification and Validation” document (hah!) to arXiv.

 
Italian-renaissance-border-2-thin

 

The Sad Story of My Previous Ineptitude

 

Well, there’s nothing like hearing about someone else’s screw-up in order to make us feel better about our own life, so here goes.

I’d previously used straighforward, structured code to compute the configuration variables for the 2-D CVM.

The problem was, I was carrying over my thinking from the 1-D CVM, and going about things in a simple left-to-right manner.

What I totally missed was that both the z(i) and y(i) configuration variables for the 2-D case need to be computed going two rows up and down from a given node, and not just to the left and right of that node. Essentially, I missed half of each of the z(i) and y(i) variables.

Now, I don’t think that messed up the results too much. I think that the overall gist of what I found will hold true, even when I run what will be new code, on the same problem. (And thank God, that was exploratory work. And I can always post revisions on arXiv. NOW I know why there are so many revisions on some documents.)

The thing is, I didn’t learn about my mistake until I started developing the object-oriented approach. It was a lesson directly from Looking at Friends and Neighbors from a Node’s Point of View (Nodes, Nets, and Grids).

 
Italian-renaissance-border-2-thin

 

The Old Approach

 

I’m not going to say that the mistake was totally a function of my using a structured programming method. I’m still all in favor of structure.

The problem was in thinking about the nearest-neighbors and triplets for the configuration variables in a simple left-to-right sense, without looking at the full node topography.

Figure 1 shows my initial visualization looked like, for the 1-D CVM case.

A 1-D CVM grid with two instances of a base pattern.
Figure 1: A 1-D CVM grid with two instances of a base pattern.

Figure 2 shows how I was looking at the z(i) configuration variables.

The z(i) triplets in the 1-D CVM, showing how the triplets can be read left-to-right.
Figure 2: The z(i) triplets in the 1-D CVM, showing how the triplets can be read left-to-right.

This is fine, and it doesn’t need to be changed – for the 1-D case.

The problem was, I was still thinking about the same approach when I started work on the 2-D CVM.

 
Italian-renaissance-border-2-thin

 

The New Approach – Thinking in Object-Oriented Terms

 

It wasn’t until I started the object-oriented approach, and ran into snags just thinking of how I would identify all the configuration variables associated with a given node, that I found my error.

More specifically, I was thinking of how to “pad” an area around the 2-D CVM grid.

This is very analogous to how we create a “padded layer” when we work with a convolutional neural network (ConvNet). ConvNets are, of course, ubiquitous in the neural networks / deep learning community, so I’m only citing a single tutorial that shows ConvNet padding; anyone who wants to learn can find a plethora of excellent tutorials. The ConvNet padding allows the full masking filter to be used on edge and corner cells as well as interior ones.

Similarly, we need to create a “padded grid” in working with (an object-oriented form of) CVM. The reason is that when we compute the set of configuration variables for a given node, we need to look at the neighborhood of nodes around that given node. Looking just to the left and the right isn’t enough; we need to look up and down as well.

If I create a padded version of the CVM grid, I can use my old approach of working left-to-right, and top-to-bottom, addressing each node in the original CVM grid in turn. It’s easier if the computations can simply look left and right, and top and bottom, with regard to any particular specific node. Otherwise, for a node on the right edge, the code would have to go find the node on the left side that would be its neighbor, in the sense that we’re creating a CVM grid that is a full envelope; the rows connect with each other at the left-and-right, and top-and-bottom layers.

Now, I’ve been finding it immensely challenging to keep track of what node corresponds with what, in moving from the basic CVM grid to the padded one. However, that’s a subject for a different post.

For the moment, it suffices to illustrate how the z(i) triplet configuration variables really need to be considered, as illustrated in the following Figure 3.

For any node in a 2-D CVM grid, there are eight different associated z(i) triplets; four in the horizontal direction, and four vertical.
Figure 3: For any node in a 2-D CVM grid, there are eight different associated z(i) triplets; four in the horizontal direction, and four vertical.

 
Italian-renaissance-border-2-thin

 

Illustration of the Padded Grid for Object-Oriented CVM Computations

 

Figure 4 shows what it looks like when we pad around the edges of a 2-D CVM grid. For simplicity, the 2-D CVM grid really is a 1-D; it’s just got two rows. The point is just to show how the padding replicates the values that would be observed from making an “envelope” of the basic grid.

Illustration of a padded 2-D CVM grid. The activations for the padding nodes correspond to the activations of the "envelope" nodes - where the nodes on an  edge would connect with the other edge. Corner padding nodes have an activation of zero.
Figure 4: Illustration of a padded 2-D CVM grid. The activations for the padding nodes correspond to the activations of the “envelope” nodes – where the nodes on an edge would connect with the other edge. Corner padding nodes have an activation of zero.

 
Italian-renaissance-border-2-thin

 

Code Sharing – Yeah, Not Quite Yet

 

I will share code. Just not yet.

Right now, I’m still figuring out how to cross-reference the padding nodes vs. the originals; I’ve got two notations going on, and all of a sudden, just counting gets difficult.

More than that, I don’t have any real new code to share. The latest bit was a 1-D object-oriented case, it was posted on GitHub, and you’re welcome to it. (See the links below.)

In general, I’m going to wait to share until I’ve gone through not only my own V&V (blooper time!) and also run the code and results and every form of documentation and walkthrough that I can think of by just a few people.

It’s just a way to keep error proliferation down.

Until next week, folks!

 
Italian-renaissance-border-2-thin

 

Live free or die, my friend –

AJ Maren

Live free or die: Death is not the worst of evils.
Attr. to Gen. John Stark, American Revolutionary War

 
Italian-renaissance-border-2-thin
 

References & Resources

 

The Cluster Variation Method – Essential Papers

 

Previous Related Posts (and One That’s Forward-in-Time)

 

The 1D CVM – Code, Documentation, and V&V Documents (Including Slidedecks)

 
Italian-renaissance-border-2-thin
 

2 thoughts on “Object-Oriented for the CVM (Continued), and an Oops!

Leave a Reply

Your email address will not be published. Required fields are marked *