Home > Technology peripherals > AI > I used ChatGPT to write a neural network: I didn't change a word, and the result turned out to be very useful.

I used ChatGPT to write a neural network: I didn't change a word, and the result turned out to be very useful.

WBOY
Release: 2023-04-12 12:28:06
forward
1529 people have browsed it

Since its launch at the end of last year, the conversational AI model ChatGPT has become popular throughout the community.

ChatGPT is indeed an amazing tool, like a "Pandora's Box". Once you find the right way to open it, you may find that you can't live without it anymore.

As an all-rounder, people have various requests for ChatGPT. Some people use it to write papers, and some people use it to chat. These are common ways to play. Open your mind a little more. Since ChatGPT is the "king" of AI, will it write an AI?

Recently, a blogger in the field of machine learning had a sudden idea. He decided to let ChatGPT build a neural network and use Keras to solve the MNIST problem.

MNIST is a classic problem in the field of machine learning. Even though this handwritten digit data set has gradually faded out of the field of computer vision, its commemorative significance cannot be ignored. The first data set for many people to get started with deep learning and the first experiment to verify algorithms are MNIST.

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

Without saying much, I started working as soon as I thought of it. The author simply asked ChatGPT to write a piece of code that looked perfect without even having to change anything.

This is a great start.

ChatGPT chose categorical cross-entropy as the loss function. The author proposed to rewrite the categorical cross-entropy code, and ChatGPT replaced it with sparse categorical cross-entropy. The updated code can still work. It can be found that the new loss function gives up the classification conversion of labels.

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

The code generated by ChatGPT uses fully connected layers, but the author wants to use convolutional layers. Therefore, ChatGPT modified the code as instructed and added a Conv2D and a MaxPooling layer.

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

Then it came to the stage of evaluating the final model, where the author had ChatGPT write the code using the test set.

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

The results look great, and every ChatGPT reply comes with a full explanation. For example, in this evaluation, it is explained like this:

The "Evaluate" method takes the test data and test labels as parameters and returns the values ​​specified during model compilation (here, accuracy) Loss and Measurement. The code snippet above outputs the accuracy of the test, which should give you an idea of ​​how well the model generalizes to new data.

The model used the entire test set as validation data during training. The authors then asked ChatGPT to change this to 20% of the training data.

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

Additionally, the author wanted smaller batches and ran the code for fewer epochs. Although ChatGPT is not necessary for this step, he does not want to change the code without updating the ChatGPT context.

So this task still falls on ChatGPT:

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

Next, the author intends to plot the training and test loss during the training process. ChatGPT's suggestion is that the line fitting the model needs to be changed to capture its resulting value.

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

To show some examples from the dataset, the author asked ChatGPT to write code to output a combination of images and tags . The code for these outputs is also perfect and comes with a collection of 20 images.

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

When building a model, it is also necessary to look at its structure. If you ask ChatGPT this question, the reply is:

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

## ChatGPT gives a summary of the model:

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

A summary of the model is useful, but the author would have liked to see a diagram showing the structure of the model. So continue to ask:

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

##The result is satisfactory. Finally, we are ready to deploy this model and let ChatGPT Save the model to disk:

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

Now, the author wants to create a class that uses the saved model for prediction. This prompt is interesting and the solution is perfect.

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

Now write an example that uses the class of the predictor to predict the labels of 10 random images:

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

In order to accomplish this, the author asked ChatGPT to display a confusion matrix:

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

Should be said or not, The style used by ChatGPT is really nice.

I used ChatGPT to write a neural network: I didnt change a word, and the result turned out to be very useful.

After completing all the experiments, the author published all the codes generated by ChatGPT. You can also try it:

Address: https://colab.research.google.com/drive/1JX1AVIfGtIlnLGqgHrK6WPylPhZvu9qe?usp=sharing

The above is the detailed content of I used ChatGPT to write a neural network: I didn't change a word, and the result turned out to be very useful.. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:51cto.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template