2
$\begingroup$

Does artificial intelligence write its own code and then execute it? If so, does it create separate functions for each purpose?

$\endgroup$
0

3 Answers 3

2
$\begingroup$

Does artificial intelligence write its own code and then execute it? If so, does it create separate functions for each purpose?

Artificial intelligence comprises more than one technique. Here you seem to be asking about machine learning, a subfield of AI which itself contains many subfields.

Self-modifying code is one of the (many) techniques used in some applications of artificial intelligence. So, in that sense, the answer to your question is "yes".

In Neural Networks (NNs), for example, the NN isn't writing any code, it is just running through an optimization algorithm (and back-propagation) that incrementally changes some weights (or coefficients) such that when you enter a certain input, you get an output that's close to the desired output.

You also have genetic algorithms (GA) to evolve the weights of a neural network, as opposed to using back-propagation. GAs are closer to the idea of "an AI coding itself" (although not exactly).

$\endgroup$
0
1
$\begingroup$

Computers are able to write their own code without needing any intelligence -- see the Wikipedia entries for self-modifying code and metaprogramming. You do have to write the instructions for how the computer should program itself, and there's a stigma against doing this because (a) it makes it hard to reason about what your program is doing when it's changing its source code, and (b) the solution is usually slower than just hardcoding in what you want the program to do in the first place. But it is possible, and programmers have done it (usually for maintainability or aesthetic reasons).

Some AI researchers are interested in Genetic Programming though. Genetic Programming is a subset of evolutionary algorithms and Wikipedia provides a good summary of how they usually work:

Step One: Generate the initial population of individuals randomly. (First generation)

Step Two: Evaluate the fitness of each individual in that population

Step Three: Repeat the following regenerational steps until termination (time limit, sufficient fitness achieved, etc.):

  • Select the best-fit individuals for reproduction. (Parents)

  • Breed new individuals through crossover and mutation operations to give birth to offspring.

  • Evaluate the individual fitness of new individuals.

  • Replace least-fit population with new individuals.

The "individuals" in this case are randomly-generated computer programs, which are then tested against a fitness function.

The Wikipedia page for Genetic Programming claimed that these programs are usually represented by tree structures, though there has been some experiments in using non-tree structures as well.

$\endgroup$
1
$\begingroup$

I think the answer is most likely no, not in the most notable examples of AI programs (such as Machine Learning). There is a set of AI techniques which involve automatic programming, but in that scenario, we have a computer program which automatically codes another program (we can call it "target program"). But the target program is not the program which perfoms the coding; so technically speaking, no, it does not write its own code. This is an important difference; the programmer still has the task to write the code-generator.

If you are interested in automated coding, though, the most notable example is Genetic Programming, a technique which uses an evolutionary algorithm to breed computer programs. As you can see, we have an AI which produces as a result a computer program (which may be or not an AI program); it is not interacting with its own code.

As a final remark, note that automatic coding is a pretty vague term and not all techniques are AI-related (for instance, back then, the first compilers were seen as a form of automatic programming). The most relevant techinque to your question is probably Program Synthesis.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .