Files: Weight Files

Weight files are used for saving and restoring link weights and other link values. They can be written in binary or text. Links are traversed in standard traversal order, which iterates over groups in index order, over units in each group, and over incoming links to each unit. This ordering is highly dependent on the order in which the network was built, so the exact same code should be used to build the network from which values are saved and the network into which values are loaded.

Note that Lens does not use the same traversal order as Xerion. Xerion writes all bias links first and then traverses the other links in the same order as Lens. A Xerion text weight file may be loaded into Lens using the loadXerionWeights command.

Remember that if the structure of a network is randomized, as it may be when using sparse connectivity, you must save the random seed value before the network is built and reuse the same seed value to build equivalent networks that may share weight files. Otherwise, the weight files may appear to load properly (because the networks happen to have the same number of links) but the resulting network will produce garbage.

Weight files can either contain just the weights (1 value), the weights and the weight deltas (2 values), or the weights, deltas, and lastValues (3 values). num-values specifies which format is used.

The binary weight file is recognized because it begins with the magic cookie 0x55555556 (decimal 1431655766). It must be written with four-byte integers and four-byte reals. Both must be big-endian. When reading and writing binary files on your own, you can convert to standard network byte order and back to your computer's byte order using the ntohl() and htonl() commands. Note that PCs use little-endian order.

The binary and text formats are identical, except that the binary is written in binary with no extra bits and the text format allows arbitrary whitespace. The format specification is described in the Example Files page.

    <I magic-weight-cookie>
    <I total-number-of-links>
    <I num-values>
    <I totalUpdates>
    for each group:
      for each unit in group:
        for each incoming link to unit:
          <R link-weight>
	  if num-values >= 2:
            <R link-lastWeightDelta>
	  if num-values >= 3:
            <R link-lastValue>

Douglas Rohde
Last modified: Fri Nov 10 19:37:56 EST 2000