<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Ask Ghassem - Recent questions in Deep Learning</title>
<link>https://ask.ghassem.com/questions/deep-learning</link>
<description>Powered by Question2Answer</description>
<item>
<title>how many samples do we need to test image segmentation using synthetic data ?</title>
<link>https://ask.ghassem.com/993/many-samples-need-test-image-segmentation-using-synthetic</link>
<description>Hello,&lt;br /&gt;
&lt;br /&gt;
I trained a CNN using synthetic data to perform a segmentation task on human faces. During the test and to evaluate the prediction of this network, I used 200 examples from the database to compute precision and recall.&lt;br /&gt;
&lt;br /&gt;
Is this number sufficient, knowing that I control myself the data generator and that I build the database by randomly drawing the elements using centered Gaussian distributions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thank you,</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/993/many-samples-need-test-image-segmentation-using-synthetic</guid>
<pubDate>Mon, 21 Jun 2021 12:26:32 +0000</pubDate>
</item>
<item>
<title>Binary Classification and neutral tag</title>
<link>https://ask.ghassem.com/978/binary-classification-and-neutral-tag</link>
<description>&lt;p&gt;I am trying to create a sentiment analysis model using binary classification as loss.I have a batch of tweets that some of them are tagged as positive (labeled as 1)&amp;nbsp;and&amp;nbsp;negative (labeled as 0).I manage to gather some tweets that are tagged as neutral but there are less&amp;nbsp; tweets than positive and negative.My thinking is to tag them with 0.5 to balance the classification probability.Is this legit?&lt;/p&gt;

&lt;div id=&quot;gtx-trans&quot; style=&quot;position: absolute; left: 460px; top: 54px;&quot;&gt;
&lt;div class=&quot;gtx-trans-icon&quot;&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/978/binary-classification-and-neutral-tag</guid>
<pubDate>Sat, 30 Jan 2021 10:08:01 +0000</pubDate>
</item>
<item>
<title>&quot;Rare words&quot; on vocabulary</title>
<link>https://ask.ghassem.com/977/rare-words-on-vocabulary</link>
<description>I am trying to create a sentiment analysis model and I have a question.&lt;br /&gt;
&lt;br /&gt;
After I preprocessed my tweets and created my vocabulary I&amp;#039;ve noticed that I have words that appear less than 5 times in my dataset (Also there are many of them that appear 1 time). Many of them are real words and not gibberish. My thinking is that if I keep those words then they will get wrong &amp;quot;sentimental&amp;quot; weights and gonna make my model worse.&lt;br /&gt;
Is my thinking right or am I missing something?&lt;br /&gt;
&lt;br /&gt;
My vocab size is around 40000 words and those that are &amp;quot;rare&amp;quot; are around 10k.Should I &amp;quot;sacrifice&amp;quot; them?&lt;br /&gt;
&lt;br /&gt;
Thanks in advance.</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/977/rare-words-on-vocabulary</guid>
<pubDate>Sat, 30 Jan 2021 09:57:31 +0000</pubDate>
</item>
<item>
<title>How to calculate convolutions on a CONV layer for a Convolutional Neural Network?</title>
<link>https://ask.ghassem.com/650/calculate-convolutions-layer-convolutional-neural-network</link>
<description>&lt;p&gt;Assume we have a $5\times5$ px&amp;nbsp;RGB image with 3&amp;nbsp;channels respectively for R, G, and B. If&lt;/p&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:100px&quot;&gt;
&lt;caption&gt;R&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:100px&quot;&gt;
&lt;caption&gt;G&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:100px&quot;&gt;
&lt;caption&gt;B&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We have one&amp;nbsp;$3\times3$ px kernel (filter) with 3 channels as follows:&lt;/p&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:100px&quot;&gt;
&lt;caption&gt;Filter - R&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:100px&quot;&gt;
&lt;caption&gt;Filter - G&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;-1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;-1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; style=&quot;height:100px; width:100px&quot;&gt;
&lt;caption&gt;Filter - B&lt;/caption&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;-1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;-1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;a)&lt;/strong&gt; If&amp;nbsp;&lt;strong&gt;Stride = 2&lt;/strong&gt;,&lt;strong&gt; &lt;/strong&gt;and&lt;strong&gt;&amp;nbsp;Zero-padding = 1&lt;/strong&gt;, and &lt;strong&gt;Bias&amp;nbsp;= 1&lt;/strong&gt;, what will be the result of convolution?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b)&lt;/strong&gt; What is the result after applying a &lt;strong&gt;ReLU&amp;nbsp;layer ($max(z,0)$)&lt;/strong&gt;on the result with the same size of the reuslt&amp;nbsp;in part a?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c)&lt;/strong&gt; Calculate the output&amp;nbsp;by applying &lt;strong&gt;max-pooling&lt;/strong&gt; layer with the size of $2\times2$ on the output of part b, and &lt;strong&gt;Stride = 1&lt;/strong&gt;. (hint: max-pooling layer here and&amp;nbsp;usually do not include any zero-paddings)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;d)&lt;/strong&gt; What is the result after applying &lt;strong&gt;flatten&lt;/strong&gt; on the output of part c and creating a vector?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e)&lt;/strong&gt; Assume the vector you created contains m elements. Consider it as the input vector for a &lt;strong&gt;Softmax&lt;/strong&gt; &lt;strong&gt;Regression classifier&amp;nbsp;&lt;/strong&gt;(without any hidden layers and biases and it is fully connected). Assume there are 2 classes of 0 and 1. For all the weights from&amp;nbsp;each element in the feature vector, the optimized weights are 1 for odd elements and 2 for even elements. For example, if the feature vector is [10,11,12,13,14], all the weights &lt;strong&gt;from &lt;/strong&gt;10 are 1 (because 10 is element 1 and 1 is odd), all the weights &lt;strong&gt;from&lt;/strong&gt; 11 are 2, all the weights &lt;strong&gt;from&lt;/strong&gt; 12 are&amp;nbsp;1, all the weights &lt;strong&gt;from&lt;/strong&gt; 13 are&amp;nbsp;2 and all the weights &lt;strong&gt;from&lt;/strong&gt; 14 are 1 and so on. Draw the&amp;nbsp;Softmax&amp;nbsp;Regression network and calculate the class should be 0 or 1?&lt;/p&gt;

&lt;p&gt;Hint:&amp;nbsp;&lt;br&gt;
&lt;strong&gt;Softmax Regression:&lt;/strong&gt;&amp;nbsp;$p_{i}=\frac{e^{z_{i}}}{\sum_{i=1}^{c} e^{z_{i}}}$&lt;br&gt;
Where $p_{i}$ is the probability of class $i$ anc $c$ is the number of classes.&lt;/p&gt;</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/650/calculate-convolutions-layer-convolutional-neural-network</guid>
<pubDate>Wed, 26 Jun 2019 08:54:12 +0000</pubDate>
</item>
<item>
<title>What loss function to use in CNN-SVM model</title>
<link>https://ask.ghassem.com/641/what-loss-function-to-use-in-cnn-svm-model</link>
<description>I am using Matlab R2018b and am trying to infuse SVM classifier within CNN. My plan is to use CNN only as a feature extractor and use SVM as the classifier. I know people have already implemented it a few years back either in tensorflow or in other platforms. In implementing this I got stuck at a point during backward propagation. I got puzzled about which loss function I need to implement to upgrade the gradients and the parameters.&lt;br /&gt;
&lt;br /&gt;
Few points came up during this:&lt;br /&gt;
&lt;br /&gt;
1. I got a feeling to implement the hinge loss here. But which form of hinge loss should I implement? Should I move on to the second form of hinge loss implementation for calculating loss during backward propagation?&lt;br /&gt;
&lt;br /&gt;
2. Besides, calculating the backward loss, should I calculate the forward loss as well to find out the loss occurred in the model?&lt;br /&gt;
&lt;br /&gt;
Any form of advice doing this CNN-svm infusion will be appreciated as I am unable to find any such material implemented in Matlab to get help.&lt;br /&gt;
&lt;br /&gt;
Thanks.</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/641/what-loss-function-to-use-in-cnn-svm-model</guid>
<pubDate>Sat, 08 Jun 2019 09:24:21 +0000</pubDate>
</item>
<item>
<title>is impossible predict hours time series to minutes time series?</title>
<link>https://ask.ghassem.com/625/is-impossible-predict-hours-time-series-minutes-time-series</link>
<description>&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://stackoverflow.com/questions/55930051/is-impossible-predict-hours-time-series-to-minutes-time-series&quot;&gt;https://stackoverflow.com/questions/55930051/is-impossible-predict-hours-time-series-to-minutes-time-series&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i want to this hours time series predict model to minute predict model&lt;/p&gt;</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/625/is-impossible-predict-hours-time-series-minutes-time-series</guid>
<pubDate>Wed, 01 May 2019 13:11:26 +0000</pubDate>
</item>
<item>
<title>Training neutral net with Tensor Flow</title>
<link>https://ask.ghassem.com/513/training-neutral-net-with-tensor-flow</link>
<description>Hello,&lt;br /&gt;
&lt;br /&gt;
I have a jpeg, where each image is around 1080 x 2048 in size and I have around 3000 of those images. I want to train a simple NN on this data. However, I am not sure how to feed the image data in to tensor flow. The examples online have a minst data which is easier since the image size is smaller.&lt;br /&gt;
&lt;br /&gt;
When i tried make an numpy array out of the images I have i get the memory exception.&lt;br /&gt;
&lt;br /&gt;
Any help would be appreciated !</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/513/training-neutral-net-with-tensor-flow</guid>
<pubDate>Mon, 12 Nov 2018 20:09:54 +0000</pubDate>
</item>
<item>
<title>Using Tensorflow.DNNClassifier, getting Error: assertion failed: [Labels must &gt;= 0]</title>
<link>https://ask.ghassem.com/440/tensorflow-dnnclassifier-getting-assertion-failed-labels</link>
<description>&lt;p&gt;Hi All,&lt;/p&gt;

