Machine Heart report
Edit: Egg sauce
AI writes AI, and it comes a little faster than expected.
Since its launch late last year, conversational AI model ChatGPT has caught fire 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 no longer live without it.
As an all-around player, people put all kinds of requirements for ChatGPT, some people use it to write papers, some people let it accompany the chat, these are common ways to play. Open the brain hole a little more, since ChatGPT is the "king" in AI, will it write an AI?
Recently, a blogger in the field of machine learning had a whim and decided to let ChatGPT build a neural network to solve the MNIST problem using Keras.
MNIST is a classic problem in the field of machine learning. Even if this handwritten digit dataset gradually fades out of the field of computer vision, its commemorative significance cannot be ignored, and the first dataset and the first experiment for many people to get started with deep learning and verify algorithms are MNIST.
Without further ado, I started work as soon as I thought of it. The author directly asked ChatGPT to write a piece of code that looked flawless and didn't even need to change anything.
This is a great start.
ChatGPT chose categorical cross-entropy as the loss function. The author proposes to rewrite the code of classification cross-entropy, and ChatGPT replaces it with sparse classification cross-entropy, and the updated code can still work. It can be found that the new loss function abandons the classification transformation of labels.
The code generated by ChatGPT uses a fully connected layer, but the author wants to use a convolutional layer. So ChatGPT modified the code as instructed and added a Conv2D and a MaxPooling layer.
Then came the evaluation of the final model, where the authors asked ChatGPT to write code using the test set.
The results look great, and every reply from ChatGPT comes with a full explanation. For example, in this assessment, it explains it this way:
The Evaluate method takes test data and test labels as parameters and returns the losses and measures specified during model compilation (in this case, accuracy). The above code snippet outputs the accuracy of the test, which should give you an idea of how generalized the model is for the new data
The model uses the entire test set as validation data during training. The authors then asked ChatGPT to change it to 20% of the training data.
In addition, authors want smaller batches and run less epoch code. While ChatGPT isn't necessary for this step, he doesn't want to change the code without updating the ChatGPT context.
So this task still falls to ChatGPT:
Next, the authors intend to plot the training and test losses during training. ChatGPT's recommendation is that you need to change the line that fits the model to capture its resulting value.
To show some examples in the dataset, the authors asked ChatGPT to write code to output a combination of images and tags. The code for these outputs is also perfect, with a collection of 20 images attached.
When building a model, it is also necessary to look at its structure. If you ask ChatGPT with this question, the response is:
ChatGPT gives a summary of the model:
A summary of the model is useful, but authors would prefer to see a diagram showing the structure of the model. So keep asking:
The result is satisfactory, and finally ready to deploy the model, let ChatGPT save the model to disk:
Now the author wants to create a class that uses the saved model for prediction. It's prompt it's fun and the solution is perfect.
Now write an example that uses the predictor's class to predict the labels of 10 random images:
To accomplish this, the authors had ChatGPT show a confusion matrix:
Needless to say, the style used by ChatGPT is really good-looking.
After all the experiments, the author has published all the ChatGPT-generated code, you can also try it:
Address: https://colab.research.google.com/drive/1JX1AVIfGtIlnLGqgHrK6WPylPhZvu9qe?usp=sharing