<commit_before>package ml.wolfe.examples

/**
 * @author <NAME>
 */
object GridExample {

  import ml.wolfe.Wolfe._
  import ml.wolfe.macros.OptimizedOperators._

  type Image = Map[(Int, Int), Boolean]

  def main(args: Array[String]) {
    val n = 10
    val l_w = 1.0
    val l_g = 0.1
    def pixels = (0 until n) x (0 until n)
    def images = maps(pixels, bools)
    def local(x: Image)(y: Image) = sum(pixels) { p => l_w * I(x(p) == y(p)) }
    def vertical(y: Image) = sum(0 until n - 1) { i => sum(0 until n) { j => l_g * I(y(i, j) == y(i + 1, j)) } }
    def horizontal(y: Image) = sum(0 until n) { i => sum(0 until n - 1) { j => l_g * I(y(i, j) == y(i, j + 1)) } }
    def grid(x: Image)(y: Image) = local(x)(y) + vertical(y) + horizontal(y)
    def stats(y: Image) = sum(pixels) { p => oneHot(p, I(y(p))) }

    val x = (pixels map { p => p -> random.nextBoolean() }).toMap<commit_msg>fixed naming of weights in grid<commit_after>package ml.wolfe.examples

/**
 * @author <NAME>
 */
object GridExample {

  import ml.wolfe.Wolfe._
  import ml.wolfe.macros.OptimizedOperators._

  type Image = Map[(Int, Int), Boolean]

  def main(args: Array[String]) {
    val n = 10
    val l_w = 1.0
    val g_w = 0.1
    def pixels = (0 until n) x (0 until n)
    def images = maps(pixels, bools)
    def local(x: Image)(y: Image) = sum(pixels) { p => l_w * I(x(p) == y(p)) }
    def vertical(y: Image) = sum(0 until n - 1) { i => sum(0 until n) { j => g_w * I(y(i, j) == y(i + 1, j)) } }
    def horizontal(y: Image) = sum(0 until n) { i => sum(0 until n - 1) { j => g_w * I(y(i, j) == y(i, j + 1)) } }
    def grid(x: Image)(y: Image) = local(x)(y) + vertical(y) + horizontal(y)
    def stats(y: Image) = sum(pixels) { p => oneHot(p, I(y(p))) }

    val x = (pixels map { p => p -> random.nextBoolean() }).toMap
{'fraction_non_alphanumeric': 0.19426048565121412, 'fraction_numerical': 0.017660044150110375, 'mean_word_length': 2.8411016949152543, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1564876', 'n_tokens_mistral': 773, 'n_tokens_neox': 743, 'n_words': 218}