# data[].attributes.headline
[做了什麼? 如何解決困難? 想到什麼? 未

# data[].attributes.body
[做了什麼? 如何解決困難? 想到什麼? 未來應用?]

這次的學習經驗讓我深刻地體會到了資訊科技的應用價值，也讓我知道如何在生活上使用利用資訊科技。相信在某一天的未來我會依靠資訊科技創造出對人類有貢獻的價值。

# data[].attributes.attachment_link.description
Train a computer to recognize your own images, sounds, & poses. A fast, easy way to create machine learning models for your sites, apps, and more - no expertise or coding required.

# data[].attributes.headline
在這個資訊科技課上，老師安排了一個非常有趣的

# data[].attributes.body
在這個資訊科技課上，老師安排了一個非常有趣的活動，讓我們利用Google的Teachable Machine平台進行影像識別，它可讓每個人快速且輕鬆地建立機器學習模型。

我們運用在課堂上所學到的知識，並且將其應用到實際的情境中去。我所在的小組對這個任務充滿了興趣和熱情，我們迫不及待地開始了這個挑戰。

# data[].attributes.attachment_link.description
Train a computer to recognize your own images, sounds, & poses. A fast, easy way to create machine learning models for your sites, apps, and more - no expertise or coding required.

# data[].attributes.attachment_link.title
Teachable Machine - Saving and sharing your model

# data[].attributes.headline
Epoch, Batch size, Iteration, Learning Rate

# data[].attributes.subject
Epoch, Batch size, Iteration, Learning Rate

# data[].attributes.attachment_link.readable_text
之前文章提到過梯度下降（Gradient descent），在每次計算誤差後會做偏微分來更新權重，這邊我放個公式方便回想：

更新的程度會由 ∇E（Gradient）乘上一個 「 η（Learning rate）」 來決定，而這邊的 ∇E 會受到一次丟給神經網路做運算的資料量影響，所以 Batch size 會影響神經網路收斂過程中，往 Minima 前進的速度與方向。

接下來沿用之前 Gradient descent 文章的實作來呈現 Batch size 對於收斂過程的影響。

這次的設定與之前些微不同，差異之處在於資料集總共有 2 筆資料，這樣才能比較 Batch size 數值大小所產生的差異。

我先在每次 Iteration 運算整個資料集，然後訓練 25 個 Epoch，結果像這個樣子：

結果並不意外，與之前只有1筆資料的收斂過程類似。

接著來看 Batch size = 1 的樣子，因為每個Iteration從運算 2 筆資料變成 1 筆，為了讓運算量接近，將 Epoch 調整成 50，結果像這樣子：

先以運算時間相同為前提來說明：

Batch size 大的時候，因為考量了比較多的數據，修正的方向會比較準確，但因為每次 Iteration 要算比較久，往 Minima 前進的次數就相對小。

Batch size 相對小的時候，因為只有考量局部數據，所以修正的方向會出現偏差，但因為每次 Iteration 要計算的資料量比較少，就有機會在同樣的時間成本下，修正比較多次。

Batch size = 1，又被稱為 Incremental mode，因為一次 Iteration 只需要算一筆資料，所以權重會被非常頻繁地更新，但因為方向較不準確，就會像是橫衝直撞一般，雖然快速但就整體而言不見得比較有效率，很多時候可能只是走冤枉路。

那我們回到真實訓練模型的過程，要花多少時間訓練模型其實沒有一定的標準，都是開發者自己要去決定的。我可以用較大的 Batch size 搭配較大的 η，那結果可能是不用那麼多的 Epoch 就能達到我的期望。

相對的，如果我想用 Batch size = 1 的條件下去訓練，那可能就要配置較小的 η，才不會在接近 Minima 的時候來回走動，也就不用走太多冤枉路。但也因為 η較小，我可能就需要比較多的 Epoch 才會走到 Minima。

# data[].attributes.attachment_link.title
Epoch, Batch size, Iteration, Learning Rate

# data[].attributes.attachment_link.description
這幾個字眼在訓練 AI model 或閱讀 Paper 時都很常出現，這篇文章會以簡單的舉例來說明它們之間的關係。

# data[].attributes.attachment_link.readable_text
As a museum goer, I have slowly got acquainted with the works of Vermeer, Rembrandt, Caravaggio and other prolific old masters. Even though I am a casual art lover and their works did cover a wide range of subjects, from biblical, mythical to genre art, there seems to be certain individual styles that distinguish one from another. In fact, these unique styles became their signatures and were well documented online. But more often than not, I was often surprised by how different some first-seen Rembrandts are from his other works. In those cases, I would have wrongfully concluded those are someone else's works.

Before the NFT, art authentification is not always straightforward. It is more than just about determining the author of a painting, but also about telling the fake from the real. On the one hand, artists were under constant influence from others and pick up styles from their teachers and peers. On the other hand, forgers tried their best to mimic the works from the more famous masters, from colors, texture to craquelure. One example is the Dutchman Han van Meegeren. Meegeren forged Vermeer's works so masterfully that not only experts at that time were fooled, but even Hermann Göring was tricked into buying one of his "Vermeer": Christ with the Adulteress (Figure 1). After the war, he was put to trial for selling such a Vermeer to the enemy. Meegeren finally proved to the Dutch publics what Göring got was his forgery. And he was acquitted for colluding with the Nazi but sent to a year in prison for fraud.

So is there a way for us, who have a little something in machine learning and nothing in art, to authenticate these paintings? And when we do go down this machine learning road, can we start with something simple first? The answers are yes! What is more, even though we don't not have any provenance, forensic, electron microscopic and chemical data and we don't know how to build the perfect Keras models by hand, we can still tell Vermeer from van Meegeren apart, just by using the paintings themsevles and without a single line of code! Introducing Goolge's Teachable Machine.

According to its own FAQ:

Teachable Machine is a web-based tool that makes creating machine learning models fast, easy, and accessible to everyone.

So basically we can upload or webcam images, audios or poses from different categories (or classes) and let Teachable Machine to learn the different "styles". Afterwards, we can test how well it learned by giving it some new test files. It will classify the files and output the probabilities for each class. Finally, we can deploy the model created by Teachable Machine for our own purpose. For example, you can download the Tensorflow model or simply get a sharable link to get an online deployment.

In this article, I am going to show you how to use Teachable Machine to test authenticate the known works of Vermeer, van Meegeren, and some other masters. So let's get started. All the data for this project is hosted in my Github repository here: https://github.com/dgg32/teachable-machine-paintings.

For this project, we need the works from artists such as Vermeer, van Meegeren, Rembrandt, Caravaggio and Bouguereau. For this reason, I downloaded their masterworks from Wikipedia. Please git clone my repo and you will see I have set up two folders: train and test. Images in the "train" folder are going to serve as training data while the ones in "test" folder are for testing the model, so that we can get a sense of how well the model is going to perform at unseen data.

Let's start with what the title suggested - to tell whether the test paintings are Vermeer or not. So far, according to Wikipedia, there are 34 paintings firmly attributed to Vermeen while the other three are questionable. So I put the three questionable ones and two of his most iconic paintings as tests. In the "Not Vermeer" camp, I could only find eight paintings by van Meegeren online, therefore we need to supplement this set a bit to give Teachable Machine more training examples. In this case, I decided to add the works from Rembrandt to the "Not Vermeer" side. Rembrandt was Vermeer's Dutch contemporary. Both masters left corpora of portraits. I have thought about adding the works from a third Dutch golden age artist Jan Steen, my personal favorite. But compared to Vermeer's mostly single portraits, Steen's works mostly feature a large crowd. In addition, Steen's works are visually quite recognizable for the signature smirk on his characters' faces. That would have been too easy for Teachable Machine and so I decided not to include Steen. So for this round, I ended up with 32 Vermeer and 44 "Not Vermeer" for the training, and five Vermeer and six "Not Vermeer" for the test.

Now go ahead to Teachable Machine, click "Get Started" -> "Image Project". In the "Class 1" box, change the label to "Vermeer" and upload the images from my train/vermeer folder. In "Class 2", change the label to "Not Vermeer" and upload the images from train/meegeren and train/rembrandt. And then move to the middle box and click "Train Model". Wait a short while until the training is finished.

In the "Training" box, click "Advanced" -> "Under the hood" and then inspect "Accuracy per class", "Confusion Matrix" and so on in the sidebar. These data are the internal validation results during the training. In my case, four out of five Vermeer were correct (80%) and all "Not Vermeer" are correct (100%).

Now let's give the model some paintings from the test folder, so that we can see how well it performs. On the right panel, switch "Webcam" to "File". Upload the images from test/vermeer, test/meegeren and test/rembrandt one by one. And you can see the predicted probabilities for each class for each image.

As you can see from Figure 2. and 3., the model I trained did really well in the tests. Vermeer's two most famous paintings: the Milkmaid and Girl with a Pearl Earring got 98% and 100% probabilities in the "Vermeer" class. Two of the three questionable could also be classified as "Vermeer", even though A Young Woman Seated at the Virginals just got 86% in "Vermeer".

The third one, Girl with a Fluteis a curious case. Its attribution to Vermeer is contested. The girl's jacket and pearl earring remind us of other Vermeer's female portraits. Especially her facial expression is quite similar to the Girl with a Red Hat, which was also in the training data. The rigidity of her facial execution is perhaps the reason why the model rejected it as a Vermeer.

As to the "Not Vermeer" paintings, the test results were clear-cut. The model gives some credits to van Meegeren. Although both his Vermeer fakes - his first "early Vermeer" and the one sold to Göring, were flagged, they still got 8% and 10% of "Vermeerness". All four Rembrandt were 100% not Vermeer.

Here is the model that I trained: https://teachablemachine.withgoogle.com/models/Jzud_4PE8/.

The model we built above did its job well. But it is in essence a binary classification model - only two classes in the race. It is considered to be a relatively easy task: even though we did not provide the model with many paintings, it performed surprisingly well. Now let's push Teachable Machine further to the limit by giving it a multiclass classification problem. In this case, I included Caravaggio and Bouguereau to see how well the model can distinguish works with a different style or from a different period.

Now create four classes in Teachable Machine: "Vermeer", "Rembrandt", "Caravaggio" and "Bouguereau", upload the corresponding training images, train the model and inspect what is "under the hood". You can again test it with the images in the test folder. It is worth noting that even though van Meegeren was not in the training set in this trial, you can still use his works in test to see whether the model will fall for it this time.

Above are the ten test results of my model. Again, the new model firmly recognized Girl with a Pearl Earring as an unmistaking Vermeer. But then it was not so sure about A Young Woman Seated at the Virginals like my previous model. Perhaps its chiaroscuro elements reminded it of Caravaggio. The model apparently struggled a bit for Vermeer (33%) but then attributed it to the Italian master. Girl with a Flute was rejected as a Vermeer again, even though it got 16% probability in "Vermeer" this time versus 0% last time.

van Meegeren's works still got no chance of being recognized as Vermeer. The model still saw some elements of Vermeer in them, but the probabilities of being Vermeer were even lower here compared to my previous model.

Rembrandt's chiaroscuro and his color palette rival that of Caravaggio's. But the model can tell the two Baroque masters apart with ease. For a human spectator, the sharp contour in Conversion on the Way to Damascus is a good indication that the work was out of Caravaggio's hands.

As to Bouguereau, the model successfully picked out all three his paintings. The little "Caravagesques" in Tobias Saying Farewell to his Father probably came from its color palette mainly in yellow, brown and red and its dark shadow. But its neoclassic, academistic and even a bit Art Nouveau features are perhaps too strong for the model to misclassify it. The bright skin tones and ideal figures in both the Holy family and Baigneuse are distinct Bouguereau's giveaways.

Here is the model that I trained: https://teachablemachine.withgoogle.com/models/gLIwpTQL-/.

# data[].attributes.attachment_link.title
Hey Google Teachable Machine: Is this a Vermeer or a van Meegeren?

# data[].attributes.attachment_link.description
As a museum goer, I have slowly got acquainted with the works of Vermeer, Rembrandt, Caravaggio and other prolific old masters. Even though I am a casual art lover and their works did cover a wide...

# data[].attributes.body
每 3 個透過您的連結註冊的朋友可以讓您獲得一個免費的 padlet 看板。

您的朋友也會獲得一個免費的 padlet 看板。

# data[].attributes.body
首先，我們討論了我們想要建立的影像識別模型。我們決定要建立一個可以區分蝦子和螃蟹的模型。這個想法既有趣又具有挑戰性，因為我們需要收集各種動物的圖像資料，並確保模型能夠正確地識別它們。

接著，我們開始收集圖像資料。我們利用網路搜索引擎和圖像庫，找到了許多不同種類的蝦子和螃蟹照片。我們盡可能地收集了多樣性的圖片，以確保我們的模型能夠辨識不同品種的貓蝦子和螃蟹。

資料的品質會直接影響到模型的性能，平台建議上傳 244x244像素的彩圖，為確保圖庫的圖片尺寸和品質一致，本組直接利用關鍵字搜尋蝦子和螃蟹照片，下載縮圖建立圖片庫，這是建立一個準確模型的重要步驟。

# data[].attributes.body
Epoch、Batch size、Learning rate

參數調整

# data[].attributes.body
從測試資料夾中為模型提供一些新的螃蟹和蝦子照片，測試結果如何呢?

我們可以看到每個影像的每個類別的預測機率，這個模型的辨識率高達100%。

# data[].attributes.headline
從測試資料夾中為模型提供一些新的螃蟹和蝦子照

# data[].attributes.body
從測試資料夾中為模型提供一些新的螃蟹和蝦子照片，測試結果如何呢?

我們可以看到每個影像的每個類別的預測機率，這個模型的辨識率高達100%。

# data[].attributes.headline
完成資料前處理後，我們開始使用Teachab

# data[].attributes.body
完成資料前處理後，我們開始使用Teachable Machine平台建立模型。我們將資料輸入到平台上，並選擇了適合的模型架構和參數設定。然後，我們對模型進行了訓練，不斷地調整和優化，直到我們得到了我們滿意的結果。