<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>2018 on Simplestory</title><link>https://simplestory.github.io/en/categories/2018/</link><description>Recent content in 2018 on Simplestory</description><generator>Hugo</generator><language>en-us</language><copyright>Simplestory</copyright><lastBuildDate>Sat, 03 Nov 2018 00:00:00 +0000</lastBuildDate><atom:link href="https://simplestory.github.io/en/categories/2018/index.xml" rel="self" type="application/rss+xml"/><item><title>Deep Learning Optimization</title><link>https://simplestory.github.io/en/posts/20181103_7b202c9a380844d1b8ae2c4f5ee3461f/</link><pubDate>Sat, 03 Nov 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20181103_7b202c9a380844d1b8ae2c4f5ee3461f/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Optimization is a very difficult problem; usually one has to carefully design an objective function and related constraints, and also make sure the problem to be optimized is a convex function, but most real-world problems are non-convex. For non-convex optimization problems there are some basic optimization methods: SGD, Momentum, AdaGrad, RMSProp, Adam and so on&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="stochastic-gradient-descent-sgd"&gt;Stochastic Gradient Descent (SGD)&lt;/h2&gt;
&lt;hr&gt;
&lt;p&gt;// stochastic gradient descent&lt;/p&gt;
&lt;p&gt;Given the dataset $X=\\{x^{(1)},x^{(2)},...,x^{(n)}\\}$ and the dataset labels $Y=\\{y^{(1)}, y^{(2)},...,y^{(n)}\\}$&lt;/p&gt;</description></item><item><title>How the FFM Model Works</title><link>https://simplestory.github.io/en/posts/20181028_fa81994273e28bed9a6b443a7af7f69e/</link><pubDate>Sun, 28 Oct 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20181028_fa81994273e28bed9a6b443a7af7f69e/</guid><description>&lt;blockquote&gt;
&lt;p&gt;CTR (click-through rate) prediction plays an important role in content recommendation and delivery, and the FFM model is good at handling this kind of data. The FFM model is a variant of the FM model, or rather the FM model is a special case of the FFM model&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="rough-pipeline"&gt;Rough pipeline&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Convert the dataset format (using the LIBSVM or FFMs style)&lt;/li&gt;
&lt;li&gt;Compute the loss function (using the exponential loss function)&lt;/li&gt;
&lt;li&gt;Optimize the parameters (using the AdaGrad + SG strategy)&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="converting-the-data-format"&gt;Converting the data format&lt;/h2&gt;
&lt;p&gt;LIBSVM format (does not store zero-valued features):&lt;/p&gt;</description></item><item><title>Decision Tree</title><link>https://simplestory.github.io/en/posts/20180829_3cb42cd7fd688b586f483bd682fc8209/</link><pubDate>Wed, 29 Aug 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180829_3cb42cd7fd688b586f483bd682fc8209/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Decision tree, a common machine learning method, is somewhat like a flowchart. A sample is divided into a set according to the value it takes on some feature, and this is done recursively&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="basic-algorithm"&gt;Basic algorithm&lt;/h1&gt;
&lt;p&gt;Input: training set $D=\\{(\mathbf{x_1},y_1),(\mathbf{x_2},y_2),...,(\mathbf{x_m},y_m)\\}$;
attribute set $A=\\{a_1,a_2,...,a_d\\}$&lt;/p&gt;
&lt;p&gt;Output: a decision tree with node as the root node&lt;/p&gt;
&lt;p&gt;Simple process:&lt;/p&gt;
&lt;p&gt;Using some splitting criterion, the optimal feature is selected to split the samples, and this is done recursively, finally yielding the branch nodes of the decision tree&lt;/p&gt;</description></item><item><title>A Scikit-learn Cheat Sheet Collection</title><link>https://simplestory.github.io/en/posts/20180826_8cb44c1627565d8ede47d43e49e9c8ae/</link><pubDate>Sun, 26 Aug 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180826_8cb44c1627565d8ede47d43e49e9c8ae/</guid><description>&lt;blockquote&gt;
&lt;p&gt;This time I am putting together the commonly used scikit-learn packages as a memo&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;K-nearest neighbors:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html"&gt;from sklearn.neighbors import KNeighborsClassifier&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Linear regression:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html"&gt;from sklearn.linear_model import LinearRegression&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Logistic regression:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html"&gt;from sklearn.linear_model import LogisticRgression&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Decision tree:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html"&gt;from sklearn.tree import DecisionTreeClassifier&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Naive Bayes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Gaussian distribution: &lt;a href="http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.GaussianNB.html"&gt;from sklearn.neive_bayes import GaussianNB&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Multinomial distribution: &lt;a href="http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.MultinomialNB.html#sklearn.naive_bayes.MultinomialNB"&gt;from sklearn.neive_baybes import MultinomnalNB&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Bernoulli distribution: &lt;a href="http://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.BernoulliNB.html#sklearn.naive_bayes.BernoulliNB"&gt;from sklearn.neive_baybes import BernoulliNB&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Support vector machine:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Classification: &lt;a href="http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html"&gt;from sklearn.svm import SVC&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Regression: &lt;a href="http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVR.html"&gt;from sklearn.svm import SVR&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Ensemble algorithms (sklearn.ensemble):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;bagging:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Classification: &lt;a href="http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.BaggingClassifier.html"&gt;from sklearn.ensemble import BaggingClassifier&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Bayesian Classification</title><link>https://simplestory.github.io/en/posts/20180819_72c962ee57eaf5ebe2b4645dd6827ce3/</link><pubDate>Sun, 19 Aug 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180819_72c962ee57eaf5ebe2b4645dd6827ce3/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Bayesian decision theory considers how to choose the optimal class label based on the relevant probabilities and misclassification losses&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Suppose there are N possible class labels, that is $\mathbf{y}=\\{c_1,c_2,...,c_N\\}$, and $\lambda_{ij}$ is the loss incurred by misclassifying a sample whose true label is $c_j$ as $c_i$. Based on the posterior probability $P(c_i\vert\mathbf{x})$, we can obtain the expected loss incurred by classifying sample $\mathbf{x}$ as $c_i$, that is, the &amp;ldquo;conditional risk&amp;rdquo; on sample $\mathbf{x}$:&lt;/p&gt;</description></item><item><title>SVM Support Vector Machine</title><link>https://simplestory.github.io/en/posts/20180816_7ed73172fd758adf99c76ebc108ea063/</link><pubDate>Thu, 16 Aug 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180816_7ed73172fd758adf99c76ebc108ea063/</guid><description>&lt;blockquote&gt;
&lt;p&gt;SVM is a very important model in machine learning, proposed by Vladimir Vapnik, the father of statistical learning theory&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;This post takes binary classification with SVM as the example&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id="derivation"&gt;Derivation&lt;/h2&gt;
&lt;p&gt;Given the training dataset $D=\\{(\mathbf{x_1},y_1),(\mathbf{x_2},y_2),...,(\mathbf{x_m},y_m)\\}, y_i \in \\{-1, +1\\}$, the most basic idea of a classifier is to find in the sample space a dividing space based on the training set D that separates the samples of different classes. The dividing hyperplane can be described by the following linear equation:&lt;/p&gt;</description></item><item><title>Linear Regression and Logistic Regression</title><link>https://simplestory.github.io/en/posts/20180813_135c495c1e86bceb067f1bc3135c278b/</link><pubDate>Mon, 13 Aug 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180813_135c495c1e86bceb067f1bc3135c278b/</guid><description>&lt;blockquote&gt;
&lt;p&gt;I have not updated the blog for a long time, having paused for about half a year, and I have also read half a year&amp;rsquo;s worth of books on machine learning and deep learning; now it is time to write some output&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="linear-regression"&gt;Linear regression&lt;/h1&gt;
&lt;p&gt;Given a dataset $D=\\{(\mathbf{x_1},y_1),(\mathbf{x_2},y_2),...,(\mathbf{x_m},y_m)\\}$, where $\mathbf{x_i}=(x_{i1};x_{i2};...;x_{id}), \ y_{i} \in R$. Linear regression tries to learn a linear model&lt;/p&gt;
$$f(x_i)=wx_i+b$$&lt;p&gt;such that $f(x_i)\simeq y_i$.&lt;/p&gt;
&lt;h2 id="derivation"&gt;Derivation&lt;/h2&gt;
&lt;p&gt;Consider using MSE (mean squared error) to measure how good the model is; then the loss function $L(w,b)$ is:&lt;/p&gt;</description></item><item><title>Using g++ and gdb</title><link>https://simplestory.github.io/en/posts/20180302_5ed219da904f7b6718ebebb4c8b47d3c/</link><pubDate>Fri, 02 Mar 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180302_5ed219da904f7b6718ebebb4c8b47d3c/</guid><description>&lt;blockquote&gt;
&lt;p&gt;G++ is the C++ compiler under Unix/Linux, and gdb is a powerful debugging tool under Unix/Linux. Most of the time, the C/C++ code we write does not run on Windows but on a Linux system. Here I record some usage of g++ and gdb in case they are needed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="using-g"&gt;Using g++&lt;/h3&gt;
&lt;p&gt;When g++ performs compilation work, it needs 4 steps in total:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Preprocessing, generating a .i file, mainly expanding header files and macro definitions: &lt;code&gt;g++ -E test.cpp -o test.i&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Compilation, converting the preprocessed file into assembly language and generating a .s file: &lt;code&gt;g++ -S test.i -o test.s&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Assembly, turning the assembly into object code (machine code) and generating a .o file, mainly converting the .s file into a binary file: &lt;code&gt;g++ -c test.s -o test.o&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Linking, linking the object code to generate an executable program: &lt;code&gt;g++ test.o -o test&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The steps above can also be done with a single command:&lt;/p&gt;</description></item><item><title>Configuring Django on Ubuntu</title><link>https://simplestory.github.io/en/posts/20180219_c851e812699d1207837d404c0af593ce/</link><pubDate>Mon, 19 Feb 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180219_c851e812699d1207837d404c0af593ce/</guid><description>&lt;blockquote&gt;
&lt;p&gt;At the time of the 2018 Spring Festival, heaven knows what I went through, posting a blog article on the fourth day of the new year. Django was actually configured before the New Year; I had just learned some knowledge about developing web applications with python at that time, so I configured it along the way.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Environment used for the configuration&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;System: Ubuntu16.04 (LTS)&lt;/li&gt;
&lt;li&gt;python version: python3.6 (using Anaconda to create a virtual environment)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="preparation"&gt;Preparation&lt;/h2&gt;
&lt;h4 id="uninstalling-an-old-version-of-django"&gt;Uninstalling an old version of Django&lt;/h4&gt;
&lt;p&gt;If you are upgrading from an older version of Django, you need to deal with the old version a little.&lt;/p&gt;</description></item><item><title>Configuring Tensorflow on Linux</title><link>https://simplestory.github.io/en/posts/20180204_68b9e972b5a534bc31d12d9be53b57ec/</link><pubDate>Sun, 04 Feb 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180204_68b9e972b5a534bc31d12d9be53b57ec/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Borrowing a line from the &lt;a href="http://www.tensorfly.cn/"&gt;TensorFlow Chinese community&lt;/a&gt;: TensorFlow, an open-source magic tool for artificial intelligence.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Environment used for the configuration&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;System: Ubuntu16.04 (LTS)&lt;/li&gt;
&lt;li&gt;python version: python3.6 (using Anaconda to create a virtual environment)&lt;/li&gt;
&lt;li&gt;Nvidia card: Geforce 920M (if there is no Nvidia card, only the CPU version can be installed)&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id="installing-tensorflow"&gt;Installing Tensorflow&lt;/h1&gt;
&lt;p&gt;tensorflow has two versions, CPU and GPU; I created two python virtual environments and installed these two versions separately. Below I record this painful installation process&lt;/p&gt;</description></item><item><title>Linux Penetration Testing Commands</title><link>https://simplestory.github.io/en/posts/20180120_3e2c28e497c306d34f88081093e32c89/</link><pubDate>Sat, 20 Jan 2018 00:00:00 +0000</pubDate><guid>https://simplestory.github.io/en/posts/20180120_3e2c28e497c306d34f88081093e32c89/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Below is a penetration testing memo for Linux machines; I came across it on the internet by chance and copied it over here.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="penetration-testing-a-linux-machine"&gt;Penetration testing a Linux machine&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align:left"&gt;Command&lt;/th&gt;
&lt;th style="text-align:left"&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;netstat -tulpn&lt;/td&gt;
&lt;td style="text-align:left"&gt;Show network ports in Linux together with the corresponding ID (PID)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;watch ss -stplu&lt;/td&gt;
&lt;td style="text-align:left"&gt;Observe TCP and UDP ports in real time through sockets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;lsof -i&lt;/td&gt;
&lt;td style="text-align:left"&gt;Show established connections&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;macchanger -m MACADDR INTR&lt;/td&gt;
&lt;td style="text-align:left"&gt;Change the MAC address on KALI Linux&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;ifconfig eth0 192.168.2.1/24&lt;/td&gt;
&lt;td style="text-align:left"&gt;Set the IP address in Linux&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;ifconfig eth0:192.168.2.3/24&lt;/td&gt;
&lt;td style="text-align:left"&gt;Add an IP address to an existing network interface in Linux&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;ifconfig eth0 hw ether MAC ADDR&lt;/td&gt;
&lt;td style="text-align:left"&gt;Change the address in Linux using ifconfig&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;ifconfig eth0 mtu 1500&lt;/td&gt;
&lt;td style="text-align:left"&gt;Change the MTU size with ifconfig; change 1500 to the MTU you want&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;dig -x 192.168.1.1&lt;/td&gt;
&lt;td style="text-align:left"&gt;Perform a reverse lookup on an IP address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;host 192.168.1.1&lt;/td&gt;
&lt;td style="text-align:left"&gt;Perform a reverse lookup on an IP address; useful when dig is not installed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;dig @192.168.2.2 domain.com -t AXFR&lt;/td&gt;
&lt;td style="text-align:left"&gt;Perform a DNS zone transfer with dig&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;host -l domain.com nameserver&lt;/td&gt;
&lt;td style="text-align:left"&gt;Perform a DNS zone transfer with host&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;nbtstat -A x.x.x.x&lt;/td&gt;
&lt;td style="text-align:left"&gt;Obtain the domain name corresponding to an IP address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;ip addr add 192.168.2.22/24 dev eth0&lt;/td&gt;
&lt;td style="text-align:left"&gt;Add a hidden IP address that does not show up when running ifconfig&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;tcpkill -9 host goole.com&lt;/td&gt;
&lt;td style="text-align:left"&gt;Block access to goole.com from the host&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;echo &amp;quot;1&amp;quot;&amp;gt;/proc/sys/net/ipv4/ip_forward&lt;/td&gt;
&lt;td style="text-align:left"&gt;Enable IP forwarding, turning the Linux box into a router — which makes it convenient to control the traffic routed through this box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:left"&gt;echo &amp;quot;8.8.8.8&amp;quot;&amp;gt;/etc/resolv.conf&lt;/td&gt;
&lt;td style="text-align:left"&gt;Use Goole's DNS&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="system-information-commands"&gt;System information commands&lt;/h2&gt;
&lt;p&gt;Very helpful for local enumeration&lt;/p&gt;</description></item></channel></rss>