<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Reza Chu on Medium]]></title>
        <description><![CDATA[Stories by Reza Chu on Medium]]></description>
        <link>https://medium.com/@rezachu?source=rss-e9567d539e15------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HKjkwUxmhRcaScVZYljL0Q.jpeg</url>
            <title>Stories by Reza Chu on Medium</title>
            <link>https://medium.com/@rezachu?source=rss-e9567d539e15------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 13:24:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rezachu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Speech Emotion Recognition with Convolution Neural Network]]></title>
            <link>https://medium.com/data-science/speech-emotion-recognition-with-convolution-neural-network-1e6bb7130ce3?source=rss-e9567d539e15------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e6bb7130ce3</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[speech-recognition]]></category>
            <category><![CDATA[emotion-recognition]]></category>
            <dc:creator><![CDATA[Reza Chu]]></dc:creator>
            <pubDate>Sat, 01 Jun 2019 06:52:17 GMT</pubDate>
            <atom:updated>2021-07-30T16:51:11.868Z</atom:updated>
            <content:encoded><![CDATA[<h3>Speech Emotion Recognition with Convolutional Neural Network</h3><h4>Recognizing Human Emotion from Audio Recording</h4><p>Recognizing human emotion has always been a fascinating task for data scientists. Lately, I am working on an experimental Speech Emotion Recognition (SER) project to explore its potential. I selected the most starred SER repository from <a href="https://github.com/MITESHPUTHRANNEU/Speech-Emotion-Analyzer"><strong>GitHub</strong></a> to be the backbone of my project.</p><p>Before we walk through the project, it is good to know the major bottleneck of Speech Emotion Recognition.</p><h4><strong>Major Obstacles:</strong></h4><ul><li>Emotions are subjective, people would interpret it differently. It is hard to define the notion of emotions.</li><li>Annotating an audio recording is challenging. Should we label a single word, sentence or a whole conversation? How many emotions should we define to recognize?</li><li>Collecting data is complex. There are lots of audio data can be achieved from films or news. However, both of them are biased since news reporting has to be neutral and actors’ emotions are imitated. It is hard to look for neutral audio recording without any bias.</li><li>Labeling data require high human and time cost. Unlike drawing a bounding box on an image, it requires trained personnel to listen to the whole audio recording, analysis it and give an annotation. The annotation result has to be evaluated by multiple individuals due to its subjectivity.</li></ul><h4><strong>Project Description:</strong></h4><p>Using Convolutional Neural Network to recognize emotion from the audio recording. And the repository owner does not provide any paper reference.</p><h4><strong>Data Description:</strong></h4><p>These are two datasets originally made use in the repository RAVDESS and SAVEE, and I only adopted RAVDESS in my model. In the RAVDESS, there are two types of data: speech and song.</p><p>Data Set: <a href="https://zenodo.org/record/1188976#.XN0fwnUzZhE">The Ryerson Audio-Visual Database of Emotional Speech and Song (RAVDESS)</a></p><ul><li>12 Actors &amp; 12 Actresses recorded speech and song version respectively.</li><li>Actor no.18 does not have song version data.</li><li>Emotion Disgust, Neutral and Surprised are not included in the song version data.</li></ul><h4>Total Class:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qImiLykubf8uVqU8BJTUqg.png" /></figure><p>Here is the emotion class distribution bar chart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*24IqeFa-tHgt5XvpMKH1Qw.png" /></figure><h4><strong>Feature Extraction:</strong></h4><p>When we do Speech Recognition tasks, MFCCs is the state-of-the-art feature since it was invented in the 1980s.</p><blockquote>This shape determines what sound comes out. If we can determine the shape accurately, this should give us an accurate representation of the <a href="http://en.wikipedia.org/wiki/Phoneme">phoneme</a> being produced. The shape of the vocal tract manifests itself in the envelope of the short time power spectrum, and the job of MFCCs is to accurately represent this envelope. — Noted from: <a href="http://practicalcryptography.com/miscellaneous/machine-learning/guide-mel-frequency-cepstral-coefficients-mfccs/">MFCC tutorial</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*t4v3_4s1Cp84OUWJw3bk2w.png" /><figcaption>Waveform</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*XJc259ThXmnYT1JrOYyImw.png" /><figcaption>Spectrogram</figcaption></figure><p>We would use MFCCs to be our input feature. If you want a thorough understanding of <strong>MFCCs</strong><em>, here is a great </em><a href="http://practicalcryptography.com/miscellaneous/machine-learning/guide-mel-frequency-cepstral-coefficients-mfccs/"><em>tutorial</em></a><em> for you. </em>Loading audio data and converting it to MFCCs format can be easily done by the Python package librosa.</p><h4>Default Model Architecture:</h4><p>The author developed the CNN model with Keras and constructed with 7 layers — 6 Conv1D layers followed by a Dense layer.</p><pre>model = Sequential()<br>model.add(Conv1D(256, 5,padding=&#39;same&#39;, input_shape=(216,1))) #1<br>model.add(Activation(&#39;relu&#39;))<br>model.add(Conv1D(128, 5,padding=&#39;same&#39;)) #2<br>model.add(Activation(&#39;relu&#39;))<br>model.add(Dropout(0.1))<br>model.add(MaxPooling1D(pool_size=(8)))<br>model.add(Conv1D(128, 5,padding=&#39;same&#39;)) #3<br>model.add(Activation(&#39;relu&#39;))<br>#model.add(Conv1D(128, 5,padding=&#39;same&#39;)) #4<br>#model.add(Activation(&#39;relu&#39;))<br>#model.add(Conv1D(128, 5,padding=&#39;same&#39;)) #5<br>#model.add(Activation(&#39;relu&#39;))<br>#model.add(Dropout(0.2))<br>model.add(Conv1D(128, 5,padding=&#39;same&#39;)) #6<br>model.add(Activation(&#39;relu&#39;))<br>model.add(Flatten())<br>model.add(Dense(10)) #7<br>model.add(Activation(&#39;softmax&#39;))<br>opt = keras.optimizers.rmsprop(lr=0.00001, decay=1e-6)</pre><blockquote>The author commented layer #4 and #5 in the latest notebook (18 Sep 2018 Update) and the model weight file does not fit the network provided, thus, I cannot load the weight provide and replicate its result <strong>72% Testing Accuracy.</strong></blockquote><p>The model only simply trained with batch_size=16 and 700 epochs without any learning rate schedule, etc.</p><pre># Compile Model<br>model.compile(loss=&#39;categorical_crossentropy&#39;, optimizer=opt,metrics=[&#39;accuracy&#39;])</pre><pre># Fit Model<br>cnnhistory=model.fit(x_traincnn, y_train, batch_size=16, epochs=700, validation_data=(x_testcnn, y_test))</pre><p>Its loss function is categorical_crossentropy and the evaluation metric is accuracy.</p><h3><strong><em>My Experiment</em></strong></h3><h4>Exploratory Data Analysis:</h4><p>In the RADVESS dataset, each actor has to perform 8 emotions by saying and singing two sentences and two times for each. As a result, each actor would induce 4 samples for each emotion except neutral, disgust and surprised since there is no singing data for these emotions. Each audio wave is around 4 second, the first and last second are most likely silenced.</p><p><strong>The standard sentences are:</strong></p><blockquote>1. Kids are talking by the door.<br>2. Dogs are sitting by the door.</blockquote><p><strong>Observation:</strong></p><p>After I selected 1 actor and 1 actress’s dataset and listened to all of them. I found out male and female are expressing their emotions in a different way. Here are some findings:</p><ul><li>Male’s <strong><em>Angry</em></strong> is simply increased in volume.​</li><li>Male’s <strong><em>Happy</em></strong> and <strong><em>Sad</em></strong> significant features were laughing and crying tone in the silenced period in the audio.</li><li>Female’s <strong><em>Happy</em></strong>, <strong><em>Angry</em></strong> and <strong><em>Sad</em></strong> are increased in volume.​</li><li>Female’s <strong><em>Disgust</em></strong> would add vomiting sound inside.</li></ul><p><strong>Replicating Result:</strong></p><p>The author excluded the class neutral, disgust and surprised to do a 10 class recognition for the RAVDESS dataset.</p><p>I tried to replicate his result with the model provided, I can achieve a result of</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*p9Q2o3v-QpveQ2IEI5D3VQ.png" /></figure><p>However, I found out there is a data leakage problem where the validation set used in the training phase is identical to the test set. So, I re-do the data splitting part by isolating two actors and two actresses data into the test set which make sure it is unseen in the training phase.</p><ul><li>Actor no. 1–20 are used for Train / Valid sets with 8:2 splitting ratio.</li><li>Actor no. 21–24 are isolated for testing usage.</li><li>Train Set Shape: (1248, 216, 1)</li><li>Valid Set Shape: (312, 216, 1)</li><li>Test Set Shape: (320, 216, 1) — (Isolated)</li></ul><p>I re-trained the model with the new data-splitting setting and here is the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*O6QH63rFvvMQPhoMqjZ91Q.png" /></figure><h4><strong>Benchmark:</strong></h4><p>From the train valid loss graph, we can see the model cannot even converge well with 10 target classes. Thus, I decided to reduce the complexity of my model by recognizing male emotions only. I isolated the two actors to be the test set, and the rest would be the train/valid set with 8:2 <strong><em>Stratified Shuffle Split</em></strong> which ensures there is no class imbalance in the dataset. Afterward, I trained both male and female data separately to explore the benchmark.</p><p><strong>Male Dataset</strong></p><ul><li>Train Set = 640 samples from actor 1- 10.</li><li>Valid Set = 160 samples from actor 1- 10.</li><li>Test Set = 160 samples from actor 11- 12.</li></ul><p><strong>Male Baseline</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*Rf7IVRLl92KIsW2SbCxZ8Q.png" /></figure><p><strong>Female Dataset</strong></p><ul><li>Train Set = 608 samples from actress 1- 10.</li><li>Valid Set = 152 samples from actress 1- 10.</li><li>Test Set = 160 samples from actress 11- 12.</li></ul><p><strong>Female Baseline</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*B1Y_RHckoH9t8tKzADUmKg.png" /></figure><p>As you can see, the confusion matrix of the male and female model is different.</p><p>- <strong><em>Male</em></strong>: Angryand Happy are the dominant predicted classes in the male model but they are unlikely to mix up.​</p><p>- <strong><em>Female</em></strong>: Sad and Happy are the dominant predicted classes in the female model and Angry and Happy are very likely to mix up.</p><p>Referring to the observation form the <strong>EDA</strong> section, I suspect the reason for female Angry and Happy are very likely to mix up is because their expression method is simply increasing the volume of the speech.</p><p>On top of it, I wonder what if I further simplify the model by reducing the target class to Positive, Neutral and Negative or even Positive and Negative only. So, I grouped the emotions into 2 class and 3 class.</p><p><strong>2 Class:</strong></p><ul><li>Positive: happy, calm.</li><li>Negative: angry, fearful, sad.</li></ul><p><strong>3 Class:</strong></p><ul><li>Positive: happy.</li><li>Neutral: calm, neutral.</li><li>Negative: angry, fearful, sad.</li></ul><p>(Added neutral to the 3 class to explore the result.)</p><p>Before I do the training experiment, I tune the model architecture with the male data by doing 5 class recognition.</p><pre># Set the target class number<br>target_class = 5</pre><pre># Model <br>model = Sequential()<br>model.add(Conv1D(256, 8, padding=&#39;same&#39;,input_shape=(X_train.shape[1],1))) #1<br>model.add(Activation(&#39;relu&#39;))<br>model.add(Conv1D(256, 8, padding=&#39;same&#39;)) #2<br>model.add(BatchNormalization())<br>model.add(Activation(&#39;relu&#39;))<br>model.add(Dropout(0.25))<br>model.add(MaxPooling1D(pool_size=(8)))<br>model.add(Conv1D(128, 8, padding=&#39;same&#39;)) #3<br>model.add(Activation(&#39;relu&#39;)) <br>model.add(Conv1D(128, 8, padding=&#39;same&#39;)) #4<br>model.add(Activation(&#39;relu&#39;))<br>model.add(Conv1D(128, 8, padding=&#39;same&#39;)) #5<br>model.add(Activation(&#39;relu&#39;))<br>model.add(Conv1D(128, 8, padding=&#39;same&#39;)) #6<br>model.add(BatchNormalization())<br>model.add(Activation(&#39;relu&#39;))<br>model.add(Dropout(0.25))<br>model.add(MaxPooling1D(pool_size=(8)))<br>model.add(Conv1D(64, 8, padding=&#39;same&#39;)) #7<br>model.add(Activation(&#39;relu&#39;))<br>model.add(Conv1D(64, 8, padding=&#39;same&#39;)) #8<br>model.add(Activation(&#39;relu&#39;))<br>model.add(Flatten())<br>model.add(Dense(target_class)) #9<br>model.add(Activation(&#39;softmax&#39;))<br>opt = keras.optimizers.SGD(lr=0.0001, momentum=0.0, decay=0.0, nesterov=False)</pre><p>I added 2 Conv1D layers, 1 MaxPooling1D layer and 2 BarchNormalization layers, moreover, I changed the dropout value to 0.25. Lastly, I changed the optimizer to SGD with 0.0001 learning rate.</p><pre>lr_reduce = ReduceLROnPlateau(monitor=’val_loss’, factor=0.9, patience=20, min_lr=0.000001)</pre><pre>mcp_save = ModelCheckpoint(‘model/baseline_2class_np.h5’, save_best_only=True, monitor=’val_loss’, mode=’min’)</pre><pre>cnnhistory=model.fit(x_traincnn, y_train, batch_size=16, epochs=700, validation_data=(x_testcnn, y_test), callbacks=[mcp_save, lr_reduce])</pre><p>For the model training, I adopted Reduce Learning On Plateau and save the best model with the min val_loss only. And here are the model performance of different target class setups.</p><h4>New Model Performance</h4><p><strong>Male 5 Class</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*9_8FW-RThilmRDSFrBeIUQ.png" /></figure><p><strong>Female 5 Class</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*eOBDi3S2Ja-lmZnTikrPEA.png" /></figure><p><strong>Male 2 Class</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*ruj6I8fODYZQk4Tiamo97g.png" /></figure><p><strong>Male 3 Class</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*McCmsojGDfMS_kSzfAYvfA.png" /></figure><h3>Augmentation</h3><p>After I tuned the model architecture, optimizer and learning rate schedule, I found out the model still cannot converge in the training period. I assumed it is the data size problem since we have 800 samples for train valid set only. Thus, I decided to explore the audio augmentation methods. Let’s take a look at some augmentation method with code. I simply augmented all of the datasets once to double the train / valid set size.</p><h4>Male 5 Class:</h4><p><strong>Dynamic Value Change</strong></p><pre>def dyn_change(data):<br>    &quot;&quot;&quot;<br>    Random Value Change.<br>    &quot;&quot;&quot;<br>    dyn_change = np.random.uniform(low=1.5,high=3)<br>    return (data * dyn_change)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*dR1-3A2o4Zpwc0sw_ph6EA.png" /></figure><p><strong>Pitch Tuning</strong></p><pre>def pitch(data, sample_rate):<br>    &quot;&quot;&quot;<br>    Pitch Tuning.<br>    &quot;&quot;&quot;<br>    bins_per_octave = 12<br>    pitch_pm = 2<br>    pitch_change =  pitch_pm * 2*(np.random.uniform())   <br>    data = librosa.effects.pitch_shift(data.astype(&#39;float64&#39;), <br>                                      sample_rate, n_steps=pitch_change, <br>                                      bins_per_octave=bins_per_octave)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*yE5cHHQzVt-Ged6Fh2B7ag.png" /></figure><p><strong>Shifting</strong></p><pre>def shift(data):<br>    &quot;&quot;&quot;<br>    Random Shifting.<br>    &quot;&quot;&quot;<br>    s_range = int(np.random.uniform(low=-5, high = 5)*500)<br>    return np.roll(data, s_range)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*D5rR69BGVxdWwseFhMQlkg.png" /></figure><p><strong>White Noise Adding</strong></p><pre>def noise(data):<br>    &quot;&quot;&quot;<br>    Adding White Noise.<br>    &quot;&quot;&quot;<br>    # you can take any distribution from <a href="https://docs.scipy.org/doc/numpy-1.13.0/reference/routines.random.html">https://docs.scipy.org/doc/numpy-1.13.0/reference/routines.random.html</a><br>    noise_amp = 0.005*np.random.uniform()*np.amax(data)<br>    data = data.astype(&#39;float64&#39;) + noise_amp * np.random.normal(size=data.shape[0])<br>    return data</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*wcgJinD4psnHim0YzEWzHQ.png" /></figure><blockquote>We can see that the augmentation can jack up the <strong>Validation Accuracy</strong> a lot, 70+% in general. Especially that adding white noise can achieve 87.19% <strong>Validation Accuracy</strong>, however, the <strong>Testing Accuracy</strong> and <strong>Testing F1-score</strong> dropped more than 5% respectively. Then, I wonder if I mixing different augmentation methods would bring a good result.</blockquote><h4>Mixing Multiple Methods</h4><p><strong>Noise Adding + Shifting</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*Mz7oznM7YiWWSNa89XmV5w.png" /></figure><h3>Testing Augmentation on Male 2 Class Data</h3><h4>Male 2 Class:</h4><p><strong>Noise Adding + Shifting<br></strong>For all sample</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*BqZgD8PvjaU3r8vUdmQohw.png" /></figure><p><strong>Noise Adding + Shifting </strong><br>For positive sample only since the 2 class set is imbalance (skewed toward negative).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*Nda3UKutRTfxx17FoyD1Vg.png" /></figure><p><strong>Pitch Tuning + Noise Adding<br></strong>For all sample</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*9-CmRnGCCvGI9F-9sjKSIQ.png" /></figure><p><strong>Pitch Tuning + Noise Adding<br></strong>For positive sample only</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*8NB_NjB7nl0pKsbcsQeDow.png" /></figure><h3>Conclusion</h3><p>In the end, I only have time to experiment with the male data set. I re-split the data with stratified shuffle split to make sure there is no data imbalance nor data leakage problem. I tuned the model by experimenting the male dataset since I want to simplified the model at the beginning. I also tested the by with different target label setups and augmentation method. I found out <strong>Noise Adding </strong>and<strong> Shifting </strong>for the imbalanced data could help in achieving a better result.</p><h3>Key Take Away</h3><ul><li>Emotions are subjective and it is hard to notate them.</li><li>We should define the emotions that suitable for our own project objective.</li><li>Do not always trust the content from GitHub even it has lots of stars.</li><li>Be aware of the data splitting.</li><li>Exploratory Data Analysis always grant us good insight, and you have to be patient when you work on audio data!</li><li>Deciding the input for your model: a sentence, a recording or an utterance?</li><li>Lack of data is a crucial factor to achieve success in SER, however, it is complex and very expensive to build a good speech emotion dataset.</li><li>Simplified your model when you lack data.</li></ul><h3>Further Improvement</h3><ul><li>I only selected the first 3 seconds to be the input data since it would reduce the dimension, the original notebook used 2.5 sec only. I would like to use the full length of the audio to do the experiment.</li><li>Preprocess the data like cropping silence voice, normalize the length by zero padding, etc.</li><li>Experiment the Recurrent Neural Network approach on this topic.</li></ul><h3><strong>About Me</strong></h3><ul><li><strong>GitHub</strong>: <a href="https://github.com/rezachu/emotion_recognition_cnn">rezachu/emotion_recognition_cnn</a></li><li><strong>Linkedin</strong>: <a href="https://www.linkedin.com/in/rezachukc/">Kai Cheong, Reza Chu</a></li></ul><p><em>Remarks: Some papers related to this topic will be noted in the GitHub soon.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e6bb7130ce3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/speech-emotion-recognition-with-convolution-neural-network-1e6bb7130ce3">Speech Emotion Recognition with Convolution Neural Network</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Complete Step by Step Guide of Keras Transfer Learning with GPU on Google Cloud Platform]]></title>
            <link>https://medium.datadriveninvestor.com/complete-step-by-step-guide-of-keras-transfer-learning-with-gpu-on-google-cloud-platform-ed21e33e0b1d?source=rss-e9567d539e15------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed21e33e0b1d</guid>
            <category><![CDATA[transfer-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Reza Chu]]></dc:creator>
            <pubDate>Fri, 22 Jun 2018 20:00:00 GMT</pubDate>
            <atom:updated>2018-06-23T08:12:54.687Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zVYsG6L_uuBpi7ShAIjYWg.png" /></figure><blockquote>In this guide, I have chosen an expired <a href="http://www.kaggle.com/"><em>Kaggle</em></a> competition — <a href="https://www.kaggle.com/c/plant-seedlings-classification"><strong>Plant Seedlings Classification</strong></a> to be the template project. And the guide is constructed by five parts.</blockquote><p>a. Google Cloud Storage Utilization<br>b. Initialize GPU Compute Engine<br>c. Install CUDA, cuDNN &amp; Tensorflow-GPU<br>d. Install Jupyter Notebook<br>e. Running Keras Transfer Learning model with GPU</p><h4>Part A: Google Cloud Storage Utilization</h4><p><strong>Step: 1</strong><br>In the beginning, we need to apply a <a href="https://cloud.google.com/"><strong><em>Google Cloud Platform (GCP)</em></strong></a> account and the new client would have $300 credit to spend in the first 12 months.</p><p>Once we logged in to the GCP console, we need to create a new project in order to use the GCP services. Simply click the <strong><em>New Project</em></strong> button and type the project name. At the same time, it would assign a unique project ID for your project which we need to use to access the GCP in terminal later.</p><p><strong>Step: 2</strong><br>Now, we would create a bucket in the Storage. There are three ways to create a bucket in the Storage.</p><blockquote>1. Web UI<br>2. Command Line<br>3. Programmatically (Not going to talk about it)</blockquote><p><strong><em>Web UI:</em></strong> <br>We simply need to click the <strong>CREATE BUCKET</strong> button and configure the bucket setting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bUWT7vsj45Chy07WdRN5gA.png" /></figure><p><strong><em>Command Line: </em></strong><br>This one is a bit tricky. First, we need to create an environment with Python 2.7. Then, we would install the Google Cloud SDK. Since I use MacOS, I would use it as an <a href="https://cloud.google.com/sdk/docs/downloads-interactive"><strong><em>example</em></strong></a>. To install and initiate the Google Cloud SDK, we only need to type three lines of code in the terminal.</p><ul><li>Enter the following at a command prompt:</li></ul><pre>curl <a href="https://sdk.cloud.google.com/">https://sdk.cloud.google.com</a> | bash</pre><ul><li>Restart the Shell:</li></ul><pre>exec -l $SHELL</pre><ul><li>Run gcloud init to initialize the gcloud environment:</li></ul><pre>gcloud init</pre><p>After running “gcloud init”, we simply need to select the target project created and log in with our Gmail. And here is an <a href="https://cloud.google.com/sdk/docs/quickstarts"><strong><em>Installation Quickstarts Guide</em></strong></a> where you can choose the appropriate method according to your machine setting.</p><p>Now, we can start to work with the <a href="https://cloud.google.com/storage/docs/gsutil"><strong><em>gsutil</em></strong></a> tool. Here are a couple of major functions.</p><pre>#Create a bucket:<br><strong>gsutil mb gs://&lt;bucket_name&gt;</strong></pre><pre>#Copy some files to the bucket:<br><strong>gsutil cp &lt;file_name_*&gt; gs://&lt;bucket_name&gt;</strong></pre><pre>#List the files in the bucket:<br><strong>gsutil ls -l gs://&lt;bucket_name&gt;</strong></pre><pre>#Copy a file from our bucket back to the target directory<br><strong>gsutil cp gs://&lt;bucket_name&gt;/&lt;file_name_*&gt; /&lt;target_dir&gt;</strong></pre><pre>#Delete the files:<br><strong>gsutil rm gs://&lt;bucket_name&gt;/&lt;file_name_*&gt;</strong></pre><pre>#Remove the bucket:<br><strong>gsutil rb gs://&lt;bucket_name&gt;</strong></pre><p>Here are few things we need to upload to the bucket:<br>- Training &amp; Testing data<br>- pre-trained model</p><p>I created a folder name “plant-seedling” which has two sub-folders “Train” &amp; “Test” to store the data separately. Also, we can download the pre-trained model weight of <a href="https://gist.github.com/baraldilorenzo/07d7802847aaad0a35d3"><strong><em>VGG16</em></strong></a> &amp; <a href="https://gist.github.com/baraldilorenzo/8d096f48a1be4a2d660d"><strong><em>VGG19</em></strong></a> here. Once it finished uploading these files to the bucket, we can move on to the next part.</p><h4>Part B: Initialize GPU Compute Engine</h4><p><strong>Step 1:</strong><br>First, we need to click into the compute engine page of the GCP console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HQ41-shYxprJGT7klezibw.png" /></figure><p>Then, we need to click the “<strong><em>CREATE INSTANCE </em></strong>” button at the top bar and we will get directed to this page.</p><p><strong>Step 2: </strong><br>In this phase, we need to configure the instance setting before creating it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZD1z43u4ERB86QldZkKP9Q.png" /></figure><p>In the figure above, I underlined some items that we should change. First, we need to assign a unique name for this instance. Then, we have to choose the regions and zone for the instance. Please be reminded that only some of the regions would provide GPU instance service. We can check the information through this link: <a href="https://cloud.google.com/compute/docs/gpus/">https://cloud.google.com/compute/docs/gpus/</a></p><p>After that, we need to decide the machine type and no worry since we can change the machine type at any time we want even the instance is created. In this case, I choose a high memory 4 cores CPU machine with 1 NVIDIA Tesla K80 GPU. You could adjust the machine type according to your demand and you can check the price with the <a href="https://cloud.google.com/products/calculator/"><strong><em>GCP Price Calculator</em></strong></a> here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*feJLuJlfh5NKGicTZqifIA.png" /></figure><p>In the lower part of the configuration page, we would check both HTTP &amp; HTTPS traffic boxes at the Firewall. And then, we click the “Change” button at the Boot Disk section. (The default is Debian GNU/Linux 9 (stretch) with 10 GB memory)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nSTiE5bLfAbztWdiOWLGkQ.png" /></figure><p>Once we clicked in, we could select the Ubuntu 16.04 LTS disk and change the size to 100 GB since we have a thousands of image to train and need to reserve memory space for pre-trained-weight and the best trained models.</p><p><strong>Step 3:</strong><br>The last step before launching our instance, we need to request Google to increase our GPU quota since the default would be zero and normally it only takes few hours for approval.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*b2k2Xojh7h7J49hQ8R764w.png" /></figure><p>Normally, if we start our GPU instance now, it will pop up this notification on the right top corner. What we need to do is to click the request increase button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2fz2GCNB7KdyYkaiWN-Rew.png" /></figure><p>To edit the quota, we need to click the <strong>Compute Engine API </strong>with the same GPU (NVIDIA K80) we have chosen in the machine-type setting and the location has to be as same as the region of the instance. <strong>KINDLY REMINDED </strong>that do not choose the Preemptible NVIDIA K80 one since it is for the Preemptible instance which would be automatically removed after 24 hours. Then we can click the <strong>EDIT QUOTAS</strong> button at the top to increase the GPUs quota and wait for Google’s approval.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NeFSiMZLUUog42DL6cMDA.png" /></figure><p>Congratulation, we finally can start our first GPU instance by clicking the Start button!</p><blockquote>Alert: The instance would start to charge once you turned it on, therefore, please be reminded to stop it if you are not using it.</blockquote><p><strong>Step 4:</strong><br>In this part, we would start the instance and create a Python 3 virtual environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EayHN_GHFIubnLbD0VJzww.png" /></figure><p>Once we clicked the SSH button, it would pop up a new window that has a terminal view. Then we only need to run these few lines of code step by step in order to set up our python environment.</p><pre># Download the Anaconda3<br><strong>wget </strong><a href="http://repo.continuum.io/archive/Anaconda3-4.0.0-Linux-x86_64.sh"><strong>http://repo.continuum.io/archive/Anaconda3-4.0.0-Linux-x86_64.sh</strong></a></pre><pre># Install Anaconda3<strong><br>bash Anaconda3-4.0.0-Linux-x86_64.sh</strong></pre><pre># It will ask you this question and we would enter yes<br><strong>Do you wish the installer to prepend the <br>Anaconda3 install location to PATH <br>in your /home/haroldsoh/.bashrc ? <br>[yes|no][no] &gt;&gt;&gt; yes</strong></pre><pre># Use it right away<br><strong>source ~/.bashrc</strong></pre><pre># Create a Python 3 virtual environment<br><strong>conda create -n &lt;env_name&gt; python=3.5</strong></pre><pre># Activate our environment<br><strong>source activate &lt;env_name&gt;</strong></pre><h4>Part C: Install CUDA, cuDNN &amp; Tensorflow-GPU</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*chq6T7-VMiqTu06RVVC73w.jpeg" /></figure><p><strong>Step 1: </strong><br>To use the GPU function in our instance, we need to download couples of a package. The first one is the CUDA tool-kit and we can install it by running these codes.</p><pre># Activate your environment<br><strong>source activate &lt;env_name&gt;</strong></pre><pre># download the CUDA 9.2<br><strong>curl -O </strong><a href="https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.2.88-1_amd64.deb"><strong>https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.2.88-1_amd64.deb</strong></a></pre><pre># install the CUDA<br><strong>sudo dpkg -i cuda-repo-ubuntu1604_9.2.88-1_amd64.deb</strong></pre><pre># Downgrade it to 9.0 since tensorflow-gpu can only use v9.0<br><strong>sudo apt-get update<br>sudo apt-get install cuda-9-0</strong></pre><pre># check if CUDA is installed<br><strong>nvidia-smi</strong></pre><p>If CUDA successfully installed, it would show something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2sbR8Hw8BHM6XeDU1rrrw.png" /></figure><p>There is another alternative to install the CUDA because sometimes the curl might not work well. We could download the CUDA package <a href="https://developer.nvidia.com/cuda-downloads?target_os=Linux&amp;target_arch=x86_64&amp;target_distro=Ubuntu&amp;target_version=1604&amp;target_type=debnetwork"><em>here</em></a> and upload it to the bucket and then run this two commands to copy the file to the instance.</p><pre># Initialize GCP in the instance<br><strong>gcloud init</strong></pre><pre># Transfer the file to your instance<br><strong>gsutil cp -r gs://&lt;bucket_name&gt;/&lt;file_path&gt; /home/&lt;username&gt;</strong></pre><pre># install the CUDA<br><strong>&lt;Follow the upper commands&gt;</strong></pre><p><strong>Step 2:<br></strong>Before we install the cuDNN, we need to register a <a href="https://developer.nvidia.com/"><strong><em>Nvidia Developer Account </em></strong></a>first. Then, we need to <a href="https://developer.nvidia.com/rdp/cudnn-download"><strong><em>download</em></strong></a> two packages for the Ubuntu instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ejYLeXcZT-e1SX1FZ1tIxg.png" /></figure><blockquote>We have to download:<br>- cuDNN v7.1.4 Runtime Library for Ubuntu16.04 (Deb)<br>- cuDNN v7.1.4 Developer Library for Ubuntu16.04 (Deb)</blockquote><p>Next, we can use the bucket upload &amp; file transfer method I mentioned above to put these two files into the instance home path.</p><p>Lastly, we would run these commands to install the packages. Please be remembered to install the Runtime Library first, otherwise, it would return an error.</p><pre># install the cuDNN Runtime Library<br><strong>sudo dpkg -i libcudnn7_7.1.4.18-1+cuda9.0_amd64.deb</strong></pre><pre># install the cuDNN Developer Library<br><strong>sudo dpkg -i </strong><a href="https://storage.cloud.google.com/kaggle-data-archive/libcudnn7-dev_7.1.4.18-1%2Bcuda9.2_amd64.deb"><strong>libcudnn7-dev_7.1.4.18-1+cuda9.0_amd64.deb</strong></a></pre><p><strong>Step 3:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*8AG-IenMA-eBxR2PG0Cn0Q.png" /></figure><p>Installing tensorflow-gpu package is the easiest part of this guide. We simply need to run two codes.</p><pre># install the tensorflow-gpu<br><strong>pip3 install tensorflow-gpu</strong></pre><pre># Make sure the package is up to date<br><strong>pip3 install --upgrade tensorflow-gpu</strong></pre><p><strong>Step 4:</strong><br>To verify if the GPU is ready to use, we would have to run these few lines of code.</p><pre># enter python <br><strong>python</strong></pre><pre># check tensorflow<strong><br>&gt;&gt;&gt;import tensorflow as tf<br>&gt;&gt;&gt;from tensorflow.python.client import device_lib</strong><br><strong>&gt;&gt;&gt;print(device_lib.list_local_devices())</strong></pre><p>It should return something like this if everything was installed correctly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zZnPeYgRQaT_GSyboixsbg.png" /></figure><h4>Part D: Install Jupyter Notebook</h4><p>Before we install the Jupyter notebook, we need to configure the instance network setting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g00_DdW2XE2BuY1_vsBQYA.png" /></figure><p><strong>Step 1:</strong><br>Since the initial IP is dynamic, so we would need to go to VPC network &gt; External IP address page to configure the IP type from Ephemeral to Static.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DEwPPA09muEC5JXXZl4HuQ.png" /></figure><p><strong>Step 2:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PZB91xDvFwYOtb19RIGoXw.png" /></figure><p>After we clicked into the Firewall rules page below the External IP addresses tab. We need to create a new firewall rule.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8T-lAUyd6joEgqORKMkirg.png" /></figure><p>We would insert two items into the configuration setting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3NRdmBTEybx90EJ8SdW7Ig.png" /></figure><p>We would enter “<strong>0.0.0.0/0</strong>” for the Source IP ranges and specify the protocols and ports to “<strong>tcp:&lt;port_number&gt;</strong>” and I selected <strong>tcp:4000</strong> for my rule.</p><p>Before we move on, please ensure the external IP address is <strong>In use by</strong> our target instance. We can click the change button on the right-hand side to do the setting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c5WPVxezbjMPpF9-Ug8Ngw.png" /></figure><p><strong>Step 3:</strong><br>Now, we can start the SSH terminal to install our Jupyter Notebook.</p><pre># Activate your environment<br><strong>source activate &lt;env_name&gt;</strong></pre><pre># download the jupyter notebook to your environment<br><strong>pip3 install Jupyter Notebook</strong></pre><p>Once the Jupyter Notebook package is installed, we need to configure the Jupyter Notebook setting.</p><pre># Generate Configuration file<br><strong>jupyter notebook --generate-config</strong></pre><pre># Check if the configure file exist<br><strong>ls ~/.jupyter/jupyter_notebook_config.py</strong></pre><pre># change directory to target path<br><strong>cd /home/&lt;uesr_name&gt;/.jupyter/</strong></pre><pre># open jupyter_notebook_config.py<strong><br>nano jupyter_notebook_config.py</strong></pre><p>And we need to add these few lines into the configuration file.</p><pre><strong>c = get_config()<br>c.NotebookApp.ip = &#39;*&#39;<br>c.NotebookApp.open_browser = False<br>c.NotebookApp.port = &lt;Port Number&gt;</strong></pre><p>The <strong>jupyter_notebook_config.py </strong>should look something like this and I use green underline to highlight where should we insert the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dfrP7s4wlNq_ahGfB8uUOA.png" /></figure><p>Save and quit the file and we are good to launch the Jupyter Notebook now!</p><p><strong>Step 4:</strong><br>Launching Jupyter Notebook in the Google Cloud instance is a bit different from what we do on our local machine. The command line is variated and we need to open the notebook by ourselves.</p><pre># Launch the Notebook<br><strong>jupyter-notebook --no-browser --port=&lt;PORT-NUMBER&gt;</strong></pre><pre># Insert this url in the browser url section to open notebook<br><strong>http://&lt;External Static IP Address&gt;:&lt;Port Number&gt;</strong></pre><p>Now we should see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5m2qEdTbU0bu4CYDv90WDw.png" /></figure><p>Sometimes, it might ask you to insert password or token by showing this page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*5DgYvgHKl0ftTOv4UMJPrA.png" /></figure><p>Don’t worry, it is a normal security precaution of Jupyter Notebook to prevent random website you visit from executing code on your machine. If we look up the SSH terminal, you will find out an URL in this format.</p><pre># First time visit token<br><strong>http://&lt;bucket_name&gt;:&lt;port_number&gt;/?token=&lt;token&gt;</strong></pre><p>All we need to do is to copy the <strong>&lt;token&gt;</strong> part and paste it to the Token column and set a new password in order to log in the notebook smoothly.</p><h4>Part E: Running Keras Transfer Learning model with GPU</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*LSwQ8xZZwEmo9MmnD8YJww.png" /></figure><p>The <a href="https://www.kaggle.com/c/plant-seedlings-classification"><strong><em>Kaggle Plant Seedlings Classification</em></strong></a> project provided 4750 training images divided into 12 classes and 794 testing images and all of them have different resolution and size. As a result, we need to crop the image and downsize them before feeding into our Keras model. On top of it, the data is imbalance since some of the classes have significantly more samples than other classes. Here is a brief glance at the data.</p><pre><strong>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>The number of category is 12<br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>Here are the training data intel:<br>- Black-grass 263 images<br>- Charlock 390 images<br>- Cleavers 287 images<br>- Common Chickweed 611 images<br>- Common wheat 221 images<br>- Fat Hen 475 images<br>- Loose Silky-bent 654 images<br>- Maize 221 images<br>- Scentless Mayweed 516 images<br>- Shepherds Purse 231 images<br>- Small-flowered Cranesbill 496 images<br>- Sugar beet 385 images</strong></pre><p>In this transfer learning model, I adopted VGG 16 with pre-trained “imagenet” weights. The input shape of the model is (224, 224, 3) and the output shape is (12). And I simply removed the last dense layer with output shape 1000 and added a dense layer with output shape 12, “softmax” activation and the weight initializer was “glorot_norma”l ( aka Xavier Normal). And here is the model highlight.</p><pre><strong># VGG_16 model above with the last layer</strong><br>model.add(Dense(1000, activation=&#39;softmax&#39;))    <strong><br>    <br><em># Load VGG_16 pretrained weight</em><br></strong>model.load_weights(&#39;./pre_trained_model/vgg16_weights.h5&#39;, by_name=True)</pre><pre><strong><em># Remove the last softmax Dense layer</em><br></strong>model.pop()</pre><pre><strong><em># Add a new Dense layer to output 12 classes</em><br><em># Initialize the weight with Xavier Normal Initialization</em><br></strong>model.add(Dense(12, activation=&#39;softmax&#39;, kernel_initializer=&#39;glorot_normal&#39;))<strong><br>    <br><em># Using SGD as an optimizer with learning rate=0.001 and decay = 0.000001</em><br></strong>sgd = SGD(lr=1e-3, decay=1e-6, momentum=0.9, nesterov=True)</pre><pre><strong><em># Compile model with custom fscore metric </em><br></strong>model.compile(optimizer=sgd, loss=&#39;categorical_crossentropy&#39;, metrics=[&#39;accuracy&#39;, fscore])</pre><p>Basically, with all the setup we made before, the Jupyter Notebook would use GPU to run automatically. And, I didn’t do much data preprocessing and hyperparameter tuning since it is a walk through guide project. I simply ran 20 epochs with a batch size = 32, each epoch took around 130 seconds where the CPU required at least 6000 seconds per epoch. Therefore, the accuracy is not that high but the training fscore was still higher than 0.89.</p><pre>Epoch 1/20<br>3800/3800 [==============================] - 144s 38ms/step - loss: 2.4417 - acc: 0.1300 - fscore: 0.0000e+00 - val_loss: 2.4202 - val_acc: 0.1221 - val_fscore: 0.0000e+00</pre><pre>.<br>.<br>.</pre><pre>Epoch 20/20<br>3800/3800 [==============================] - 126s 33ms/step - loss: 0.2892 - acc: 0.8887 - fscore: 0.8912 - val_loss: 0.4537 - val_acc: 0.8495 - val_fscore: 0.8551</pre><p>The whole Jupyter Notebook can be cloned on my <a href="https://github.com/rezachu/Kaggle-Plant-Seedling-Classification">Github</a> and my next blog post will talk about how to increase the accuracy of this project. Hopefully, it could help anyone who has no idea how to train their model on cloud and stay tuned!</p><figure><a href="http://eepurl.com/dw5NFP"><img alt="" src="https://cdn-images-1.medium.com/max/800/1*6pBE3RfO8w8lfccDXjUwiQ.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed21e33e0b1d" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/complete-step-by-step-guide-of-keras-transfer-learning-with-gpu-on-google-cloud-platform-ed21e33e0b1d">Complete Step by Step Guide of Keras Transfer Learning with GPU on Google Cloud Platform</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Andrew Ng’s Deep Learning Specialization Course Review]]></title>
            <link>https://medium.datadriveninvestor.com/andrew-ngs-deep-learning-specialization-course-review-b90076aa2432?source=rss-e9567d539e15------2</link>
            <guid isPermaLink="false">https://medium.com/p/b90076aa2432</guid>
            <category><![CDATA[coursera]]></category>
            <category><![CDATA[review]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Reza Chu]]></dc:creator>
            <pubDate>Thu, 24 May 2018 09:29:56 GMT</pubDate>
            <atom:updated>2019-01-25T07:52:49.913Z</atom:updated>
            <content:encoded><![CDATA[<figure><a href="http://www.track.datadriveninvestor.com/1B9E"><img alt="" src="https://cdn-images-1.medium.com/max/700/0*kfAz-Byu1MhoqaGl" /></a></figure><p>Lately, I had accomplished <a href="https://www.coursera.org/specializations/deep-learning"><em>Andrew Ng’s Deep Learning Specialization course</em></a> series in Coursera. I hope this review would be insightful for those whom might want to enter this field or simply consolidate your deep learning knowledge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*myxaiKiFVxPgLghlnKSccg.jpeg" /></figure><h4>Course Overview</h4><ol><li><strong><em>Deep Learning and Neural Network:</em></strong><br>In course 1, it taught what is Neural Network, Forward &amp; Backward Propagation and guide you to build a shallow network then stack it to be a deep network. Also, you will learn about the mathematics (Logistics Regression, Gradient Descent and etc.) related to it step by step. Andrew explained the maths in a very simple way that you would understand it without prior knowledge in linear algebra nor calculus. Last but not least, it discussed the activation functions and their Pros &amp; Cons respectively. — <em>Favorite topic: how to get your matrix dimension right</em></li><li><strong><em>Improving DNN: Hyperparameter Tuning, Regularization, and Optimization:</em></strong><br>In course 2, we would proceed to learn different regularization techniques and why they could reduce overfitting. On top of it, Andrew would teach you how to evaluate your deep learning model and note down his hyperparameter tuning technique in different situations (It is a gold for DL Enthusiast) — <em>favourite topic: Minibatch application and how it affects the model.</em></li><li><strong><em>Structuring Machine Learning Projects:</em></strong><br>In course 3, Andrew would talk about how to set up evaluation metric since the highest accuracy model might not be the best in daily practice. He also discusses how to select and split the train/test/validation set and the methods we could use while lacking of data —<em> favourite topic: error analysis table which drill down the prediction results to look for model tuning insights.</em></li><li><strong><em>Convolutional Neural Network:</em></strong><br>In course 4, Andrew would teach what is computer vision and how does a Convolutional Neural Network work by explaining the theory and maths of convolutional filter, Maxpooling filter, etc. On top of it, he would go through the structure of the famous pre-trained network: LeNet5, AlexNet’ VGG-16, and ResNet, then guide you to utilize them with transfer learning. <em>— favourite topic: Image localisation and detection.</em></li><li><strong><em>Sequence Models:</em></strong><br>In the last course, it first talks about RNNs and LSTM then dive in to NLP and teach the major concepts such as <em>Word Embedding, Word2Vec, Bleu Score, Beam Search, Skip Gram, etc</em>. Lastly, you could practice how to build a machine translation model .<em>— favourite topic: Trigger Detection with the self-made audio data.</em></li></ol><h4>Why you should take it</h4><p><strong><em>Course Design:</em></strong><br>The course was designed to educate Deep Learning in a simple way in order to lower the entry barrier of this industry and boost up the development of Artificial Intelligence. These five courses are a step by step series to cover all fundamental aspect of deep learning although you could only take those you are interested. It is absolutely suitable for Deep Learning beginner with fundamental Python programming skill.</p><p><strong><em>Programming Assignment:</em></strong><em><br></em>The program assignments after each week’s lecture are very practical, especially it requires you to code every function you have learned in the class instead of simply calling the framework. For example, it requires you to code the forward &amp; backward propagation, gradient descent, splitting minibatch and etc. in Python. Although it is not a difficult task that could transform you to be a coding veteran, this process could really help the beginner understanding the mechanism behind it. And for the DL partitioner, it is a good chance to consolidate your knowledge of the Neural Network. On top of it, all of the assignments were graded automatically, so you can get the result right away and proceed asap. Lastly, the classroom forum would provide all you need to solve the assignment. And the honour of code prevented students from posting the actual code on the forum. In the other words, you have to pass all of the assignment by yourself. It might be challenging for a beginner but you would get the reward at the end of the course.</p><p><strong><em>Heroes of Deep Learning Interview:</em></strong><br>Despite the great course content that enables us to build and train Deep Learning model. We all know the wide variation of DL application requires us to iterate countless experiments to bring the model out from the lab to daily practice. Andrew and the guests including Geoffrey Hinton, Pieter Abbeel, Ian Goodfellow, etc. shared a lot of experiences they learned from their works and their career path in the industry which is gold to us.</p><p><strong><em>Course Certification:</em></strong><br>After you accomplished the courses it would issue 5 course certifications plus one deep learning specialization certification which could directly attach to your Linkedin profile. For those who want to switch the career path, I could say this course could really grant you the knowledge you expected and the validation from an authority.</p><p><strong><em>Course Workload and Pricing:</em></strong><br>Each course would have four-week syllabus in average which requires to devote you 2 to 4 hour a week. The workload is not big at all for people who have a full-time job. And the course fee is only $49 per month with 7 days free trial which is arguably one of the cheapest MOOC course I have ever taken.</p><h4>Conclusion</h4><p>After taking this course, I can foresee more and more DL talent would pop out since the DL knowledge enables us to drill down to the topic we are interested in and connecting us to the entry of this industry. I would recommend this course to everyone who is interested in Deep Learning and not only for beginner but for those who has knowledge in this field as well. Knowledge consolidation is always good and teaches you new stuff. If you don’t want to miss the A.I. trend in this decade, dive in the course now.</p><p>Related Posts from DDI:</p><ul><li><a href="https://www.datadriveninvestor.com/2019/01/23/deep-learning-explained-in-7-steps/">Deep Learning Explained in 7 Steps - Updated | Data Driven Investor</a></li><li><a href="https://www.datadriveninvestor.com/2019/01/23/which-is-more-promising-data-science-or-software-engineering/">Which is More Promising: Data Science or Software Engineering? | Data Driven Investor</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fb2a0d6%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fb2a0d6%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href">https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b90076aa2432" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/andrew-ngs-deep-learning-specialization-course-review-b90076aa2432">Andrew Ng’s Deep Learning Specialization Course Review</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is AI? A Brief Explanation for layman]]></title>
            <link>https://medium.datadriveninvestor.com/what-is-ai-a-brief-explanation-for-layman-f79f368702ea?source=rss-e9567d539e15------2</link>
            <guid isPermaLink="false">https://medium.com/p/f79f368702ea</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Reza Chu]]></dc:creator>
            <pubDate>Sun, 15 Apr 2018 14:54:41 GMT</pubDate>
            <atom:updated>2018-05-29T00:38:32.425Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*06IE39yuNnEIeAaNrBwpdQ.jpeg" /></figure><p>In the past two years, Artificial Intelligence has become one of the hottest topics. Thanks to AlphaGo, the general public believes A.I. is a monster that had beaten human and sooner it is going to take their jobs away. As a machine learning engineer, I see the necessity to explain what is A.I. to the layman which could clear the illustration forged by the media. Here we go.</p><blockquote><em>“AI is all about figuring what to do when you don’t know what to do.”, </em>Peter Norvig.</blockquote><p>Artificial Intelligence is not a magical program that can think like a human. The mechanism behind it is to utilise different mathematic algorithms to learn from a tremendous amount of structured data to solve dedicated cognitive problems that originally can be only solved by human intelligence. And the robust part of A.I. is it can acquire a pattern from the provided data to solve a problem in high accuracy. Meanwhile, we don’t even know what is actually happening inside the program but the algorithm would take care of it. In a simple word, A.I. learns from the data feed by human to solve dedicated problem. Let’s take a look to these six major subfields in A.I.</p><p><strong>1. Computer Vision:</strong><br><em>e.g. Recognizing object from real world images or video, just like the iPhone X’s Face ID.</em></p><p><strong>2. Planning:</strong><br><em>e.g. Searching for the shortest path between your home and the nearest shopping mall.</em></p><p><strong>3. Natural Language Processing:</strong><br><em>e.g. Interpreting what are you saying, writing, etc.</em></p><p><strong>4. Knowledge Representation and Reasoning:</strong><br><em>e.g. Chatbot that answer customer questions.</em></p><p><strong>5. Robotics:</strong><br><em>e.g. The self driving car that take care of your travel.</em></p><p><strong>6. Machine Learning:</strong><br><em>e.g Predicting the housing price by learning from the historical data.</em></p><blockquote><em>How does Artificial Intelligence Agent solve problems?</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I_ogxxyO8d_sgoOoCPh4xg.jpeg" /></figure><p>So, how does A.I. learn? Typically, there are three learning methods, Supervised Learning, Unsupervised Learning and Reinforcement Learning. In supervised learning, we would label the correct answer inside the data and the agent would learn the pattern by comparing the result with the target label in order to achieve accurate prediction.; In unsupervised learning, we would not tell what we are looking for but let the learning algorithm to help us divide the data into category as many as we desired.; Lastly, reinforcement learning is more like learning by doing. At the beginning, we do not have any labeled data, however, we would set up different policies with corresponding reward or penalty. The A.I. would learn the optimal by trying different actions in each condition to achieve the highest reward under the specified environment and policies.</p><blockquote>Can Artificial Intelligence Agent replace human?</blockquote><p>To develop an A.I. agent to solve a task, there are four basic criteria.</p><ul><li>1. We need to clearly define the problem domain and the learning objective.</li><li>2. We have to provide structured data for the agent or we are able to design a good environment, policies and reward system for reinforcement learning.</li><li>3. The data provided must contain useful information for the agent to learn from it. If the data fed in have no value, the agent would never be able to solve the task.</li><li>4. Decide an evaluation method to measure the performance of the agent. Otherwise, we won’t know the model is accurate or not.</li></ul><blockquote><em>Rule no.1: Garbage In, Garbage Out.</em></blockquote><p>From my experience, the hardest part of building a prediction model is to decide what sample data should I use and how to gather those data. Luckily, there are many open-sourced data and algorithm library that could let us to train our model much easier than few year before. However, you could also gather the desired data by yourselves.</p><blockquote>Conclusion ~ Will it take our job?</blockquote><p>Undoubtedly, A.I. would disrupt our world in the soon future, however, we should firstly understand it and think of the opportunities created by A.I. instead of blindly worrying the fourth industrial revolution would replace all of the jobs. A.I. technology required a large amount of training data to look for a specific pattern in order to resolve the problem. And it has its own bottleneck such as: Do we have the data? Does the specific problem has a pattern? Can we structure the information into computer interpretable data? Is the computer powerful enough to handle a huge amount of data. Moreover, A.I. would soon replaces jobs that are highly repeatable, however, it would also create many job posts, for instance: data scientist, data security engineer, etc. On top of it, applying the new technology to the real world needs to solve many political, legislative and humane problems which might take years. Let’s say the self driving car application, lots of researches and experiments proved that self driving car is safer than human driving. However, once it killed people in an accident (which happened lately in U.S.), who is going to take the responsibility? In addition, do we need a driver sitting in the driver seat in case of any malfunction, so he can switch it to manual mode to save lives? If a driver is compulsory for self driving car after legislation, it ain’t gonna bring a big impact on the driver job.</p><p>It is very likely a large amount of traditional labor force, especially the grassroots class would be replaced by Robots and AI, however, the replacing process might take years and the society would have time to digest it gradually. The most important thing is we should learn about what is AI and think about how is it going to change our job instead of blindly panic. Hopefully this read could give you a brief glance of the A.I. world and motivated you to learn more about A.I.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f79f368702ea" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/what-is-ai-a-brief-explanation-for-layman-f79f368702ea">What is AI? A Brief Explanation for layman</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>