iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📘

Chapter 5: Visualizing Arrays as Colors

に公開

- Drawing Weights -

In this chapter, we will experience
visually seeing something that likely exists inside an AI.

It's finally appearing.

Weights

We won't do anything difficult yet.
We won't even perform any training.

However, by the time you finish this chapter,

"Oh, so this is what the inside of an AI looks like."

a feeling of understanding will surely remain.


What We Will Do in This Chapter

  • Prepare an array (a large set of numbers)
  • Convert the numbers into "colors"
  • Display them side-by-side on the screen

This is our goal.

To see a collection of numbers as a meaningful "structure"


What is an Array?

An array is a very simple thing.

  • Numbers are
  • Many of them
  • Lined up

That is all.

But inside an AI,

Weights are almost entirely expressed as "arrays"


  • MYON
    "Aren't weights something more special than that?"

  • EDiE
    "Their true identity is just a collection of numbers."


Let's Start by Creating an Array

Please copy and paste the following code into Processing.

float[] weights = new float[100];

void setup() {
  size(500, 100);

  for (int i = 0; i < weights.length; i++) {
    // Set random weights between -1 and 1
    weights[i] = random(-1, 1);
  }
}

void draw() {
  background(240);

  for (int i = 0; i < weights.length; i++) {
    float w = weights[i];

    if (w > 0) {
      // Positive weights are reddish
      fill(255, 100, 100);
    } else {
      // Negative weights are bluish
      fill(100, 100, 255);
    }

    float h = abs(w) * height;
    rect(i * 5, height - h, 5, h);
  }
}

Success Conditions

  • Bars are displayed side-by-side
  • A mix of reddish and bluish bars
  • Varying heights

If you see this, you have succeeded.


  • MYON
    "...It suddenly feels like AI."

  • EDiE
    "Yes. But for now, it's just a 'picture'."


What Are We Drawing?

What is being displayed on the screen now consists only of:

  • 100 numbers
  • Positive and negative values
  • Differences in magnitude

That is all. However, you will want to call this:

Weight Distribution

Inside an AI, these are numbers that play roles such as:

  • Being multiplied by input
  • Being added together
  • Influencing the output

Moving Them Just a Little

Next, let's try changing the weights little by little.

void draw() {
  background(240);

  for (int i = 0; i < weights.length; i++) {
    // Add a small random change
    weights[i] += random(-0.01, 0.01);
    // Keep the value between -1 and 1
    weights[i] = constrain(weights[i], -1, 1);

    float w = weights[i];

    if (w > 0) {
      fill(255, 100, 100);
    } else {
      fill(100, 100, 255);
    }

    float h = abs(w) * height;
    rect(i * 5, height - h, 5, h);
  }
}

Success Conditions (Part 2)

  • The height and color of the bars
  • Change slowly

Please watch it for a while.


  • MYON
    "Is it... alive?"

  • EDiE
    "No. It's just changing."


But, People Feel This Way

  • It is changing
  • It is being maintained
  • It is cohesive as a whole

Just because of this, people think:

"It has an internal state."

This is one of the reasons why AI appears to "possess an inner life."


Column: Why Showing "Weights" Makes Sense

Even when looking at a list of numerical values, many people don't get the point. However, when you convert them into:

  • Colors
  • Heights
  • Sequences

Suddenly, it makes sense.

Structure is understood visually.

Having this sense will also change how you look at mathematical formulas.


To the Next Chapter

In the next chapter, we will try to change these "weights":

  • Toward a goal
  • Little by little

The theme is:

"Drawing the state of changing values"
― Doing something like training ―

Finally, we head into a world that "looks like it is learning."


Discussion