&lt;p&gt;I am writing a simple program using Tensorflow and DNNClassifier. Training Data is 9 pixel with four spectral bands, i.e. 4*9=36 featurs. And each data-point will be mapped to a class (from 1 to 7).&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Last parameter, is the class label.&lt;/p&gt;

&lt;p&gt;A line of data-point is like this:&lt;/p&gt;

&lt;pre&gt;
67,75,77,62,67,79,81,62,75,87,89,71,66,79,88,63,66,79,84,63,66,79,80,59,67,84,86,68,71,84,86,64,67,81,82,64,7&lt;/pre&gt;

&lt;p&gt;But I got below Error:&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-python&quot; data-pbcklang=&quot;python&quot; data-pbcktabsize=&quot;4&quot;&gt;
InvalidArgumentError (see above for traceback): assertion failed: [Labels must &amp;gt;= 0] [Condition x &amp;gt;= 0 did not hold element-wise:] [x (dnn/head/labels:0) = ] [[3][3][3]...]&lt;/pre&gt;

&lt;p&gt;I am sure there is no datapoint&amp;nbsp;which has a label&amp;nbsp;less than 0. Would you please advise?&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-python&quot; data-pbcklang=&quot;python&quot; data-pbcktabsize=&quot;4&quot;&gt;
import numpy as np

import pandas as pd

import tensorflow as tf

from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import GridSearchCV, KFold
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
from sklearn.model_selection import StratifiedShuffleSplit

print(&#039;** DNN Classification *******************************************************&#039;)

landsatData = pd.read_csv(&quot;./resources/landsat/lantsat.1.csv&quot;)

landsatData.describe()

X_landSatAllFeatures = landsatData.iloc[:, np.arange(36)].copy()

y_midPixelAsTarget = landsatData.iloc[:, 36].copy()

# Testing and training sentences splitting (stratified + shuffled) based on the index (sentence ID)
allFeaturesIndexes = X_landSatAllFeatures.index
targetData = y_midPixelAsTarget
sss = StratifiedShuffleSplit(n_splits=1, test_size=0.3, random_state=42)

for train_index, test_index in sss.split(allFeaturesIndexes, targetData):
    train_ind, test_ind = allFeaturesIndexes[train_index], allFeaturesIndexes[test_index]

Test_Matrix = X_landSatAllFeatures.loc[test_ind]
Test_Target_Matrix = y_midPixelAsTarget.loc[test_ind]
Train_Matrix = X_landSatAllFeatures.loc[train_ind]
Train_Target_Matrix = y_midPixelAsTarget.loc[train_ind]

scaler = StandardScaler().fit(Train_Matrix)
Train_Matrix, Test_Matrix = scaler.transform(Train_Matrix), scaler.transform(Test_Matrix)

def reset_graph(seed=42):
    tf.reset_default_graph()
    tf.set_random_seed(seed)
    np.random.seed(seed)

X_train = Train_Matrix
y_train = Train_Target_Matrix
X_test = Test_Matrix
y_test = Test_Target_Matrix

xx, yy = Train_Matrix.shape
#training phase
feature_cols = [tf.feature_column.numeric_column(&quot;X&quot;, shape=[36])]
dnn_clf = tf.estimator.DNNClassifier(hidden_units=[300,100], n_classes=8, feature_columns=feature_cols)
# dnn_clf = tf.estimator.DNNClassifier(hidden_units=[300,100], n_classes=10)


input_fn = tf.estimator.inputs.numpy_input_fn(
    x={&quot;X&quot;: X_train}, y=y_train, num_epochs=40, batch_size=64, shuffle=True)
dnn_clf.train(input_fn=input_fn)

#testing phase
test_input_fn = tf.estimator.inputs.numpy_input_fn(
    x={&quot;X&quot;: X_test}, y=y_test, shuffle=False)
eval_results = dnn_clf.evaluate(input_fn=test_input_fn)
print(&quot;The prediction result is : {0:.2f}%&quot;.format(100*eval_results[&#039;accuracy&#039;]))
y_pred_iter = dnn_clf.predict(input_fn=test_input_fn)
y_pred = list(y_pred_iter)
y_pred[0]


print(&#039;**********************************************************************************&#039;)&lt;/pre&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/440/tensorflow-dnnclassifier-getting-assertion-failed-labels</guid>
<pubDate>Wed, 24 Oct 2018 03:12:33 +0000</pubDate>
</item>
<item>
<title>What are the best resources for studying Deep Learning?</title>
<link>https://ask.ghassem.com/2/what-are-the-best-resources-for-studying-deep-learning</link>
<description>I am wondering if anyone can suggest the best resources for studying Deep Learning?</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/2/what-are-the-best-resources-for-studying-deep-learning</guid>
<pubDate>Sun, 26 Aug 2018 07:43:30 +0000</pubDate>
</item>
</channel>
</rss>