date
stringlengths
10
10
nb_tokens
int64
60
629k
text_size
int64
234
1.02M
content
stringlengths
234
1.02M
2018/10/18
864
3,725
<issue_start>username_0: Introduction ------------ Exhaustive search is a method in AI planning to find a solution for so-called Constraint Satisfaction Problems. (CSP). Those are problems that have some conditions to fulfill and the solver is trying out all the alternatives. An example CSP problem is the 8-queens problem which has geometrical constraints. The standard method in finding a solution for the 8-queens problem is a backtracking solver. That is an algorithm that generates a tree for the state space to search inside the graph. Apart from practical applications of backtracking search, there are some logic-oriented discussions available which are asking on a formal level which kind of problems have a solution and which not. For example to find a solution for the 8-queen problem many millions of iterations of the algorithm are needed. The question is now: which problems are too complex to find a solution. The second problem is, that sometimes the problem itself has no solution, even the complete state space was searched fully. Let us take an example. At first, we construct a problem in which the constraints are so strict that even a backtracking search won't find a solution. One example would be to prove that “1+1=3” another example would be to find a chess sequence if the game is lost or it is also funny to think about how to arrange nine! queen on a chess table so that they don't hurt. Is there any literature available which is describing Constraint Satisfaction Problems on a theoretical basis in which the constraints of the problem are too strict? Original posting ---------------- Just wondering - like with an 8-queens problem. If we change it to a 9-queens problem and do an exhaustive search, we will see that there is no solution. Is there a problem in which the search fails to show that a solution does not exist?<issue_comment>username_1: *This should be a comment, but I don't have enough reputation to comment. I will remove this answer if question is updated* Your question is not really clear. As I understand it, the definition itself of the exhaustive search show that it's always possible to determine if a solution is valid or not. Exhaustive search is defined as : * For a given potential solution, can determine if this solution resolve the problem. * Test every possible potential solution From this, there is no problem where every potential solution is tested, but the search cannot show that a solution exist : either it exist and the search found the candidate, or it does not exist because all possible candidates were tested. --- Maybe what you meant when asking your question is : "Any problems in which exhaustive search cannot be applied ?" And the answer is yes, there is plenty of problems where the search space is way to big to be integrally searched : for example the Rubik's cube 3\*3\*3 has 43 252 003 274 489 856 000 combinations ([source](https://www.therubikzone.com/number-of-combinations/)). *My answer need more source, specifically about the exhaustive search definition. I would be happy to add it if you could share :)* Upvotes: 1 <issue_comment>username_2: In addition to the problems like Rubik's cube (as described by @username_1) which are practically too complex to solve exhaustively (due to limitations of speed and memory of our machines), there are other problems which no one has yet been able to show can be solved, like [Halting Problem](https://en.wikipedia.org/wiki/Halting_problem). Moreover, with the advances in Quantum Machine Learning we may be able to solve problems which are yet impractical to solve with exhaustive search (like Rubik's Cube). Problems like Halting Problem are a different story. Upvotes: 0
2018/10/19
1,739
6,877
<issue_start>username_0: I've created a neural net using the ConvNetSharp library which has 3 fully connected hidden layers. The first having 35 neurons and the other two having 25 neurons each, each layer with a ReLU layer as the activation function layer. I'm using this network for image classification - kinda. Basically it takes inputs as raw grayscale pixel values of the input image and guesses an output. I used stochastic gradient descent for the training of the model and a learning rate of 0.01. The input image is a row or column of OMR "bubbles" and the network has to guess which of the "bubble" is marked i.e filled and show the index of that bubble. I think it is because it's very hard for the network to recognize the single filled bubble among many. Here is an example image of OMR sections: [![OMR bubbles example](https://i.stack.imgur.com/F1cql.png)](https://i.stack.imgur.com/F1cql.png) Using image-preprocessing, the network is given a single row or column of the above image to evaluate the marked one. Here is an example of a preprocessed image which the network sees: [![OMR bubble column - what the network sees](https://i.stack.imgur.com/3r60U.png)](https://i.stack.imgur.com/3r60U.png) Here is an example of a marked input: [![Marked OMR Column](https://i.stack.imgur.com/LF0AO.png)](https://i.stack.imgur.com/LF0AO.png) I've tried to use Convolutional networks but I'm not able to get them working with this. **What type of neural network and network architecture should I use for this kind of task? An example of such a network with code would be greatly appreciated.** I have tried many preprocessing techniques, such as background subtraction using the AbsDiff function in EmguCv and also using the MOG2 Algorithm, and I've also tried threshold binary function, but there still remains enough noise in the images which makes it difficult for the neural net to learn. I think this problem is not specific to using neural nets for OMR but for others too. It would be great if there could be a solution out there that could store a background/template using a camera and then when the camera sees that image again, it perspective transforms it to match exactly to the template I'm able to achieve this much - and then find their difference or do some kind of preprocessing so that a neural net could learn from it. If this is not quite possible, then is there a type of neural network out there which could detect very small features from an image and learn from it. I have tried Convolutional Neural Network but that also isn't working very well or I'm not applying them efficiently.<issue_comment>username_1: I'm not familiar with ConvNetSharp library, and the tag `convolutional-neural-networks` is a bit confusing me, but from : > > So I've created a neural net using the ConvNetSharp library which has 3 fully connected hidden layers. The first having 35 neurons and the other two having 25 neurons, each with a ReLU layer as the activation function layer. > > > I assume you are building just a densely connected neural network. Correct me if I'm wrong. --- The type of neural network you need is **Convolutional Neural Network**. For image recognition (which is your case), convolutional network are almost always the answer. There is plenty of type of CNN, just pick one that seems appropriate and try. In my opinion, your task seems quite simple, you won't need really deep / complex architecture. --- > > It would be great if there could be a solution out there that could store a background/template using a camera and then when the camera sees that image again > > > I am not aware of a model that could do what you are asking. But what you are asking is not really in the 'neural network' mindset. The goal of building a neural network is that you don't specify anything. The neural network will learn and find the features for you. So you just have to feed him a lot of data, and he will be able to recognize your pattern. Take a look at this visualization of CNN filters : [![enter image description here](https://i.stack.imgur.com/SExae.jpg)](https://i.stack.imgur.com/SExae.jpg) Here, no one gave the neural network the template of a nose or the template of an eye or the template of a face. The CNN learned it over a lot of image. Upvotes: 1 <issue_comment>username_2: Is it the case that one of the numbers if filled in? If so a CNN with 10 output should work well. Just choose the output that has the highest probability. If your data allows no number to be filled in, then have 11 outputs where the eleventh output indicates none is filled in. I would recommend transfer learning using the MobileNet model. Documentation is [here](https://keras.io/applications/). Here is the code to adapt MobileNet to your problem: ``` image_size=128 no_of_classes=10 # set to 11 if in some cases no numbers are filled in lr_rate=.001 dropout=.4 mobile = tf.keras.applications.mobilenet.MobileNet( include_top=False, input_shape=(image_size,image_size,3), pooling='avg', weights='imagenet', alpha=1, depth_multiplier=1) x=mobile.layers[-1].output x=keras.layers.BatchNormalization(axis=-1, momentum=0.99, epsilon=0.001 )(x) x=Dense(128, kernel_regularizer = regularizers.l2(l = 0.016),activity_regularizer=regularizers.l1(0.006), bias_regularizer=regularizers.l1(0.006) ,activation='relu')(x) x=Dropout(rate=dropout, seed=128)(x) x=keras.layers.BatchNormalization(axis=-1, momentum=0.99, epsilon=0.001 )(x) predictions=Dense (no_of_classes, activation='softmax')(x) model = Model(inputs=mobile.input, outputs=predictions) for layer in model.layers: layer.trainable=True model.compile(Adam(lr=lr_rate), loss='categorical_crossentropy', metrics=['accuracy']) ``` I would also create a training, test and validation set with about 150 images in the test set and 150 images in the validation set leaving 1700 images for training. I also recommend you use two useful callbacks. Documentation is [here](https://keras.io/callbacks/). Use the ReduceLROnPlateau callback to monitor the validation loss and adjust the learning rate downward by a factor. Use ModelCheckpoint to monitor the validation loss and save the model with the lowest validation loss to use to make predictions on the test set. Upvotes: 1 <issue_comment>username_3: From what I understand, don't bother with a CNN, you have essentially perfectly structured images. You can hand code detectors to measure how much filled in a circle is. Basically do template alignment and then search over the circles. Ex a simple detector would measure the average blackness of the circle which you could then threshold. Upvotes: 3 [selected_answer]
2018/10/19
940
3,842
<issue_start>username_0: What are some ways to design a neural network with the restriction that the $L\_1$ norm of the output values must be less than or equal to 1? In particular, how would I go about performing back-propagation for this net? I was thinking there must be some "penalty" method just like how in the mathematical optimization problem, you can introduce a log barrier function as the "penalty function"<issue_comment>username_1: The term 'size' isn't applicable to the tensor output of a network or network. These are the qualities. * Rank $N$ that defines the rank of each tensor instance in $\mathbb{R}^N$ * Ranges of the indices to the dimensions from $1$ to $N$ * Ranges of the scalar values that comprise the tensor instance — If they are discrete rather than real (approximated by floating point or fixed point numbers), then the range is the description of the permissible ordinal values. The question may be referring to this last quality. The imposition of a penalty for values that are in the range of the numeric type used as the output of the last activation function but not in the allowable range of output for the desired trained function works in a limited way. It skews the output distribution with respect to the natural distribution of possible learning states and therefore can easily interfere with convergence quality or speed or both. There are a number of techniques that map natural output distribution with constrained ranges, but it must be done without skewing the distribution upstream from the technique used, to avoid negatively impacting favorable convergence properties of the artificial network. One simple case that can be described here is when the number of possible output states is in the set of $2^i$ where $i \in$ { positive integers }. In such a case, the final layer of the network can be $i$ threshold activation functions with 1 or -1 as possible output values. In that case, the ordinal then becomes $$o = \sum\_{n=0}^i \frac {y\_n + 1} {2},$$ where $y\_n$ is the output from activation function index $n$. Upvotes: -1 <issue_comment>username_2: Penalty ([barrier function](https://en.wikipedia.org/wiki/Barrier_function)) is perfectly valid and simplest method for simplex type constraint (L1 norm is simplex constraint on absolute values). Any type of barrier function may work, logarithmic, reciprocal or quadratic. All of them supported by any major framework(pytorch, tensorflow), just add them to loss function. You would need some hyperparameter tuning for the scale factor of penalty. There is more efficient, though more complex way to do it. Instead of putting constraint you can automatically output value wich satisfy simplex constraint: Assume that L1 norm constraint is $\left \|v\right \|\_1 \leq 1$, $v \in \mathbb{R}^n$ 1. put $sigmoid(v\_i)$ activation on output to norm elements to [-1, 1] 2. add slack (fake) variable element $v\_{n+1} = 1 - \sum\_{1}^{n} v\_i $ 3. project new $v{}'\in \mathbb{R}^{n+1}$, $v{}'\_i = |v\_i|,1\leq i \leq n+1$ onto unit simplex [with standard algorithm](https://en.wikipedia.org/wiki/Simplex#Projection_onto_the_standard_simplex) (also [here](https://arxiv.org/abs/1101.6081)) Backpropagation of last step may require *differentiable sorting*, which is missing in most of frameworks, you may have to look for open sourced implementation, for example extract it from [here](https://github.com/MaestroGraph/sparse-hyper) or use some automatic differentiation package. Both require some substantial code reading/debugging. However in my experience assuming constant $\Delta$ also works in many cases, in that case differentiable sorting is not needed. Intuition behind constant $\Delta$ is that $\Delta$ could be chosen such way that there is some interval on which it's value doesn't affect sorting order. Upvotes: 2
2018/10/21
715
3,057
<issue_start>username_0: What is the best and easiest programming language to learn to implement genetic algorithms? C++ or Python, or any other?<issue_comment>username_1: There is no "best language" for any problem. There are too many variables to consider, even when advising a single person with a single project plan. If the choice is between Python and C++, I would generally advise: * If you want to implement from scratch and learn how the algorithm works, use Python with numeric/accelerated libraries such as NumPy or PyTorch. Python script is quicker to prototype and try different ideas, due to loose variable typing and built-in high-level structures such as `dict` and `list`. * If you want to write core, efficient libraries, then C++ will out-perform Python, but writing these will take longer. There are plenty of C++ libraries available (e.g. TensorFlow is available with a C++ API), but the community around them is less focused than with Python toolkits. You can also combine both approaches and write specific libraries in C or C++ to improve performance at any time. With Genetic Algorithms, the speed bottleneck is most often population assessment - e.g. running the environment simulation to get a fitness measure for each individual - and not the GA itself. So if you have a specific problem or problem domain in mind, may want to orient your choice around a language that already has support for the kind of environments where you want to run your GA. GAs usually benefit greatly from parallelisation, so if you are aiming for something ambitious you will want to look into GPU support and/or distributed computing toolkits. Most researchers/hobbyists working in AI-related fields end up using multiple languages over time. You may end up with a favourite language environment, which might be Python, Julia, Java, C++, C, C#, Lua, LISP, Prolog, Matlab/Octave, R . . . but you will end up needing a smattering of other languages, and usually skills with specific toolkits such as TensorFlow, Scikit-Learn, Hadoop etc in order to complete projects. Don't be afraid that you will "waste time" learning in one language initially then needing to transfer to another. Your learning of algorithms will be transferable, and your first attempts will most likely not be that re-usable as library code anyway, so you are going to re-implement your ideas, perhaps many times. My first simulated annealing project was written in Fortran 77 . . . 20 years later I dug that knowledge up again and implemented in Ruby/C - nowadays I work in Python for the AI/hobby stuff even though my professional career sees me working mostly in Ruby. Upvotes: 3 <issue_comment>username_2: Matlab may be a good option to get started with the implementation of genetic algorithms, given that there a lot of pre-defined functions. See e.g. <https://www.mathworks.com/discovery/genetic-algorithm.html> and <https://www.mathworks.com/help/gads/examples/coding-and-minimizing-a-fitness-function-using-the-genetic-algorithm.html>. Upvotes: -1 [selected_answer]
2018/10/21
3,358
9,003
<issue_start>username_0: I am trying to study the book [Reinforcement Learning: An Introduction](http://incompleteideas.net/book/bookdraft2018jan1.pdf) (Sutton & Barto, 2018). In chapter 3.1 the authors state the following exercise > > *Exercise 3.5* Give a table analogous to that in Example 3.3, but for $p(s',r|s,a)$. It should have columns for $s$, $a$, $s'$, $r$, and $p(s',r|s,a)$, and a row for every 4-tupel for which $p(s',r|s,a)>0$. > > > The following table and graphical representation of the Markov Decision Process is given on the next page. [![Example 3.3](https://i.stack.imgur.com/5xt43.png)](https://i.stack.imgur.com/5xt43.png) I tried to use $p(s'\cup r|s,a)=p(s'|s,a)+p(r|s,a)-p(s' \cap r|s,a)$ but without a significant progress because I think this formula does not make any sense as $s'$ and $r$ are not from the same set. How is this exercise supposed to be solved? ### Edit Maybe this exercise intends to be solved by using $$p(s'|s,a)=\sum\_{r\in \mathcal{R}}p(s',r|s,a)$$ and $$r(s,a,s')=\sum\_{r\in \mathcal{R}}r\dfrac{p(s',r|s,a)}{p(s|s,a)}$$ and $$\sum\_{s'\in\mathcal{S}}\sum\_{r\in\mathcal{R}}p(s',r|s,a)=1$$ the resulting system is a linear system of 30 equation with 48 unknowns. I think I am missing some equations...<issue_comment>username_1: The function $r(s,a,s')$ gives the *expected* reward in each scenario, but not the distribution of rewards that lead to values $r\_{search}$ and $r\_{wait}$ The text explains that reward is $+1$ for each can found, and that different distributions of numbers of cans are expected when waiting as opposed to searching. However, it does not give any description of the actual distributions, just summarises them as the two expected rewards, and suggests $r\_{search} \gt r\_{wait}$ You have two main ways to answer the exercise: 1. Invent some parameters for the distributions of $r\_{search}$ and $r\_{wait}$ in order to split up single values of $p(s'|s,a)$ into multiple values of $p(s', r|s,a)$. E.g you could decide that $r\_{search}$ consists of $0 \eta\_0 + 1 \eta\_1 + 2 \eta\_2 + 3 \eta\_3$ where $\eta\_0, \eta\_1, \eta\_2, \eta\_3$ are probabilities that sum to $1$ - each row that currently has $r\_{search}$ as the output of $r(s,a,s')$ would then split into 4 rows with reward 0, 1, 2, 3 to complete the new table . . . $r\_{wait}$ would need a different set of parameters. 2. Ignore the details of the distribution, move column $r(s,a,s′)$ to the left and call it $r$, changing $p(s|s,a)$ to $p(s', r|s,a)$. It might be all that's expected given the lack of information. My personal opinion is that the authors want you to think about solution 1 - the only issue is that it requires you to invent some new parameters that were not provided. The ones I name are only a suggestion, they do not represent a specific "correct" answer in terms provided by the book, because the book omits those details. As an example to start with, if you start solution 1, and use parameters as I have labelled them, you will end up with a first row looking like this: $s\qquad \qquad a\qquad \qquad s'\qquad \qquad r \qquad p(s', r| s, a)$ $high \qquad \quad search \qquad high \qquad \quad 0 \qquad \alpha \eta\_0$ Upvotes: 2 <issue_comment>username_2: In the announced problem, most of the transitions aren't possible, so most the terms of equations (3.3) and (3.4) from the book will end up being 0. In my understanding, $$ \begin{align} p(s'= high | s = high, a = search) &= \sum\_{r \in \{0, -3, r\_{search}, r\_{wait}\}} p(s'=high, r | s = high, a = search) \\ &= p(s'=high, r =0 | s = high, a = search) \\ &+p(s'=high, r = -3 | s = high, a = search) \\ &+p(s'=high, r = r\_{search}| s = high, a = search) \\ &+p(s'=high, r = r\_{wait} | s = high, a = search) \end{align} $$ The problem states that if the agent has high batteries and it chooses to search, then there is no chance that it ends up having a negative reward ($r= -3$), thus its transition probability is 0 by definition: $p(s'=high, r = -3 | s = high, a = search) = 0$. Applying the same logic to all other terms, we get, $$ \begin{align} p(s'= high | s = high, a = search) &= \sum\_{r \in \{0, -3, r\_{search}, r\_{wait}\}} p(s'=high, r | s = high, a = search) \\ &= p(s'=high, r = r\_{search}| s = high, a = search) \\ &= \alpha \end{align} $$ It looks weird. I not 100% sure that that's the solution, because the question would not make much of sense (the table would've been quite the same). Upvotes: 1 <issue_comment>username_3: At first, like username_1 says, I thought this could only be solved using the expected rewards instead of actual rewards, or else there wasn't enough information to solve it. But now I think there might be a way to solve this question. Here is my thinking on this problem (I would be curious for anyone's thoughts, as I am working through this book myself). I think the key part is where the book says: > > Each can collected by the robot counts as a unit reward, whereas a reward of $-3$ results whenever the robot has to be rescued. > > > This means that the reward set is actually $\mathcal R = \{0, 1, -3\}$ (we assume that in each timestep, the robot can only collect one can). Now using $$r(s,a,s') = \sum\_r r \frac{p(s',r\mid s,a)}{p(s'\mid s,a)} \tag{3.6}$$ and $$p(s'\mid s,a) = \sum\_r p(s',r\mid s,a)\tag{3.4}$$ it seems possible to solve for all the probabilities. I'll do an example for $(s,a,s') = (\mathtt{high}, \mathtt{search}, \mathtt{high})$ and leave the rest to you (I haven't actually done the rest, since this does seem rather tedious). Equation 3.6 gives $$r\_\mathtt{search} = 0\cdot \frac{p(s', 0 \mid s,a)}{\alpha} + 1\cdot \frac{p(s', 1 \mid s,a)}{\alpha} -3\cdot \frac{p(s', -3 \mid s,a)}{\alpha}$$ Since $p(s', -3 \mid s,a) = 0$ (it's impossible for the robot to have to be rescued, since we started in the "high" state), we get $p(s', 1 \mid s,a) = \alpha r\_\mathtt{search}$. Now equation 3.4 gives $$\alpha = p(s', 0 \mid s,a) + p(s', 1 \mid s,a) + p(s', -3 \mid s,a)$$ which solves to $p(s', 0 \mid s,a) = \alpha - \alpha r\_\mathtt{search}$. So the first two rows of the table will look like: $$\begin{array}{cccc|c} s& a & s' & r & p(s',r\mid s,a)\\ \hline \mathtt{high} & \mathtt{search} & \mathtt{high} & 1 & \alpha r\_\mathtt{search}\\ \mathtt{high} & \mathtt{search} & \mathtt{high} & 0 & \alpha (1- r\_\mathtt{search}) \end{array}$$ Upvotes: 2 <issue_comment>username_4: > > This means that the reward set is actually R={0,1,−3} (we assume that in each timestep, the robot can only collect one can). > > > @riceissa While I agree with the rest of your demonstration, I wouldn't assume that the robot can only collect 0 or 1 can. As username_1 suggest, I think the robot could pick any number of cans between 0 and N. Below is how I solve the problem for the more general case, assuming specific values for $s',s, a$. This generalization encompasses @riceissa answer. --- Let : * $S\_t=s'=\texttt{high}$ * $S\_{t-1}=s=\texttt{high}$ * $A\_{t-1}=a=\texttt{search}$ We have the following equality : $$r\_{search}=\sum\_{r \in R}r\cdot\frac{p(s', r|s, a)}{p(s'|s, a)}$$ For these values of $s', s, a$ we also have: * $p(s'|s,a)=\alpha$. * $p(s', -3|s,a)=0$ Writing $\eta\_r:=p(s',r|s,a)$ and for $R=\{0, 1, 2, \dots,N\}$ (we omit $r=-3$ since the proba is 0 for this case) we have then: \begin{align\*} r\_{\texttt{search}}&=\sum\_{r=0}^N r\cdot\frac{\eta\_r}{\alpha}\\ r\_{\texttt{search}}\cdot\alpha&=\sum\_{r=0}^N r\cdot\eta\_r\\ r\_{\texttt{search}}\cdot\alpha&=i\cdot\eta\_i + \sum\_{\substack{r=0 \\ r\neq i}}^N r\cdot\eta\_r\\ i\cdot\eta\_i&= r\_{\texttt{search}}\cdot\alpha- \sum\_{\substack{r=0 \\ r\neq i}}^N r\cdot\eta\_r \end{align\*} For $i\neq 0$ : $$\eta\_i= \frac{1}{i}\cdot\left(r\_{\texttt{search}}\cdot\alpha- \sum\_{\substack{r=0 \\ r\neq i}}^N r\cdot\eta\_r\right)$$ For $i=0$, we use that fact that \begin{align\*} \alpha&=p(s'|s,a)=\sum\_{r=0}^N p(s',r|s,a)=\sum\_{r=0}^N\eta\_r\\ &\Rightarrow\eta\_0=\alpha - \sum\_{r>0} \eta\_r \end{align\*} So substituting $\eta\_r$ by its probability formula we end up having, for these specific values of $s', s, a$ : \begin{equation} \begin{cases} p(s',i|s,a)= \frac{1}{i}\cdot\left(r\_{\texttt{search}}\cdot\alpha- \sum\_{\substack{r=0 \\ r\neq i}}^N r\cdot p(s',r|s,a)\right) & \texttt{$\forall i \in [1,N]$}\\ p(s',0|s,a)=\alpha -\sum\_{r>0} p(s',r|s,a) & \texttt{if $i=0$} \end{cases} \end{equation} Upvotes: 1 <issue_comment>username_5: My understanding is that it will be the same as p(s' | s, a) for any s, a, s', r combination. The reward r(s, a, s') is already defined in terms of s, a, s'. Since p(s', r| s, a) = p(r|s', a, s)\* p(s'| a, s). For each case the p(r | s', a, s) is equal to 1 by definition. Thus, the column for p(s', r| a, s) = p(s'| s, a) For instance, If, S= high, A=search and S'=High, then the reward is always alpha. p(r=alpha| s=high, a = search , s'=high) = 1 (you always get that reward for this case) etc. Upvotes: 0
2018/10/21
881
3,323
<issue_start>username_0: > > Batch size is a term used in machine learning and refers to the number of training examples utilised in one iteration. The batch size > can be one of three options: > > > 1. **batch mode**: where the batch size is equal to the total dataset thus making the iteration and epoch values equivalent > 2. **mini-batch mode**: where the batch size is greater than one but less than the total dataset size. Usually, a number that can be divided into the total dataset size. > 3. **stochastic mode**: where the batch size is equal to one. Therefore the gradient and the neural network parameters are updated after each sample. > > > How do I choose the optimal batch size, for a given task, neural network or optimization problem? If you hypothetically didn't have to worry about computational issues, what would the optimal batch size be?<issue_comment>username_1: Here are a few guidelines, inspired by the deep learning specialization course, to choose the size of the mini-batch: * If you have a small training set, use batch gradient descent (m < 200) In practice: * Batch mode: long iteration times * Mini-batch mode: faster learning * Stochastic mode: lose speed up from vectorization The typically mini-batch sizes are 64, 128, 256 or 512. And, in the end, make sure the minibatch fits in the CPU/GPU. Have also a look at the paper [Practical Recommendations for Gradient-Based Training of Deep Architectures](https://arxiv.org/abs/1206.5533) (2012) by <NAME>. Upvotes: 3 <issue_comment>username_2: *From the blog [A Gentle Introduction to Mini-Batch Gradient Descent and How to Configure Batch Size](https://machinelearningmastery.com/gentle-introduction-mini-batch-gradient-descent-configure-batch-size/) (2017) by <NAME>*. > > How to Configure Mini-Batch Gradient Descent > -------------------------------------------- > > > Mini-batch gradient descent is the recommended variant of gradient > descent for most applications, especially in deep learning. > > > Mini-batch sizes, commonly called “batch sizes” for brevity, are often > tuned to an aspect of the computational architecture on which the > implementation is being executed. Such as a power of two that fits the > memory requirements of the GPU or CPU hardware like 32, 64, 128, 256, > and so on. > > > Batch size is a slider on the learning process. > > > * Small values give a learning process that converges quickly at the cost of noise in the training process. > * Large values give a learning process that converges slowly with accurate estimates of the error gradient. > > > **Tip 1: A good default for batch size might be 32.** > > > Upvotes: 3 <issue_comment>username_3: The batch size can also have a significant impact on your model’s performance and the training time. In general, the optimal batch size will be lower than 32 (in April 2018, <NAME> even tweeted "Friends don’t let friends use mini-batches larger than 32“). A small batch size ensures that each training iteration is very fast, and although a large batch size will give a more precise estimate of the gradients, in practice this does not matter much since the optimization landscape is quite complex and the direction of the true gradients do not point precisely in the direction of the optimum Upvotes: 2
2018/10/22
681
2,858
<issue_start>username_0: Why are we now considering neural networks to be artificial intelligence?<issue_comment>username_1: > > Why are we now considering neural networks to be artificial intelligence? > > > "We" aren't. It is generally due to reporting by media sources that simplify science and technology news. The definition of AI is somewhat fluid, and also contentious at times, but in research and scientific circles it has not changed to the degree that AI=NN. What has happened is that research into neural networks has produced some real advances in the last decade. These advances have taken research-only issues such as very basic computer vision, and made them good enough to turn into technology products that can be used in the real world on commodity hardware. These *are* game-changing technology advances, and they use neural networks internally. Research and development using neural networks is still turning out new and improved ideas, so has become a very popular area to learn. A lot of research using neural networks is also research into AI. Aspects such as computer vision, natural language processing, control of autonomous agents are generally considered parts of AI. This has been simplified in reporting, and used by hyped-up marketing campaigns to label pretty much any product with a NN in it as "Artificial Intelligence". When often it is more correctly statistics or *Data Science*. Data Science is another term which has been somewhat abused by media and technology companies - the main difference between use of AI and Data Science is that Data Science was a new term, so did not clash with pre-existing uses of it. The rest of AI as a subject and area of study has not gone away. Some of it may well use neural networks as part of a toolkit to build or study things. But not all of it, and even with the use of NNs, the AI part is not necessarily the neural network. Upvotes: 4 [selected_answer]<issue_comment>username_2: AI is not only about neural networks. Formal proof assistants (like [Coq](https://en.wikipedia.org/wiki/Coq), or [Frama-C](https://frama-c.com/)) are in some circles considered as AI. Projects like [DECODER](https://decoder-project.eu/) have an AI flavor. Symbolic AI systems (like [RefPerSys](http://refpersys.org/)) and more generally [expert systems](https://en.wikipedia.org/wiki/Expert_system) are advocated in AI books like *Artificial Beings, the conscience of a conscious machine*. That book (by Pitrat) don't mention much neural networks. Neural networks are good for some problems (e.g. computer vision), but less adequate for other problems. Autonomous robots (like [Mars Pathfinder](https://en.wikipedia.org/wiki/Mars_Pathfinder)) don't use only neural networks. Natural language processing is a subpart of AI, and is not only using a neural network approach. Upvotes: 1
2018/10/24
872
3,752
<issue_start>username_0: The intelligence of the human brain is said to be a strong factor leading to human survival. The human brain functions as an overseer for many functions the organism requires. Robots can employ artificial intelligence software, just as humans employ brains. When it comes to the human brain, we are prone to make mistakes. However, artificial intelligence is sometimes presented to the public as perfect. Is artificial intelligence really perfect? Can AI also make mistakes?<issue_comment>username_1: > > When it comes to the human brain, we are prone to make mistakes. However, artificial intelligence is sometimes presented to the public as perfect. Do artificial intelligent systems make mistakes? > > > Anything that exists outside of fiction that can be called AI and is not trivial is not perfect. Examples: * Alexa: [creepy laugh](https://www.theverge.com/circuitbreaker/2018/3/7/17092334/amazon-alexa-devices-strange-laughter) - not trivial, but not perfect * Tic-Tac-Toe / Connect four: perfect algorithms exist, but trivial (you can create a game tree) The problem is that you didn't bother to define "perfect". What does it mean to be perfect? Natural selection favors living beings that are energy efficient. Remembering everything might be considered perfect, but it is certainly not efficient. We tend to make mistakes because some skills - especially abstract/mathematical ones or long-term decision making are not supported by natural selection. Another big group of traits that are not supported by natural selection are health traits that are after the age of reproduction / helping children to grow up. Specifically cancer above the age of 40. Upvotes: 2 <issue_comment>username_2: Since the question was tagged with [philosophy](/questions/tagged/philosophy "show questions tagged 'philosophy'"), I'll provide a philosophical perspective. There is no definition of perfection. Just think about the silly example that is always brought up when we talk about autonomous cars: You are about to crash into a group of school kids and the AI's only chance to avoid them is by crashing into an old person. What should the AI do in order to react "perfectly"? All actions that we take are based on our personal value system, so what is perfect to one person might be completely nonsense to another person. It might be possible to create an AI that always acts perfectly in terms of the value system you fitted it out with, but even in this case there are some caveats like: * reaction time: is the system fast enough to process all available information fast enough in order to take a fast action? * available information: not all information might be available with the system. Do you consider it acting imperfect, if the action of the system turns out to be wrong once you posses all information about the situation, even though some information will never be available to the system (e.g. Heisenberg's principle of uncertainty) Upvotes: 3 <issue_comment>username_3: Yes it's error prone, just like us humans. But just like in chess it is just a whole lot better at dealing with it. AI does not contain all the possible knowledge in the universe out of no where without interaction with the world and such it should need to make assumptions and test those assumptions making it prone to error. If you're asking about current techniques within reinforcement learning, image detection,etc. Those techniques are error prone, just likes us humans. During training of those algorithms you have a trade off between how good it will generalize on new data and how correct it can answer your questions. (it will "memorize" the questions and not actually learn in the latter, called overfitting) Upvotes: 0
2018/10/24
703
3,097
<issue_start>username_0: Can artificial intelligence (or machine learning) applications or agents be hacked, given that they are software applications, or are all AI applications secure?<issue_comment>username_1: Everything can be hacked. The solutions found by artificial intelligence can be much more efficient than human solutions, but they can also be confused because of the diversity and immensity of details that our mind possesses. Artificial Intelligence models bring us more secure solutions, but nothing is 100% safe when we talk about information security. There are ways to improve security, hinder invasions and attacks, but every system has flaws. Perhaps, in the future (things of my imagination) we will have an artificial superintelligence ahead of the human, which may be one of the greatest challenges of invasion of history, but until then .. just my imagination. Upvotes: 1 <issue_comment>username_2: To answer your question, it really depends on the purpose of the Artificial Intelligence program. For example, 4Chan has hacked a number of "Artificial Intelligent" bots, most notably was Microsoft's Twitter bot Tay. The general purpose of the bot was to parse what was tweeted at it and respond in kind, learning and evolving with each and every interaction. Within 24 hours, 4Chan had corrupted Tay beyond repair, by teaching it racist and sexist terminology, ironic memes, sending it to shitpost tweets, and otherwise attempting to alter its output so much so that Microsoft had to remove it. Now, the flaw with Tay was that it accepted any input, and learned off of that exclusively, without any interaction from the developers. Other bots have similar features, but they have checks in place that require human intervention to determine what is "quality" information to learn, and what is "bad" information to learn as to not pollute the global knowledge base of the bot. These are just two examples of how Artificial Intelligence can be "hacked", but it ultimately comes down to how the programs are implemented. You mention in one of your comments about Cellphone Artificial Intelligence such as Siri, and whether this technology can be hacked. The answer is - not really. Siri learns based off of her global interactions - with limited user input allowed. You can ask Siri how to pronounce a name. When she pronounces it incorrectly, you can say to her "Siri that's now how you pronounce that". And she will provide you with a limited set of options of how you pronounce that name, and you have to choose which option sounds the best. There was no option to allow a user to give Siri "bad" information, as she already populates the results for you, and you have to teach her based off of her list of options. To give Siri bad input, you would have to have access to Siri's global learning base, which we do not have access to, and alter how she accepts human interactions within the program - which would never happen due to too many moving parts within the iPhone update process, and would be caught before you were able to deploy your update. Upvotes: 3
2018/10/24
750
2,883
<issue_start>username_0: I am training a multilayer neural network with 146 samples (97 for the training set, 20 for the validation set, and 29 for the testing set). I am using: * automatic differentiation, * SGD method, * fixed learning rate + momentum term, * logistic function, * quadratic cost function, * L1 and L2 regularization technique, * adding some artificial noise 3%. When I used the L1 or L2 regularization technique, my problem (overfitting problem) got worst. I tried different values for lambdas (the penalty parameter 0.0001, 0.001, 0.01, 0.1, 1.0 and 5.0). After 0.1, I just killed my ANN. The best result that I took was using 0.001 (but it is worst comparing the one that I didn't use the regularization technique). The graph represents the error functions for different penalty parameters and also a case without using L1. [![enter image description here](https://i.stack.imgur.com/NwBl2.png)](https://i.stack.imgur.com/NwBl2.png) and the accuracy [![enter image description here](https://i.stack.imgur.com/MTgRD.png)](https://i.stack.imgur.com/MTgRD.png) What can be?<issue_comment>username_1: You have a small dataset. Should you even be using neural nets? Have you done any diagnostics to see if you even have enough data? Are you using the right metric? Accuracy is not always the correct metric. Which weights are you retaining? You will overfit if you save the weights that produce the lowest training error. Save the weights that produced the lowest validation error. L1, L2, and dropout are all great. So many things not described in the problem... <http://www.ultravioletanalytics.com/blog/kaggle-titanic-competition-part-ix-bias-variance-and-learning-curves> I'm wondering why you're not trying interpretable models to see if the resulting weights for the features make sense. Also if your comparing all those models and parameters, set your random initial starting point to be the same by setting the seed. I also hope you are using the same training set for each model. You probably need more data... Upvotes: 1 <issue_comment>username_2: Your network without regularization does not appear to be over fitting but rather it appears to be converging to a minima. I am actually a bit surprised it is doing as well as it is given that your data set is small. So You don't need regularization. If you want to improve the accuracy you might try using an adjustable learning rate. The Keras call back ReduceLROnPlateau can be used for this. Documentation is [here](https://keras.io/api/callbacks/reduce_lr_on_plateau/). Also use the callback ModelCheckpoint to save the model with the lowest validation loss. Documentation is [here](https://keras.io/api/callbacks/model_checkpoint/). It would help a lot if you posted your model code. I have found if you do encounter over fitting dropout works more effectively than regularization. Upvotes: 0
2018/10/24
1,098
4,997
<issue_start>username_0: I am so much curious about how do we see(with eyes ofc) and detect things and their location so quick. Is the reason that we have huge gigantic network in our brain and we are trained since birth to till now and still training. basically I am saying , are we trained on more data and huge network? is that the reason? or what if there's a pattern for about how do we see and detect object. please help me out, maybe my thinking is in wrong direction. what I wanna achieve is an AI to detect object in picture in human ways.thanks.<issue_comment>username_1: If you have studied about Convolution Neural Network, you probably know how present day object detection algorithms works. Basically, an Artificial Neural Network tries to mimic the way our brain might work. So, CNN is probably the way our brain works to perform object detection, trying to recognize each small parts at each stage, that slowly grows to compile into the larger object to be recognised. However since, we are not restricted to data from just 2D plane, so the processing might be more complicated. We all learn things after being trained to do so. You could never have recognized a particular fruit if you have never seen it. The way we store the information, we gain, is different, that helps us to remember/recognise objects after only a few look. Until, we have more research that provides more details into the working of our brain, we are all good with Artificial Neural Network. Honestly, we are still far away from achieving general artificial intelligence. Now, if you want to implement an object detection algorithm, CNN is your only way. Upvotes: 0 <issue_comment>username_2: Object detection can conceivably imitate what the human visual system does. Research along these lines began in the 1980s in multiple laboratories and was termed *Computer Vision*. > > How do we see ... and detect things and their location so quick[?] Is the reason that we have huge gigantic network in our brain and we are trained since birth to till now and still training[?] > > > Neurological visual systems continue to train as long as the eyes and neurons continue to function. A person may, long after doing well in sports, learn how to catch glass objects that fall off a counter using peripheral vision, using the same neural pathways as were used for visually coordinated movement in sports but. They are newly trained to the new cognitive intention of saving glassware and clean-up time. The mapping of signals from the rods and cones to the visual cortex has been studied and some generalities have influenced artificial vision research and development. The convolution kernels used in CNNs are partly derived from biological research. In summary, the way mammals and other organisms with the equivalents of retinas see is via a set of transformations and pattern matching circuits. The sequence of information types through biological visual networks can be summarized. * Light as a function of compound angle and time. * Edges in both space and time * Elements of objects and actions — These are real world features, not in the machine learning sense but in the natural language use of the term features. * Objects and actions The development of object and action recognition in computers follows this same basic sequence. The goal stated in the question is this. > > Achieve an AI to detect object in picture in human ways > > > Something like this has been the goal of many government, academic, and corporate laboratories, however the ability to recognize objects in still pictures is not as valuable as detecting the trajectories and other expressions of objects (such as changes in facial expressions) in real time. Automated aiming, piloting, walking, and driving have been computer vision objectives since the first control systems were developed for anti-aircraft defense systems. Considerable effort is being invested into how steering, breaking, and signaling can be automated in road vehicles. A large array of household and industrial devices are being developed that rely on mapping the environment and navigating a robotic device through the map. Stationary object recognition work is largely surrounding either categorizing images or drawing vector graphics from raster images, but these functions have limited application. As mobile devices develop further and images on the web give way to videos on the web, a very strong and uninterrupted trend, the temporal dimension will continue to gain importance in the field computer vision. None of these objectives are novel. They are all based on animal capabilities, only some of which are uniquely human, and have been the subject of research since before the advent of digital computers. However the feasibility of many designs has improved, largely due to a significant reduction in costs for fixed computing resources. The vision system hardware of today costs roughly one thousandth of its 1990 cost. Upvotes: 2
2018/10/25
3,977
16,954
<issue_start>username_0: One of the cornerstones of The Selfish Gene (Dawkins) is the spontaneous emergence of replicators, i.e. molecules capable of replicating themselves. Has this been modeled *in silico* in open-ended evolutionary/artificial life simulations? Systems like Avida or Tierra explicitly **specify** the replication mechanisms; other genetic algorithm/genetic programming systems explicitly **search for** the replication mechanisms (e.g. to simplify the von Neumann universal constructor) Links to simulations where replicators emerge from a primordial digital soup are welcome.<issue_comment>username_1: Although difficult to prove a negative, I don't think that this has been done. The most advanced simulations of low-level features are not capable of scaling to simulate large enough populations at large enough time scales where scientific consensus claims that this has happened in reality. Although you say that you are not directly interested in chemistry, but some abstract substrate, I am using chemistry as an example of the challenge. That is because creating a simplified substrate with enough rich emergent behaviour is non-trivial. The chemical elements essentially have rules about how they combine into larger physical structures (via different bonding mechanisms) and only roughly a dozen types of atom are involved. It's actually reasonably simple and tractable at the lowest level. The problems come from the multiple scales of structure - building "unit" molecules (DNA/RNA bases, protein peptides, lipids, sugar bases etc), creating polymers from those units, interactions between polymers, physical structures built and torn down by those interactions, each of which exhibits more complex behaviour. This structural hierarchy is likely required for any self-replicating machinery that is not simply being fed the higher-level units directly. In your question you want to find self-replication that is emergent, not designed . . . so feeding in these higher-level units would probably count as cheating. We probably don't have the computational power to properly simulate even the [Miller-Urey experiment](https://en.wikipedia.org/wiki/Miller%E2%80%93Urey_experiment) which is far from self-replication - chemical simulations *in silico* are limited to things like protein folding calculations, and these are far from real-time. Inside just a single bacterial cell getting ready to divide, proteins are produced and fold by the hundreds every second. One thing that has been done is to create a self-replicating machine in [Conway's Game of Life called "Gemini"](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life#Self-replication). This was designed, not spontaneously created. However, it would have a very low but non-zero chance of spontaneously being created with random initialisation. It would be a very fragile replicator though, any mutation or collision with other active elements would likely break it. The experiment of attempting to randomly/spontaneously create Gemini is not computationally feasible. It is likely that any physical system simple enough to be considered "primordial soup" yet rich enough to express replicating units is going to require a few layers of construction before you get to see those units. These layers need to be built up combinatorially, and odds of this happening spontaneously in a small experiment with limited computation appear to be low. You need to bear in mind the *extremely large* computation that would effectively have been done by an order of $10^{30}$ molecules that can interact at very fast rates in parallel (compared to rate at which these same interactions can be simulated in current CPUs), with processing times of the order $10^8$ years. It is mainly conjecture that this is enough to create an Initial Darwinian Ancestor - it is basically a logical extrapolation to the theory of evolution, following the Occam's Razor principle of looking for simplest compatible explanation. Upvotes: 2 <issue_comment>username_2: **Systems Approach** Let's set out to replicate a real time system $S: \mathcal{X} \Rightarrow \mathcal{Y} \; | \; I$, where $\mathcal{X}$ is a empirical continuous history of input and $\mathcal{Y}$ empirical continuous history of output, conditioned upon a real initial system state $I$. Based on some definition, we require $S$ to be alive. We cannot simulate a replication of a theoretical model of life, with a selfish gene or any other such attribute, simply because no mathematically terse model on which the simulation could be based exists. As of this writing, only hints to and minutia of such a model are known. Furthermore, models are mathematical representations that, throughout human history, are found to be approximations of complexities once anomalies are addressed and new models develop to incorporate them into the theory.1 **Simulation Roughly Defined** If we examine a general algorithm $\mathcal{A}$ to replicate $S$, replication can be roughly sketched as follows. * Estimate system $S$, essentially forming hypothesis $H$. * Simulate initial state $I$. * Initiate a series of discrete stimuli $\mathcal{X}\_t$ approximating the real and continuous $\mathcal{X}$. * Acquire resulting system behavior $\mathcal{Y}\_t$ as discrete observations of $\mathcal{Y}$. * Verify the difference between simulated and actual systems to be within allowable error $\epsilon$. **Defining Spontaneous Emergence** By spontaneous emergence is meant that such an astronomically large array of initial states and sequences of stimuli occurred that there is a high probability of one of the permutations being alive, based on some specific and reasonable definition of what is living. **Defining What Life Is** Reviewing several definitions of living organisms, the most reasonable definitions include these: * The organism can be distinguished from its environment. * The organism can acquire and cache potential energy and materials required to operate. * Its operation includes continued acquisition, producing a bidirectional and sustainable relationship with its environment. * The organism can roughly reproduce itself. * The reproduction is similar to but not exactly like the parent(s). * The method of energy and materials acquisition may include the consumption of other organisms or its energy and materials. Competing for resources, natural selection, and all the other features of evolutionary theory are corollary to the above five requirements. In addition to these, the current trend toward recognizing symbiogenesis as a common theme in the emergence of species should not be dismissed. * Replication of one organism may be influenced by the composition of another organism through forms of assimilation or symbiosis such that traits are passed across categories of organisms. **Artificial Life as a Simulation** These seven criteria poses a challenge for humans attempting to artificially generate life. It is easy to create a computer model such that life is simulated in some way. Consider how. * The environment contains virtual energy and virtual matter. * The model of the organism, distinguished from its environment, can acquire its operational requirements from the environment through a set of operations on it. * Mater and energy are conserved because the temperatures are far below nuclear thresholds. * The model of the organism allows acquisition only if enough of the energy and materials acquisition has occurred to maintain the cache. * Mater and energy acquired by one organism cannot be acquired by another organism except by consumption or absorption of an organism that acquired it or produced it from that which was acquired. * The model of the organism can self-replicate in such a way that stochastic differences in the replication is introduced in small quantities. * Operational information, including replication information, may be acquired through consumption or symbiotic relationship under some conditions. **Magical Genes for Spontaneous Life** Notice that the selfish gene is not mentioned above. Selfishness, the prerequisite of which is intention, is not a requirement for life. An amoeba does not think selfishly when it moves or eats. It operates witlessly. We should not anthropomorphize every organism we study, or develop theory based on anthropomorphic conceptions. Similarly, symbiotic relationships form that are neither loving nor altruistic. They exist because there is a mutual benefit that appeared as an unintended byproduct of normal operations and both symbiotic parents happened to pass that symbiotic connection to their respective offspring. The mutual benefit, the symbiosis, and the replication are witless and unintended. There need not be a control mechanism distinct from all other replicated mechanisms to control either symbiotic collaboration or competition. They too are natural consequences of living things sharing an environment. Whether an organism dies because it * Lost its symbiont, * Starves because other organisms consumed its necessities, * The organism itself depleted its own resources, or * Those needed resources were otherwise rendered unavailable, it is still unable to replicate, so its traits die with it. Note also that there is no known molecule that can replicate itself. Complex systems of molecules in a variety of chemical states and equilibria are required for reproduction to take place. **Returning to Simulating an Already Existing Organism** Running a time sharing system or distributing these simulated organisms in a parallel processing arrangement may some day simulate a biosphere, but it is not one in that only transistor electro-chemistry is involved. There is no actual direct relationship between the energy and mater of the system used to assemble the simulation and the energy and mater of the simulated environment in which the simulated systems $S$ reside. Certainly genetic algorithms, such as Avida and Tierra, have been developed. Compare those simulations to the modelling scenario described above, and their deficiencies become clear. Human researchers have not yet found $\mathcal{A}$ to replicate $S$ in a way that aligns with biological reality. **Open-endedness Requires Verification to Have Merit** The most significant limitation on implementations *in silico*, is that they can never be truly open-ended. There is no way as of this writing to replicate that which was simulated outside the simulation system. Until nanotechnology reaches a point where 3D construction and assembly can migrate alive simulations into the unsimulated universe, these simulations are closed-ended in that way and their viability *in vito* is untested. The value of open-ended simulations without any way to validate them is essentially zero except for amusement. Even in the space of digital simulation, as far as that technology has progressed, nothing even close to von Neumann's universal constructor has been accomplished. Although generic functional copy constructors are available in Scheme, LISP, C++, Java, and later languages, such is a minuscule step toward living objects in computers. **Digital Soup** The simulation of life's origins is considerably more difficult than finding an algorithm $\mathcal{A}$ to replicate $S$, where $S$ is a single life form and a sufficient portion of its environment to be representative of the biosphere on earth with an organism in it. The issue with primordial digital soup is one of the combinatory explosion. There are 510 million square Km on the earth's surface, and there are only three categories of life origin time frames possible. * The current estimates are close to correct, that the earth formed 4.54 billion years ago and extremely primitive life emerged 3.5 billion years ago * The organic material found in Canada that is allegedly 3.95 billion years old shortens the gap between planetary formation and life formation on it and older terrestrial life may be found * <NAME>'s comment that life may have preexisted earth is more than just a possibility If we go with the 1.04 billion year gap, then $(4.54 - 3.5) \cdot 10^9 \cdot 510 \cdot 10^6$ Km-years of soup must be simulated, since we cannot assume that life started in the ocean or a puddle or even on the surface. It could have started underground or in the atmosphere. The biosphere is currently thought to be 1,800 m above to 8,372 m below thick. With nanobes being 20 nm in diameter and the possibility that the emergence may have only taken one second we have to simulate in three dimensions over time the following space-time domain in finite elements with at least 50% overlap in all three dimensions. $$\dfrac {2^3 \cdot (4.54 - 3.5) \cdot 10^9 \cdot 510 \cdot 10^6 \cdot (1,800 - 8,372) \cdot 365.25 \cdot 24 \cdot 60 \cdot 60} {(20 \cdot 10^{-9})^3} \\ = 170,260,472,379 \cdot 10^{9+6+27} = 1.7 \cdot 10^{56}$$ With a quantum computer two stories high the size of Switzerland, the computing time would vastly exceed the duration of the average species on earth. Humans are likely to be extinct before the computation completes. As the dating of the oldest found fossils converges on the dating of earth, it may seem that life emerged quickly on earth, but that is not a logical conclusion. If life formed as soon as the earth cooled sufficiently and no evidence of continuous emergence is found in the remaining billions of years, then Vernadsky's inference that life arrived on earth through one or more of the bodies that struck it becomes more probable. If that is the case, then one must ask the question, if all assumptions are dropped, whether life had a beginning at all. **Simulating Life Versus Simulating Its Formation** We may simulate what life is, that is, find an algorithm $\mathcal{A}$ to replicate $S$, where $S$ is a single live organism. It is not realistic to, by brute force, simulate how life began without learning more about what conditions can lead to its formation theoretically to drastically reduce the soup simulation space. It is that learning that is an ongoing area of research in the genetic algorithm field. Early musings about the possibility of an algorithm $\mathcal{B}$, which can provide the conditions that allow an arbitrary organism $S$ conforming to the above definition of life to form with out a parent or parents were interesting. Given algorithm $\mathcal{A}$ that simulates a life form and algorithm $\mathcal{B}$ that simulate the formation of life, it may be the later algorithm that proves significantly more difficult. Conforming physics outside a computer to the simulation may be impossible. Whether simulated life, when embodied in a robotic system is actually going to be considered life will be left to our descendants, should the species endure sufficiently. **Footnotes** [1] Classic cases include the heliocentric Copernican system giving way to the Law of Gravity, that law being shown an approximation of general relativity as shown by the proper prediction of the orbit of Mercury and light's curvature near the sun, the Four Elements dismissed in light of Lavoisier's discovery of oxygen, and absolute provability of truth within a closed symbolic system disproved by Gödel in his second incompleteness theorem and then recouped partially (in terms of computability) by Turing's completeness theorem. Upvotes: 2 <issue_comment>username_3: Primordial replicators can be simpler than you think. Check out this video: [Self Replication: How molecules can make copies of themselves](https://www.youtube.com/watch?v=w2lqZL153JE) [Source: University of Groeningen] In a noisy environment you get natural mutation. And voila, replication + mutation = evolution. Upvotes: 0 <issue_comment>username_4: It's yes in cellular automata space, you have this old one from 1997: *"Emergence of self-replicating structures in a cellular automata space"* <http://fab.cba.mit.edu/classes/S62.12/docs/Chou_CA.pdf> I quote you the part of the abstract you'll be interested in: *"This article demonstrates for the first time that it is possible to create cellular automata models in which a self-replicating structure emerges from an initial state having a random density and distribution of individual components."* And those replicators carry some kind of information and are in some minimalistic sense evolvable (the loops can grow). But, you'll see the emergence is mainly due to the fact that the cellular automata universe designed allow small replicators, and by just being chaotic enough those replicators form by luck. It's an Langton loop system, you have a live demo there (but quite old as well): <https://www.complexcomputation.org/hhchou/research/research_ca_demo1.html> I dont know any other work that come close to that in term of simulating emergence of replicators, it's old and with limitations but at least it's something. Regards. Upvotes: 1
2018/10/27
3,878
16,546
<issue_start>username_0: What is the difference between learning agents and other types of agents? In what ways learning agents can be applied? Do learning agents differ from deep learning?<issue_comment>username_1: Although difficult to prove a negative, I don't think that this has been done. The most advanced simulations of low-level features are not capable of scaling to simulate large enough populations at large enough time scales where scientific consensus claims that this has happened in reality. Although you say that you are not directly interested in chemistry, but some abstract substrate, I am using chemistry as an example of the challenge. That is because creating a simplified substrate with enough rich emergent behaviour is non-trivial. The chemical elements essentially have rules about how they combine into larger physical structures (via different bonding mechanisms) and only roughly a dozen types of atom are involved. It's actually reasonably simple and tractable at the lowest level. The problems come from the multiple scales of structure - building "unit" molecules (DNA/RNA bases, protein peptides, lipids, sugar bases etc), creating polymers from those units, interactions between polymers, physical structures built and torn down by those interactions, each of which exhibits more complex behaviour. This structural hierarchy is likely required for any self-replicating machinery that is not simply being fed the higher-level units directly. In your question you want to find self-replication that is emergent, not designed . . . so feeding in these higher-level units would probably count as cheating. We probably don't have the computational power to properly simulate even the [Miller-Urey experiment](https://en.wikipedia.org/wiki/Miller%E2%80%93Urey_experiment) which is far from self-replication - chemical simulations *in silico* are limited to things like protein folding calculations, and these are far from real-time. Inside just a single bacterial cell getting ready to divide, proteins are produced and fold by the hundreds every second. One thing that has been done is to create a self-replicating machine in [Conway's Game of Life called "Gemini"](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life#Self-replication). This was designed, not spontaneously created. However, it would have a very low but non-zero chance of spontaneously being created with random initialisation. It would be a very fragile replicator though, any mutation or collision with other active elements would likely break it. The experiment of attempting to randomly/spontaneously create Gemini is not computationally feasible. It is likely that any physical system simple enough to be considered "primordial soup" yet rich enough to express replicating units is going to require a few layers of construction before you get to see those units. These layers need to be built up combinatorially, and odds of this happening spontaneously in a small experiment with limited computation appear to be low. You need to bear in mind the *extremely large* computation that would effectively have been done by an order of $10^{30}$ molecules that can interact at very fast rates in parallel (compared to rate at which these same interactions can be simulated in current CPUs), with processing times of the order $10^8$ years. It is mainly conjecture that this is enough to create an Initial Darwinian Ancestor - it is basically a logical extrapolation to the theory of evolution, following the Occam's Razor principle of looking for simplest compatible explanation. Upvotes: 2 <issue_comment>username_2: **Systems Approach** Let's set out to replicate a real time system $S: \mathcal{X} \Rightarrow \mathcal{Y} \; | \; I$, where $\mathcal{X}$ is a empirical continuous history of input and $\mathcal{Y}$ empirical continuous history of output, conditioned upon a real initial system state $I$. Based on some definition, we require $S$ to be alive. We cannot simulate a replication of a theoretical model of life, with a selfish gene or any other such attribute, simply because no mathematically terse model on which the simulation could be based exists. As of this writing, only hints to and minutia of such a model are known. Furthermore, models are mathematical representations that, throughout human history, are found to be approximations of complexities once anomalies are addressed and new models develop to incorporate them into the theory.1 **Simulation Roughly Defined** If we examine a general algorithm $\mathcal{A}$ to replicate $S$, replication can be roughly sketched as follows. * Estimate system $S$, essentially forming hypothesis $H$. * Simulate initial state $I$. * Initiate a series of discrete stimuli $\mathcal{X}\_t$ approximating the real and continuous $\mathcal{X}$. * Acquire resulting system behavior $\mathcal{Y}\_t$ as discrete observations of $\mathcal{Y}$. * Verify the difference between simulated and actual systems to be within allowable error $\epsilon$. **Defining Spontaneous Emergence** By spontaneous emergence is meant that such an astronomically large array of initial states and sequences of stimuli occurred that there is a high probability of one of the permutations being alive, based on some specific and reasonable definition of what is living. **Defining What Life Is** Reviewing several definitions of living organisms, the most reasonable definitions include these: * The organism can be distinguished from its environment. * The organism can acquire and cache potential energy and materials required to operate. * Its operation includes continued acquisition, producing a bidirectional and sustainable relationship with its environment. * The organism can roughly reproduce itself. * The reproduction is similar to but not exactly like the parent(s). * The method of energy and materials acquisition may include the consumption of other organisms or its energy and materials. Competing for resources, natural selection, and all the other features of evolutionary theory are corollary to the above five requirements. In addition to these, the current trend toward recognizing symbiogenesis as a common theme in the emergence of species should not be dismissed. * Replication of one organism may be influenced by the composition of another organism through forms of assimilation or symbiosis such that traits are passed across categories of organisms. **Artificial Life as a Simulation** These seven criteria poses a challenge for humans attempting to artificially generate life. It is easy to create a computer model such that life is simulated in some way. Consider how. * The environment contains virtual energy and virtual matter. * The model of the organism, distinguished from its environment, can acquire its operational requirements from the environment through a set of operations on it. * Mater and energy are conserved because the temperatures are far below nuclear thresholds. * The model of the organism allows acquisition only if enough of the energy and materials acquisition has occurred to maintain the cache. * Mater and energy acquired by one organism cannot be acquired by another organism except by consumption or absorption of an organism that acquired it or produced it from that which was acquired. * The model of the organism can self-replicate in such a way that stochastic differences in the replication is introduced in small quantities. * Operational information, including replication information, may be acquired through consumption or symbiotic relationship under some conditions. **Magical Genes for Spontaneous Life** Notice that the selfish gene is not mentioned above. Selfishness, the prerequisite of which is intention, is not a requirement for life. An amoeba does not think selfishly when it moves or eats. It operates witlessly. We should not anthropomorphize every organism we study, or develop theory based on anthropomorphic conceptions. Similarly, symbiotic relationships form that are neither loving nor altruistic. They exist because there is a mutual benefit that appeared as an unintended byproduct of normal operations and both symbiotic parents happened to pass that symbiotic connection to their respective offspring. The mutual benefit, the symbiosis, and the replication are witless and unintended. There need not be a control mechanism distinct from all other replicated mechanisms to control either symbiotic collaboration or competition. They too are natural consequences of living things sharing an environment. Whether an organism dies because it * Lost its symbiont, * Starves because other organisms consumed its necessities, * The organism itself depleted its own resources, or * Those needed resources were otherwise rendered unavailable, it is still unable to replicate, so its traits die with it. Note also that there is no known molecule that can replicate itself. Complex systems of molecules in a variety of chemical states and equilibria are required for reproduction to take place. **Returning to Simulating an Already Existing Organism** Running a time sharing system or distributing these simulated organisms in a parallel processing arrangement may some day simulate a biosphere, but it is not one in that only transistor electro-chemistry is involved. There is no actual direct relationship between the energy and mater of the system used to assemble the simulation and the energy and mater of the simulated environment in which the simulated systems $S$ reside. Certainly genetic algorithms, such as Avida and Tierra, have been developed. Compare those simulations to the modelling scenario described above, and their deficiencies become clear. Human researchers have not yet found $\mathcal{A}$ to replicate $S$ in a way that aligns with biological reality. **Open-endedness Requires Verification to Have Merit** The most significant limitation on implementations *in silico*, is that they can never be truly open-ended. There is no way as of this writing to replicate that which was simulated outside the simulation system. Until nanotechnology reaches a point where 3D construction and assembly can migrate alive simulations into the unsimulated universe, these simulations are closed-ended in that way and their viability *in vito* is untested. The value of open-ended simulations without any way to validate them is essentially zero except for amusement. Even in the space of digital simulation, as far as that technology has progressed, nothing even close to von Neumann's universal constructor has been accomplished. Although generic functional copy constructors are available in Scheme, LISP, C++, Java, and later languages, such is a minuscule step toward living objects in computers. **Digital Soup** The simulation of life's origins is considerably more difficult than finding an algorithm $\mathcal{A}$ to replicate $S$, where $S$ is a single life form and a sufficient portion of its environment to be representative of the biosphere on earth with an organism in it. The issue with primordial digital soup is one of the combinatory explosion. There are 510 million square Km on the earth's surface, and there are only three categories of life origin time frames possible. * The current estimates are close to correct, that the earth formed 4.54 billion years ago and extremely primitive life emerged 3.5 billion years ago * The organic material found in Canada that is allegedly 3.95 billion years old shortens the gap between planetary formation and life formation on it and older terrestrial life may be found * <NAME>'s comment that life may have preexisted earth is more than just a possibility If we go with the 1.04 billion year gap, then $(4.54 - 3.5) \cdot 10^9 \cdot 510 \cdot 10^6$ Km-years of soup must be simulated, since we cannot assume that life started in the ocean or a puddle or even on the surface. It could have started underground or in the atmosphere. The biosphere is currently thought to be 1,800 m above to 8,372 m below thick. With nanobes being 20 nm in diameter and the possibility that the emergence may have only taken one second we have to simulate in three dimensions over time the following space-time domain in finite elements with at least 50% overlap in all three dimensions. $$\dfrac {2^3 \cdot (4.54 - 3.5) \cdot 10^9 \cdot 510 \cdot 10^6 \cdot (1,800 - 8,372) \cdot 365.25 \cdot 24 \cdot 60 \cdot 60} {(20 \cdot 10^{-9})^3} \\ = 170,260,472,379 \cdot 10^{9+6+27} = 1.7 \cdot 10^{56}$$ With a quantum computer two stories high the size of Switzerland, the computing time would vastly exceed the duration of the average species on earth. Humans are likely to be extinct before the computation completes. As the dating of the oldest found fossils converges on the dating of earth, it may seem that life emerged quickly on earth, but that is not a logical conclusion. If life formed as soon as the earth cooled sufficiently and no evidence of continuous emergence is found in the remaining billions of years, then Vernadsky's inference that life arrived on earth through one or more of the bodies that struck it becomes more probable. If that is the case, then one must ask the question, if all assumptions are dropped, whether life had a beginning at all. **Simulating Life Versus Simulating Its Formation** We may simulate what life is, that is, find an algorithm $\mathcal{A}$ to replicate $S$, where $S$ is a single live organism. It is not realistic to, by brute force, simulate how life began without learning more about what conditions can lead to its formation theoretically to drastically reduce the soup simulation space. It is that learning that is an ongoing area of research in the genetic algorithm field. Early musings about the possibility of an algorithm $\mathcal{B}$, which can provide the conditions that allow an arbitrary organism $S$ conforming to the above definition of life to form with out a parent or parents were interesting. Given algorithm $\mathcal{A}$ that simulates a life form and algorithm $\mathcal{B}$ that simulate the formation of life, it may be the later algorithm that proves significantly more difficult. Conforming physics outside a computer to the simulation may be impossible. Whether simulated life, when embodied in a robotic system is actually going to be considered life will be left to our descendants, should the species endure sufficiently. **Footnotes** [1] Classic cases include the heliocentric Copernican system giving way to the Law of Gravity, that law being shown an approximation of general relativity as shown by the proper prediction of the orbit of Mercury and light's curvature near the sun, the Four Elements dismissed in light of Lavoisier's discovery of oxygen, and absolute provability of truth within a closed symbolic system disproved by Gödel in his second incompleteness theorem and then recouped partially (in terms of computability) by Turing's completeness theorem. Upvotes: 2 <issue_comment>username_3: Primordial replicators can be simpler than you think. Check out this video: [Self Replication: How molecules can make copies of themselves](https://www.youtube.com/watch?v=w2lqZL153JE) [Source: University of Groeningen] In a noisy environment you get natural mutation. And voila, replication + mutation = evolution. Upvotes: 0 <issue_comment>username_4: It's yes in cellular automata space, you have this old one from 1997: *"Emergence of self-replicating structures in a cellular automata space"* <http://fab.cba.mit.edu/classes/S62.12/docs/Chou_CA.pdf> I quote you the part of the abstract you'll be interested in: *"This article demonstrates for the first time that it is possible to create cellular automata models in which a self-replicating structure emerges from an initial state having a random density and distribution of individual components."* And those replicators carry some kind of information and are in some minimalistic sense evolvable (the loops can grow). But, you'll see the emergence is mainly due to the fact that the cellular automata universe designed allow small replicators, and by just being chaotic enough those replicators form by luck. It's an Langton loop system, you have a live demo there (but quite old as well): <https://www.complexcomputation.org/hhchou/research/research_ca_demo1.html> I dont know any other work that come close to that in term of simulating emergence of replicators, it's old and with limitations but at least it's something. Regards. Upvotes: 1
2018/10/28
1,183
4,991
<issue_start>username_0: What is the difference between goal-based and utility-based agents? Please, provide a real-world example.<issue_comment>username_1: [Utility](https://en.wikipedia.org/wiki/Utility) is a fundamental to Artificial Intelligence because it is the means by which we evaluate an agent's performance in relation to a problem. To distinguish between the concept of economic utility and utility-based computing functions, the term "performance measure" is utilized. The simplest way to distinguish between a goal-based agent and a utility-based agent is that a goal is specifically defined, where maximization of utility is general. *(Maximizing utility is itself a form of goal, but generalized as opposed to specific.)* * A [goal-based](https://en.wikipedia.org/wiki/Intelligent_agent#/media/File:Model_based_goal_based_agent.png) navigation agent is tasked with getting from point A to point B. If the agent succeeds, the goal has been satisfied. * A [utility-based](https://en.wikipedia.org/wiki/Intelligent_agent#/media/File:Model_based_utility_based.png) navigation agent could seek to get from point A to point B in the shortest amount of time, with the minimum expenditure of fuel, or both. In the above example, the utility agent is also goal based, but where the performance measure for the goal agent is a binary [succeed/fail], the utility agent can use real numbers and measure performance by degree. The utility agent allows more granularity in evaluation. --- For an example of a non-goal based utility agent consider a form of a [partisan sudoku](http://mbranegame.com/rules-of-m/) in which players compete to control regions on the gameboard by placement of weighted integers. In a game with 9 regions, **the goal based agent seeks to control a specific number of regions at the end of play**. If the agent is conservative, the goal might be 5 regions. If the agent is hyper-aggressive, the goal might be 9 regions. When evaluating the environment (gameboard), if the agent dominates the desired number of regions, it could choose to consolidate (reinforce); if the agent does not dominate the desired number of regions, it could choose to expand (attack). The above strategy can be effective, but is limited by the specificity of the goal. A hyper-aggressive goal would work well against a weak opponent, but against a strong opponent it might prove disastrous. If the agent is sophisticated, where performance has been poor, it might alter it's goal by switching to a "turtling strategy" and seek to control fewer regions, but, because the new goal is still specific, the agent may miss opportunities to improve it's final status beyond the adjusted goal. The utility-based agent can approach the game with no specific goal beyond improving it's status. Rather than seeking to control a set number of regions, **the utility-agent evaluates whether a given choice improves or worsens it's status.** ("Do I dominate more or less regions if I take this position?") The utility agent can distinguish between sets of beneficial choices ("which choice maximizes my expected benefit?") and, where no benefit can be obtained, distinguish among the set of choices with the least downside ("among the set of bad choices, which is the least bad choice?") In this example, the utility-agent doesn't even need to understand the victory condition (controlling the more regions than the opponent at the end of play.) Instead, the utility-agent merely seeks to maximize the number of controlled regions over the course of play, which will result in victory if the agent makes more optimal choices than the opponent. Upvotes: 4 [selected_answer]<issue_comment>username_2: ### What is the difference between goal-based and utility-based agents? Both goal-based and utility-based agents have goals. However, having goals isn't effective (or efficient) enough, given that a goal-based agent may have several actions that can lead to the goals, but not all these actions are equally effective. So there's the need for an agent to perform the most effective action. And this is done by a utility-based agent. That said, for an agent that exhibits the utility function, it maps each state after each action being taken nor performed efficiently and effectively. ### Example Consider two drones $G$ and $U$, where $G$ is a goal-based and $U$ a utility-based agent. (The two drones have onboard computerized chips, so there is no need for ground control). These drones are sent on a mission and they have a goal. Both drones detect the given goal, but $G$ does not know which of its available actions is more efficient or effective. However, $U$, based on its *utility function*, can select the most efficient or effective action. ### Further reading Sections 2.4.4. and 2.4.5 of the book [Artificial Intelligence: A Modern Approach (3rd edition)](https://cs.calvin.edu/courses/cs/344/kvlinden/resources/AIMA-3rd-edition.pdf#page=71) provide more info. Upvotes: 0
2018/10/28
2,517
7,335
<issue_start>username_0: In [one of his lectures](https://www.youtube.com/watch?v=PTbxa6GsTWc&index=3&list=PLkFD6_40KJIznC9CDbVTjAF2oyt8_VAe3) Levine describes the objective of reinforcement learning as: $$J(\tau) = E\_{\tau\sim p\_\theta(\tau)}[r(\tau)]$$ where $\tau$ refers to a single trajectory and $p\_\theta(\tau)$ is the probability of having taken that trajectory so that $p\_\theta(\tau) = p(s\_1)\prod\_{t = I}^T \pi\_{\theta}(a\_t, s\_t)p(s\_{t+1}|s\_t, a\_t))$. Starting from this definition, he writes the objective as $J(\tau) =\sum\_{t=1}^T E\_{(s\_t, a\_t)\sim p\_\theta(\tau)}[r(s\_t, a\_t)]$ and argues that this sum can be decomposed by using conditional expectations, so that it becomes: $$J(\tau) = E\_{s\_1 \sim p(s\_1)}[E\_{a\_1 \sim \pi(a\_1|s\_1)}[r(s\_1, a\_1) + E\_{s\_2 \sim p(s\_2|s\_1, a\_1)}[E\_{a\_2 \sim \pi(a\_2|s\_2)}[r(s\_2, a\_2)] + ...|s\_2]|s\_1,a\_1]|s\_1]]$$ Can anyone explain this last step? I guess the [law of total expectation](https://en.wikipedia.org/wiki/Law_of_total_expectation) is involved, but I can not figure out how exactly.<issue_comment>username_1: In the [*YouTube depiction of CS294-112 fall 2017 lecture 3 Reinforcement Learning*, Levine](https://www.youtube.com/watch?v=PTbxa6GsTWc&index=3&list=PLkFD6_40KJIznC9CDbVTjAF2oyt8_VAe3), the transition of the finite horizon expected reward to a form where each transition is decoupled from the entire Markov chain of state-action marginals is explained between $t\_{video}$ = 44:04 and $t\_{video}$ = 45:22. At t=44:29, the probabilistic expectation where no actions take place is given as a starting point. It's a distribution already known, the initial state distribution. The statement, "Inside that expectation ...," at $t\_{video}$ = 44:39, begins the description of how to build an expectation expression for the first two vertices of the Markov chain. This is the beginning of a process where expectations $E$ are factored recursively. The purpose of the expansions is to decouple the expectation at each vertex from those of other vertices in the Markov chain, clarifying dependencies and exposing the mathematical features of the recursion. The right-hand factor is the integrated expectation of reward over the achievement of the next state-action marginal, where the action is distributed according to the fixed policy. How a state and action pair fits into a state-action marginals which can then form a Marcov Chain, provided the policy is fixed and known, was explained at $t\_{video}$ = 21:40 in this same lecture. Each vertex in the chain is taken to be the aggregation of a state with the proposed action to be applied to it, leading to a reward $r(s, a)$. Returning to $t\_{video}$ = 44:39, notice the plus sign without the right-hand addend, waiting for another recursion. When the recursion is expressed later in the process, the right-hand factor becomes the integrated expectation of reward over the achievement of the finite sequence represented by the remainder of the Markov chain. Multiplication is implied because we are now conditioning on **both** probabilities of the initial state and a transition from it. Notice also that the second vertex in the Marcov Chain is a state-action marginal. Notice now that rewards are additive because the goal of learning was defined as a sum of products, which is a simplifying assumption. Also notice that each expectation distributions of reward after the first one can be expressed as a product of single-vertex expectation distributions. Each factor is a localized expectation along the sequence of vertices in the Markov chain of state-action marginals. This is the factoring of expectation distributions. This factoring is the application of Product distribution, which [can be proven](https://ipfs.io/ipfs/QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco/wiki/Product_distribution.html) using the "law" of total expectations. At $t\_{video}$ = 44:51, the pattern recursion is expressed with a single ellipsis. Recognition of the recursion pattern can be facilitated by re-expressing with a few modifications of mathematical style. * Use of the original variable to represent the value objective * Extending the equality * Using two ellipses instead of one clarify the recursion is a continuation of conditions from right to left as well as continuation of rewards from left to right * Strategically placing line returns $$\pi\_{\theta}(\tau) = \sum\_{t=1}^T \operatorname{E}\_{(s\_t, a\_t)\sim p\_\theta(\tau)}[r(s\_t, a\_t)] \\ = E\_{s\_1 \sim p(s\_1)}[E\_{a\_1 \sim \pi(a\_1|s\_1)}[r(s\_1, a\_1) \\ + E\_{s\_2 \sim p(s\_2|s\_1, a\_1)}[E\_{a\_2 \sim \pi(a\_2|s\_2)}[r(s\_2, a\_2)] \\ + \; ... \\ ...|s\_2]|s\_1,a\_1]|s\_1]]$$ Inverting the transformation, recombining the expansion back to its original form may also be illustrative. Upvotes: 2 <issue_comment>username_2: I tried to sketch a mathematical justification of the equality. So we have: $$J(\tau) = E\_{\tau\sim p\_\theta(\tau)}[r(\tau)]$$ where $p\_\theta(\tau) = p(s\_1)\prod\_{t = 1}^T \pi\_{\theta}(a\_t, s\_t)p(s\_{t+1}|s\_t, a\_t))$. Now, $p\_\theta(\tau)$ can be re-written in terms of the Markov Chain transition probabilities, namely: $p\_\theta(\tau)= \prod\_{t = 1}^T \pi\_{\theta}(a\_t, s\_t)p(s\_{t}|s\_{t-1}, a\_{t-1})) = \prod\_{t = 1}^T p(s\_{t}, a\_{t})$. Here we focus on T = 2 (I guess it is not difficult to prove with a general T, maybe by induction over T). The following holds: $$J(\tau) = E\_{\tau\sim p\_\theta(\tau)}[r(\tau)] = E\_{(s\_1, a\_1, s\_2, a\_2)\sim p(s\_1,a\_1)p(s\_2,a\_2)}[r(s\_1,a\_1) + r(s\_2,a\_2)] \\ = \int\_{(s\_1,a\_1)} \int\_{(s\_2,a\_2)} (r(s\_1,a\_1) + r(s\_2,a\_2))p(s\_1,a\_1)p(s\_2,a\_2) d(s\_1,a\_1)d(s\_2, a\_2) \\ = \int\_{(s\_1,a\_1)} \left( \int\_{(s\_2,a\_2)} (r(s\_1,a\_1) + r(s\_2,a\_2))p(s\_2,a\_2) d(s\_2,a\_2)\right)p(s\_1,a\_1)d(s\_1, a\_1) \\ = E\_{(s\_1, a\_1)\sim p(s\_1,a\_1)}\left[E\_{(s\_2, a\_2)\sim p(s\_2,a\_2)}[r(s\_1,a\_1) + r(s\_2,a\_2)]\right] \\ = E\_{(s\_1, a\_1)\sim p(s\_1,a\_1)} \left[E\_{(s\_2, a\_2)\sim p(s\_2,a\_2)}[r(s\_1,a\_1)] + E\_{(s\_2, a\_2)\sim p(s\_2,a\_2)}[r(s\_2,a\_2)] \right] \\ = E\_{(s\_1, a\_1)\sim p(s\_1,a\_1)} \left[ r(s\_1,a\_1) + E\_{(s\_2, a\_2)\sim p(s\_2,a\_2)}[r(s\_2,a\_2)] \right] $$ where the second line is due to the definition of the expectation, in the third line we just changed the order of the terms, in the fourth we used the definition of expectation, in the fifth we used the linearity property of the expectation and the last line is because $r(s\_1, a\_1)$ is constant with respect to the integration over $(s\_2, a\_2)$. I preferred to move to the integral form of the expectation in line two and three because it was not clear to me how exactly the expectation could factorise. To conclude the justification, note that we defined $p(s\_t, a\_t) = \pi\_{\theta}(a\_t, s\_t)p(s\_{t}|s\_{t-1}, a\_{t-1})$, so we have another product here which can be factorised in the same way we did in line two and three of the set of equations above. This brings us the to conditional expectation form of the objective. In general, every term we have in the original trajectory distribution $p\_\theta(\tau)$ corresponds to an expectation and every reward can be moved up to the first outer expectation which it depends on. Upvotes: 1 [selected_answer]
2018/10/29
827
3,199
<issue_start>username_0: How do I define a reward function for my POMDP model? In the literature, it is common to use one simple number as a reward, but I am not sure if this is really how you define a function. Because this way you have to do define a reward for every possible action-state combination. I think that the examples in the literature might not be practical in reality, but only for the purpose of explanation.<issue_comment>username_1: In a POMDP, you minimize the following cost function \begin{align} J\_{\pi\_{0:N-1}} (\cdot) &= \mathbb{E} \left( g\_N (x\_N) + \sum\_{k=0}^{N-1} g\_k (x\_k, \pi\_k(\cdot)) \right), \end{align} where $g\_N$ is the terminal cost and $g\_k$ is the step cost. Note that this is only the formal problem definition. If you talk about an actual system, you might have a hard time recognizing that this is connected to your reward. What you observe is formally a value of the function J and practically a simple float More details in German are on my blog: <https://martin-thoma.com/probabilistische-planung/#mdp-vs-pomdp-vs-rl_1> Upvotes: 0 <issue_comment>username_2: There is no major difference here between a POMDP and MDP. When setting reward values, you are generally trying to give the minimal information to the agent that when the sum of rewards is maximised, it solves the problem that you are posing. > > In literature it is common to use one simple number as a reward, but I am not sure if this is really how you define a function. Because this way you have do define a reward for every possible Action-State combination. > > > Some defined value of reward has to be returned after *all* state, action pairs taken in the environment. The value could be $0$ of course. Reward can depend on, or be a function of, current state, action, next state and a random factor. In a POMDP it may also be from any unobserved factor in the environment (you might know this in a simulation because you have created the environment and are choosing not to share the data with the agent). In practice, the reward often does not have to depend on all the possible factors. In addition, the relationship between the factors and the possible reward can be very simple or sparse. Classic examples you may find in the literature include: * Reward in a game can be simply $+1$ for winning, or $-1$ for losing, granted at the end. All other rewards are $0$ * If your goal is to reach a certain state, such as exit from a maze, in minimum time, then a fixed reward of $-1$ per time step is enough to express the need to minimize the total number of steps. * For a goal of maintaining stability and avoiding a failure in e.g. [CartPole](https://gym.openai.com/envs/CartPole-v0/), then a reward of +1 per time step without failure suffices. All of these examples express the reward function as a simple condition plus one or two numbers. The key thing is that they allow you to *calculate* a suitable reward on each and every time step. They are all strictly reward functions - the general case can cover very complex functions if you wish, that will depend entirely on the goals you want to set the agent to learn/solve. Upvotes: 2 [selected_answer]
2018/10/29
615
2,483
<issue_start>username_0: I need to be able to detect and track humans from all angles, especially above. There are, obviously, quite a few well-studied models for human detection and tracking, usually as part of general-purpose object detection, but I haven't been able to find any information that explicitly works for tracking humans from above.<issue_comment>username_1: > > Look at all the Haar boosted classifiers that are available with OpenCV and the dedicated class CascadeClassifier to use it. Here are a list of what the classifiers have locally... > > > You can try `frontalface`. The shoulders I searched and did not find much. You may have to create a shoulder dataset and train to detect it. <https://stackoverflow.com/a/5727231/5336017> Upvotes: 0 <issue_comment>username_2: There were no pre-trained models for human that were taken from all angles (which is a somewhat extreme requirement) or specifically from above. This condition may change due to the high value of such to the surveillance industry. There are already several projects for which there is human specific pattern recognition and there have emerged some data sets to support this more specific field of objectives, some of which are based on moving rather than stationary images. This is for two reasons. * Multiple frames has the potential (should computing resource utilization be overcome) to produce higher accuracy and reliability in human recognition partly because of the identification of joints in movement and partly because there is simply more information available on each object that could be a human. * Trajectory of pedestrians is important for both law enforcement and security and for avoiding pedestrians in vehicle automation. These are some of the projects and download sites that are related to the goal of the question, but unfortunately do not seem to provide data sets of humans from above or pre-trained networks from that visual perspective. * <https://software.intel.com/en-us/openvino-toolkit/documentation/pretrained-models> * <https://docs.microsoft.com/en-us/azure/machine-learning/studio-module-reference/pretrained-cascade-image-classification> * <https://github.com/matterport/Mask_RCNN> * <https://drive.google.com/drive/folders/1zvl89AgFAApbH0At-gMuZSeQB_LpNP-M> * <https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md> * <https://modelzoo.co/model/human-pose-estimation-with-tensorflow> Upvotes: 1
2018/10/30
581
2,452
<issue_start>username_0: How much can the addition of new features improve the performance of the model during the optimization process? Let's say I have a total of 10 features. Suppose I start the optimisation process using only 3 features. Can the addition of the 7 remaining ones improve the performance of the model (which, you can assume, might already be quite high)?<issue_comment>username_1: The optimization of 10 features, as opposed to optimization of 3 features, will converge more slowly. > > Let's say I have a total of 10 features. Suppose I start the optimisation process using only 3 features. Can the addition of the 7 remaining ones improve the performance of the model (which, you can assume, might already be quite high). > > > The answer might be *no*. * The accuracy and reliability of the convergence toward ground truth (a formalized objective used to guide the optimization process) when split into groups of three and seven features may be better or worse than when left as a group of ten. * Except in rare cases, the results will not be the same. The likelihood of identical results is so low it may never happen in the world in the next century except when conditions are arranged solely to cause it to occur. Why then do may approaches group the dimensions of the result and converge on groups of axes, then another, then another, and back again to the first, iterating until the convergence goal is reached? This approach is used to reduce the time and computing resources used to reach the optimal. As the problem complexity increases, the use of groupings in this way is more common. Upvotes: -1 <issue_comment>username_2: It depends on the used network as well as the feeding mechanism but let's give an example; When working with LSTM, giving **the time data** (as an integer sequence) in addition to the time-series data(coming from features) dramatically increases the performance of the network. **[$X\_{0}$,$X\_{1}$, ...] $\rightarrow$ [[$X\_{0}$,$t\_{0}$],$[X\_{1}$,$t\_{1}$], ...]** If you go and look for the **kaggle** competition winner's notebooks, they do also *create additional features* based on the featured data. Let's assume that the performance is already **quite high** on the three features so that you can predict those three features with high reliability. It would only make sense to increase the number of features if you would like to predict additional features! Upvotes: 1
2018/10/31
293
1,254
<issue_start>username_0: I am building 2 models using XGboost, one with x number of parameters and the other with y number of parameters of the data set. It is a classification problem. A yes-yes, no-no case is easy, but what should I do when one model predicts a yes and the other model predicts a no ? Model A with x parameters has an accuracy of 82% and model B with y parameters has accuracy of 79%.<issue_comment>username_1: Given only the fact that model A has a higher accuracy than model B you should just use model A. More information on the performance of the two classifiers should be provided for a better answer. Upvotes: 0 <issue_comment>username_2: Without any additional information, lean towards the vote of the best performing classifier when it comes to ties. However, as others have stated already, it is best to analyze the performances in more detail (e.g. confusion matrices). For instance, it could be that model B almost always classifies class X correctly (hardly any false positives). In that case, you could lean towards the prediction of model B if it predicts class X and model A does not. In other words; you could weigh the votes of the models based on how well they did in similar, previous predictions. Upvotes: 1
2018/11/01
384
1,540
<issue_start>username_0: I have trained a convolutional neural network on images to detect emotions. Now I need to use the same network to extract features from the images and use them to train an LSTM. The problem is: the dimensions of the top layers are: `[None, 4, 4, 512]` or `[None, 4, 4, 1024]`. Therefore, extracting features from this layer will result in a `4 x 4 x 512 = 8192` or `4 x 4 x 1024 = 16384` dimensional vector for each image. Clearly, this is not what I want. Therefore, I would like to know what to do in this case and how to extract features that are of reasonable size. Should I apply global average pooling to the activation or what? Any help is much appreciated!<issue_comment>username_1: Given only the fact that model A has a higher accuracy than model B you should just use model A. More information on the performance of the two classifiers should be provided for a better answer. Upvotes: 0 <issue_comment>username_2: Without any additional information, lean towards the vote of the best performing classifier when it comes to ties. However, as others have stated already, it is best to analyze the performances in more detail (e.g. confusion matrices). For instance, it could be that model B almost always classifies class X correctly (hardly any false positives). In that case, you could lean towards the prediction of model B if it predicts class X and model A does not. In other words; you could weigh the votes of the models based on how well they did in similar, previous predictions. Upvotes: 1
2018/11/02
227
1,021
<issue_start>username_0: When should the iterative deepening search (IDS), also called iterative deepening depth-first search (IDDFS), and the depth-limited search be used?<issue_comment>username_1: Given only the fact that model A has a higher accuracy than model B you should just use model A. More information on the performance of the two classifiers should be provided for a better answer. Upvotes: 0 <issue_comment>username_2: Without any additional information, lean towards the vote of the best performing classifier when it comes to ties. However, as others have stated already, it is best to analyze the performances in more detail (e.g. confusion matrices). For instance, it could be that model B almost always classifies class X correctly (hardly any false positives). In that case, you could lean towards the prediction of model B if it predicts class X and model A does not. In other words; you could weigh the votes of the models based on how well they did in similar, previous predictions. Upvotes: 1
2018/11/02
1,588
6,314
<issue_start>username_0: I am working on a project for price movement forecasting and I am stuck with poor quality predictions. At every time-step I am using an LSTM to predict the next 10 time-steps. The input is the sequence of the last 45-60 observations. I tested several different ideas, but they all seems to give similar results. The model is trained to minimize MSE. For each idea I tried a model predicting 1 step at a time where each prediction is fed back as an input for the next prediction, and a model directly predicting the next 10 steps(multiple outputs). For each idea I also tried using as input just the moving average of the previous prices, and extending the input to input the order book at those time-steps. Each time-step corresponds to a second. These are the results so far: 1- The first attempt was using as input the moving average of the last N steps, and predict the moving average of the next 10. At time t, I use the ground truth value of the price and use the model to predict t+1....t+10 This is the result: Predicting moving average: [![image](https://i.stack.imgur.com/YOXxu.png)](https://i.stack.imgur.com/YOXxu.png) On closer inspection we can see what's going wrong: Prediction seems to be a flat line. Does not care much about the input data: [![image](https://i.stack.imgur.com/m4Xb5.png)](https://i.stack.imgur.com/m4Xb5.png) 2. The second attempt was trying to predict differences, instead of simply the price movement. The input this time instead of simply being X[t] (where X is my input matrix) would be X[t]-X[t-1]. This did not really help. The plot this time looks like this: Predicting differences: [![image](https://i.stack.imgur.com/toFGz.png)](https://i.stack.imgur.com/toFGz.png) But on close inspection, when plotting the differences, the predictions are always basically 0. [![enter image description here](https://i.stack.imgur.com/eSqGU.png)](https://i.stack.imgur.com/eSqGU.png) At this point, I am stuck here and running our of ideas to try. I was hoping someone with more experience in this type of data could point me in the right direction. Am I using the right objective to train the model? Are there any details when dealing with this type of data that I am missing? Are there any "tricks" to prevent your model from always predicting similar values to what it last saw? (They do incur in low error, but they become meaningless at that point). At least just a hint on where to dig for further info would be highly appreciated. **UPDATE** Here is my config ``` { "data": { "sequence_length":30, "train_test_split": 0.85, "normalise": false, "num_steps": 5 }, "training": { "epochs":200, "batch_size": 64 }, "model": { "loss": "mse", "optimizer": "adam", "layers": [ { "type": "lstm", "neurons": 51, "input_timesteps": 30, "input_dim": 101, "return_seq": true, "activation": "relu" }, { "type": "dropout", "rate": 0.1 }, { "type": "lstm", "neurons": 51, "activation": "relu", "return_seq": false }, { "type": "dropout", "rate": 0.1 }, { "type": "dense", "neurons": 101, "activation": "relu" }, { "type": "dense", "neurons": 101, "activation": "linear" } ] } } ``` Notice the last layer with 101 neurons. It is not an error. We just want to predict the features as well as the price. In other words, we want to predict the price for time t+1 and use the features predicted to predict the price and new features at time t+2, ...<issue_comment>username_1: Given a model that takes in a price and a second value, such as a moving average of the price, the following configuration is my recommendation. This is based on training on a history of 45 input time steps and forecasting out 10 steps in the future. I have assumed that your 'num\_steps' is a stride through the training data. Note that I have not tested this and you will most likely need to tweak a parameter or two: ``` { "data": { "sequence_length": 55, "train_test_split": 0.85, "normalise": true, "num_steps": 5 }, "training": { "epochs":200, "batch_size": 64 }, "model": { "loss": "mse", "optimizer": "adam", "layers": [ { "type": "lstm", "neurons": 100, "input_timesteps": 45, "input_dim": 2, "return_seq": true, "activation": "relu" }, { "type": "dropout", "rate": 0.2 }, { "type": "lstm", "neurons": 100, "activation": "relu", "return_seq": false }, { "type": "dropout", "rate": 0.2 }, { "type": "dense", "neurons": 1, "activation": "linear" } ] } } ``` Try this out and plot your model's loss and accuracy by epoch. See [Display Deep Learning Model Training History in Keras](https://machinelearningmastery.com/display-deep-learning-model-training-history-in-keras/) for some information and code in this area. Let me know if you are not using Keras and I will point you to another article/code solution. Upvotes: 2 <issue_comment>username_2: Remember that any machine learning model works good only when there is a "rule" or a correlation between modeling data and modeled data. When there is not, even the best algorithm will not predict/classify correctly. I am not saying that this must be the case, but probably you have come pretty close to the physical limit of what can be achieved using this data. Maybe you should consider adding or extracting new features to your model. Upvotes: 2
2018/11/05
781
2,992
<issue_start>username_0: What are the differences in scope between statistical AI and [classical AI](https://en.wikipedia.org/wiki/Symbolic_artificial_intelligence)? Real-world examples would be appreciated.<issue_comment>username_1: **Statistical AI**, arising from machine learning, tends to be more concerned with *inductive* thought: given a set of patterns, induce the trend. **Classical AI** is the branch of artificial intelligence research that concerns itself with attempting to explicitly represent human knowledge in a *declarative* form, i.e given a set of constraints, *deduce* a conclusion. Another difference is that C++, Python, and R tend to be a favorite language for statistical AI, while LISP and PROLOG dominate in classical AI. A system can't be more intelligent without displaying properties of both inductive and deductive thought. This leads many to believe that, in the end, there will be some kind of synthesis of statistical and classical AI. Upvotes: 3 [selected_answer]<issue_comment>username_2: Machine learning techniques are usually using a lot of statistical approaches, like [neural networks](https://en.wikipedia.org/wiki/Neural_network_software): a book like [this one](https://www.cs.huji.ac.il/%7Eshais/UnderstandingMachineLearning/) (*Understanding Machine Learning: From Theory to Algorithms* ISBN 978-1-107-05713-5) is full of mathematical equations. [Symbolic artificial intelligence](https://en.wikipedia.org/wiki/Symbolic_artificial_intelligence), e.g. classical [expert system](https://en.wikipedia.org/wiki/Expert_system) approaches (with some knowledge base), is more related to *logic*: a book like [that one](https://rads.stackoverflow.com/amzn/click/com/1848211015) (*Artificial Beings: the Conscience of a Conscious Machine* ISBN 978 1848211018) has mostly no complex equations, but simple ones. An AI software can combine both approaches (in particular with meta-programming: programs that generate other programs; or even [meta-rules](https://www.sciencedirect.com/science/article/abs/pii/0004370280900430)): the [RefPerSys](http://refpersys.org/) project tries to do so. Artificial neural networks are somehow "working", but you cannot understand why. Knowledge-based systems are more [explainable artificial intelligence](https://en.wikipedia.org/wiki/Explainable_artificial_intelligence). Classical AI systems could *generate* code (in C, C++, Common Lisp, machine code) using [metaprogramming](https://en.wikipedia.org/wiki/Metaprogramming) techniques, and could be mixed with machine learning or [deep learning](https://en.wikipedia.org/wiki/Deep_learning) approaches, and/or use existing machine learning libraries. Notice that the difference between statistical AI and classical AI is *not* a matter of programming languages or of operating systems. For example, [garbage collection](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) may be (and perhaps is not) relevant to both approaches. Upvotes: 1
2018/11/08
2,012
6,694
<issue_start>username_0: The field of AI has expanded profoundly in recent years, as has public awareness and interest. This includes the arts, where fiction about AI has been popular since at least Isaac Asimov. Films on various subjects can be good teaching aids, especially for younger students, but it can be difficult for a non-expert to know which films have useful observations and insights, suitable for the classroom. What are insightful films about AI? **Listed films must be suitable for academic analysis,** providing insight into theory, methods, applications, or social ramifications.<issue_comment>username_1: * [2001](https://en.wikipedia.org/wiki/HAL_9000) (1968) HAL 9000 is a great example of an artificial general intelligence that goes astray, where the humans don't understand the reasoning process as values dis-align. (This is a nod to [Asimov](https://en.wikipedia.org/wiki/Three_Laws_of_Robotics) in the sense of humans not understanding the implications of a logical framework. [Marvin Minsky](https://en.wikipedia.org/wiki/Marvin_Minsky) was an adviser on the film.) * [BladeRunner](https://en.wikipedia.org/wiki/Do_Androids_Dream_of_Electric_Sheep%3F#Critical_reception) (1982) The critical reception in the link references androids as mirror of humanity, with all the implications, including identity. Empathy is the core theme. (Seeing the self in the other. The film adapts these ideas into a love story, and includes overt Christian symbology with android [Roy Batty](https://en.wikipedia.org/wiki/List_of_Blade_Runner_characters#Roy_Batty) in the finale. HBO's Westworld draws heavily from these ideas.) The book and film also explicates an evolution of [Turing tests](https://en.wikipedia.org/wiki/Turing_test), focused on psychological responses due to the ever increasing sophistication of the androids. * [Wargames](https://en.wikipedia.org/wiki/WarGames) (1983) This film features an autonomous military AI that does not understand the context of human reality and nearly starts a total nuclear war. (An algorithm's view of reality is based on it's input, which in the film, was limited.) The ending is an early nod to machine learning. * [WALL-E](https://en.wikipedia.org/wiki/WALL-E#Technology) (2008) Here the key element is the diminishment of humanity and human purpose when strong AIs (in the form of robots) to accomplish every task. *This is already happening and seems accelerated by mobile computing.* * [Alien: Covenant](https://en.wikipedia.org/wiki/David_8) (2016) A horror film at it's core, it unveils a race of superior aliens brought down by the [hubris](https://en.wikipedia.org/wiki/Hubris) that their own creation could never turn on them. In regard to humanity this is mirrored by the [android](https://en.wikipedia.org/wiki/Android_(robot)) David. (In some sense it's a throwback to Greek Drama, where pride is the fatal flaw.) --- Shout out to [username_2's answer](https://ai.stackexchange.com/a/8847/1671) re: Ex Machina, which raises the question: "Is the AGI in Ex Machina a sociopath because she was created by a sociopath?" Nature vs. Nurture Upvotes: 3 <issue_comment>username_2: Here are my suggestions 1. [Her](https://www.imdb.com/title/tt1798709/), the AI part (movie spoiler): > > The AI can define a user's profile just by hearing his short story, and "act" based on the user's profile. The AI makes the user comfort with it (her). It shows a very advance user profiling. > > > 2. [Ex Machina](https://www.imdb.com/title/tt0470752/?ref_=tt_rec_tt) the AI part (movie spoiler): > > This movie will show you how an AI learn to trick someone. The AI can express her feelings, and make you trust their feeling. > > > 3. [Eagle Eye](https://www.imdb.com/title/tt1059786/?ref_=nv_sr_2), the AI part (movie spoiler): > > A movie about a general story "AI that want to kill". This movie can show you how The AI can compile a lot of information for its purpose. > > > 4. [Big Hero 6](https://www.imdb.com/title/tt2245084/), the AI part (movie spoiler): > > Baymax is a very good example of a very complex expert system, he has a "knowledge chip" and a very smart way to diagnose people > > > Upvotes: 4 [selected_answer]<issue_comment>username_3: Transcendence was a a pretty good look at a super-intelligent AI. Upvotes: 2 <issue_comment>username_4: [The Machine](https://en.wikipedia.org/wiki/The_Machine_(film)), which came out a year before Ex-Machina, features topics such as ethics, AI testing (specifically, the Turing test), artificial consciousness, emotional intelligence, artificial general intelligence, super-intelligence, the singularity and AI safety. An old but milestone movie is [Wargames](https://en.wikipedia.org/wiki/WarGames), which will likely get you some points for digging back into history on the subject. [2001: A Space Odyssey](https://en.wikipedia.org/wiki/2001:_A_Space_Odyssey_(film)), which is an excellent movie. However, to truly appreciate the nuance of the *Hal 9000*, you need to also see the sequel, or at least read a summary as it shows WHY Hal 9000 behaved the way it did. (In short, contradictory and irreconcilable instructions). [Alien](https://en.wikipedia.org/wiki/Alien_(film)), the original, first one, which contains both humanistic and non-humanistic AI. [Her](https://en.wikipedia.org/wiki/Her_(film)), which is either sadly romantic or creepy as all hell, depending on how you interpret it. Upvotes: 2 <issue_comment>username_5: A great movie to watch would be [A.I. Artificial Intelligence](https://en.wikipedia.org/wiki/A.I._Artificial_Intelligence), which is a sort of modern retelling of Pinocchio. Another good AI movie where the main character is a robot would be [Bicentennial Man](https://en.wikipedia.org/wiki/Bicentennial_Man_(film)), based on <NAME>'s *the positronic man*. Upvotes: 2 <issue_comment>username_6: Here are the best movies about artificial intelligence * 2001: A Space Odyssey (1968) * Colossus: The Forbin Project (1970) * Blade Runner (1982) * A.I. Artificial Intelligence (2001) * Her (2013) Upvotes: 2 <issue_comment>username_7: ### [Upgrade](https://en.wikipedia.org/wiki/Upgrade_(film)) This film depicts a very plausible near future when drones oversee our lives (e.g. the police use them to fight crime) and common people possess self-driving cars. This is definitely one of the best science fiction movies I have ever watched in my entire life, and I have watched many, such as **2001**, **Blade Runner**, or **The Matrix**. In fact, these are the four best science fiction movies ever made, in my opinion (and I have some knowledge of cinema, cinematography, directing, etc.) Upvotes: 1
2018/11/08
1,905
7,613
<issue_start>username_0: I'm aware of those AI systems that can play games and neural networks that can identify pictures. But are they really thinking? Do they think like humans? Do they have consciousness? Or are they just obeying a bunch of codes? For example, when an AI learns to play Pacman, is it really learning that it should not touch the ghosts, or are they just following a mechanical path that will make them win the game?<issue_comment>username_1: > > Do genetic algorithm and neural networks really think? > > > Genetic algorithms and neural networks are vastly different concepts. Both of them do not think. > > I'm aware of those AI programmes which can play games and neural networks which can identify pictures. But are they really thinking > > > Depends on how you define "thinking", but I say "no". > > Do they think like humans? > > > No. > > Do they have consciousness? > > > No. > > Or are they just obeying a bunch of codes? > > > Yes. It is a machine. A program. --- One example where most people realize that it is very different is the common thread for RNNs which generate text ([example texts](http://karpathy.github.io/2015/05/21/rnn-effectiveness/)). They can generate syntactically correct texts, but they "forget" about any actors in it. They don't connect the cables. But then, on the other hand, would you say a bacterium thinks? An ant? A mouse? A dog? A chimpanzee? Do we "think"? Where exactly is the border - and why? Upvotes: 3 <issue_comment>username_2: This is a really interesting question that can't be answered correctly since we lack a common understanding or a universally valid definition of what "thinking" means. Still I will try to give my humble opinion on it. First of all I would like to mention that consciousness might not exist in a binary fashion (as possessing it or not) but in a gradual fashion. In my understanding what neural networks do is learning a mapping, i.e. a function from the input space of their sensors to the output space of the actuators. If the neural network is playing Pacman, input consists of the pixels of the game and the output are actions the agent can take in the game. Since this process runs in a sequential session (i.e. `input` $\rightarrow\_{NN}$ `output`; `input` $\rightarrow\_{NN}$ `output` and so on) I would not go so far as to consider the neural network conscious. An interesting approach on this question comes from <NAME> with his book ["Gödel, Escher, Bach"](https://en.wikipedia.org/wiki/G%C3%B6del,_Escher,_Bach). The main thesis of this book (in my understanding) is that self-reference is a crucial and necessary precondition for (self-) consciousness. Upvotes: 1 <issue_comment>username_3: ***TL;DR*** Ignore the hype, current systems (in 2018) are very far removed from human-like "thinking", despite interesting and useful results. State-of-the-art for "thinking and behaving like a creature in general" has not reached the sophistication level of insects, even though we have example narrow AIs that can beat the world's best at intellectual games. There are some issues with the question as phrased, it is not a precise question, and includes some common wooly logic that many people have when discussing AI. However, I think these occur so often, that they are worth addressing here: > > But are they really thinking. > > > Define "thinking". It is not easy. > > Do they think like humans? > > > We don't fully know or understand how humans think. > > Do they have consciousness? > > > We don't fully know or understand what consciousness is. > > Or are they just obeying a bunch of codes? > > > Are you just obeying a "bunch of codes"? There is no reason to suspect that humans have a magic "something" that powers thought. All scientific evidence points to humans being sophisticated machines that follow the laws of physics and chemistry. However, the level of complexity is such that how brains, thinking and consciousness work is a very hard problem to solve. It is also *possible* that our lack of knowledge obscures some unknown property of the brain or "thinking" that means it is more than applied physics and chemistry - but there is zero evidence for such a thing. > > For example, when an AI learns to play pacman, is it really learning that it should not touch the ghosts or are they just following a mechanical path which will make them win the game? > > > This is an interesting question, and there is more to it than a simple yes/no answer: **Learning is not the same as thinking**. We expect an intelligent entity to be able to learn, when it receives new information. However, something that only learns - the only feature of it is that it gains some performance measure when fed experience - is only solving part of what it means to be intelligent or thinking. **A human player starts with assumptions**. A game like Pacman presents a simplified world that obeys many rules that we are already familiar with. In the game there is a space (the screen), in which rules of distance apply. There are objects (the pacman, walls, pills, power pills, ghosts) that have coherent shapes, and persistent properties that are recognisable. Object persistence is a thing. The game play follows familiar concepts of time. All these things are at least initially meaningless to a neural network. **A neural network generalises**. One of the reasons of the success of Deep Learning is that neural networks can, within limits, learn rules such as "avoid the ghosts" or in the case of a typical agent in DQN, that ghosts getting closer to the player is an indication that there is a low value in staying still or moving towards a ghost, and a high value in moving away towards an escape route. Not only that, but there is a good chance that a deep neural network will learn an internal representation that really does detect the ghosts and learn an association between them and the type of action, and this can be inspected by generating "heat maps" of neuron response to different areas of an image **Neural networks require far more experience than humans to learn to play well**. This demonstrates that they are learning differently. Some of this may be due to human innate knowledge transferring to playing a game. However, a typical reinforcement-learning training scenario would need to demonstrate that ghosts are dangerous 100s of times before the neural network finally is able to generalise well. Whilst a human would learn that after only a few encounters, maybe only one. There is much research in this area, as making learning as efficient as possible is an important goal. **Neural networks are too direct and simple to possess internal world models**. Raw generalisation is not the same as having the kind of rich internal model that you may be considering as "thinking". After training, the neural network is a function which maps a visual field of pixels into values and/or actions. There is no internal "narrative", even though the function is enough to behave correctly, it does not encode concepts such as space, object persistence, object traits etc, and it most definitely does not experience them. In some ways, asking if an artificial neural network can think is like asking if a small slice of your retina, or a tiny cube (less than 1mm3) of brain tissue can think. Or perhaps if your walking reflex and innate sense of balance counts as thinking. Current state-of-the-art efforts are at that kind of scale both in terms of computer power and complexity. Upvotes: 3 [selected_answer]
2018/11/09
1,193
4,754
<issue_start>username_0: We seem to be experiencing an AI revolution, spurring advancement in many fields. Please explain, at a high level, the uses of artificial intelligence and why we might need it.<issue_comment>username_1: The question, "Why do we need artificial intelligence?" is quite to the point. Technically, the answer is, "No reason." If we needed artificial intelligence, then we would have become extinct over the last 50,000 or more years we've been a species with human intelligence, so we want it. We do want it, and there are benefits. Some claim there are risks too, which is logical. We should be open to all views. Some of them may be spot on, and others may be without merit. One list of benefits already seen might include these, with most beneficial on top. * Deeper interest in what exactly we mean when we say someone or some thing is intelligent * Revisiting of the validity of the g-factor belief * Revised interest in parallel computing architecture * Heightened awareness of the distinction between fake and authentic * Improved use of an interest in probability and statistics These are further potential benefits that may also emerge. * Young students taking mathematics more seriously than hacking * The elimination of circular, wasteful job functions * More leisure time for families to enjoy together * Improved economic efficiency * Better planning regarding the use and preservation of natural resources These are the risks from highest to lowest. * Possibly accidentally causing the emergence of an uncontained and potentially dangerous digital entity * Additional nihilism (belief that nothing matters) in our culture, which could emerge if the last refuge of human pride is overrun by smarter artificial systems * People losing their jobs, which may have only a temporary impact, if the AI does quality work, but the transition may be painful and destructive Upvotes: 3 [selected_answer]<issue_comment>username_2: We don't really need artificial intelligence, but it is proving ever more useful. This is a function of what is known as utility--the capability of an algorithm to perform a task adequately. The new utility of AI has upsides and downsides. **Weak AI: Less capable than a human** At the lower end of the scale, there might be situation where a human would be better, but the work is so dangerous, or expensive for humans, that we use automatons instead. (Space exploration is a good example. The AI on a deep space probe or [Mars rover](http://Home/News/How%20does%20Mars%20rover%20Curiosity's%20new%20AI%20system%20work?%201.5K%20How%20does%20Mars%20rover%20Curiosity's%20new%20AI%20system%20work?).) **Semi-Strong AI: About as capable as a human** I'm defining "semi-strong" for this answer. Here we have AI or automation that can do tasks as well as humans, such as on an assembly line, but where automation is more efficient. (This type of automation spurred the [Luddite movement](https://en.wikipedia.org/wiki/Luddite), responding to the loss of human jobs due to automation.) As Machine Learning continues to get more effective, the range of tasks that AI can perform as well as humans will surely grow. This might lead to unprecedented levels of persistent human unemployment, but some argue that automation will also create new opportunities for humans and mostly eliminate repetitive, less fulfilling work. (See also: [Technological unemployment](https://en.wikipedia.org/wiki/Technological_unemployment)) **Strong AI: Exceeds human capability** Strong AI is the "holy grail", and some believe it will lead to a technological "singularity" in which smarter machines make ever smarter machines. (No one knows:) Nevertheless, Machine Learning has demonstrated greater than human capability in a number of tasks, and the range of such tasks will surely grow. ([AlphaGo](https://en.wikipedia.org/wiki/AlphaGo) was a milestone because the game of Go is unsolvable and notoriously difficult for AI, prior to AlphaGo. Now it's unclear if unmodified humans will ever again be able to beat strong AI at these types of games.) Although game AIs are not directly useful, except for recreational purposes, the methods used to create them can be extended to real-world problems. There are many forms of Machine Learning, not restricted to [Neural Networks](https://en.wikipedia.org/wiki/Artificial_neural_network) and [MCTS](https://en.wikipedia.org/wiki/Monte_Carlo_tree_search), with [Evolutionary Algorithms](https://en.wikipedia.org/wiki/Evolutionary_algorithm) as another type, also recently demonstrating strong utility. Strong AI is useful because it has greater utility than humans. It is desirable because it increases efficiency and expected return on investment. Upvotes: 1
2018/11/09
602
2,468
<issue_start>username_0: I observed in several papers that the variational autoencoder's output is blurred, while GANs output is crisp and has sharp edges. Can someone please give some intuition why that is the case? I did think a lot but couldn't find any logic.<issue_comment>username_1: In essence, Variational Autoencoders learn an "explicit" distribution of the data by trying to fit the data via a multi-dimensional Gaussian/Normal distribution. However, Generative Adversarial Networks learn an "implicit" distribution of data meaning that you cannot directly sample them. Also, due to the deterministic nature of neural networks, GANs tend to learn a [Dirac Delta function](https://en.wikipedia.org/wiki/Dirac_delta_function). If you're lucky and the training of the GAN is successful, you can therefore get sharper images, since the model doesn't have to explicitly deal with the noise injected into it due to samplings, hence this could be a simpler learning problem. By deterministic, I mean assuming that you have no sampling anywhere in the middle layers of your model and only use the neural network as an input-output mapping function. Upvotes: 1 <issue_comment>username_2: The key is: VAE usually use a small latent dimension, the information of input is so hard to pass through this bottleneck, meanwhile it tries to minimize the loss with the batch of input data, you should know the result -- VAE can only have a mean and blurry output. If you increase the bandwidth of the bottleneck, i.e. the size of latent vector, VAE can get a high reconstruction quality, e.g. [Spatial-Z-VAE](https://github.com/username_2/Spatial-Z-VAE) Upvotes: 2 <issue_comment>username_3: The reason is because of L1 (or L2) reconstruction loss used in VAEs. As is discussed in [Image-to-Image Translation with Conditional Adversarial Networks](https://arxiv.org/pdf/1611.07004.pdf): " If we take a naive approach and ask the CNN to minimize the Euclidean distance between predicted and ground truth pix- els, it will tend to produce blurry results. This is because Euclidean distance is minimized by averaging all plausible outputs, which causes blurring". Further: " GANs learn a loss that tries to classify if the output image is real or fake, while simultaneously training a generative model to minimize this loss. Blurry images will not be tolerated since they look obviously fake." For further details read the ablation study in 4.2 of linked paper. Upvotes: 1
2018/11/10
630
2,712
<issue_start>username_0: Do GANs come under supervised learning or unsupervised learning? My guess is that they come under supervised learning, as we have labeled dataset of images, but I am not sure as there might be other aspects in GANs which might come into play in the determination of the class of algorithms GAN falls under.<issue_comment>username_1: GANs are unsupervised machine learning algorithms. According to [Wikipedia](https://en.wikipedia.org/wiki/Unsupervised_learning), unsupervised algorithms are : > > Unsupervised learning is a branch of machine learning that learns from test data that has not been labelled, classified or categorized > > > In GAN networks, only training data is provided which is not labelled. The network generates candidates ( generative ) which are evaluated by the discriminator. The network slowly learns from the data given from a latent space. > > Suppose, you want to create a GAN network which can make a Monet painting. You just need to feed it some Monet paintings. Here, **you are not interested in classifying the painting, but copying/mimicking it**. > > > Hence, there is no need for labels here which makes GAN an unsupervised machine learning algorithm. Upvotes: 0 <issue_comment>username_2: The terms *Supervised Learning* and *Unsupervised Learning* predate the invention of the application of artificial networks to a generative and discriminative network pair, which was the first popular generative topology. The existence of labeling is the key distinction between the two. Even partial labeling indicates supervision, as odd as that jargon is, since the supervisor does no learning and the labels are constants. Based on the original description of the discriminative network in a GAN, that it consumes examples without labels, GANs are a type of unsupervised learning. That fact does not eliminate the use of labels as part of an extension of the original design that generates based on some labeled element in the examples or the use of other labels to indicate the fitness of each image for a class into which generated images are expected to fall. Upvotes: 1 <issue_comment>username_3: GANs are usually trained in a [**self-supervised** fashion](https://ai.stackexchange.com/a/10624/2444), i.e. they use the unlabelled data as the supervisory signal. Note that some self-supervised learning methods are unsupervised learning techniques, given that no human-annotated data is needed. However, not all SSL techniques are used for solving an unsupervised learning task. In fact, there are SSL techniques that are specifically used to generate labeled data, which can then be used to train a model in a supervised fashion. Upvotes: 1
2018/11/10
1,558
5,792
<issue_start>username_0: What are the differences between the A\* algorithm and the greedy best-first search algorithm? Which one should I use? Which algorithm is the better one, and why?<issue_comment>username_1: According to the book [Artificial Intelligence: A Modern Approach](http://aima.cs.berkeley.edu/) (3rd edition), by <NAME> and <NAME>, specifically, section **3.5.1 Greedy best-first search** (p. 92) > > Greedy best-first search tries to expand the node that is closest to the goal, on the grounds that this is likely to lead to a solution quickly. Thus, it evaluates nodes by using just the heuristic function; that is, $f(n) = h(n)$. > > > In this same section, the authors give an example that shows that greedy best-first search is neither optimal nor complete. In section **3.5.2 A\* search: Minimizing the total estimated solution cost** of the same book (p. 93), it states > > A\* search evaluates nodes by combining $g(n)$, the cost to reach the node, and $h(n)$, the cost to get from the node to the goal $$f(n) = g(n) + h(n).$$ > > > Since $g(n)$ gives the path cost from the start node to node $n$, and $h(n)$ is the estimated cost of the cheapest path from $n$ to the goal, we have $f(n)$ = estimated cost of the cheapest solution through $n$. > > > Thus, if we are trying to find the cheapest solution, a reasonable thing to try first is the node with the lowest value of $g(n) + h(n)$. It turns out that this strategy is more than just reasonable: provided that the heuristic function $h(n)$ satisfies certain conditions, A\* search is both complete and optimal. The algorithm is identical to uniform-cost search except that A\* uses $g + h$ instead of $g$ > > > Upvotes: 2 <issue_comment>username_2: What you said isn't totally wrong, but the A\* algorithm becomes optimal and complete if the heuristic function h is admissible, which means that this function never overestimates the cost of reaching the goal. In that case, the A\* algorithm is way better than the greedy search algorithm. Upvotes: 1 <issue_comment>username_3: Both algorithms fall into the category of "best-first search" algorithms, which are algorithms that *can* use both the knowledge acquired so far while exploring the search space, denoted by $g(n)$, and a heuristic function, denoted by $h(n)$, which estimates the distance to the goal node, for each node $n$ in the search space (often represented as a graph). Each of these search algorithms defines an "evaluation function", for each node $n$ in the graph (or search space), denoted by $f(n)$. This evaluation function is used to determine which node, while searching, is "expanded" first, that is, which node is first removed from the ["fringe" (or "frontier", or "border")](https://ai.stackexchange.com/q/5949/2444), so as to "visit" its children. In general, the difference between the algorithms in the "best-first" category is in the definition of the evaluation function $f(n)$. In the case of [*the greedy BFS algorithm*](https://en.wikipedia.org/wiki/Best-first_search#Greedy_BFS), the evaluation function is $f(n) = h(n)$, that is, the greedy BFS algorithm first expands the node whose estimated distance to the goal is the smallest. So, greedy BFS does not use the "past knowledge", i.e. $g(n)$. Hence its connotation "greedy". In general, the greedy BST algorithm is **not complete**, that is, there is always the risk to take a path that does not bring to the goal. In the greedy BFS algorithm, all nodes on the *border* (or fringe or frontier) are kept in memory, and nodes that have already been expanded do not need to be stored in memory and can therefore be discarded. In general, the greedy BFS is also **not optimal**, that is, the path found may not be the optimal one. In general, the time complexity is $\mathcal{O}(b^m)$, where $b$ is the (maximum) branching factor and $m$ is the maximum depth of the search tree. The space complexity is proportional to the number of nodes in the fringe and to the length of the found path. In the case of [*the A\* algorithm*](https://en.wikipedia.org/wiki/A*_search_algorithm), the evaluation function is $f(n) = g(n) + h(n)$, where $h$ is an [admissible heuristic function](https://en.wikipedia.org/wiki/Admissible_heuristic). The "star", often denoted by an asterisk, `*`, refers to the fact that A\* uses an admissible heuristic function, which essentially means that A\* is **optimal**, that is, it always finds the optimal path between the starting node and the goal node. A\* is also **complete** (unless there are infinitely many nodes to explore in the search space). The time complexity is $\mathcal{O}(b^m)$. However, A\* needs to keep all nodes in memory while searching, not just the ones in the fringe, because A\*, essentially, performs an "exhaustive search" (which is "informed", in the sense that it uses a heuristic function). In summary, greedy BFS is not complete, not optimal, has a time complexity of $\mathcal{O}(b^m)$ and a space complexity which can be polynomial. A\* is complete, optimal, and it has a time and space complexity of $\mathcal{O}(b^m)$. So, in general, A\* uses more memory than greedy BFS. A\* becomes impractical when the search space is huge. However, A\* also guarantees that the found path between the starting node and the goal node is the optimal one and that the algorithm eventually terminates. Greedy BFS, on the other hand, uses less memory, but does not provide the optimality and completeness guarantees of A\*. So, which algorithm is the "best" depends on the context, but both are "best"-first searches. Note: in practice, you may not use any of these algorithms: you may e.g. use, instead, [IDA\*](https://en.wikipedia.org/wiki/Iterative_deepening_A*). Upvotes: 5 [selected_answer]
2018/11/11
533
2,385
<issue_start>username_0: How are artificial neural networks different from normal computer programs (or software)?<issue_comment>username_1: ANNs learn and adapt to the patterns inside inputs, however, general PCs don't. PCs take the process as input and provide results based on user preferences, but never adapt i.e., always depends on users what to do with the data, meanwhile, ANNs are customized for specific tasks like forecasting, function approximations etc. Upvotes: 2 [selected_answer]<issue_comment>username_2: Well, a computer consists of the hardware (CPU, GPU, memory, etc.), the operational system (OS) and software/programs (OS is also a software, but it is a very special software). A neural network is simply a program that runs on a computer. Like a calculator app. In fact, the most simple NNs are indeed just some sort of a calculator that performs matrix multiplications. Upvotes: 2 <issue_comment>username_3: **Personal Computers** are hardware, whereas artificial neural networks are software. (There are also neuromorphic chips, but that is a different story.) A **traditional computer program** receives some input, calculates stuff based on predefined rules / flow diagrams and generates the output and side effects (such as changed files). The complexity often lies in the number of rules: What is the most reasonable part to adjust, given a change of requirements / a bug? How can I be sure I didn't forget an important edge case? Do I have off-by-one errors? Null-Pointer references? Overflows? An **artificial neural network** is just one machine learning model. **Machine learning** programs are also software, but they take data and an optimization criterion to infer the desired rules. There is no machine learning without data. The side effect of a machine learning programs training algorithm is the trained model, which usually is a big binary file. The complexity often lies in the data/the model: Is the training data representative for my real task? Did the model learn something reasonable? When / how often do I have to retrain? How can we maintain this? To be more precise, here is Tom Mitchells definition of machine learning: > > A computer program is said to learn from experience E with respect to some task T and some performance measure P if its performance on T, as measured by P, improves with experience E. > > > Upvotes: 2
2018/11/13
787
2,852
<issue_start>username_0: I found the below image of how a CNN works [![Image](https://i.stack.imgur.com/I5nj1.png)](https://i.stack.imgur.com/I5nj1.png) But I don't really understand it. I think I do understand CNNs, but I find this diagram very confusing. My simplified understanding: * Features are selected * Convolution is carried out so that to see where these features fit (repeated with every feature, in every position) * Pooling is used to shrink large images down (select the best fit feature). * ReLU is used to remove your negatives * Fully-connected layers contribute weighted votes towards deciding what class the image should be in. * These are added together, and you have your % chance of what class the image is. Confusing points of this image to me: * Why are we going from one image of $224 \times 224 \times 3$ to two images of $224 \times 224 \times 64$? Why does this halving continue? What is this meant to represent? * It continues on to $56 \times 56 \times 256$. Why does this number continue to halve, and the number, at the end, the $256$, continues to double?<issue_comment>username_1: > > Why are we going from one image of $224 \times 224 \times 3$ to two images of $224 \times 224 \times 64$? > > > They do a Convolution with a $1 \times 1$ kernel, with $64$ filters. That way, you keep your size as the inputs ($224 \times 224$), but changes the number of filters to 64. And this is not two image, but two layers ! > > Why does this halving continue? What is this meant to represent? > > > This is the maxpooling operation (the layer is in red colour, see the legend). In general, max pooling is applied with a kernel stride of 2 (rarely 3, but not more, because you lose too much informations). That way your size is cut by 2, and the activation maps are more little, and you have faster computation. > > It continues on to $56 \times 56 \times 256$. Why does this number continue to halve, and the number, at the end, the $256$, continues to double? > > > Still max-pooling. There are no reason to double the numbers of filters, though. This just a trend, but you can put the numbers of filters that you want. Upvotes: 2 <issue_comment>username_2: The number of feature maps is increased because we increased the number of filters that are applied throughout the process. ### Here is the reason why: --- Filters at first layers would find simple features like lines and edges. Subsequent layers would take those features -in other words, patterns- and combine them to create much bigger patterns. Therefore we should increase the size of the filters to meet the increased size of complexity. Since the filter size increased, the number of feature maps would increase as a result. Also, keep in mind that filters at the deeper layers tend to find more complicated features. Upvotes: 1
2018/11/13
2,782
11,154
<issue_start>username_0: What is the actual learning algorithm: back-propagation or gradient descent (or, in general, the optimization algorithm)? I am reading through chapter 8 of Parallel Distributed Processing hand book and the title of the chapter is "Learning internal representation by error propagation" by PDP research Group. <https://web.stanford.edu/class/psych209a/ReadingsByDate/02_06/PDPVolIChapter8.pdf> If there are no hidden units, no learning happens. If there are hidden units, they learn internal representation by propagating error back. Does this mean back propagation[delta rule] is the learning rule and gradient descent is an optimization algorithm used to optimize cost function?<issue_comment>username_1: **Gradient descent** is a very general optimization algorithm. **Backpropagation** is a special case of auto-differenciation combined with gradient descent. So backpropagation is a clever way to do gradient descent. The idea of Gradient descent is to calculate the gradient (derivative) and use that to descent on the error surface. In 3D, you could imagine 2 parameters (x,y) and the 3rd dimension (z) gives you the training error the model makes with those two parameters. You are at some (random) starting point in this error surface and make a step in downwards direction. Then you calculate the error again and do again a step in downwards direction. Note that I didn't write "downwards" but "in downwards direction" as your step might be too big. Backpropagation consists of two steps: The forward-pass and the backward-pass. In the forward pass, the output of the network for a given input is calculated. In the backward pass, the gradients are calculated with the chain rule. See <http://cs231n.github.io/optimization-2/> for a good reference for back propagation. Please note that machine learning is way broader than neural networks. For example, decision trees don't use gradient descent at all to train. > > What is the actual learning algorithm: back-propagation or gradient descent? > > > Gradient descent is the learning algorithm. It is realized in backpropagation in the weight-update of the backward pass. Notes and References -------------------- When I write "backpropagation algorithm", I refer to <NAME>s "Machine Learning", Chapter 4.5.2. To cite <NAME>s "Machine Learning": > > Algorithms such as BACKPROPAGATION use gradient descent to tune network parameters to best fit a training set of input-output pairs. > > > [...] gradient descent provides the basis > for the BACKPROPAGATION algorithm [...] > > > [The section 4.5 MULTILAYER NETWORKS AND THE BACKPROPAGATION > ALGORITHM] discusses how to learn such multilayer networks using a gradient descent algorithm similar to that discussed in the previous section. > > > [...] > > > As shown above, the BACKPROPAGATION algorithm implements a gradient descent search through the space of possible network weights > > > Upvotes: 1 <issue_comment>username_2: You can run gradient descent without back propagation, in some cases: * Simple structures such as linear or logistic regression, where the gradients can be calculated directly from the inputs and cost function value. * In "black box" gradient-based learning algorithms where you don't know how (or don't want to) calculate gradient analytically, so you choose to *measure* it. This is a slow process, similar to [gradient checking](http://deeplearning.stanford.edu/tutorial/supervised/DebuggingGradientChecking/) of neural networks, i.e. adjust each parameter in turn by a small $+\epsilon$, measure your loss function, and divide difference by $\epsilon$ to get gradient estimate for that parameter. In those cases, you can calculate the gradient, and then use the optimisation function of your choice - e.g. SGD, Adam, Nesterov Momentum - to make changes to the learned parameters. The model will be changed and should learn its task based on the cost function. You can also run back propagation without gradient descent. In that case, the model will not change and nothing is learned. That makes the different flavours of gradient descent technically the "core" learning algorithm in my opinion, and back propagation the preferred method for calculating gradients in neural networks. These gradients are most often estimates of an unknown "true gradient" due to training in batches of small samples of training data. In practice, the two terms back propagation and gradient descent are rarely separated when discussing neural network training. So a lot of people will say that they train a network "using back propagation" or that they are using a gradient descent method without mentioning how they are calculating the gradients using back propagation (because that's pretty much a given). Or they might just say they are "using the Adam optimiser" which in the library they are using automatically runs an NN forward on a mini-batch of data, performs back propagation\*, and then changes weight parameters based on the gradients, but heavily adjusted by previous gradient measurements. --- \* With auto-differentiating frameworks such as TensorFlow, PyTorch etc, it is not really clear that the algorithms are performing "classic back propagation" - although they work using the same chain rule, they may well not perform calculations in the exact same groups that you learned when you studied neural networks and had to write the code for calculating gradients by hand. Instead of back propagating gradients layer-by-layer, they are propagated through an abstract computation graph that includes the learnable parameters. Upvotes: 3 <issue_comment>username_3: [**Gradient descent**](https://en.wikipedia.org/wiki/Gradient_descent) (GD) is an optimisation algorithm, that is, it is used to find a (local) minimum of a [multi-variable](https://en.wikipedia.org/wiki/Function_of_several_real_variables) and [differentiable](https://en.wikipedia.org/wiki/Differentiable_function) function $f$. GD is an *iterative* and *numerical* optimisation algorithm. It is *iterative* because it proceeds in iterations. It is *numerical* because it is not an algorithm which produces an exact solution, due to [numerical errors](https://en.wikipedia.org/wiki/Numerical_error) (e.g., round-off errors). GD is based on the idea that, if a (multi-variable) function $f(\mathbf{x})$ (where $\mathbf{x} \in \mathbb{R}^N$ is a variable representing the input of $f$) is *defined* and *differentiable* in a "[neighbourhood](https://en.wikipedia.org/wiki/Neighbourhood_(mathematics))" of a point $\mathbf{\theta} \in \mathbb{R}^N$, which is a point (in the loose sense of the word "point") in the [domain](https://en.wikipedia.org/wiki/Domain_of_a_function) of $f$ (that is, $f(\mathbf{\theta})$ is defined and differentiable), then $f$ **decreases fastest** if one goes from $\mathbf{\theta}$ in the "direction" of the **negative gradient** of $f$ at $\mathbf{\theta}$, that is, $-\nabla f(\mathbf {\theta})$. (Do not be scared of the symbol $\theta$, we could have denoted it by $\mathbf{a}$!). Let us break this dense definition down! Note that here we assume that $f$ is a multi-variable function (that is, a function whose input is not just one real number, but it is a function of $N$ real numbers, which can be grouped in a vector, e.g. $\mathbf{\theta} \in \mathbb{R}^N$), hence $\mathbf{x}$ and $\mathbf{\theta}$ are vectors of real numbers. To emphasize, $\mathbf{\theta}$ is some specific (and "fixed") point in the domain of $f$, whereas $\mathbf{x}$ is a variable that can take any of these specific points. The basic statement/assignment which is iterated in GD, which captures the definition above, is the following: $$\mathbf{\theta}\_{n+1} \gets \mathbf{\theta}\_{n} - \gamma \nabla f(\mathbf{\theta} \_{n}) \label{gd-assignment}\tag{1}$$ where the $\gamma$ is a [hyper-parameter](https://en.wikipedia.org/wiki/Hyperparameter_(machine_learning)) which represents the "strength" of the step we take in the direction of the negative gradient (i.e., $-\nabla f(\mathbf{\theta} \_{n})$). Note the "minus" (i.e., $-$) in front of $\nabla f(\mathbf{\theta}\_{n})$, hence the expression "in the direction of the *negative* gradient". Note also that here "direction" is implemented as a subtraction. The subscript $\_n$ represents the current iteration number. As simple as it looks, the GD algorithm consists in the execution of the assignment \ref{gd-assignment} until some condition is met (e.g., ${\theta}\_{n+1}$ is "close enough" to ${\theta}\_{n}$). In a nutshell, GD is an iterative algorithm which updates $\theta$ by iterating \ref{gd-assignment} multiple times. In the context of machine learning (ML), in particular supervised learning, we initially have an untrained model $\mathcal{M}$ (e.g., a neural network), that is, a model whose parameters (sometimes also called "weights") are e.g. randomly initialised. To train $\mathcal{M}$ (i.e., to find the most appropriate parameters of the model with respect to the training data), we first define a so-called "loss function" (which is differentiable), denoted by $\mathcal{L}$, which represents the discrepancy between the current output of $\mathcal{M}$ and the expected output (with respect to the training data) of $\mathcal{M}$. The process of *training a model* consists in minimising this loss function, that is, it consists in finding the minimum of $\mathcal{L}$. To do this, as we have just seen above, we can use GD. If you consider the learning process the one of minimising this loss function $\mathcal{L}$, then any algorithm which minimises $\mathcal{L}$ should be called a "learning algorithm". Hence GD should be called a "learning algorithm". Note that the parameters of the model $\mathcal{M}$, which need to be found during the training process, are often denoted, in ML, by $\theta$. So, the reason why I used the strange symbol $\theta$ in the assignment $\ref{gd-assignment}$ should now be clearer. [**Back-propagation**](https://en.wikipedia.org/wiki/Backpropagation) (BP) is just an algorithm, [proposed by <NAME> in his master's thesis](http://people.idsia.ch/~juergen/who-invented-backpropagation.html), to compute the derivative of a *differentiable* (composite) function, which can be represented as a graph. In ML, back-propagation is often used to compute $\nabla f(\mathbf{\theta}\_{n})$ in the assignment \ref{gd-assignment}. So, BP is used as a sub-routine in the GD algorithm (or any other optimization algorithm) to find the parameters of the model $\mathcal{M}$. Note that, in the context of ML, $\gamma$ in \ref{gd-assignment} is often called the "*learning* rate". There's a reason for this: GD is the actual learning algorithm. BP is just a sub-routine used to compute the gradient, but we could have used another sub-routine. We could say, in the context of ML (and, in particular, NNs), that the combination of GD and BP is the actual "learning algorithm", but, if by "learning" we mean "optimisation", then the actual "learning algorithm" is GD and **not** BP, because BP does *not* optimise anything alone. Upvotes: 3
2018/11/15
971
3,428
<issue_start>username_0: I have three equations that relates five variables *{a, b, c, r, s}* with a sum and two ratios. ``` Eq. 1: a = b + c; Eq. 2: s = b / a; Eq. 3: r = b / c. ``` Given two values for any of the five variables I get a solution. But, this is not the automation problem I want to solve. I can have the solution of variable *r* by simply knowing *s*. This is solved by a "human algorithm" as follows. 1. Substitute a of Eq. 1 in Eq. 2. - Divide the second term of the new Eq. 2 by the variable c. - Replace b/c by the expression of Eq. 3. That means s = r / (r+1). The questions is -How can an AI algorithm solve this?, i.e. the machine should recognize that given the variable *r* she can obtain directly the variable *s* and do no require another variable.<issue_comment>username_1: What you're asking here is actually not reasoning but rather symbolic computation. [Sympy](https://www.sympy.org/en/index.html) is an example of a library which does it. Explaining computer algebra systems could be a series of lectures and this is too broad for a single question. To give you an idea: (1) represent equations symbolically (2) bring them in a normal form (3) substitute. Although it is not elegant, you can simplify the problem by brute Force: try all combinations of solving for a variable and substituting it in the other equations. Related: * [How do symbolic math software work? | Mathematics Stack Exchange](https://math.stackexchange.com/q/532897/6876) Upvotes: 2 <issue_comment>username_2: I would turn this problem into graph search in which vertices are "equivalent sets of equations" and edges are "valid operations" such as such as substitution, division and so on, which always ensure that all states are mathematically equivalent. A very simple example of a few states and edges (to requote from your question): ``` State 0: Eq. 1: a = b + c; Eq. 2: s = b / a; Eq. 3: r = b / c. Operation 0-->1: Multiply Eq. 3 by c State 1: Eq. 1: a = b + c; Eq. 2: s = b / a; Eq. 3: rc = b. Operation 0-->2: Substitute Eq 1 into 2 State 2: Eq. 1: a = b + c; Eq. 2: s = b / (b+c); Eq. 3: r = b / c. Operation 2-->3: Rearrange Eq 3 so B is on right hand side. etc etc ``` Depending on how many operations you have, this does mean that the graph could be quite large, so you may not want to generate the entire graph (actually, the graph will be infinite if the number of operations allowed is unlimited). It's also possible that the graph will contain cycles, since there may be multiple ways to reach the same state. You will have to think about how to develop data structures for representing the states and operations. Since this is a search problem, it will help to define what your "goal" states look like (e.g. states where *s* is defined in terms of *r*). To search the graph, I recommend one of these approaches: * Breadth-first search: this will find the shortest number of operations needed to reach any goal states * Best-first search: if the graph is too large for breadth first, you may need to guide the search to the goal states using a heuristic, e.g. you could rate states by how few variables are needed on the LHS of equations or something like that -- some experimentation will be needed here. The exact choice of search algorithm will depend on how big the graph is, which in turns depends on how many operations/edges you want. Upvotes: 1
2018/11/15
1,025
4,069
<issue_start>username_0: What are the limitations of the *hill climbing algorithm*? How can we overcome these limitations?<issue_comment>username_1: [Hill climbing](https://github.com/aimacode/aima-pseudocode/blob/master/md/Hill-Climbing.md) is not an algorithm, but a family of "local search" algorithms. Specific algorithms which fall into the category of "hill climbing" algorithms are 2-opt, 3-opt, 2.5-opt, 4-opt, or, in general, any N-opt. See chapter 3 of the paper "[*The Traveling Salesman Problem: A Case Study in Local Optimization*](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.92.1635&rep=rep1&type=pdf)" (by <NAME> and <NAME>) for more details regarding some of these local search algorithms (applied to the TSP). What differentiates one algorithm in this category from the other is the "neighbourhood function" they use (in simple words, the way they find neighbouring solutions to a given solution). Note that, in practice, this is not always the case: often these algorithms have several different implementations. The most evident limitation of hill climbing algorithms is due to their nature, that is, they are local search algorithms. Hence they usually just find *local* maxima (or minima). So, if any of these algorithms has already converged to a local minimum (or maximum) and, in the solution or search space, there is, close to this found solution, a better solution, none of these algorithms will be able to find this better solution. They will basically be trapped. Local search algorithms are not usually used alone. They are used as sub-routines of other meta-heuristic algorithms, like simulated annealing, iterated-local search or in any of the ant-colony algorithms. So, to overcome their limitations, we usually do not use them alone, but we use them in conjunction with other algorithms, which have a probabilistic nature and can find global minima or maxima (e.g., any of the ant-colony algorithms). Upvotes: 3 <issue_comment>username_2: As @username_1 has already said that Hill Climbing is a family of **local search algorithms**. So, when you said Hill Climbing in the question I have assumed you are talking about the standard hill climbing. The standard version of hill climb has some limitations and often gets stuck in the following scenario: * Local Maxima: Hill-climbing algorithm reaching on the vicinity a local maximum value, gets drawn towards the peak and gets stuck there, *having no other place to go*. * Ridges: These are *sequences of local maxima*, making it difficult for the algorithm to navigate. * Plateaux: This is a *flat state-space region*. As there is no uphill to go, algorithm often gets lost in the plateau. To resolve these issues many variants of hill climb algorithms have been developed. These are most commonly used: * **Stochastic Hill Climbing** selects at random from the uphill moves. The probability of selection varies with the steepness of the uphill move. * **First-Choice Climbing** implements the above one by generating successors randomly until a better one is found. * **Random-restart hill climbing** searches from randomly generated initial moves until the goal state is reached. The success of hill climb algorithms depends on the architecture of the state-space landscape. Whenever there are few maxima and plateaux the variants of hill climb searching algorithms work very fine. But in real-world problems have a landscape that looks more like a widely scattered family of balding porcupines on a flat floor, with miniature porcupines living on the tip of each porcupine needle (as described in the 4th Chapter of the book Artificial Intelligence: A Modern Approach). NP-Hard problems typically have an exponential number of local maxima to get stuck on. Given algorithms have been developed to overcome these kinds of issues: * Stimulated Annealing * Local Beam Search * Genetic Algorithms Reference [Book - Artificial Intelligence: A Modern Approach](https://rads.stackoverflow.com/amzn/click/0136042597) Upvotes: 4 [selected_answer]
2018/11/16
1,140
4,618
<issue_start>username_0: Let's say there are two types of cancer(Type 1 and Type 2). Say we want to see if one of pour friends has cancer Type 1 or 2. We can treat this as a classification problem. But what if we use unsupervised learning (clustering) to separate the data into to 2 different groups and see each whether each item in group 1 belongs to a person with cancer Type 1 or 2. We will then see whether our friend belongs to group 1 or 2. I know it is stupid to do this and we have to do extra work but can we even do this? Let's say that the features are only the age and the height (I know it's really dumb but just bear with me). The data associated with people with cancer Type 1 is `[10, 150], [12, 153], [9, 143], [13, 160]` and for people with Type 2 cancer : `[20, 175], [23, 180], [19, 174]`. Let's say we plot the data on a graph (without labelling the data) and the unsupervised program (Clustering) just separates the two groups (Say group 1 for Type 1). We then can see that to whom each data in group 1 belongs. We see those people have cancer Type 1. So given new data, we see what group our friend belongs to. If she/he belonged to group 1, he's got cancer Type 1 and if not, she/he has cancer Type 2.<issue_comment>username_1: *You cannot use clustering as an "unsupervised classifier", with the goal of targeting specific known classes that are already defined. For that you need supervised learning and a labelled dataset.* A clustering algorithm would only separate into clusters as you hope if the feature variables you use are already: * **All** strongly associated with the trait you want the clusters to find * Carefully scaled to match the expected relationship Now this might happen by chance with an arbitrary dataset. However in practice in a complex dataset with many features (as you might use in cancer classification) you would need to select and scale just relevant features. Thus you would need to already know the relationship between features and class from some other model. The main task of clustering is to *discover* naturally occurring groups within your data, that might give you insight into the distributions within a dataset. This might let you compress or summarise information about examples. The summary feature might even be predictive, but it would very rarely overlap with pre-defined classes, even when the full feature vector could be used in an accurate supervised learning predictive model. With your given example of `[age, height]` you might discover that the population splits naturally into people who are still growing, fully-grown youths and mature people. If this happens to overlap with predictions of type 1 and type 2 cancer that might be interesting - perhaps a person's cluster is even a good predictive variable for having type 1 or type 2 cancer. However, whatever the features are, it is highly unlikely that it would be so strong a predictive variable that you would use it on its own to make a classification. The only variables that would be that predictive would be the clinical measurements *of the cancer growth* that clinicians already use to decide the cancer type. Potentially you *could* build a Bayesian model around the clusters, where you can ask questions such as: * What is the probability that a random person is in cluster A $p(x \in A)$? * What is the probability that a random person has cancer type 1 $p(x \in C\_1)$? * What is the conditional probability that a person with type 1 cancer is found in cluster A $p(x \in A|x \in C\_1)$? Bayes' Theorem would then allow you to calculate the probability of having type 1 cancer based on their clustering: $$p(x \in C\_1 | x \in A) = \frac{p(x \in A|x \in C\_1)}{(x \in A)}p(x \in C\_1)$$ To do this fully with Bayesian statistics would involve setting some prior beliefs about the probabilities and using the data from your analysis to adjust them, which is beyond the scope of this answer. However, you could as a crude shortcut just take the measured frequencies, and that might be fine as a guide and give you some intuitions about what your clustering is doing towards helping with predictions. Upvotes: 1 <issue_comment>username_2: There are several ways to use clustering for classification. 1. To use features associated with classes, then do clustering and find the relationships between clusters and classes. 2. To use classes in the training set as clusters and to classify each new data vector by its closeness to each cluster. 3. To use class label as one of features for clustering. Then, find association between clusters and classes. Upvotes: 0
2018/11/17
865
3,649
<issue_start>username_0: I'm new to machine learning. I was watching a Prof. <NAME>'s video about gradient descent from the machine learning online course. It said that we want our cost function (in this case, the *mean squared error*) to have the minimum value, but that minimum value shown in the graph was not 0. It was a negative number! How can our cost function, which is mean squared error, have a negative value, given that the square of a real number is always positive? Even if it is possible, don't we want our error to be 0?<issue_comment>username_1: In general a cost function can be negative. The more negative, the better of course, because you are measuring a cost the objective is to minimise it. A standard Mean Squared Error function cannot be negative. The lowest possible value is $0$, when there is no output error from any example input. > > How can our cost function which is mean squared error have a value under 0? > > > It cannot. You don't link the precise graph or lecture where you saw this, but I would suspect <NAME> drew a representative graph for *any* cost function in order to point out that it would typically have an optimum, minimum value. He may have been talking at the same time about MSE as an example. Many loss or cost functions are designed with an absolute minimum of $0$ possible for "no error" results. In supervised learning that is often a simple consequence of basing the cost on the difference between the model outputs and desired outputs. So in supervised learning problems of regression and classification, you will rarely see a negative cost function value. But there is no absolute rule against negative costs in principle. Upvotes: 3 <issue_comment>username_2: Mean squared error terms must be positive because the square of a number is positive. Therefore the sum (cost) is positive. The error is the difference between the hypothesis and the observation. I would focus on understanding why Ng seeks to minimize J and how it is minimization is achieved with partial derivatives via matrix implementation. Upvotes: 1 <issue_comment>username_3: I am watching the same course too, and I think that in the example graph, the cost function is not a sum of MSE (Mean squarred errors), but it could be a cubic one, so a sum of cubical errors, and thus the cost function could be negative: as there are a variety of cost functions, the MSE ones are not adapted for every problems, and other formulations could work better. Upvotes: 0 <issue_comment>username_4: I would like to add more information to the [@username_1's answer](https://ai.stackexchange.com/a/9023/59824). <NAME> has used a "generic" graph to show min loss function mean higher performance. That is not always the case, sometimes its over fitting. Let's no go into that realm of machine learning I am not that pro The output of the function in maths is called `range` and input is called `domain`. We are using MSE in the linear regression because it is sensitive to the outliers and help in penalizing the parameters to get more accurate value that fits the training example (aka line of best fit). In the MSE, the minimum loss would be $\hat y$ = y which means the difference is $0$, so does the mean $\mu$ would be zero. Therefore the range of function would be $[0, \infty)$. In case of MSE, the min value of the cost function would be $0$ no matter what. Do not confuse the $0$ min value of the MSE with the min $0$ of gradient descent of the cost function. Remember, in the gradient descent there is no 2 in the power, it can be negative, despite being positive value of the MSE function. Upvotes: 0
2018/11/20
881
3,539
<issue_start>username_0: In the context of *evolutionary computation*, in particular *genetic algorithms*, there are two stochastic operations "mutation" and "crossover". What are the differences between them?<issue_comment>username_1: The **mutation** is an operation that is applied to a single individual in the population. It can e.g. introduce some noise in the chromosome. For example, if the chromosomes are binary, a mutation may simply be the flip of a bit (or gene). The **crossover** is an operation which takes as input two individuals (often called the "parents") and somehow combines their chromosomes, so as to produce usually two other chromosomes (the "children"), which inherit, in a certain way, the genes of both parents. For more details about these operations, you can use the book [Genetic Algorithms in Search, Optimization, and Machine Learning](http://www2.fiit.stuba.sk/%7Ekvasnicka/Free%20books/Goldberg_Genetic_Algorithms_in_Search.pdf) by [<NAME>](https://scholar.google.com/citations?user=BUzKxsoAAAAJ&hl=en) (who is an expert in genetic algorithms and was *just* advised by <NAME>). You can also take a look at the book [Computational Intelligence: An Introduction](https://papers.harvie.cz/unsorted/computational-intelligence-an-introduction.pdf) (2nd edition, 2007) by [<NAME>](https://ieeexplore.ieee.org/author/37276400500). Upvotes: 4 [selected_answer]<issue_comment>username_2: Evolutionary algorithms use it in a very similar way as the two terms are used in biology: > > In biology, a **mutation** is the permanent alteration of the nucleotide sequence of the genome of an organism, virus, or extrachromosomal DNA or other genetic elements. > > > Source: [Wikipedia](https://en.wikipedia.org/wiki/Mutation) > > **Chromosomal crossover** [...] is the exchange of genetic material [...] that results in recombinant chromosomes during sexual reproduction. > > > Source: [Wikipedia](https://en.wikipedia.org/wiki/Chromosomal_crossover) Hence the main difference is that mutations happen within one individual while crossover is between two individuals. Upvotes: 0 <issue_comment>username_3: Mutation is secondary operator (10%) while Crossover is Primary (90%) which creates offspring while mutation can only shuffle information within the Choromsome Upvotes: 0 <issue_comment>username_4: I like to use the term, "recombination operator" rather than "crossover operator", because the latter term suggests a specific type of operation: constructing an offspring by switching corresponding chromosome segments between two parents. "Recombination" (to me) suggests any operation that forms an offspring from the genetic information of two parents. "Crossover" in that sense doesn't work when the individuals are, for example, permutations; but many "recombination operators" that *do* work are still possible, which preserve non-conflicting portions of two parent permutations. In GA, mutation can be thought of as a relatively small random change that occurs within an individual. Mutation usually is a change of the value of one gene *without making use of gene values in any other individuals*, but can also be a random rearrangement of elements in a permutation, or a random change in the values of several genes. Sometimes the term is applied to a "hill climbing" procedure in which several mutations are applied to an individual and their effect on fitness is tested; then the one that produces the most fitness improvement is retained. Upvotes: 1
2018/11/21
2,239
10,036
<issue_start>username_0: In the exercise [Exercise 3: Multivariate Linear Regression](http://openclassroom.stanford.edu/MainFolder/DocumentPage.php?course=MachineLearning&doc=exercises/ex3/ex3.html), by <NAME>, the author suggests to "scale both types of inputs by their standard deviations and set their means to zero". $$x\_{n e w}=\frac{x-\mu}{\sigma}$$ ### Method 1 The author provides the following Matlab (and Octave) code to scale the inputs. ``` x = [ones(m, 1), x]; sigma = std(x); mu = mean(x); x(:,2) = (x(:,2) - mu(2))./ sigma(2); x(:,3) = (x(:,3) - mu(3))./ sigma(3); ``` ### Method 2 But why not simply scale the inputs between zero and one, or, divide by the maximum? ``` x_range=max(x) x(:,2) = (x(:,2)/x_range(2)); x(:,3) = (x(:,3)/x_range(3)); ``` I have done the exercise with method 2 and these are the results. [![enter image description here](https://i.stack.imgur.com/fdhSG.png)](https://i.stack.imgur.com/fdhSG.png) ### Question Is there a computational advantage with the first method over the second method?<issue_comment>username_1: No, there is no computational advantage of the second method over the first, if you neglect the computational requirements for the calculation of $\sigma$ and $\mu$. We generally use the first method for better results. This is because if you separate your dataset into train and test data, then you may normalise the train data perfectly between $0$ and $1$ by taking $max$ and $min$ from the train dataset. Your algorithm will only see data between $0-1$, but there is no way to ensure normalising the test data on the same $max$ and $min$ will result in the data being between $0$ and $1$.. So a better way is to use the Gaussian Distribution method, as the only assumption it makes is the data distribution is Gaussian which is just about true for any phenomenon (after some functional transformations which might be handled by the ML algorithm). I answered a similar [question](https://datascience.stackexchange.com/questions/33846/normalizing-test-data/33847#33847) here. Upvotes: 1 <issue_comment>username_2: **Clarifications** Before directly answering the question, there are a few things to note. * The word range is actually applicable to a dependent variable. On the input side, it is the domain that needs to be normalized. * In the second method, since the minimum vector may not be the origin, the zeroth order term should be included in the normalization. The minimum must be subtracted from the maximum to determine the domain and must also be subtracted as an offset to the independent, pre-normalized values. * The standard deviation is always less than half the difference between the max and min, so there is a difference in proportion between the two methods. The crux of the question centers around the statistics of normalization and its potential impact on these methods. * Multivariate linear regression (in the question introduction) * Gradient descent (selected as a tag) Although these two are not technically mutually exclusive, practically they are if by linear is meant conforming to $\vec{y} = a \vec{x} + \vec{b}$, where $a$ is a matrix dimensioned appropriately for $\vec{x}$ and $\vec{y}$. For that first degree polynomial cases, there is a closed form (formula) to acquire $(\vec{a}, \vec{b}, c)$ from a set of pairs $(\vec{x}, \vec{y})$, where $c$ is the correlation coefficient. It would be grossly wasteful to use iterative convergence methods, such as gradient descent, to calculate a mean squares regression result for a first degree polynomial model of the relation between $\vec{x}$ and $\vec{y}$. If there is no closed form for the model or no known model at all, and the complexity of the function to be approximated is tenable in relation to the convergence methods available, the data available for training, and the computing resources and time that can be delegated to the task, then gradient descent is a method through which a least squares convergence on minimal loss may be possible. The significance of artificial networks is that, through the interconnection of a sequence of layers, each with an array of like activation functions, a network can approximate a useful function the mathematical model of which is not explicitly known. Of the statistical functional approximation problems where no closed form is known and for which convergence methods are possible, artificial network training has become the appropriate device for a growing set of cases. **Normalization** The metrics of mean and standard deviation are designed specifically for data that can be approximated by a Gaussian distribution. The term normalization originated from the belief that the Gaussian distribution was normal, however Gauss did not hold that belief. He presented it as a distribution resulting from the limit of an accumulation of random perturbations as the mean of the square of the perturbation size decreases to zero as the length of the series of perturbations approaches infinity. Because of this, if the loss (or error) function is a sum of the squares of difference between the current output values of an artificial network and the labels providing the accurate and correct values, a near Gaussian distribution of input is likely to produce a faster and complete convergence. In the multivariate case, there is an equivalent of the Gaussian distribution. In the real world, data distribution very close to Gaussian is not the norm. The distribution of land surface temperatures at a specific latitude and longitude on earth for a particular month reflect two maxima in the temperature distribution, one for nighttime and one for daytime. The model of the relationship between these two maxima and the time of year, in chaos theory, are called attractors. Points seem attracted to those norms. The distribution of signal amplitudes in common circuits and natural sounds in the air are not Gaussian distributed either, but the $\log(P)$ of the power of common signals and sounds are close to a Gaussian distribution, which is partly why decibels are a common measure of signal strength and loudness. The other part is that the logarithm in calculating decibels causes them to indicate relative geometric difference (ratio) in power rather than a less representative arithmatic difference. Normalization is often oversimplified to mean ensuring values fall within a specific domain convenient to an algorithm's numerical representation or around a mean with a given standard deviation to feed a least squares strategy for statistical analysis or correlation. However, data is not often symmetric and nicely distributed. In the case of land surface temperatures the nighttime distribution has a lower standard deviation than the daytime distribution, so the two peaks have different adjacent slopes in the distribution. How that is reflected in normalization varies depending on goals and algorithms receiving the normalized data. Normalization strategies for signal power and loudness would include running the data through a logarithm to reflect the near exponential Gaussian distribution of power values. **Outliers** Outliers are data points that fall outside an expected trend or relationship, either because they were incorrectly measured in one or more dimensions of measurement, the measurement was corrupted, they were strongly influenced by a phenomenon outside the intended range of study, or representative of a significant but previously undiscovered phenomenon. This last cause is why it is not wise to dismiss and exclude all outliers from functional analysis. When outliers are valid data points that inconveniently lie more than a few standard deviations from mean, normalizing from zero to one causes a very narrow distribution peak in one place within that input domain. If the outlier is of the kind that should not be dismissed and legitimately representative of the phenomena under study or being controlled, then some normalization scheme other than simply a first degree polynomial translation of the data is indicated. **Housing Predictor** In the case of square footage of living space, the data is not symmetric. An increase of 10 square meters for a large house will not produce the same price differential as 10 square meter increase for a small one. A properly configured neural network may learn to perform something similar to a logarithm in the first few layers during training, or the engineer can explicitly perform a logarithm to un-skew the data and present it in a form with closer to a Gaussian distribution to the network for training and then also later for actual use. At the exit, prior to presenting the network output to the loss function, applying an exponential function may also produce faster and more reliable convergence, since a monetary unit has different values to different buyers. A person buying a large house is less apt to be put off by cost associated with a fourth bedroom or more area than a person buying a small house. **Summary** The comparative advantages of different normalization methods are dependent upon a number of factors, including but not limited to these. * The resolution of the data types used to represent forward and backward signal propagation in the network, which affects the conditions of signal saturation * Skew of data set used for training * The number of standard deviations to the min and max in the data set used for training * Presence of multiple attractors in the distribution, which can occur in any of the features (dimensions of input) or combinations of them Method one is best for a scenario that involves a Gaussian distribution and may be best for the housing prediction. Method two might be best if the distribution is relatively flat almost all the way to the extremes. Running each method and comparing them may reveal advantages for one or the other that is not predicted in this answer and further knowledge can be gained about why by performing further experiments. Upvotes: 0
2018/11/22
1,950
9,278
<issue_start>username_0: In genetic algorithms, a function called "fitness" (or "evaluation") function is used to determine the "fitness" of the chromosomes. Creating a good fitness function is one of the challenging tasks in genetic algorithms. How would you create a good fitness function?<issue_comment>username_1: No, there is no computational advantage of the second method over the first, if you neglect the computational requirements for the calculation of $\sigma$ and $\mu$. We generally use the first method for better results. This is because if you separate your dataset into train and test data, then you may normalise the train data perfectly between $0$ and $1$ by taking $max$ and $min$ from the train dataset. Your algorithm will only see data between $0-1$, but there is no way to ensure normalising the test data on the same $max$ and $min$ will result in the data being between $0$ and $1$.. So a better way is to use the Gaussian Distribution method, as the only assumption it makes is the data distribution is Gaussian which is just about true for any phenomenon (after some functional transformations which might be handled by the ML algorithm). I answered a similar [question](https://datascience.stackexchange.com/questions/33846/normalizing-test-data/33847#33847) here. Upvotes: 1 <issue_comment>username_2: **Clarifications** Before directly answering the question, there are a few things to note. * The word range is actually applicable to a dependent variable. On the input side, it is the domain that needs to be normalized. * In the second method, since the minimum vector may not be the origin, the zeroth order term should be included in the normalization. The minimum must be subtracted from the maximum to determine the domain and must also be subtracted as an offset to the independent, pre-normalized values. * The standard deviation is always less than half the difference between the max and min, so there is a difference in proportion between the two methods. The crux of the question centers around the statistics of normalization and its potential impact on these methods. * Multivariate linear regression (in the question introduction) * Gradient descent (selected as a tag) Although these two are not technically mutually exclusive, practically they are if by linear is meant conforming to $\vec{y} = a \vec{x} + \vec{b}$, where $a$ is a matrix dimensioned appropriately for $\vec{x}$ and $\vec{y}$. For that first degree polynomial cases, there is a closed form (formula) to acquire $(\vec{a}, \vec{b}, c)$ from a set of pairs $(\vec{x}, \vec{y})$, where $c$ is the correlation coefficient. It would be grossly wasteful to use iterative convergence methods, such as gradient descent, to calculate a mean squares regression result for a first degree polynomial model of the relation between $\vec{x}$ and $\vec{y}$. If there is no closed form for the model or no known model at all, and the complexity of the function to be approximated is tenable in relation to the convergence methods available, the data available for training, and the computing resources and time that can be delegated to the task, then gradient descent is a method through which a least squares convergence on minimal loss may be possible. The significance of artificial networks is that, through the interconnection of a sequence of layers, each with an array of like activation functions, a network can approximate a useful function the mathematical model of which is not explicitly known. Of the statistical functional approximation problems where no closed form is known and for which convergence methods are possible, artificial network training has become the appropriate device for a growing set of cases. **Normalization** The metrics of mean and standard deviation are designed specifically for data that can be approximated by a Gaussian distribution. The term normalization originated from the belief that the Gaussian distribution was normal, however Gauss did not hold that belief. He presented it as a distribution resulting from the limit of an accumulation of random perturbations as the mean of the square of the perturbation size decreases to zero as the length of the series of perturbations approaches infinity. Because of this, if the loss (or error) function is a sum of the squares of difference between the current output values of an artificial network and the labels providing the accurate and correct values, a near Gaussian distribution of input is likely to produce a faster and complete convergence. In the multivariate case, there is an equivalent of the Gaussian distribution. In the real world, data distribution very close to Gaussian is not the norm. The distribution of land surface temperatures at a specific latitude and longitude on earth for a particular month reflect two maxima in the temperature distribution, one for nighttime and one for daytime. The model of the relationship between these two maxima and the time of year, in chaos theory, are called attractors. Points seem attracted to those norms. The distribution of signal amplitudes in common circuits and natural sounds in the air are not Gaussian distributed either, but the $\log(P)$ of the power of common signals and sounds are close to a Gaussian distribution, which is partly why decibels are a common measure of signal strength and loudness. The other part is that the logarithm in calculating decibels causes them to indicate relative geometric difference (ratio) in power rather than a less representative arithmatic difference. Normalization is often oversimplified to mean ensuring values fall within a specific domain convenient to an algorithm's numerical representation or around a mean with a given standard deviation to feed a least squares strategy for statistical analysis or correlation. However, data is not often symmetric and nicely distributed. In the case of land surface temperatures the nighttime distribution has a lower standard deviation than the daytime distribution, so the two peaks have different adjacent slopes in the distribution. How that is reflected in normalization varies depending on goals and algorithms receiving the normalized data. Normalization strategies for signal power and loudness would include running the data through a logarithm to reflect the near exponential Gaussian distribution of power values. **Outliers** Outliers are data points that fall outside an expected trend or relationship, either because they were incorrectly measured in one or more dimensions of measurement, the measurement was corrupted, they were strongly influenced by a phenomenon outside the intended range of study, or representative of a significant but previously undiscovered phenomenon. This last cause is why it is not wise to dismiss and exclude all outliers from functional analysis. When outliers are valid data points that inconveniently lie more than a few standard deviations from mean, normalizing from zero to one causes a very narrow distribution peak in one place within that input domain. If the outlier is of the kind that should not be dismissed and legitimately representative of the phenomena under study or being controlled, then some normalization scheme other than simply a first degree polynomial translation of the data is indicated. **Housing Predictor** In the case of square footage of living space, the data is not symmetric. An increase of 10 square meters for a large house will not produce the same price differential as 10 square meter increase for a small one. A properly configured neural network may learn to perform something similar to a logarithm in the first few layers during training, or the engineer can explicitly perform a logarithm to un-skew the data and present it in a form with closer to a Gaussian distribution to the network for training and then also later for actual use. At the exit, prior to presenting the network output to the loss function, applying an exponential function may also produce faster and more reliable convergence, since a monetary unit has different values to different buyers. A person buying a large house is less apt to be put off by cost associated with a fourth bedroom or more area than a person buying a small house. **Summary** The comparative advantages of different normalization methods are dependent upon a number of factors, including but not limited to these. * The resolution of the data types used to represent forward and backward signal propagation in the network, which affects the conditions of signal saturation * Skew of data set used for training * The number of standard deviations to the min and max in the data set used for training * Presence of multiple attractors in the distribution, which can occur in any of the features (dimensions of input) or combinations of them Method one is best for a scenario that involves a Gaussian distribution and may be best for the housing prediction. Method two might be best if the distribution is relatively flat almost all the way to the extremes. Running each method and comparing them may reveal advantages for one or the other that is not predicted in this answer and further knowledge can be gained about why by performing further experiments. Upvotes: 0
2018/11/22
328
1,324
<issue_start>username_0: In evolutionary computation and, in particular, in the context of genetic algorithms, there is the concept of a [*fitness function*](https://en.wikipedia.org/wiki/Fitness_function). The better a state, the greater the value of the fitness function for that state. What would be a good fitness function for the [8-queens problem](https://en.wikipedia.org/wiki/Eight_queens_puzzle)?<issue_comment>username_1: [Here](https://kushalvyas.github.io/gen_8Q.html) you can find an example of how to apply genetic algorithms to solve the 8-queens problem. The proposed fitness function is based on the chessboard arrangement, and in particular, it is inversely proportional to the number of clashes amongst attacking positions of queens; thus, a high fitness value implies a low number of clashes. Upvotes: 3 [selected_answer]<issue_comment>username_2: This can be calculated quite easily in the context of 8-queen problem. Just start with a particular configuration. Starting from the queen in the left-most column just keep on counting the non-attacking positions (pairs) on the right with each queen. Carry on column by column towards your right until you reach the last queen. As a special case for the last queen the non-attacking pairs will be zero as their are no other queens after that. Upvotes: 0
2018/11/24
885
3,153
<issue_start>username_0: I am a new learner in NLP. I am interested in the sentence generating task. As far as I am concerned, one state-of-the-art method is the [CharRNN](https://github.com/karpathy/char-rnn), which uses RNN to generate a sequence of words. However, [BERT](https://arxiv.org/abs/1810.04805) has come out several weeks ago and is very powerful. Therefore, I am wondering whether this task can also be done with the help of BERT? I am a new learner in this field, and thank you for any advice!<issue_comment>username_1: No. Sentence generating is directly related to language modelling (given the previous words in the sentence, what is the next word). [Because of bi-directionality of BERT, BERT cannot be used as a language model.](https://github.com/google-research/bert/issues/35) If it cannot be used as language model, I don't see how you can generate a sentence using BERT. Upvotes: 2 <issue_comment>username_2: For newbies, NO. Sentence generation requires sampling from a language model, which gives the probability distribution of the next word given previous contexts. But BERT can't do this due to its bidirectional nature. --- For advanced researchers, YES. You can start with a sentence of all [MASK] tokens, and generate words one by one in arbitrary order (instead of the common left-to-right chain decomposition). Though the text generation quality is hard to control. Here's the technical report [BERT has a Mouth, and It Must Speak: BERT as a Markov Random Field Language Model](https://arxiv.org/abs/1902.04094), its [errata](https://sites.google.com/site/deepernn/home/blog/amistakeinwangchoberthasamouthanditmustspeakbertasamarkovrandomfieldlanguagemodel) and the [source code](https://github.com/nyu-dl/bert-gen). --- In summary: * If you would like to do some research in the area of decoding with BERT, there is a huge space to explore * If you would like to generate high quality texts, personally I recommend you to check [GPT-2](https://blog.openai.com/better-language-models/). Upvotes: 6 [selected_answer]<issue_comment>username_3: this experiment by <NAME> suggests that BERT is lousy at sequential text generation: <http://mayhewsw.github.io/2019/01/16/can-bert-generate-text/> > > > ``` > although he had already eaten a large meal, he was still very hungry > > ``` > > As before, I masked “hungry” to see what BERT would predict. If it could predict it correctly without any right context, we might be in good shape for generation. > > > This failed. BERT predicted “much” as the last word. Maybe this is because BERT thinks the absence of a period means the sentence should continue. Maybe it’s just so used to complete sentences it gets confused. I’m not sure. > > > One might argue that we should continue predicting after “much”. Maybe it’s going to produce something meaningful. To that I would say: first, this was meant to be a dead giveaway, and any human would predict “hungry”. Second, I tried it, and it keeps predicting dumb stuff. After “much”, the next token is “,”. > > > So, at least using these trivial methods, BERT can’t generate text. > > > Upvotes: 3
2018/11/27
2,443
9,239
<issue_start>username_0: Advantage Actor-Critic algorithm may use the following expression to get 1-step estimate of the advantage: $ A(s\_t,a\_t) = r(s\_t, a\_t) + \gamma V(s\_{t+1}) (1 - done\_{t+1}) - V(s\_t) $ where $done\_{t+1}=1$ if $s\_{t+1}$ is a terminal state (end of the episode) and $0$ otherwise. Suppose our learning environment has a goal, collecting the goal gives reward $r=1$ and terminates the episode. Agent also receives $r=-0.1$ for every step, encouraging it to collect the goal faster. We're learning with $\gamma=0.99$ and we terminate the episode after $T$ timesteps if the goal wasn't collected. For the state before collecting a goal we have the following advantage, which seems very reasonable: $A(s\_t,a\_t) = 1 - V(s\_t)$. For the timestep $T-1$, regardless of the state, we have: $ A(s\_{T-1},a\_{T-1}) = r(s\_{T-1}, a\_{T-1}) - V(s\_{T-1}) \approx -0.1 -\frac{-0.1}{1-\gamma} = -0.1 + 10 = 9.9 $ (this is true under the assumption that we're not yet able to collect the goal reliably often, therefore the value function converges to something close to $\frac{r\_{avg}}{1-\gamma} \approx -10 $ ). Usually, $T$ is not a part of the state, so the value function has no way to anticipate the sudden change in reward-to-go. So, all of a sudden, we got a (relatively) big advantage for the arbitrary action that we took at the timestep $T-1$. Following the policy gradient rule, we will significantly increase the probability of an arbitrary action that we took at the end of the episode, even if we didn't achieve anything. This can quickly destroy the learning process. How do people deal with this problem in practice? My ideas: 1. Differentiate between actual episode terminations and ones caused by the time limit, e.g. for them we will not replace next step value estimate with $0$. 2. Somehow add $t$ to the state such that the value function can learn to anticipate the termination of the episode. As I noticed, the A2C implementation in OpenAI baselines does not seem to bother with any of that: * [A2C implementation - calculation of discounted rewards](https://github.com/openai/baselines/blob/f3a5abaeeb1c1c9136a01c9dbfebc173dc311fef/baselines/a2c/runner.py#L64) * [`discount_with_dones` function](https://github.com/openai/baselines/blob/8c2aea2addc9f3ba36d4a0c937e6a2d09830afc7/baselines/a2c/utils.py#L147)<issue_comment>username_1: The practical need for a $T$ or $t\_{max}$ is based on the importance of prudent doubt as a cost containment measure. At a certain point, it is wise to abandon an objective the resolution of which cannot be certain. This is a technique used in the minimization of a much wider loss function associated with the business into which the seeking of the learning objective fits. Dismissing the easily retained knowledge of the state of the independent process variable $t$ in the context of its domain $[1, T]$ as irrelevant is like working on a project without project management. What things to skip and what risks to take cannot be accurately evaluated, reducing the probability of success in relation to its optimum. Certainly the value gained at any step is an indicator of the advantage of the current path, an affirmation that impacts the probability of achieving favorable results before $t$ reaches $T$. Certainly any knowledge that can be used to predict possible values along the paths that begin with choices that can be made at any step should impact that choice. The question author's intuition that the critic should be aware that the stakeholder may pull the plug on the project soon is correct. In terms of the mathematics, whether urgency can be formulated as something like $u(t) \propto \dfrac {1} {T - t + 1}$ and used as a term or a factor requires some thought about the probabilities involved. The advantage expression should reflect the application of the basic relations of probability to the probability distributions as seen considering all the information known at any temporal point along the pursuit of the objective. The only occasion when a variable that can be known should be excluded from the advantage expression is if it can be shown to be absolutely irrelevant or that its relevance is sufficiently small to warrant exclusion to gain computational speed in exchange for loss of accuracy and/or reliability. Upvotes: 1 <issue_comment>username_2: First a small note: I don't think your expression for $A(s\_{T-1}, a\_{T - 1})$ looks correct. If we assume that $V(s\_T) = 0$ (i.e., assume that we cannot possibly reach the goal in one single step from $s\_{T - 1}$), we have: \begin{align} A(s\_{T-1}, a\_{T-1}) &= r(s\_{T-1}, a\_{T-1}) + \gamma V(s\_{T}) (1 - done\_{T}) - V(s\_{T-1}) \\ &= r(s\_{T-1}, a\_{T-1}) - V(s\_{T-1}). \end{align} In this expression, we'd normally have that $r(s\_{T-1}, a\_{T-1}) = -0.1$, whereas you seem to have mistakenly taken $+0.1$ in your post. --- Those details aside; yes, there can be sudden bumps of positive advantage estimates as you described. This is not a problem though, this is exactly what we'd expect to happen given your description of the environment. You describe an environment in which the agent is likely going to be wandering around randomly (at least when it hasn't learned a good policy yet), and incurring negative rewards over and over again. This naturally leads to negative value estimates for all encountered states. Suddenly, it does something and the episode terminates; it receives a nice reward of $0$ rather than yet another negative reward (this actually "feels" like a bonus, a positive reward, something more than was expected). When your agent has not yet learned a good policy that can reach the better reward of $1$, this is indeed a good result, a good action, and it rightfully should get reinforced. Because this event of the episode terminating is mostly uncorrelated with the state (I say "mostly", because in theory it probably ends up being a slightly rarer event in states close to the goal than in states far away from the goal), it will eventually (after sufficient training time) end up occurring approximately equally often in all states. From the perspective of an agent that is oblivious to the current time step, this will be perceived as an event that can simply occur by pure chance in a nondeterministic environment. This is not necessarily a problem. It can slow down learning due to increased variance in your reward observations (which can be addressed by using low learning rates / large batch sizes), but Reinforcement Learning algorithms are almost always naturally built to handle nondeterministic environments, it can work this out, it can average out all the different outcomes observed for the same state+action pairs. **This is not a problem that requires dealing with**. --- > > My ideas: > > > 1. Differentiate between actual episode terminations and ones caused by the time limit, e.g. for them we will not replace next step value estimate with $0$. > 2. Somehow add $t$ to the state such that the value function can learn to anticipate the termination of the episode. > > > The first idea fundamentally changes the quantity that your algorithm is learning, it will essentially make your learning algorithm incorrect. There's always a chance that it might still appear to learn something useful (many Machine Learning/Reinforcement Learning algorithms can still appear to be okay even when there are bugs/technically incorrect parts), but it'll very likely perform worse. The second idea, while **not necessary** as explained in my answer above, **may still be beneficial to learning speed provided it is done well**. It may help because it can add to the power of your algorithm to "explain" its observations, and more importantly "explain" the variance in its observations. The main problem I see with adding $t$ to your input is that it is not naturally a binary variable. Very often you'll find that we're just using a bunch of binary inputs in (Deep) Reinforcement Learning algorithms. When all inputs are of the same magnitude like that, it tends to be easier to get the learning process to run well, tune hyperparameters like learning rate, etc. If you suddenly plug in an additional input which can take significantly larger values (like straight up adding $t$ as an input), this will be more difficult. Adding $\frac{t}{T}$ as an input may be better, since that will always still be bounded between $0$ and $1$. Upvotes: 4 [selected_answer]<issue_comment>username_3: I would like to point out this paper: <https://arxiv.org/pdf/1712.00378.pdf>, that answers exactly that question. > > We then showed that, when learning policies for time-unlimited tasks, it is necessary for correct value estimation, to continue bootstrapping at the end of the partial episodes when termination is due to time limits, or any early termination causes other than the environmental ones. > > > The authors therefore argue, that the target $y$ for a one-step TD update, after transitioning to a state $s′$ and receiving a reward $r$, should be: $$ y = \begin{cases} r & \text{if environment terminates}\\ r+\gamma\hat{v}\_{\pi}(s') & \text{otherwise (including timeouts)} \end{cases} $$ Upvotes: 3
2018/11/28
3,630
16,267
<issue_start>username_0: I'm working on stock price prediction and automatic or semi-automatic control of trading. The price trends of these stocks exhibit recurring patterns that may be exploited. My dataset is currently small, only in the thousands of points. There are no images or very high dimensional inputs at all. The system must select from among the usual trading actions. * Buy $n$ shares at the current bid price * Hold at the current position * Sell $n$ shares at what the current market will bear I'm not sure if reinforcement learning is the best choice, deep learning is the best choice, something else, or some combination of AI components. It doesn't seem to me to be a classification problem, with hard to discern features. It seems to be an action-space problem, where the current state is a main input. Because of the recurring patterns, the history that demonstrates the observable patterns is definitely pertinent. I've tried some code examples, most of which employ some form of artificial nets, but I've been wondering if I even need deep learning for this, having seen the question, [*When is deep-learning overkill?*](https://ai.stackexchange.com/questions/3002/when-is-deep-learning-overkill) on this site. Since I have very limited training data, I'm not sure what AI design makes most sense to develop and test first.<issue_comment>username_1: Unclear from your description how RL is useful. RL is a technique that allows your model learn interactive by trial and error. Where is your "trial and error" in your problem? Stock price prediction sounds more like a regression problem to me. It can be done by DL or many other methods. Probably a shallow neural network would work well for you. Upvotes: 1 <issue_comment>username_2: This is an interesting problem, the answer of which is highly coveted for obvious reasons. The production of an answer in this public space is appropriate, provided one believes in a more level distribution of assets across those alive and is comfortable with rewarding technical people for the abilities they developed while others might have been engaging in less technical pursuits. I only ask that those who may successfully employ it consider using at least some of any windfall generated in a philanthropic manner, to benefit the less fortunate. Here we go. **Abstract Algebra** One of the fundamental principles presented in Morgenstern and von Neumann's *Theory of Games and Economic Behavior* is the idea that the value of a monetary unit may vary based on actions of those that control the monetary system, but the underlying value itself has abstract algebraic properties favorable to prediction. These properties, the book proposes in early chapters, permit additive modelling. Explained another way, imagine a pile of paper bills of a particular denomination. The selection of any one of the bills from anywhere in the deque is identical in value to the selector as any other selection of one bill. The selection of which particular bill is also not a factor in the value remaining in the deque after the selection. This is also true of shares, which is why serial numbers are not a trading parameter at the investor-trade interface. For more theory behind this, the interested parties can study group theory and rings. **Critique of M&VN** This convenient additive view of value beneath monetary systems has been critiqued. The value of assets, products, and services may be demonstrated to vary with life expectancy and philosophic divergence. While some people fall into an investment mode, others may be divesting. Fortunately, similar to Isaac Asimov's fictional presentation of psycho-history, the predictive mechanisms that may be developed are, in fact, not fettered by this investment versus divestment mode variance. The volume of trading and number of traders typically hide the variance through cancellations across either side of mean behavior. Those with considerable assets can exploit this caveat and a large number of other caveats in the additive nature, but most traders cannot. **Patterns in Stock Values** The phrase that may have started a number of investment firms down the path toward the use of machine learning in high speed training, leading to a conspicuous growth in the number of billionaires in the world, is a simple phrase from <NAME>'s *Pi*, a 1998 movie in black and white. The protagonist, <NAME>, looks at the scrolling LED version of a ticker tape and says, "I know these numbers," and then begins to verbally state each price just before it appears. The patterns in stock prices have intrigued those who watch trends since the emergence of the New York Stock Exchange. But they are not cyclic, in spite of the naive belief that they run in cycles. They only appear to run in cycles, just as one might find a pattern they think they understand in a graphic representation of the *Mendelbrot Set*, but when the renderer of the set zooms in or out, the greater detail or the generality respectively reveal that the understanding was an illusion. Attempts to use Fourier Analysis as part of a predictive strategy for anything but extremely narrowly timed speculation have been of limited value. The reliability of the prediction of advantageous trading choice, expressed as a probability $P(C)$, dwindles to pure entropy (zero bits of actual predictive information) as the clock time of the prediction increases relative to that of the last time in the complete vector of state historic states $\vec{S}$ used for prediction. $$\lim\_{(t - t\_\emptyset) \rightarrow \inf} P(A|\vec{S}) \rightarrow 0$$ In plain terms, the risk of trading based on a predictive model from past price trend increases with the staleness of trend information. The increase in entropy is likely to be a feature of the prediction of any system as complex as the stock market even as prediction tools mature. It is a consequence of initial input sensitivity combined with measurement inaccuracy and the inevitable unsatisfactory distributed model of decisioning. These constraints may not be inescapable, but they are certainly resistant to brute force attacks, such as adding artificial network layers. There are tools that can be predictive in ways better than trying to identify a spectrum using Fourier Analysis. But let's first consider a spectrum, which is how music listeners identify the pitch, loudness, timbre, and envelope of notes. Unlike the playing and listening to music, the distribution of pitches in the spectrum from moment to moment are not purely a representation of the spectral distribution in which value fluctuations reside. The spectral analysis of stock prices reflects artificial bounds. The spectrum is bounded by the market sampling rate and Nyquest's criteria on the high frequency side. It is bound by the accumulation of additive effects that tends price fluctuation toward a Gaussian distribution on the low frequency end of the spectrum. **Three-fold Challenge of Freshness, Accuracy, and Complexity** Some may note that the intention of the question, to control (with or without human moderation) a stock portfolio to maximize profit is a planning problem that appears to have the Markov Property, provided the trader is not wealthy or trading in penny stocks, since the impact of previous trades seems unlikely to have significantly impacted market trends. As we shall see, this appearance may not be objectively true. Initial input sensitivity is a nearly universal quality of complex systems. In the case of the stock market, the complexity is high. Consider a cursory examination of the magnitude of market complexity, understanding that a single price is affected by neighboring prices in that sector and business and in the major market indicators that people watch. A stock is almost completely isolated in terms of trading actions but inherently tied to all traders and other stocks through an interconnected network of IT pipelines, trading interfaces, news events, and brains, each containing a few billion neurons with complexities much greater than artificial cells. A popular name for initial input sensitivity is the *Buterfly Effect*, which, properly explained is this. > > Whether a butterfly flaps its wings in Brazil may determine the path of a major storm in Peking a month later. > > > Sometimes the initial word, "Whether," is not included, which renders the explanation incorrect. It is a statement of the effect of whether or not the perturbation occurs. Once cannot say that the air movement from the wing flap causes the storm but rather the presence of a small perturbation may be grossly amplified over time in a complex system. Or it may not. Studies of chaotic systems have proven this potential of amplified effect as a characteristic of many if not most complex systems of differential equations with sufficient curvature in their behavioral surface to cause a system phenomena that could most descriptively be called, "Radically increasing bifurcations." For those seeking greater depth of understanding, the work of Fourier, Nyquist, Cantor; <NAME> and <NAME>; and <NAME> may be of interest. Because of initial input sensitivity, the Markov Property cannot be guaranteed for stock trading, even at low levels of investment. Even though, technically, the Markov Property is not guaranteed, its assumption at low trading levels and in the leveraging of fresh data for short term gains, it may lead to reasonable approximations with sufficient reliability to win at the negative sum game of trading. **Trading as a Below Zero Sum Game** In a zero sum game, those trading with stale information and trying to apply ineffective predictive strategies will, over any longer period lose. Their monetary assets will pass to those with fresher information using effective predictive strategies. With trading fees, the condition is more challenging, because the sum of all interactions is below zero by the sum of the fees. **Gaining Advantage** To gain advantage in any practical way above those who may have already employed machine learning in their trading operations or hired a funds manager that already did, there will have to be some clever application of more advanced principles in a way that drives effectiveness even higher than those already in game play. These are some key elements. * Since the windowing over the price sequence of any LTS (liquid tradable security) to derive a spectrum will produce spectra with no particularly improved predictive power than the price sequence in the time domain, the goal must be to discover the nature of the patterns beyond spectral features. * For very short duration investments, spectral features may provide some advantage but perhaps not enough to overcome others using similar predictive strategies. * Some stocks are predictors of others in that there is a strong unidirectional or bidirectional causal relationship. For instance, the cost of a barrel of oil impacts the future cost of toys, since plastic is a refinery product. The development of a semantic net with causal relationships modeled and tuned with each epoch of training can produce predictive power that may exceed the market norm. In this context, something like convolution may be advantageous, but not in the frame-horizontal-vertical-pixel-layer sense, since semantic networks have a non-cartesian topology. The edges and vertices in a semantic net of LTSs don't make nice 90 degree angles that lend themselves to trivial applications of loops and arrays. * Attractors, another analytical concept from the world of chaos, are an analytical tool that lend themselves to trends in stock groups and possibly individual stocks, however diversification principles of investment also apply well to attractors. The thing to study is auto-correlation in $\mathbb{R}^{(m n)}$, where $m$ is the number of features in the stock statistics for which there is a fresh historical record and $n$ is the number of LTSs in the group. The group is not a trench, with varying risk pooled together to provide a favorable curve of return versus stability. The group is a set of LTSs that correlated positively or negatively and with or without relative temporal shift (delay). * Leverage factors outside the exchange. For instance, the result of a close election is a key event that impacts markets. Terrorism is. Experts who may know nothing about where the market is going but sound good can vastly sway trends. Some billionaire somewhere may have rode a wave in a temporary correlation between the price of oranges and the price of gold, floating down the eastern seaboard in a yacht, not having the faintest idea why oranges correlated to gold, but analysis showed too many correlative effects to deny the tie, and they rode it until the model broke. **Project Strategy** It is recommended NOT to test with actual trades. Build a system and create a simulated portfolio. Do not use retirement funds and college funds to test a system pitted against some of the best trading automation in the world funded by a few hundred billionaires. You will end up in Gamblers Anonymous that way. Also understand that, as time passes, the bar will rise, and more people will be trading using predictive systems so that what is a profitable system today may consume all your time and energy and eventually lose everything you gained as other systems gain advantage over yours. Also remember that asset management, in the final summary, is a zero sum game. Trading gains are inescapably stuck inside the larger game where the pieces are placed back in the box and the box back in the closet. This is true even if you have children or grandchildren. Eventually, chaos has its sway. Our great, great, great, great grandchildren, who probably won't care to know our name, might end up poorer because we were wealthy or wealthier because we were poor. It's the Butterfly Effect again. There are infinitely more important things than asset accumulation. Ask any honest billionaire with an advanced terminal condition. **Layer Depth?** Yes depth. There is no way to meaningfully model even the most banal aspects of the complexity of markets with a few layers of perceptrons. **Real Time Learning?** Reinforcement, yes, because the Q-learning algorithm class and variants are a powerful tool for re-entrant, real time learning system design. However, be careful to not necessarily assuming the Markov Property. Whether you can use an algorithm, right out of the box, wired directly to inputs from market data with no normalization and prevail in a sub-zero sum game is unlikely. Innovation will be a requirement to any earned and even short term sustainable success. Always, with the application of these powerful AI components, thoughtfully apply what is known to the design, initialization, and further development of the system into which the component fits. Another network type worthy of consideration with time series is the LSTM network design. This is where layer depth makes sense, however systems with multiple AI components are really the work horses of the industry today. Very few problems give way easily to the deployment of some code generated from one algorithm specified in one paper and nothing added. **System Topology** There is likely to be multiple pipelines containing information in a system that sustainably provides growth-positive automated or semi-automated portfolio management, even among groupings of LTSs that seem to display patterned and more easily predictable trends. If one wishes to get a general sense of the complexity of system design that may be required to beat those at the forefront of the investment community, visit a nuclear power plant or disassemble the control system of the jet engine of a passenger jet. Still, someone seems to be getting it right. A suspiciously large number of new billionaires have emerged since 1998 with *investing* given as the industry in their Forbes entry. Additional technical information is provided in [this answer](https://ai.stackexchange.com/questions/3233/use-of-machine-learning-for-analyzing-companies-enlisted-in-stock-market/3649#3649). Upvotes: 2
2018/11/28
259
1,166
<issue_start>username_0: If my algorithm detects the type of object, how should I know if that object is moving or not? Suppose a person carrying an umbrella. How to know that the umbrella is moving? I am working on a project where I want to know whether that particular object belongs to the person entering inside the store. I was thinking about the bounding boxes(bb) approach where if the person's bb overlaps with the object's bb. But the problem arises when there are multiple objects with a person. I would appreciate your help. Thanks.<issue_comment>username_1: You can use several consecutive frames as an input. If you have dataset of moving/not moving objects, you can use it to train your model. You can use CNNs with additional time dimension in this case, for example. Upvotes: 0 <issue_comment>username_2: Either (a) re-recognize it in subsequent frames and then train a network employing a trajectory model to the changing object model parameters or (b) recognize the object and its motion in a single object-trajectory parameterized model from the sequence of sets of detected edges indicating edge movement in the sequence of frames. Upvotes: 1
2018/11/28
267
1,103
<issue_start>username_0: Why do we apply the mutation operation after generating the offspring, in genetic algorithms?<issue_comment>username_1: The mutation operation is (usually) needed to introduce new genes not found in the population. For example, suppose that you have 4 possible genes $A$, $B$, $C$, and $D$, and that your chromosomes have a non-binary encoding. In that case, if no member of your population has the gene $D$, then no amount of crossover operations will result in the introduction of that gene. However, if your chromosomes use a binary encoding, then new genes could be introduced as a side effect of crossover operations. But it is always safer to have some kind of mutation to ensure that all genes can be accessed. See also the paper [Genetic Algorithm for Traveling Salesman Problem with Modified Cycle Crossover Operator](https://www.hindawi.com/journals/cin/2017/7430125/), which mentions several non-binary encodings for the TSP. Upvotes: 2 <issue_comment>username_2: Mutation is used to maintain diversity in the solutions. Crossover alone cannot do this. Upvotes: 1
2018/11/30
701
2,645
<issue_start>username_0: I am having a video feed with multiple faces in it. I need to detect each face and the gender as well and assign the gender against each person. I am not sure how to uniquely identify a face as Face1 and Face2 etc. I do not need to know their names, just need to track a person in the entire video. I thought of tracking methods but people are constantly moving and changing so a box location can be occupied by another person after some frames. I am interested in a way where I can assign an id to a face but I am not sure how to do it. I can use Facial Recognition Based embedding on each face and track that. But that seems to be an overkill for the job. Is there any other method available or Facial Recognition/Embedding is the only method to uniquely identify people in a video?<issue_comment>username_1: > > Can I detect unique people in a video? > > > Yes. However, for some applications commercial systems are not good enough: [German source](https://netzpolitik.org/2017/ueberwachungslabor-berlin-suedkreuz-tracking-und-gesichtserkennung-geplant/) The concepts you are looking for are: * [Optical Flow](https://en.m.wikipedia.org/wiki/Optical_flow): for two frames, define for each point how it moved * Object tracking: given a single object in one frame, find it in the next. Optical flow helps with that. * [Object detection](https://www.pyimagesearch.com/2018/11/26/instance-segmentation-with-opencv/): look at YOLO / SSD. Small introduction [here](https://medium.com/comet-app/review-of-deep-learning-algorithms-for-object-detection-c1f3d437b852). Upvotes: 2 <issue_comment>username_2: You can detect faces in video frames by employing the standard method of Viola-Jones detector (though there are sophisticated ones available now). You can get the paper from [here](https://ieeexplore.ieee.org/document/990517). All the standard image processing libraries will have it implemented. You have to use the necessary API of that library. This will give a bounding box around each of the detected face (it may miss out a few faces which are at different poses or illumination). You can now encode the detected face, inside the bounding box, into a vector using the features given by [face2vec](https://link.springer.com/article/10.3103%2FS0146411617010072). In the face2vec model remove the classification part alone. This will give you a feature vector of size 905 dimension. Now given two face detections, you can find the euclidean distance between their feature vectors. If it is below a threshold say $T$ then, you have detected same face, else you have detected two different faces. Upvotes: 1
2018/11/30
375
1,588
<issue_start>username_0: For which problems are Genetic Algorithms more suitable than Particle Swarm Optimization, and vice-versa? Are there any guidelines?<issue_comment>username_1: These kind of questions cannot be answered without looking at a particular project. Each algorithm has its particular strengths and weaknesses; and trade-offs in terms of use of resources (processing power and/or storage space, for example). If there was an objective answer, then the worse algorithm would surely fall in disuse. It also depends what you mean by "better". Faster? Better score according to some evaluation measure? More robust (ie works with many diverse data sets)? I would recommend looking at both algorithms in more detail, and trying to understand how they work. Then you should be able to find out which best fits your problem. However, one problem with [Particle Swarm Optimisation](https://en.wikipedia.org/wiki/Particle_swarm_optimization) is that it is not well understood, so you might have to resort to trial-and-error. Upvotes: 2 <issue_comment>username_2: The paper [Comparison between genetic algorithms and particle swarm optimization](https://homepages.ecs.vuw.ac.nz/foswiki/pub/Users/BingXue/Topics/GAvsPSO.pdf) (1998, by Eberhart and Shi) does not really answer the question of when to use one over the other (this may be an open question), but at least it provides a comparison of how the methods work and what could affect their performance (i.e. which parameters or operators they use, and what the typical values are), so it may be worth reading it. Upvotes: 2
2018/12/01
1,921
7,173
<issue_start>username_0: Biology is used in AI terminology. What are the reasons? What does biology have to do with AI? For instance, why is the genetic algorithm used in AI? Does it fully belong to biology?<issue_comment>username_1: Biological organisms (such as animals or plants) are the main examples of *intelligent* systems that we are aware of (excluding artificially intelligent systems, so as not to discuss whether current AI systems are really intelligent or not). Consequently, biological life is often an inspiration for AI researchers to develop AI systems. There are numerous examples of AI systems that have been introduced (at least, partially) *based on* or just *inspired by* the biology. Here are a few examples. * **Reinforcement learning** is based on a similar way that animals (such as dogs or [pigeons](https://www.youtube.com/watch?v=QKSvu3mj-14)) can learn. For more details, see [Sutton & Barto's book](http://incompleteideas.net/book/RLbook2020.pdf) (especially chapters 14 and 15). * **Artificial neural networks** are very approximative models of human neural networks. * **Genetic algorithms** are roughly based on Darwin's theory of evolution. * **Ant colony optimization** algorithms (and, in general, **swarm intelligence**) are based on the way real ants (and, respectively, [biological swarms](https://en.wikipedia.org/wiki/Swarm_behaviour)) behave. (There is even [a rap song dedicated to ants](https://www.youtube.com/watch?v=XeovS8-FauM&ab_channel=PhoeneticComposition-Topic)). There are probably other examples that don't come to my mind right now. See also [this](https://ai.stackexchange.com/q/20540/2444) and [this](https://ai.stackexchange.com/q/258/2444) questions. There are cases where AI discoveries have also helped the development of biology or related fields (such as neuroscience and psychology). For instance, [Sutton & Barto (on page 4)](http://incompleteideas.net/book/RLbook2020.pdf#page=26) write > > Of all the forms of machine learning, reinforcement learning is the closest to the kind of learning that humans and other animals do, and many of the core algorithms of reinforcement learning were originally inspired by biological learning systems. Reinforcement learning has also given back, both through a psychological model of animal learning that better matches some of the empirical data, and through an influential model of parts of the brain's reward system. > > > Upvotes: 2 <issue_comment>username_2: ### Evolutionary game theory and evolutionary algorithms I see the connection arising mostly thought [Evolutionary Game Theory](https://en.wikipedia.org/wiki/Evolutionary_game_theory) and [Evolutionary Algorithms](https://en.wikipedia.org/wiki/Evolutionary_algorithm). Evolutionary algorithms are an analog of natural selection, where successive generations of a given decision making agent are more optimized than previous generations. Like organisms in nature, this process uses "reproduction, mutation, recombination and [selection](https://en.wikipedia.org/wiki/Natural_selection)". There are a couple of recent articles from Quanta Magazine. One, ["The Math That Tells Cells What They Are"](https://www.quantamagazine.org/the-math-that-tells-cells-what-they-are-20190313/) discusses mathematical optimization as the core function of fundamental biological systems. > > "Through evolution, these cells have figured out how to implement [Bayes' trick](https://en.wikipedia.org/wiki/Bayesian_network) using regulatory DNA." > > > "Natural selection [seems to be] pushing the system hard enough so that it ... reaches a point where the cells are performing at the limit of what physics allows." > > > This second quote is exactly the goal of Artificial Intelligence, where utility is limited by physics (computing resources). One way for an algorithm to increase utility is to increase computing power, but the other method is to refine the algorithm to make strong decisions more efficiently. ([MCTS](https://en.wikipedia.org/wiki/Monte_Carlo_tree_search) vs. [Brute Force](https://en.wikipedia.org/wiki/Brute-force_search) where a model is [intractable](https://en.wikipedia.org/wiki/Computational_complexity_theory#Intractability), as an example.) A second article ["Mathematical Simplicity May Drive Evolution’s Speed"](https://www.quantamagazine.org/computer-science-and-biology-explore-algorithmic-evolution-20181129/) talks about [Genetic Algorithms](https://en.wikipedia.org/wiki/Genetic_algorithm) > > "Creationists love to insist that evolution had to assemble upward of 300 amino acids in the right order to create just one medium-size human protein. With 20 possible amino acids to occupy each of those positions, there would seemingly have been more than 20300 possibilities to sift through, a quantity that renders the number of atoms in the observable universe inconsequential." > > > The game of Go on a 19x19 board has a similar quality--the number of potential gamestates is vastly exceeds the number of atoms in the universe, and, even if the entire universe were converted to [computronium](https://en.wikipedia.org/wiki/Computronium), the game would still be intractable. > > "The fatal flaw in their argument is that evolution didn’t just test sequences randomly: The process of natural selection winnowed the field. Moreover, it seems likely that nature somehow also found other shortcuts, ways to narrow down the vast space of possibilities to smaller, explorable subsets more likely to yield useful solutions." > > > This would also be an accurate description the process of [pruning a search space](https://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning). The article concludes that, although there is still much research to be conducted: > > “The idea of thinking about life as evolving software is fertile.” > > > The process of optimization in nature and in computer science is similar in spirit, if not in fact. ### Automata as a form of artificial life The second factor may arise out of the mythology of AI, via speculative fiction. In science fiction, the idea of [automata as a form of artificial life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) is persistent. Shows & films like [Westworld](https://en.wikipedia.org/wiki/Westworld_(TV_series)), [BladeRunner](https://en.wikipedia.org/wiki/Blade_Runner_2049#Plot), and the Alien franchise, with [David the Android](https://en.wikipedia.org/wiki/David_8) as a prime example of a superior, artificial species that may supplant humanity, are extremely popular. These are all based on <NAME>'s ideas explicated in [Do Androids Dream of Electric Sheep](https://en.wikipedia.org/wiki/Do_Androids_Dream_of_Electric_Sheep%3F), the plot of which turns on evolutionary game theory, *written about 5 years before the field was formalized!* (Dick's influence can even be seen in Google's ["Nexus"](https://bladerunner.fandom.com/wiki/Nexus-6) naming convention for their Android phone;) Underneath all of this is also the idea that Artificial Intelligence itself is a function of nature, with humans as merely the vehicle for the next form of dominant life. Upvotes: 1
2018/12/02
481
1,930
<issue_start>username_0: Can the same input for a plain neural network be used for CNNs? Or does the input matrix need to be structured in a different way for CNNs compared to regular NNs?<issue_comment>username_1: * Neural networks generally deal with 1 D data. For example, the data for a NN would be ( 10 , 12 ) , where 10 is the number of samples. * Convolutional neural networks generally deal with 1D, 2D and 3D data. For example, a 2D CNN would have input as shape ( 10 , 28 , 28 , 3 ) where 10 is the number of samples and ( 28 , 28 , 3 ) is the image size. ( if the input is a image ) Upvotes: 0 <issue_comment>username_1: There is no restriction on how you input a data to a NN. You can input it in 1D arrays and do element-wise multiplication using 4-5 loops and imposing certain conditions(which will be slow and hence $nD$ matrix notations are used for a CNN). Ultimately, the library you are using (TensorFlow, NumPy might convert it into its own convenient dimensions). The main thing different of a CNN from a normal NN is: * The number of parameters of a CNN in a convolutional layer is less than the number of input features. $parameters \le features$ (in general it is less than). Different people have different ways of viewing how the convolutional layer work but the general consensus is that the weights of the convolutional layers of a CNN are like digital filters. It will be a $nD$ filter if input dimension is $nD$. The output is obtained by superimposing the filter on a certain part of the input and doing element-wise multiplication of the values of filter and the values of the input upon which the filter is superimposed upon. How you implement this particular operation depends on you. So the answer to your question will be same network cannot be used, but it might be used with modifications (a normal NN is the limiting case of a CNN where $features=parameters$. Upvotes: 2 [selected_answer]
2018/12/02
1,758
7,956
<issue_start>username_0: Modular/Multiple Neural networks (MNNs) revolve around training smaller, independent networks that can feed into each other or another higher network. In principle, the hierarchical organization could allow us to make sense of more complex problem spaces and reach a higher functionality, but it seems difficult to find examples of concrete research done in the past regarding this. I've found a few sources: <https://en.wikipedia.org/wiki/Modular_neural_network> <https://www.teco.edu/~albrecht/neuro/html/node32.html> <https://vtechworks.lib.vt.edu/bitstream/handle/10919/27998/etd.pdf?sequence=1&isAllowed=y> A few concrete questions I have: * *Has there been any recent research into the use of MNNs?* * *Are there any tasks where MNNs have shown better performance than large single nets?* * *Could MNNs be used for multimodal classification, i.e. train each net on a fundamentally different type of data, (text vs image) and feed forward to a higher level intermediary that operates on all the outputs?* * *From a software engineering perspective, aren't these more fault tolerant and easily isolatable on a distributed system?* * *Has there been any work into dynamically adapting the topologies of subnetworks using a process like Neural Architecture Search?* * *Generally, are MNNs practical in any way?* Apologies if these questions seem naive, I've just come into ML and more broadly CS from a biology/neuroscience background and am captivated by the potential interplay. I really appreciate you taking the time and lending your insight!<issue_comment>username_1: A benchmark comparison of systems comprised of separately trained networks relative to single deeper networks would not likely reveal a universally applicable best choice.1 We can see in the literature the increase in the number of larger systems where several artificial networks are combined, along with other types of components. It is to be expected. Modularization as systems grow in complexity and demands on performance and capability grow is as old as industrialization. Our laboratory works with robotic control, thermodynamic instrumentation, and data analysis, artificial networks are components in these larger system contexts. we have no single MLPs or RNNs that by themselves perform any useful function. Contrary to the conjecture about hierarchies decades ago, the topology approach that seems to work well in most cases follows the more common system module relationships that are seen in power plants, automated factories, aeronautics, enterprise information architectures, and other complex engineered creations. The connections are those of flow, and if those are designed well, oversight functions are minimal. Flow occurs between modules involving protocols for communications, and each module performs its function well, encapsulating the lower level of complexity and functional detail. It is not one network overseeing another that seems to emerge most effective in actual practice but balance and symbiosis. Identification of clear master-slave design in the human brain seems to be equally slippery. It may be naive to assume that some all knowing subsystem can be a single causal factor in the remarkable collaborative synchronization of a number of other subsystems. The challenge is not finding the information paths that make up the system information topology. The information flow is often obvious upon problem analysis. The difficulty is in discovering the best of strategies to train these independent networks. Training dependencies are common and often critical, whereas in animals, the training occurs *in situ* or not at all. We're discovering conditions under which that kind of learning in our systems is practical and how to achieve it. Most of our research along these lines is intended to discover ways to achieve higher reliability and lower burden in terms of research hours to get it. Higher functionality is not always of benefit. It often produces lower reliability and consumes additional development resources with little return. Find a way to marry higher level automation, resource thrift, and reliability into one development process, and you might win an award and honorable mention around the web. Parallel systems that have the same objective is a good idea, but not a new one. In one aeronautics system, nine parallel systems have the same objective, in groups of three. Each group uses a different computing approach. If two of the systems using the same approach provide the same output and the third differs, the matching output is used and the difference in the third is reported as a system fault. If two of the different approaches provide similar results and the third differs substantially, a merge of the two similar results is used and the third is reported as a use case to further develop the dissenting approach. The improved fault tolerance has a cost, eight more systems and associated computing resources and connectivity plus the comparators at the tail, but in systems that are a matter of life and death, the extra costs are paid and the reliability is maximized. Dynamic topological adaptation is related to redundant systems and fault tolerance but in some ways is quite distinct. In that area of development, the technology to follow is neuromorphic computing, which is partly inspired by neuroplasticity. One last distinction to consider is between process topology, data topology, and hardware topology. These three geometric frames can produce greater efficiency together if aligned in specific ways that produce more direct mappings between the relationships between flow, representation, and mechanics. They are, however, distinct topologies. The meaning of alignment may not be apparent without diving deeply into these concepts and the details that emerge for specific product or service objectives. **Footnotes** [1] Deep networks that are trained as a single unit and function without connectivity to other artificial networks are not necessarily monolithic. Most practical deep networks have heterogeneous sequence of layers in terms of their activation functions and often their cell types. Upvotes: 2 <issue_comment>username_2: There is indeed an investigation in progress, regarding this topic. A first publication from last march noted that modularity has been done, although not explicitly, since some time ago, but somehow training keeps being monolithic. This paper assess some primary questions about the matter and compares training times and performances on modular and heavily recurrent neural networks. See: * [Castillo-Bolado et al. Modularity as a Means for Complexity Management in Neural Networks Learning](http://ceur-ws.org/Vol-2350/paper8.pdf) Some others are very focused on modularity, but staying with the monolithic training (see [<NAME>'s research](https://people.eecs.berkeley.edu/%7Ejda/pubs.html), specially *Learning to reason* is very related to your third question). Somewhere between late 2019 and march next year, there should be more results (edit: [mentioned results here](https://www.sciencedirect.com/science/article/pii/S0893608021001222?via%3Dihub)). In relation to your two last questions, we're starting to see now that modularity is a major key towards generalisation. Let me recommend you some papers (you can find them all in arxiv or google scholar): * Stochastic Adaptive Neural Architecture Search for Keyword Spotting (variations of an architecture to balance performance and resource usage). * Making Neural Programming Architectures Generalize via Recursion (they do task submodularity and I believe it's the first time that generalisation is guaranteed within field of neural networks). * Mastering the game of Go with deep neural networks and tree search (network topology is actually the search tree itself, you can see more of this if you look for graph neural networks). Upvotes: 2
2018/12/03
943
3,807
<issue_start>username_0: We have convolutional neural networks and recurrent neural networks for analyzing, respectively, images and sequential data. Now, suppose I want to approximate the unknown function $f(x,y) = \sin(2\pi x)\sin(2\pi y)$, with domain $\Omega = [0,1]\times [0,1]$, that is, $x$ and $y$ can be between $0$ and $1$ (inclusive). How do I determine which neural network architecture is more appropriate to approximate this function? Which kind of activation functions would be better suited for this? Note that, generally, I don't know a priori which function the neural network has to learn. I am just asking for this specific $f(x, y)$, as it could be a solution for a differential equation. And $\Omega$ is the domain, i.e., I don't care about the output of the neural network outside $\Omega$.<issue_comment>username_1: If the concept class specified is $$f(x, y) = k \, \sin(2 \pi f\_x x) \, sin(2 \pi f\_y y) \\ \land 0 < x < 1 \\ \land 0 < y < 1 \; \text{,}$$ and the optimum fit to example data is expected occur when $k \approx 1 \land f\_x \approx 1 \land f\_y \approx 1$, then it is not an AI problem. It is a problem that can be solved with a least squares convergence, probably in conjunction with a Fourier transform. If nothing is known about $f(x, y)$ except continuity and that it is single valued with respect to $(x, y)$, then few conclusions can be drawn about best approach. In such a case, the domain of $x$ and $y$ are irrelevant because they can be normalized. Furthermore, the tree of operations, such as $\sin()$ and multiplication, are irrelevant too, because the function could just as easily be $$f(x, y) = \ln(x) + \Gamma(y) - k \, \text{.}$$ The question indicates the design involves CNN and RNN components for analyzing images and sequential data. It is not clear whether the CNN is for the discovery of objects or waves (given the $\sin()$ in the function mentioned) and whether those objects move between frames so that the RNN must detect motion. Nothing is given about the pool of example data available or planned to be available or the expected outputs of the system. If data is sequential, where is $t$ in the function? What is the objective of image analysis? Although a deep MLP (multilayer perceptron) with SGD can learn an arbitrary function, it is hardly an architecture, the mention of images, CNN, RNN, and sequential data, MLP with SGD does not seem to match. Regarding activation functions, the inner layer functions would depend on the higher level design requirements. The activation functions of the last layer of a single artificial network is usually chosen to match the data type and range of desired output for each output channel (dimension). If the objective of this question is to take images and sequential data and produce something useful without *a priori* defining what useful means, then it is an unsolved AI problem thus far and no known topology comprised of artificial networks and other AI building blocks provide a solution. The autonomous development of internal concepts of usefulness would need to be developed mathematically and algorithmically and become practically speed optimized in hardware and software first. Upvotes: 1 <issue_comment>username_2: For example, suppose I want to approximate the function mashine learning is used to approximate an UNKNOWN function. If you do want to do this with NN, you will have a regression task with small full connected network with like: * Input is 2 values of range 0 ..1 * a few hidden layers, just start trying with one, of size like 3-6 neurons , activation sigmoid or tanh * need a non-linear function here to approx non linear sin \* sin, whatever * last layer with no activation function just making a difference from... known value f(x,y) Upvotes: -1
2018/12/04
521
1,826
<issue_start>username_0: We have a series of data and we want to label the parts of each series. As we do not have any training data, we could try to use *active learning* as a solution, but the problem is that our classifier is something like RNN which needs a lot of data to be trained. Hence, we have a problem in converging fast to just label proportional small parts of unlabeled data. Is there any article about this problem (active learning and some complex classifiers, like RNN)? Is there any good solution to this problem or not? (as data is a series of actions)<issue_comment>username_1: As I found this case backs to the **sequence labeling**. [Sequence labeling](https://en.wikipedia.org/wiki/Sequence_labeling) has some classic solution such as conditional random fields (CRFs) and hidden Markov model (HMM). Also, have some solution in Active learning (AL) which use from algorihtms such as struct SVM ($\text{SVM}^{\text{strcut}}$) like [this paper](https://link.springer.com/chapter/10.1007/978-3-540-70720-2_27). Also, some NLP solutions in active learning could help to solve these kind of problems such as [this paper](https://www.semanticscholar.org/paper/A-study-of-active-learning-methods-for-named-entity-Chen-Lasko/3bce5270707e75380fba9907618315728ba5a4d8) which is about active learning in named entity recognition (NER). Besides, the combination of active learning with Deep networks such as CNN happens. For example, [this paper](https://openreview.net/forum?id=H1aIuk-RW) explains more about the idea. Upvotes: 3 [selected_answer]<issue_comment>username_2: You can also check [this paper](https://www.researchgate.net/publication/328820423_Deep_Active_Learning_for_Text_Classification), which discusses the use of LSTM and GRU with Active Learning and word embeddings (word2vec). Upvotes: 0
2018/12/06
1,228
5,118
<issue_start>username_0: I am wondering how the output of randomly initialized MLPs and ConvNets behave with respect to their inputs. Can anyone point to some analysis or explanation of this? I am curious about this because in the [Random Network Distillation work from OpenAI](https://blog.openai.com/reinforcement-learning-with-prediction-based-rewards/), they use the output of randomly initialized network to generate intrinsic reward for exploration. It seems that this assumes that similar states will produce similar outputs of the random network. Is this generally the case? Do small changes in input yield small changes in output, or is it more [chaotic](https://en.wikipedia.org/wiki/Chaos_theory)? Do they have other interesting properties?<issue_comment>username_1: The output of randomly initialised neural networks will be random. I am not sure if I understand your question correctly but I would like to try and explain what OpenAI is trying to achieve with their RND Distillation approach. Any re-enforcement or supervised "learning" algorithm such as a neural network (NN) with back-propagation, genetic algorithm, partial swarm etc requires a fitness function. The fitness function "directs" the algorithm to a solution. The basic idea is that the algorithm is randomly initialised. The algorithm is run, and then parts of the algorithm are changed. In this case the weights of the NN. A number of algorithms exist to update the weights, the most common back propagation / gradient decent as used in the paper. To update the weights the output of the NN is compared to the optimum output. Sometimes the optimum is known. Other times it is not. In the case of a game the optimum output is not known. It is assumed that the more points gained the better the NN does. In this case the fitness function or policy is the sum of points gained when playing the game. But gradient descent needs an error (i.e difference between output and expected output), which does not exist when playing a game, because you don't know what the points should be. However the NN could play one round of the game score some points, then run the NN again on the next move to determine a prediction of future points. The difference between the points gained and the prediction is then the error, which gradient descent can use. [Hope this makes sense] This is fine for games like pong, a NN could play the game pong randomly and score point at each prediction, which will direct gradient descent into updating the weights to maximise points. However, games such as Montezuma’s Revenge, requires a lot of complex actions before points are gained. If the points stay 0, how does gradient descent determine if the weights should be decreased or increased? Instead, the authors initialise a second random neural network which remains the same for the duration of training. As mentioned above the output of a randomly initialised neural network is random. The output of the actual NN, and world state is then passed through the random NN (RND), which will return a random value. The NN is then required to not only determine a game action but also determine the result of the RND. The policy function is extended from just points to also predict the result of the RND. The greater the prediction error the more bonus points are allocated to the policy function. This encourages gradient descent to change the weights of the NN to explore unseen parts of the game as this increases the prediction error of the RND which increases points. At the same time gradient descent must update the weights of the NN to predict the RND. I hope this answers your question. In summary randomly initialised NN include multilayered perceptrons or convolutional networks will behave randomly with respect to their inputs. The RND network is randomly set once at the star of training, and used to basically remind the NN undergoing training that it has done this before do not do this again - i.e. rewards the NN for doing something new (exploration). Upvotes: 2 <issue_comment>username_2: In the [Large-Scale Study of Curiosity-Driven Learning](https://arxiv.org/pdf/1808.04355.pdf) paper (the prequel to the Random Network Distillation work), in their discussion of Random Features, they reference 3 papers that discuss this: 1. <NAME>, <NAME>, <NAME>, et al. [What is the Best Multi-Stage Architecture for Object Recognition?](http://yann.lecun.com/exdb/publis/pdf/jarrett-iccv-09.pdf) 2. A. <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, and <NAME>. [On Random Weights and Unsupervised Feature Learning](http://www.robotics.stanford.edu/~ang/papers/nipsdlufl10-RandomWeights.pdf) 3. <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, and <NAME>. [Deep Fried Convnets](https://arxiv.org/pdf/1412.7149.pdf) I just briefly glanced over these. For now, one interesting idea from [2] is to use randomly initialized networks for architecture search. To evaluate the architecture for the task, you don't have to train it; you can just randomly initialize it and measure its performance. Upvotes: 0
2018/12/06
1,255
5,307
<issue_start>username_0: I am preparing to perform research comparing the performance of two different systems that probabilistically generate the next word of an input sentence. For example, given the word 'the', a system might output 'car', or any other word. Given the input 'the round yellow', a system might output 'sun', or it might output something that doesn't make sense. My question is, how can I quantitatively evaluate the performance of the two different systems performing this task? Of course if I tested each system manually I could qualitatively determine how often each system responded in a way that makes sense, and compare how often each system responds correctly, but I'd really like a meaningful quantitative method of evaluation that I could preferably automate. Precision and recall don't seem like they would work here, seeing as for each given input there are many potentially acceptable outputs. Any suggestions?<issue_comment>username_1: The output of randomly initialised neural networks will be random. I am not sure if I understand your question correctly but I would like to try and explain what OpenAI is trying to achieve with their RND Distillation approach. Any re-enforcement or supervised "learning" algorithm such as a neural network (NN) with back-propagation, genetic algorithm, partial swarm etc requires a fitness function. The fitness function "directs" the algorithm to a solution. The basic idea is that the algorithm is randomly initialised. The algorithm is run, and then parts of the algorithm are changed. In this case the weights of the NN. A number of algorithms exist to update the weights, the most common back propagation / gradient decent as used in the paper. To update the weights the output of the NN is compared to the optimum output. Sometimes the optimum is known. Other times it is not. In the case of a game the optimum output is not known. It is assumed that the more points gained the better the NN does. In this case the fitness function or policy is the sum of points gained when playing the game. But gradient descent needs an error (i.e difference between output and expected output), which does not exist when playing a game, because you don't know what the points should be. However the NN could play one round of the game score some points, then run the NN again on the next move to determine a prediction of future points. The difference between the points gained and the prediction is then the error, which gradient descent can use. [Hope this makes sense] This is fine for games like pong, a NN could play the game pong randomly and score point at each prediction, which will direct gradient descent into updating the weights to maximise points. However, games such as Montezuma’s Revenge, requires a lot of complex actions before points are gained. If the points stay 0, how does gradient descent determine if the weights should be decreased or increased? Instead, the authors initialise a second random neural network which remains the same for the duration of training. As mentioned above the output of a randomly initialised neural network is random. The output of the actual NN, and world state is then passed through the random NN (RND), which will return a random value. The NN is then required to not only determine a game action but also determine the result of the RND. The policy function is extended from just points to also predict the result of the RND. The greater the prediction error the more bonus points are allocated to the policy function. This encourages gradient descent to change the weights of the NN to explore unseen parts of the game as this increases the prediction error of the RND which increases points. At the same time gradient descent must update the weights of the NN to predict the RND. I hope this answers your question. In summary randomly initialised NN include multilayered perceptrons or convolutional networks will behave randomly with respect to their inputs. The RND network is randomly set once at the star of training, and used to basically remind the NN undergoing training that it has done this before do not do this again - i.e. rewards the NN for doing something new (exploration). Upvotes: 2 <issue_comment>username_2: In the [Large-Scale Study of Curiosity-Driven Learning](https://arxiv.org/pdf/1808.04355.pdf) paper (the prequel to the Random Network Distillation work), in their discussion of Random Features, they reference 3 papers that discuss this: 1. <NAME>, <NAME>, <NAME>, et al. [What is the Best Multi-Stage Architecture for Object Recognition?](http://yann.lecun.com/exdb/publis/pdf/jarrett-iccv-09.pdf) 2. <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, and <NAME>. [On Random Weights and Unsupervised Feature Learning](http://www.robotics.stanford.edu/~ang/papers/nipsdlufl10-RandomWeights.pdf) 3. <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, and <NAME>. [Deep Fried Convnets](https://arxiv.org/pdf/1412.7149.pdf) I just briefly glanced over these. For now, one interesting idea from [2] is to use randomly initialized networks for architecture search. To evaluate the architecture for the task, you don't have to train it; you can just randomly initialize it and measure its performance. Upvotes: 0
2018/12/06
1,651
6,357
<issue_start>username_0: Can Machine Learning be applied to decipher the script of **lost** ancient languages (namely, languages that were being used many years ago, but currently are not used in human societies and have been forgotten, e.g. [Avestan language](https://en.wikipedia.org/wiki/Avestan))? If yes, is there already any successful experiment to decipher the script of unknown ancient languages using Machine Learning?<issue_comment>username_1: I would guess no, because if the language is unknown (no data available on it), then we would not have training data with which the machine learning algorithm could learn from. If it is related to some known language, then some statistical analysis can lead to a guess at decipherment (assuming certain similarities among the two languages). If interested on general language decipherment, see the following where they decipher scripts using available information on the language of interest: <http://www.aclweb.org/anthology/W99-0906>. They utilize the Expectation Maximization algorithm. I'm sure more google searching can lead to other examples that use machine learning algorithms, but they would most likely have some known information or a body of assumptions to make our problem scope easier. Upvotes: 3 <issue_comment>username_2: I say yes it definitely could be. But i agree with Skim you need some information as a starting point. Egyptian hieroglyphs were only (recently) understood following the discovery of the Rosetta Stone (<https://en.m.wikipedia.org/wiki/Rosetta_Stone>). With the same message in both known and unknown language the program could find the/a correlation. Without that info you would have to guess the potential content of the message. The results would then be confirmation-biased: how could you know it had worked properly? Say the program managed to ‘translate’, outputting a coherent phrase about bananas, great. Even if it was very consistent across multiple samples and 99% confidence, without any “control set data” it could just as easily be about, say, fish or even a prophesy on the super-bowl winner. Still a fun project tho. Upvotes: 3 <issue_comment>username_3: There is an academic paper here that studies a neural approach to deciphering ancient languages:-- (<https://arxiv.org/pdf/1906.06718.pdf>) > > "In this paper we propose a novel neural approach for automatic decipherment of lost languages. To compensate for the lack of strong supervision signal, our model design is informed by patterns in language change doc-umented in historical linguistics. The model utilizes an expressive sequence-to-sequence model to capture character-level correspon-dences between cognates. To effectively train the model in an unsupervised manner, we innovate the training procedure by formalizing it as a minimum-cost flow problem. When applied to the decipherment of Ugaritic, we achieve a 5.5% absolute improvement overstate-of-the-art results. We also report the first automatic results in deciphering Linear B, a syllabic language related to ancient Greek, where our model correctly translates 67.3% of cognates." ― Luo, Jiaming, <NAME>, and <NAME>. "Neural Decipherment via Minimum-Cost Flow: from Ugaritic to Linear B." *arXiv preprint arXiv:1906.06718* (2019). > > > --- **Further Reading and Articles for the Layperson**:-- * (<https://themindguild.com/artificial-intelligence-is-now-translating-long-lost-ancient-languages/>) * (<https://bstrategyhub.com/sanskrit-is-the-best-language-for-artificial-intelligence-says-nasa/>) * (<http://www.openculture.com/2019/07/can-artificial-intelligence-decipher-lost-languages.html>) Upvotes: 2 <issue_comment>username_4: I would say that it depends on whether that language would have wanted to be decyphered. The origin of Cryptography dates back to around 700-800 AD. We may not know the methods by which these texts are obscurred. One such example is the Lesser Banishing Ritual of the Pentagram which, revealed only by happenstance, formed the basis of a whole new esoteric renaissance in the west, the lexicon included forming a basis for the lexicon in use by these orders today. This Rite centers around the letters INRI, which tradition says were written upon the cross of Jesus Christ as an abbreviation for Jesus of Nazareth, King of the Jews. There are, however, numerous other levels of occult meaning regarding these four letters in the Rosicrucian Magical Tradition. One of these is a Hermetic secret alluded to by the Latin phrase "Igne Natura Renovatur Integra" which means "By fire, nature is perfectly renewed." These four letters additionally adorn the rays of the angles of the Rose Cross Lamen worn by Adepts of the Ordo Rosae Rubeae et Aureae Crucis. A deeper interpretation lies occulted behind the attributions of the Hebrew letters and the Magical Forces to the Paths on the Qabalistic Tree of Life. The Path attributed to the Hebrew letter y is attributed to the Zodiacal Sign Virgo as well, that of n to Scorpio, and r to the Sun. There exist further magical associations between the Sign Virgo with the Egyptian Goddess Isis, Scorpio with Apophis, and the Sun with Osiris. When the first letter is taken from the Names of each of these Gods, the name "IAO" is formed. Additionally, due to the Signs associated with Isis, Apophis, and Osiris, they form the letters "LVX." Thus within the letters IRNI lie concealed the letters IAO and LVX, which may also be found upon the rays of the angles of the Rose Cross Lamen worn by Adepts of the R. R. et A. C. The name IAO was considered by the Gnostics to be the Supreme Name of God. Its letters further allude to Salt, Sulfur, and Mercury in Alchemy and to an even more recondite secret symbolized by the relationship between Isis, Apophis, and Osiris. So I would say for machine learning to be able to decipher real languages, it would almost have to be intuitive, able to draw parallels and connect various points of reference together. It would have to determine what things mean, when a lot of the times, this is virtually impossible. Your variables are infinite. You have no real method of finding out what they are. Add to that context, lexicons, deliberate obfuscation, culture and the passage of time and I think it would not be realistic to expect machine-learning to provide much help. Upvotes: 0
2018/12/08
4,158
10,356
<issue_start>username_0: In section 7.1 (about the n-step bootstrapping) of the book *Reinforcement Learning: An Introduction* (2nd edition), by <NAME> and <NAME>, the authors write about what they call the "n-step return error reduction property": [![enter image description here](https://i.stack.imgur.com/BUSZM.png)](https://i.stack.imgur.com/BUSZM.png) But they don't prove it. I was thinking it should not be too hard but how can we show this? I was thinking of using the definition of n-step return (eq. 7.1 on previous page): $$G\_{t:t+n} = R\_{t+1} + \gamma\*R\_{t+2} + ... + \gamma^{n-1}\*R\_{t+n} + \gamma^{n}\*V\_{t+n-1}(S\_{t+n})$$ Because then this has the $V\_{t+n-1}$ in it already. But in the definition above of the n-step return it uses $V\_{t+n-1}(S\_{t+n})$ but on the right side of the inequality (7.3) that we want to prove it is just little s $V\_{t+n-1}(s)$ ? So kind of confused here which state s it is using? And then I guess after this probably pull out a $\gamma^{n}$ term or something, how should we go from here? This is the newest Sutton Barto book (book page 144, equation 7.3): <https://drive.google.com/file/d/1opPSz5AZ_kVa1uWOdOiveNiBFiEOHjkG/view><issue_comment>username_1: Let's start by looking at: $$\max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert.$$ We can rewrite this by plugging in the definition of $G\_{t:t+n}$: \begin{aligned} & \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert \\ % =& \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ R\_{t + 1} + \gamma R\_{t + 2} + \dots + \gamma^{n - 1} R\_{t + n} + \gamma^n V\_{t + n - 1}(S\_{t + n}) \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert \\ % =& \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ R\_{t:t+n} + \gamma^n V\_{t + n - 1}(S\_{t + n}) \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert, \end{aligned} where $R\_{t:t+n} \doteq R\_{t + 1} + \gamma R\_{t + 2} + \dots + \gamma^{n - 1} R\_{t + n}$. If you go all the way back to page 58 of the book, you can see the definition of $v\_{\pi}(s)$: \begin{aligned} v\_{\pi}(s) &\doteq \mathbb{E}\_{\pi} \left[ \sum\_{k = 0}^{\infty} \gamma^k R\_{t + k + 1} \mid S\_t = s \right] \\ % &= \mathbb{E}\_{\pi} \left[ R\_{t:t+n} + \gamma^n \sum\_{k = 0}^{\infty} \gamma^k R\_{t + n + k + 1} \mid S\_t = s \right] \\ % &= \mathbb{E}\_{\pi} \left[ R\_{t:t+n} \mid S\_t = s \right] + \gamma^n \mathbb{E}\_{\pi} \left[ \sum\_{k = 0}^{\infty} \gamma^k R\_{t + n + k + 1} \mid S\_t = s \right] \end{aligned} Using this, we can continue rewriting where we left off above: \begin{aligned} & \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ R\_{t:t+n} + \gamma^n V\_{t + n - 1}(S\_{t + n}) \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert \\ % =& \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ \gamma^n V\_{t + n - 1}(S\_{t + n}) \mid S\_t = s \right] - \gamma^n \mathbb{E}\_{\pi} \left[ \sum\_{k = 0}^{\infty} \gamma^k R\_{t + n + k + 1} \mid S\_t = s \right] \Bigr\rvert \\ % =& \gamma^n \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ V\_{t + n - 1}(S\_{t + n}) - \sum\_{k = 0}^{\infty} \gamma^k R\_{t + n + k + 1} \mid S\_t = s \right] \Bigr\rvert \end{aligned} Because the absolute value function is [convex](https://en.wikipedia.org/wiki/Convex_function), we can use [Jensen's inequality](https://en.wikipedia.org/wiki/Jensen%27s_inequality) to show that the absolute value of an expectation is less than or equal to the expectation of the corresponding absolute value: $$\left| \mathbb{E} \left[ X \right] \right| \leq \mathbb{E} \left[ \left| X \right| \right].$$ This means that: \begin{aligned} \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} - v\_{\pi}(s) \mid S\_t = s \right] \Bigr\rvert &\leq \gamma^n \max\_s \mathbb{E}\_{\pi} \left[ \Bigl\lvert V\_{t + n - 1}(S\_{t + n}) - \sum\_{k = 0}^{\infty} \gamma^k R\_{t + n + k + 1} \Bigr\rvert \mid S\_t = s \right] \\ % \end{aligned} Now, the important trick here is to see that: $$\max\_s \mathbb{E}\_{\pi} \left[ \Bigl\lvert V\_{t + n - 1}(S\_{t + n}) - \sum\_{k = 0}^{\infty} \gamma^k R\_{t + n + k + 1} \Bigr\rvert \mid S\_t = s \right] \leq \max\_s \mathbb{E}\_{\pi} \left[ \Bigl\lvert V\_{t + n - 1}(S\_{t}) - \sum\_{k = 0}^{\infty} \gamma^k R\_{t + k + 1} \Bigr\rvert \mid S\_t = s \right]$$ I'm skipping the formal steps to show that this is the case to save space, but the intuition is that: * The left-hand side of this inequality involves finding an $S\_t = s$ such that some function of $S\_{t + n}$ is maximized, whereas the right-hand side involves finding an $S\_t = s$ such that exactly the same function of $S\_{t}$ is maximized. * In the left-hand side, selecting an $S\_t = s$ implicitly induces a probability distribution over multiple possible states $S\_{t + n}$, given by $S\_t$, the environment's transition dynamics, and the policy $\pi$. Intuitively, this is more "restrictive" for the $\max$ operator, it does not have the "freedom" to directly select a single state $S\_{t + n}$ such that the function of $S\_{t + n}$ is maximized. The right-hand side is free to choose any single state $S\_t = s$ such that $S\_t$ in the right-hand side were equal to an "optimal" $S\_{t+n}$ on the left-hand side, but it is also free to make even better choices which might never be uniquely reachable after $n$ steps on the left-hand side. We can use this to rewrite the previous inequality we had (where we might be making the right-hand side a bit bigger than it was, but that's fine, it already was an upper bound anyway so that inequality will still hold): \begin{aligned} \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} - v\_{\pi}(s) \mid S\_t = s \right] \Bigr\rvert &\leq \gamma^n \max\_s \mathbb{E}\_{\pi} \left[ \Bigl\lvert V\_{t + n - 1}(S\_{t}) - \sum\_{k = 0}^{\infty} \gamma^k R\_{t + k + 1} \Bigr\rvert \mid S\_t = s \right] \\ % &= \gamma^n \max\_s \mathbb{E}\_{\pi} \left[ \Bigl\lvert V\_{t + n - 1}(S\_{t}) - v\_{\pi}(s) \Bigr\rvert \mid S\_t = s \right]. \end{aligned} After this rewriting we've got a hidden $\mathbb{E}\_{\pi}$ "inside" another $\mathbb{E}\_{\pi}$ (because the definition of $v\_{\pi}(s)$ contains an $\mathbb{E}\_{\pi}$), which I suppose is kind of ugly... but mathematically meaningless. The maximum of a random variable is an upper bound on the expectation of that random variable, so we can get rid of the expectation in the right-hand side (again potentially increasing the right-hand side, which again is still fine since it's already an upper bound anyway): \begin{aligned} \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} - v\_{\pi}(s) \mid S\_t = s \right] \Bigr\rvert &\leq \gamma^n \max\_s \Bigl\lvert V\_{t + n - 1}(s) - v\_{\pi}(s) \Bigr\rvert, \end{aligned} which we can finally rewrite to Equation (7.3) in the book by moving the subtraction of $v\_{\pi}(s)$ outside of the expectation on the left-hand side of the inequality (which is fine because, as I already mentioned above, the definition of $v\_{\pi}(s)$ itself contains another $\mathbb{E}\_{\pi}$ anyway). Upvotes: 3 <issue_comment>username_2: I will try to answer the question in a lesser mathematical (and hopefully correct way). NOTE: I have used $V\_{\pi}$ and $v\_{\pi}$ interchangeably. We start from LHS: $$\max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert$$ This can be written in terms of trajectories. Say the probability of observing a $n$ step trajectory (for a $n$ step return) is $p\_j^{s}$ from state $S\_t = s$ . Thus we can write the expected return as sum of returns from all trajectories multiplied with the probability of the trajectory: $$\mathbb{E}\_{\pi} [G\_{t:t+n}|S\_t = s] = \sum\_j p\_j^sG\_{t:t+n}^j = \sum\_j p\_j^s [R\_{t+1}^j + \gamma R\_{t+2}^j.....\gamma^{n-1}R\_{t+n}^j + \gamma^n V\_{t+n-1}(S\_{t + n})^j]$$ We use @Dennis's terminology for $n$ step rewards i.e $R\_{t:t+n}^j \doteq R\_{t + 1}^j + \gamma R\_{t + 2}^j + \dots + \gamma^{n - 1} R\_{t + n}^j$. Now we know $v\_{\pi}(s)$ is nothing but $\mathbb{E}\_{\pi} [G\_{t:t+n}^{\pi}|S\_t = s]$ where I have used $G\_{t:t+n}^{\pi}$ to denote that the returns are actual returns if we have evaluated the policy completely (the value functions are consistent with the policy) for every state(using infinite episodes maybe) i.e $G\_{t:t+n}^{\pi} = R\_{t:t+n} + \gamma^n V\_{\pi}(S\_{t + n})$. So now if we evaluate the equation: $$\max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert = \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - \mathbb{E}\_{\pi} [G\_{t:t+n}^{\pi}|S\_t = s]\Bigr\rvert$$ which is further written in form of trajectory probabilities (for easier comprehension): $$\max\_s \Bigl\lvert \sum\_j p\_j^s(R\_{t:t+n}^j+\gamma^n V\_{t+n-1}^j(S\_{t + n})) - \sum\_j p\_j^s(R\_{t:t+n}^j+\gamma^n V\_{\pi}^j(S\_{t + n})) \Bigr\rvert$$ Now the equation can be simplified by cancelling the reward terms ($R\_{t:t+n}^j$) as they are the same for a trajectory, and thus is common to both the terms we get: $$\max\_s \Bigl\lvert \gamma^n\sum\_j p\_j^s( V\_{t+n-1}^j(S\_{t + n})-V\_{\pi}^j(S\_{t + n}))\Bigr\rvert$$ This is basically the expectation of the deviation of each and every state at the $n$ th step (from its actual value $V\_{\pi}$,), starting from $S\_t = s$ and multiplied by a discount factor. Now using the identity $E[X] \leq \max X$ we get: $$\max\_s \Bigl\lvert \gamma^n\sum\_j p\_j^s( V\_{t+n-1}^j(S\_{t + n})-V\_{\pi}^j(S\_{t + n}))\Bigr\rvert \leq \max \Bigl\lvert \gamma^n( V\_{t+n-1}^j(S\_{t + n})-V\_{\pi}^j(S\_{t + n}))\Bigr\rvert$$ Which can finally be written as: $$\max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert \leq \max \Bigl\lvert \gamma^n( V\_{t+n-1}^j(S\_{t + n})-V\_{\pi}^j(S\_{t + n}))\Bigr\rvert$$ Now the RHS is true for only those states reachable from $S\_t = s$ via a trajectory, but since it has a maximizing operation we can include the whole state space in the $\max$ operation without any problem to finally write: $$\max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert \leq \max\_s \Bigl\lvert \gamma^n( V\_{t+n-1}(s)-V\_{\pi}(s))\Bigr\rvert$$ which concludes the proof. Upvotes: 1
2018/12/08
3,777
9,350
<issue_start>username_0: Speech is a major primary mechanism of communication between humans. With respect to artificial intelligence, which signal is used to identify the sequence of words in speech?<issue_comment>username_1: Let's start by looking at: $$\max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert.$$ We can rewrite this by plugging in the definition of $G\_{t:t+n}$: \begin{aligned} & \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert \\ % =& \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ R\_{t + 1} + \gamma R\_{t + 2} + \dots + \gamma^{n - 1} R\_{t + n} + \gamma^n V\_{t + n - 1}(S\_{t + n}) \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert \\ % =& \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ R\_{t:t+n} + \gamma^n V\_{t + n - 1}(S\_{t + n}) \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert, \end{aligned} where $R\_{t:t+n} \doteq R\_{t + 1} + \gamma R\_{t + 2} + \dots + \gamma^{n - 1} R\_{t + n}$. If you go all the way back to page 58 of the book, you can see the definition of $v\_{\pi}(s)$: \begin{aligned} v\_{\pi}(s) &\doteq \mathbb{E}\_{\pi} \left[ \sum\_{k = 0}^{\infty} \gamma^k R\_{t + k + 1} \mid S\_t = s \right] \\ % &= \mathbb{E}\_{\pi} \left[ R\_{t:t+n} + \gamma^n \sum\_{k = 0}^{\infty} \gamma^k R\_{t + n + k + 1} \mid S\_t = s \right] \\ % &= \mathbb{E}\_{\pi} \left[ R\_{t:t+n} \mid S\_t = s \right] + \gamma^n \mathbb{E}\_{\pi} \left[ \sum\_{k = 0}^{\infty} \gamma^k R\_{t + n + k + 1} \mid S\_t = s \right] \end{aligned} Using this, we can continue rewriting where we left off above: \begin{aligned} & \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ R\_{t:t+n} + \gamma^n V\_{t + n - 1}(S\_{t + n}) \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert \\ % =& \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ \gamma^n V\_{t + n - 1}(S\_{t + n}) \mid S\_t = s \right] - \gamma^n \mathbb{E}\_{\pi} \left[ \sum\_{k = 0}^{\infty} \gamma^k R\_{t + n + k + 1} \mid S\_t = s \right] \Bigr\rvert \\ % =& \gamma^n \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ V\_{t + n - 1}(S\_{t + n}) - \sum\_{k = 0}^{\infty} \gamma^k R\_{t + n + k + 1} \mid S\_t = s \right] \Bigr\rvert \end{aligned} Because the absolute value function is [convex](https://en.wikipedia.org/wiki/Convex_function), we can use [Jensen's inequality](https://en.wikipedia.org/wiki/Jensen%27s_inequality) to show that the absolute value of an expectation is less than or equal to the expectation of the corresponding absolute value: $$\left| \mathbb{E} \left[ X \right] \right| \leq \mathbb{E} \left[ \left| X \right| \right].$$ This means that: \begin{aligned} \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} - v\_{\pi}(s) \mid S\_t = s \right] \Bigr\rvert &\leq \gamma^n \max\_s \mathbb{E}\_{\pi} \left[ \Bigl\lvert V\_{t + n - 1}(S\_{t + n}) - \sum\_{k = 0}^{\infty} \gamma^k R\_{t + n + k + 1} \Bigr\rvert \mid S\_t = s \right] \\ % \end{aligned} Now, the important trick here is to see that: $$\max\_s \mathbb{E}\_{\pi} \left[ \Bigl\lvert V\_{t + n - 1}(S\_{t + n}) - \sum\_{k = 0}^{\infty} \gamma^k R\_{t + n + k + 1} \Bigr\rvert \mid S\_t = s \right] \leq \max\_s \mathbb{E}\_{\pi} \left[ \Bigl\lvert V\_{t + n - 1}(S\_{t}) - \sum\_{k = 0}^{\infty} \gamma^k R\_{t + k + 1} \Bigr\rvert \mid S\_t = s \right]$$ I'm skipping the formal steps to show that this is the case to save space, but the intuition is that: * The left-hand side of this inequality involves finding an $S\_t = s$ such that some function of $S\_{t + n}$ is maximized, whereas the right-hand side involves finding an $S\_t = s$ such that exactly the same function of $S\_{t}$ is maximized. * In the left-hand side, selecting an $S\_t = s$ implicitly induces a probability distribution over multiple possible states $S\_{t + n}$, given by $S\_t$, the environment's transition dynamics, and the policy $\pi$. Intuitively, this is more "restrictive" for the $\max$ operator, it does not have the "freedom" to directly select a single state $S\_{t + n}$ such that the function of $S\_{t + n}$ is maximized. The right-hand side is free to choose any single state $S\_t = s$ such that $S\_t$ in the right-hand side were equal to an "optimal" $S\_{t+n}$ on the left-hand side, but it is also free to make even better choices which might never be uniquely reachable after $n$ steps on the left-hand side. We can use this to rewrite the previous inequality we had (where we might be making the right-hand side a bit bigger than it was, but that's fine, it already was an upper bound anyway so that inequality will still hold): \begin{aligned} \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} - v\_{\pi}(s) \mid S\_t = s \right] \Bigr\rvert &\leq \gamma^n \max\_s \mathbb{E}\_{\pi} \left[ \Bigl\lvert V\_{t + n - 1}(S\_{t}) - \sum\_{k = 0}^{\infty} \gamma^k R\_{t + k + 1} \Bigr\rvert \mid S\_t = s \right] \\ % &= \gamma^n \max\_s \mathbb{E}\_{\pi} \left[ \Bigl\lvert V\_{t + n - 1}(S\_{t}) - v\_{\pi}(s) \Bigr\rvert \mid S\_t = s \right]. \end{aligned} After this rewriting we've got a hidden $\mathbb{E}\_{\pi}$ "inside" another $\mathbb{E}\_{\pi}$ (because the definition of $v\_{\pi}(s)$ contains an $\mathbb{E}\_{\pi}$), which I suppose is kind of ugly... but mathematically meaningless. The maximum of a random variable is an upper bound on the expectation of that random variable, so we can get rid of the expectation in the right-hand side (again potentially increasing the right-hand side, which again is still fine since it's already an upper bound anyway): \begin{aligned} \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} - v\_{\pi}(s) \mid S\_t = s \right] \Bigr\rvert &\leq \gamma^n \max\_s \Bigl\lvert V\_{t + n - 1}(s) - v\_{\pi}(s) \Bigr\rvert, \end{aligned} which we can finally rewrite to Equation (7.3) in the book by moving the subtraction of $v\_{\pi}(s)$ outside of the expectation on the left-hand side of the inequality (which is fine because, as I already mentioned above, the definition of $v\_{\pi}(s)$ itself contains another $\mathbb{E}\_{\pi}$ anyway). Upvotes: 3 <issue_comment>username_2: I will try to answer the question in a lesser mathematical (and hopefully correct way). NOTE: I have used $V\_{\pi}$ and $v\_{\pi}$ interchangeably. We start from LHS: $$\max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert$$ This can be written in terms of trajectories. Say the probability of observing a $n$ step trajectory (for a $n$ step return) is $p\_j^{s}$ from state $S\_t = s$ . Thus we can write the expected return as sum of returns from all trajectories multiplied with the probability of the trajectory: $$\mathbb{E}\_{\pi} [G\_{t:t+n}|S\_t = s] = \sum\_j p\_j^sG\_{t:t+n}^j = \sum\_j p\_j^s [R\_{t+1}^j + \gamma R\_{t+2}^j.....\gamma^{n-1}R\_{t+n}^j + \gamma^n V\_{t+n-1}(S\_{t + n})^j]$$ We use @Dennis's terminology for $n$ step rewards i.e $R\_{t:t+n}^j \doteq R\_{t + 1}^j + \gamma R\_{t + 2}^j + \dots + \gamma^{n - 1} R\_{t + n}^j$. Now we know $v\_{\pi}(s)$ is nothing but $\mathbb{E}\_{\pi} [G\_{t:t+n}^{\pi}|S\_t = s]$ where I have used $G\_{t:t+n}^{\pi}$ to denote that the returns are actual returns if we have evaluated the policy completely (the value functions are consistent with the policy) for every state(using infinite episodes maybe) i.e $G\_{t:t+n}^{\pi} = R\_{t:t+n} + \gamma^n V\_{\pi}(S\_{t + n})$. So now if we evaluate the equation: $$\max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert = \max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - \mathbb{E}\_{\pi} [G\_{t:t+n}^{\pi}|S\_t = s]\Bigr\rvert$$ which is further written in form of trajectory probabilities (for easier comprehension): $$\max\_s \Bigl\lvert \sum\_j p\_j^s(R\_{t:t+n}^j+\gamma^n V\_{t+n-1}^j(S\_{t + n})) - \sum\_j p\_j^s(R\_{t:t+n}^j+\gamma^n V\_{\pi}^j(S\_{t + n})) \Bigr\rvert$$ Now the equation can be simplified by cancelling the reward terms ($R\_{t:t+n}^j$) as they are the same for a trajectory, and thus is common to both the terms we get: $$\max\_s \Bigl\lvert \gamma^n\sum\_j p\_j^s( V\_{t+n-1}^j(S\_{t + n})-V\_{\pi}^j(S\_{t + n}))\Bigr\rvert$$ This is basically the expectation of the deviation of each and every state at the $n$ th step (from its actual value $V\_{\pi}$,), starting from $S\_t = s$ and multiplied by a discount factor. Now using the identity $E[X] \leq \max X$ we get: $$\max\_s \Bigl\lvert \gamma^n\sum\_j p\_j^s( V\_{t+n-1}^j(S\_{t + n})-V\_{\pi}^j(S\_{t + n}))\Bigr\rvert \leq \max \Bigl\lvert \gamma^n( V\_{t+n-1}^j(S\_{t + n})-V\_{\pi}^j(S\_{t + n}))\Bigr\rvert$$ Which can finally be written as: $$\max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert \leq \max \Bigl\lvert \gamma^n( V\_{t+n-1}^j(S\_{t + n})-V\_{\pi}^j(S\_{t + n}))\Bigr\rvert$$ Now the RHS is true for only those states reachable from $S\_t = s$ via a trajectory, but since it has a maximizing operation we can include the whole state space in the $\max$ operation without any problem to finally write: $$\max\_s \Bigl\lvert \mathbb{E}\_{\pi} \left[ G\_{t:t+n} \mid S\_t = s \right] - v\_{\pi}(s) \Bigr\rvert \leq \max\_s \Bigl\lvert \gamma^n( V\_{t+n-1}(s)-V\_{\pi}(s))\Bigr\rvert$$ which concludes the proof. Upvotes: 1
2018/12/08
2,508
6,711
<issue_start>username_0: Consider a perceptron where $w\_0=1$ and $w\_1=1$: [![Perceptron](https://i.stack.imgur.com/eBSki.jpg)](https://i.stack.imgur.com/eBSki.jpg) Now, suppose that we use the following activation function \begin{align} f(x)= \begin{cases} 1, \text{ if }x =1\\ 0, \text{ otherwise} \end{cases} \end{align} The output is then summarised as: \begin{array}{|c|c|c|c|} \hline x\_0 & x\_1 & w\_0x\_0 + w\_1x\_1 & f( \cdot )\\ \hline 0 & 0 & 0 & 0 \\ \hline 0 & 1 & 1 & 1 \\ \hline 1 & 0 & 1 & 1 \\ \hline 1 & 1 & 2 & 0 \\ \hline \end{array} Is there something wrong with the way I've defined the activation function?<issue_comment>username_1: Indeed I think the problem is with the way you've defined the activation function. By selecting it arbitrarily, you could solve many specific problems. In practice, activation functions used are monotonic. It keeps the error function convex at a per-layer level. In theory though I'm not sure exactly what Rosenblatt has claimed so it might be worth calling him Upvotes: 2 <issue_comment>username_2: The main problems are that your activation function is not **monotonic** (as pointed out by username_1), and that it is not **continuously differentiable**. These make it very difficult / impossible to use standard gradient-based learning algorithms. So yes, there may exist a good solution of weight values, but it is very difficult to find or approximate those weight values automatically through a learning algorithm. Also note that it completely breaks down as soon as you have a tiny error in one of the weights, even if it is approximate very closely; if one of the weights has a value of $0.999$ rather than $1.0$, the solution breaks down completely. Upvotes: 2 <issue_comment>username_3: It can be done. The activation function of a neuron does not have to be monotonic. The activation that Rahul suggested can be implemented via a continuously differentiable function, for example $ f(s) = exp(-k(1-s)^2) $ which has a nice derivative $f'(s) = 2k~(1-s)f(s)$. Here, $s=w\_0~x\_0+w\_1~x\_1$. Therefore, standard gradient-based learning algorithms are applicable. The neuron's error is $ E = \frac{1}{2}(v-v\_d)^2$, where $v\_d$ - desired output, $v$ - actual output. The weights $w\_i, ~i=0,1$ are initialized randomly and then updated during training as follows $$w\_i \to w\_i - \alpha\frac{\partial E}{\partial w\_i}$$ where $\alpha$ is a learning rate. We have $$\frac{\partial E}{\partial w\_i} = (v-v\_d)\frac{\partial v}{\partial w\_i}=(f(s)-v\_d)~\frac{\partial f}{\partial s}\frac{\partial s}{\partial w\_i}=2k~(f(s)-v\_d)(1-s)f(s)~x\_i$$ Let's test it in Python. ``` import numpy as np import matplotlib.pyplot as plt ``` For training, I take a few points randomly scattered around $[0, 0]$, $[0, 1]$, $[1, 0]$, and $[1, 1]$. ``` n = 10 sd = [0.05, 0.05] x00 = np.random.normal(loc=[0, 0], scale=sd, size=(n,2)) x01 = np.random.normal(loc=[0, 1], scale=sd, size=(n,2)) x10 = np.random.normal(loc=[1, 0], scale=sd, size=(n,2)) x11 = np.random.normal(loc=[1, 1], scale=sd, size=(n,2)) x = np.vstack((x00,x01,x10,x11)) y = np.vstack((np.zeros((x00.shape[0],1)), np.ones((x01.shape[0],1)), np.ones((x10.shape[0],1)), np.zeros((x11.shape[0],1)))).ravel() ind = np.arange(len(y)) np.random.shuffle(ind) x = x[ind] y = y[ind] N = len(y) plt.scatter(*x00.T, label='00') plt.scatter(*x01.T, label='01') plt.scatter(*x10.T, label='10') plt.scatter(*x11.T, label='11') plt.legend() plt.show() ``` [![enter image description here](https://i.stack.imgur.com/W3r4F.png)](https://i.stack.imgur.com/W3r4F.png) Activation function: ``` k = 10 def f(s): return np.exp(-k*(s-1)**2) ``` Initialize the weights, and train the network: ``` w = np.random.uniform(low=0.25, high=1.75, size=(2)) print("Initial w:", w) rate = 0.01 n_epochs = 20 error = [] for _ in range(n_epochs): err = 0 for i in range(N): s = np.dot(x[i],w) w -= rate * 2 * k * (f(s) - y[i]) * (1-s) * f(s) * x[i] err += 0.5*(f(s) - y[i])**2 err /= N error.append(err) print('Final w:', w) ``` The weights have indeed converged to $w\_0=1,~w\_1=1$: ``` Initial w: [1.5915165 0.27594833] Final w: [1.03561356 0.96695205] ``` The training error is decreasing: ``` plt.scatter(np.arange(n_epochs), error) plt.grid() plt.xticks(np.arange(0, n_epochs, step=1)) plt.show() ``` [![enter image description here](https://i.stack.imgur.com/Vy119.png)](https://i.stack.imgur.com/Vy119.png) Let's test it. I create a testing set in the same way as the training set. My test data are different from my training data because I didn't fix the seed. ``` x00 = np.random.normal(loc=[0, 0], scale=sd, size=(n,2)) x01 = np.random.normal(loc=[0, 1], scale=sd, size=(n,2)) x10 = np.random.normal(loc=[1, 0], scale=sd, size=(n,2)) x11 = np.random.normal(loc=[1, 1], scale=sd, size=(n,2)) x_test = np.vstack((x00,x01,x10,x11)) y_test = np.vstack((np.zeros((x00.shape[0],1)), np.ones((x01.shape[0],1)), np.ones((x10.shape[0],1)), np.zeros((x11.shape[0],1)))).ravel() ``` I calculate the root mean squared error, and the coefficient of determination (R^2 score): ``` def fwd(x,w): return f(np.dot(x,w)) RMSE = 0 for i in range(N): RMSE += (fwd(x_test[i],w) - y_test[i])**2 RMSE = np.sqrt(RMSE/N) print("RMSE", RMSE) ybar = np.mean(y) S = 0 D = 0 for i in range(N): S += (fwd(x_test[i],w) - y_test[i])**2 D += (fwd(x_test[i],w) - ybar)**2 r2_score = 1 - S/D print("r2_score", r2_score) ``` Result: ``` RMSE 0.09199468888373698 r2_score 0.9613632278609362 ``` ... or I am doing something wrong? Please tell me. Upvotes: 3 [selected_answer]<issue_comment>username_4: I'm also working on a perceptron that is able to solve the XOR Problem, and I get interesting results using sine as an activation function, and using the derivative to make the perceptron learn. But you will need bias to make sure the perceptron is able to solve the problem. Upvotes: 0 <issue_comment>username_3: Another activation function that could be used for this problem: $$f(x) = \underset{i}{max}(x\_i) - \underset{i}{min}(x\_i)$$ It's not continuous, no backpropagation, sorry. Some other learning algorithm is required. However, this answers the question, if an XOR can be solved with one neuron. Maybe this function is a solution of some learning problem with weights. Something like $$f(x) = max(w\_0x\_0,w\_1x\_1) - min(w\_0x\_0,w\_1x\_1)$$ I don't know how this creature is generalizable to other tasks, and how much learning can be done by just manipulating maxima and minima of weighted inputs. Any ideas? Upvotes: 0
2018/12/08
806
3,102
<issue_start>username_0: I'm trying to train a Siamese network to check if two images are similar. My implementation is based on [this](https://leimao.github.io/article/Siamese-Network-MNIST/). I find the Euclidian distance of the feature vectors(the final flattened layer of my CNN) of my two images and train the model using the contrastive loss function. My question is, how do I get a binary output from the Siamese network for testing (1 if it two images are similar, 0 otherwise). Is it just by thresholding the Euclidian distance to check how similar the images are? If so, how do I go about selecting the threshold? If I wanted to measure the training and validation accuracies, the threshold would have to be increased as the network learns better. Is there a way to learn this threshold for a given dataset? I would appreciate any leads, thank you.<issue_comment>username_1: I am working on something rather similar in the sense that I get a continuous value (between 0 and 1) as output that I want to be binary. I think you should be using the ROC curve (Receiver-Operating-Characteristic) instead of the accuracy. If you want a single value take the area-under-the-curve. The ROC curve is basically true-prositive-rate vs false-positive-rate as you test for different values of threshold. You could also (or instead) use precision vs recall. Also, the optimal threshold does not depend as much on the dataset as it depends on your neural network. As you said this value will change as your network learns. Simply use the outputted value and test different thresholds. If do want to keep the accuracy, simply pick the threshold for which is it best (at the given iteration). Keep in mind that you should not define the threshold from the validation set as you would be cheating. ps: from rereading it seems like you were implying to learn the threshold from inside the network. I believe it should just be a post-process Upvotes: 1 <issue_comment>username_2: Don't use the Euclidian distance as the similar/dissimilar factor, you'll get better results if you put a couple Dense layers at the top of your Siamese network. You don't mention how large your feature vectors are, but if they are 128D face encodings, this is what I used: ``` # dist_euclid_layer is a layers.Lambda that performs the euclid distance on the input first_dense = layers.Dense(512, activation='relu')(dist_euclid_layer) drop_one = layers.Dropout(0.5)(first_dense) output_dense = layers.Dense(2, activation='sigmoid')(drop_one) model = models.Model(inputs=[input_layer], outputs=output_dense) model.compile(loss=losses.binary_crossentropy, optimizer=opt, metrics=['accuracy']) ``` In training, use [0,1] or [1,0] for Y to indicate different / similar. Then in production, use the np.argmax to find the positive match: ``` predictions_raw = model.predict(vstack_batch_input, batch_size=len(batch_input)) predictions = np.argmax(predictions_raw,axis=1) tot_matches = np.sum(predictions) if tot_matches == 1: # ... good times, whatever face[N] has prediction[N] == 1 is the matching face ``` Upvotes: 0
2018/12/09
805
3,051
<issue_start>username_0: What is the difference between additive and discounted rewards?<issue_comment>username_1: Discounted reward has its opposite undiscounted reward. The difference between *these* is that discounted has multiplier gamma != 1 and undiscounted is gamma = 1. Gamma tells the multiplier, how much previous values are valued in next iterations. [1] Additive refers to different thing, a note found in [2]: > > An additive reward function decomposes the reward into a number of contributions and can be represented as a (non-partiotioning) MPA. > > > This short excerpt does not reveal lot, but was the only I could find that made some sense to me. What I *could* indeed find out was that although they seem similar concepts by name, they appear totally different by nature. **Sources:** [1] <https://en.wikipedia.org/wiki/Reinforcement_learning> [2] The Logic of Adaptive Behavior: Knowledge Representation and Algorithms for Adaptive Sequential Decision Making Under Uncertainty In First-Order and Relational Domains.- M. Van Upvotes: 1 [selected_answer]<issue_comment>username_2: I will disagree slightly with @username_1. There is a usage of "additive rewards" that refers to decomposable reward functions (e.g. my reward in selling an item I do not want to own is composed of the reward of not having an unwanted item anymore, plus the monetary gain in selling the item). But, there is indeed a fundamental relation between additive and discounted rewards. Additive rewards are formulated simply as $$ R([s\_0, s\_1, s\_2, ...]) = R(s\_0) + R(s\_1) + R(s\_2) + \cdots $$ whereas discounted rewards include a discount factor $\gamma \in [0,1]$ such that $$ R([s\_0, s\_1, s\_2, ...]) = R(s\_0) + \gamma R(s\_1) + \gamma^2R(s\_2) + \cdots $$ Intuitively, the additive reward for a sequence of states is simply the sum of the rewards acquired at each state, while discounted rewards include a multiplicative discount factor that reduces the influence of rewards as time goes on. You will typically see additive rewards for finite-horizon problems, i.e. you have a discrete number of timesteps to optimize over, and discounted rewards are more relevant for infinite-horizon problems, i.e. you may need to optimize over an infinite number of timesteps (or at least a very large number). The discount factor governs the agent’s greediness in achieving immediate reward, where very small discount factors (closer to 0) encourage the agent to only seek rewards in proximal states, and very large discount factors (closer to 1) encourage the agent to think further into the future about what rewards it can expect to achieve in states it will visit later. The most direct reference I found for this distinction is in [these course slides](http://www-anw.cs.umass.edu/~barto/courses/CS383-Fall11/383-Fall11-Lec22.pdf), which are somewhat authoritative since they from <NAME>, a co-author of [the de facto text](https://mitpress.mit.edu/books/reinforcement-learning-second-edition) on reinforcement learning. Upvotes: 1
2018/12/10
1,057
4,160
<issue_start>username_0: [Karel the robot](https://en.wikipedia.org/wiki/Karel_(programming_language)) is an education software comparable to turtle graphics to teach programming for beginners. It's a virtual stack-based interpreter to run a domain-specific language for moving a robot in a maze. In its vanilla version, the user authors the script manually. That means, he writes down a computer program like 1. move forward 2. if reached obstacle == true then stop 3. move left. This program is then executed in the virtual machine. In contrast, genetic programming has the aim to produce computer code without human intervention. So-called permutations are tested if they are fulfilling the constraints and, after a while, the source code is generated. In most publications, the concept is explained on a machine level. That means assembly instructions are generated with the aim to replace normal computer code. In "Karel the robot" a high-level language for controlling a robot is presented, which has a stack, but has a higher abstraction. The advantage is, that the state space is smaller. My question is: is it possible to generate "Karel the robot" programs with genetic programming?<issue_comment>username_1: Discounted reward has its opposite undiscounted reward. The difference between *these* is that discounted has multiplier gamma != 1 and undiscounted is gamma = 1. Gamma tells the multiplier, how much previous values are valued in next iterations. [1] Additive refers to different thing, a note found in [2]: > > An additive reward function decomposes the reward into a number of contributions and can be represented as a (non-partiotioning) MPA. > > > This short excerpt does not reveal lot, but was the only I could find that made some sense to me. What I *could* indeed find out was that although they seem similar concepts by name, they appear totally different by nature. **Sources:** [1] <https://en.wikipedia.org/wiki/Reinforcement_learning> [2] The Logic of Adaptive Behavior: Knowledge Representation and Algorithms for Adaptive Sequential Decision Making Under Uncertainty In First-Order and Relational Domains.- M. Van Upvotes: 1 [selected_answer]<issue_comment>username_2: I will disagree slightly with @username_1. There is a usage of "additive rewards" that refers to decomposable reward functions (e.g. my reward in selling an item I do not want to own is composed of the reward of not having an unwanted item anymore, plus the monetary gain in selling the item). But, there is indeed a fundamental relation between additive and discounted rewards. Additive rewards are formulated simply as $$ R([s\_0, s\_1, s\_2, ...]) = R(s\_0) + R(s\_1) + R(s\_2) + \cdots $$ whereas discounted rewards include a discount factor $\gamma \in [0,1]$ such that $$ R([s\_0, s\_1, s\_2, ...]) = R(s\_0) + \gamma R(s\_1) + \gamma^2R(s\_2) + \cdots $$ Intuitively, the additive reward for a sequence of states is simply the sum of the rewards acquired at each state, while discounted rewards include a multiplicative discount factor that reduces the influence of rewards as time goes on. You will typically see additive rewards for finite-horizon problems, i.e. you have a discrete number of timesteps to optimize over, and discounted rewards are more relevant for infinite-horizon problems, i.e. you may need to optimize over an infinite number of timesteps (or at least a very large number). The discount factor governs the agent’s greediness in achieving immediate reward, where very small discount factors (closer to 0) encourage the agent to only seek rewards in proximal states, and very large discount factors (closer to 1) encourage the agent to think further into the future about what rewards it can expect to achieve in states it will visit later. The most direct reference I found for this distinction is in [these course slides](http://www-anw.cs.umass.edu/~barto/courses/CS383-Fall11/383-Fall11-Lec22.pdf), which are somewhat authoritative since they from <NAME>, a co-author of [the de facto text](https://mitpress.mit.edu/books/reinforcement-learning-second-edition) on reinforcement learning. Upvotes: 1
2018/12/11
1,953
7,361
<issue_start>username_0: In AIMA, 3rd Edition on Page 125, Simulated Annealing is described as: > > Hill-climbing algorithm that *never* makes “downhill” moves toward states with lower value (or higher cost) is guaranteed to be incomplete, because it can get stuck on a local maximum. In contrast, a purely random walk—that is, moving to a successor chosen uniformly at random from the set of successors—is complete but extremely inefficient. Therefore, it seems reasonable to try to combine hill climbing with a random walk in some way that yields both efficiency and completeness. Simulated annealing is such an algorithm. In metallurgy, **annealing** is the process used to temper or harden metals and glass by heating them to a high temperature and then gradually cooling them, thus allowing the material to reach a lowenergy crystalline state. To explain simulated annealing, we switch our point of view from hill climbing to **gradient descent** (i.e., minimizing cost) and imagine the task of getting a > ping-pong ball into the deepest crevice in a bumpy surface. If we just let the ball roll, it will come to rest at a local minimum. If we shake the surface, we can bounce the ball out of the local minimum. The trick is to shake just hard enough to bounce the ball out of local minima but not hard enough to dislodge it from the global minimum. The simulated-annealing solution is to start by shaking hard (i.e., at a high temperature) and then gradually reduce the intensity of the shaking (i.e., lower the temperature) > > > I know its about its example, but I just want more examples where Stimulated Annealing used in daily life<issue_comment>username_1: Simulated annealing is just one of the approaches for an [optimization problem](https://en.wikipedia.org/wiki/Optimization_problem): * Given a function f(*X*), you want to find an *X* where f(*X*) is optimal (has maximum or minimum value). Shaking (a methaphor for introducing a degree of randomness to annealing process) is used to prevent the algorithm from stopping prematurely, when only a sub-optimal solution (local minimum or local maximum) has been found. I've once used it for finding the optimal schedule of lessons for teacher. The optimization function took into consideration "time windows" between windows, so that teachers do not have to wait too much. Upvotes: 1 <issue_comment>username_2: **Examples of simulated annealing in the 2010s** These are a few examples. * [*Optimised simulated annealing for Ising spin glasses*](https://arxiv.org/pdf/1401.1084.pdf), 2015, <NAME> et. al. * [*A parallel simulated annealing method for the vehicle routing problem with simultaneous pickup–delivery and time windows*](https://www.researchgate.net/profile/Chao_Wang213/publication/272753635_A_parallel_simulated_annealing_method_for_the_vehicle_routing_problem_with_simultaneous_pickup-delivery_and_time_windows/links/5ac6e5cea6fdcc8bfc7f86f9/A-parallel-simulated-annealing-method-for-the-vehicle-routing-problem-with-simultaneous-pickup-delivery-and-time-windows.pdf), 2014, Chao Wang et. al. * [*Feature-based tuning of simulated annealing applied to the curriculum-based course timetabling problem*](https://arxiv.org/pdf/1409.7186.pdf), 2015, <NAME> et. al. **Analysis of Quote in the Question** The quote in the question is from page 125 of *Artificial Intelligence: A Modern Approach*, <NAME> and <NAME>, 2010, 3rd Edition. The quote begins with the statement, "A hill-climbing algorithm that never makes 'downhill' moves toward states with lower value (or higher cost) is guaranteed to be incomplete," which is not strictly true. The stated guarantee has at least two important exceptions. * The class of hills being climbed have only one peak * The search is executed using parallel computing architecture scaled such that search granularity includes no more than one peak per processing unit Describing simulated annealing using the analogy of combining inverted hill climbing and random walk, as <NAME> explains it, is not as clear and technically accurate as the original analogy. It is often better to find original sources of ideas and read them than to read simplified explanations. The original ideas may be just as easy or easier to understand than the textbook paraphrases (which is why the best textbooks simply quote the originating authors). **Source of the Term** The original algorithm termed *simulated annealing* is introduced in *Optimization by Simulated Annealing*, Kirkpatrick et. al.1, which may not qualify as one one explicitly employed by AI researchers or practitioners on a daily basis. Simulating the atomic motion of metals during annealing is the first of several approaches to injecting pseudo-random perturbations into convergence mechanisms. An approximation of a ${\chi}^2$ distribution with $k$ degrees of freedom is a more progressive injection source. These approaches share the common goal of avoiding the mistaking of a local minimum in loss surface as its global minimum. Such mistaken conclusion causes a failure to achieve an optimal learning state according to the criteria the loss function represents. As can be seen in the below excerpts, the original article is a good read and sets a foundation of understanding. Such a foundation will assist in understanding all methods used avoid local minima using stochastic injection. > > Iterative improvement consists of a search in this coordinate space for > rearrangement steps which lead downhill. Since this search usually gets stuck in a local but not a global optimum, it is customary to carry out the process several times, starting from different randomly generated configurations, and save the best result. > > > ... > > > Metropolis et al 2, in the earliest days of scientific computing, introduced a simple algorithm that can be used to provide an efficient simulation of a collection of atoms in equilibrium at a given temperature. > > > ... > > > Random numbers uniformly distributed in the interval (0,l) are a convenient means of implementing the random part of the algorithm. > > > ... > > > Using the cost function in place of the energy and defining configurations by a set of parameters {$x\_i$}, it is straightforward with the Metropolis procedure to generate a population of configurations of a given optimization problem at some effective temperature. This temperature is simply a control parameter in the same units as the cost function. The simulated annealing process consists of first "melting" the system being optimized at a high effective temperature, then lowering the temperature by slow stages until the system "freezes" and no further changes occur. > > > ... > > > Simulated annealing with Z-moves improved the random routing by 57 percent, averaging results for both x and y links. > > > --- **References** [1] [*Optimization by Simulated Annealing*](https://www.jstor.org/stable/1690046), Science S. Kirkpatrick, <NAME> and <NAME>, Science New Series, Vol. 220, No. 4598, May 1983, pp. 671-680 [2] <NAME>, <NAME>, <NAME>., <NAME>, J. Chem. Phys. 21. 1087 110511 Upvotes: 2 <issue_comment>username_3: <http://www.persion.info/projects/antenna_annealing/> Using simulated annealing to evolve ideal antennas. Upvotes: 0
2018/12/12
1,329
4,657
<issue_start>username_0: What kind of problems is simulated annealing better suited for compared to genetic algorithms? From my experience, genetic algorithms seem to perform better than simulated annealing for most problems.<issue_comment>username_1: Simulated annealing algorithms are generally better at solving mazes, because they are less likely to get suck in a local minima because of their probabilistic "mutation" method. See [here](https://www.mathworks.com/help/gads/what-is-simulated-annealing.html). Genetic algorithms are better at training neural networks, because of their genetically inspired training algorithm. This makes them more versatile and efficient in more complex situations. Upvotes: -1 <issue_comment>username_2: > > Simulated Annealing vs genetic algorithm? > > > Simulated annealing is a materials science analogy and involves the introduction of noise to avoid search failure due to local minima. See images below. To improve the odds of finding the global minimum rather than a sub-optimal local one, a stochastic element is introduced by simulating Brownian (thermal) motion. Variants of simulated annealing include injection of random numbers with various distributions and the averaging effect of mini-batching (dividing a batch into segments and performing network parameter adjustment after each). Genetic algorithms are search methods based on principles of mutation, meiosis, symbiosis, test, elimination of inadequacy, and recursion. The advantages of such approaches is the simulation of sexual reproduction, where the possibility of dominant genetic features from two individuals producing a child individual containing the best of both exists. In a population of children, the probability of such a hybrid emerging is higher. Over several generations, even higher than that. > > What kind of problems does simulated annealing perform better than genetic algorithms if any? > > > This question can only be answered well if comparing original, pure versions of both, not the variants that have developed since their introduction. Simulated annealing or other stochastic gradient descent methods usually work better with continuous function approximation requiring high accuracy, since pure genetic algorithms can only select one of two genes at any given position. > > From my experience, genetic algorithm seems to perform better than simulated annealing for most problems. > > > Those performance results would be of value to others and should be published as a paper, presented as an open source project, or published creative commons in the appropriate AI venue. At the very minimum, the results could be placed in the above question or an answer to it. [![Error Surface Showing How Global Optimum Can be Missed](https://i.stack.imgur.com/2tS9r.png)](https://i.stack.imgur.com/2tS9r.png) [![The Rastrigin Function](https://i.stack.imgur.com/b7G0p.png)](https://i.stack.imgur.com/b7G0p.png) --- **References** [1] [*Optimization by Simulated Annealing*](https://www.jstor.org/stable/1690046), Science S. Kirkpatrick, <NAME> and <NAME>, Science New Series, Vol. 220, No. 4598, May 1983, pp. 671-680 [2] <NAME>, <NAME>, <NAME>., <NAME>, J. Chem. Phys. 21. 1087 110511 * [*Optimised simulated annealing for Ising spin glasses*](https://arxiv.org/pdf/1401.1084.pdf), 2015, <NAME> et. al. * [*A parallel simulated annealing method for the vehicle routing problem with simultaneous pickup–delivery and time windows*](https://www.researchgate.net/profile/Chao_Wang213/publication/272753635_A_parallel_simulated_annealing_method_for_the_vehicle_routing_problem_with_simultaneous_pickup-delivery_and_time_windows/links/5ac6e5cea6fdcc8bfc7f86f9/A-parallel-simulated-annealing-method-for-the-vehicle-routing-problem-with-simultaneous-pickup-delivery-and-time-windows.pdf), 2014, <NAME> et. al. * [*Feature-based tuning of simulated annealing applied to the curriculum-based course timetabling problem*](https://arxiv.org/pdf/1409.7186.pdf), 2015, <NAME> et. al. **Images from Other Answers** * [If digital values are mere estimates, why not return to analog for AI?](https://ai.stackexchange.com/questions/7328/if-digital-values-are-mere-estimates-why-not-return-to-analog-for-ai/7982#7982) * [Method to check goodness of combinatorial optimization algorithm implementation](https://ai.stackexchange.com/questions/10044/method-to-check-goodness-of-combinatorial-optimization-algorithm-implementation/10092#10092), plotted from <https://github.com/facebookresearch/nevergrad/blob/master/nevergrad/functions/corefuncs.py> Upvotes: 2
2018/12/12
2,298
9,113
<issue_start>username_0: This question is about **Reinforcement Learning** and **variable action spaces for every/some states**. ### Variable action space Let's say you have an MDP, where the number of actions varies between states (for example like in Figure 1 or Figure 2). We can express a variable action space formally as $$\forall s \in S: \exists s' \in S: A(s) \neq A(s') \wedge s \neq s'$$ That is, for every state, there exists some other state which does not have the same action set. In figures 1 and 2, there's a relatively small amount of actions per state. Instead imagine states $s \in S$ with $m\_s$ number of actions, where $1 \leq m\_s \leq n$ and $n$ is a really large integer. [![Some MDP's](https://i.stack.imgur.com/q2Huu.png)](https://i.stack.imgur.com/q2Huu.png) ### Environment To get a better grasp of the question, here's an environment example. Take Figure 1 and let it explode into a really large directed acyclic graph with a source node, huge action space and a target node. The goal is to traverse a path, starting at any start node, such that we'll maximize the reward which we'll only receive at the target node. At every state, we can call a function $M : s \rightarrow A'$ that takes a state as input and returns a valid number of actions. ### Approches 1. A naive approach to this problem (discussed [here](https://ai.stackexchange.com/q/7755/2444) and [here](https://ai.stackexchange.com/q/2219/2444)) is to define the action set equally for every state, return a negative reward whenever the performed action $a \notin A(s)$ and move the agent into the same state, thus letting the agent "learn" what actions are valid in each state. This approach has two obvious drawbacks: * Learning $A$ takes time, especially when the Q-values are not updated until either termination or some statement is fulfilled (like in [experience replay](https://datascience.stackexchange.com/q/20535/10640)) * We know $A$, why learn it? 2. Another approach ([first answer here](https://ai.stackexchange.com/a/8564/2444), also very much alike proposals from papers such as [Deep Reinforcement Learning in Large Discrete Action Spaces](https://arxiv.org/pdf/1512.07679) and [Discrete Sequential Prediction of continuous action for Deep RL](https://arxiv.org/pdf/1705.05035)) is to instead predict some scalar in continuous space and, by some method, map it into a valid action. The papers are discussing how to deal with large discrete action spaces and the proposed models seem to be a somewhat solution for this problem as well. 3. Another approach that came across was to, assuming the number of different action set $n$ is quite small, have functions $f\_{\theta\_1}$, $f\_{\theta\_2}$, ..., $f\_{\theta\_n}$ that returns the action regarding that perticular state with $n$ valid actions. In other words, the performed action of a state $s$ with 3 number of actions will be predicted by $\underset{a}{\text{argmax}} \ f\_{\theta\_3}(s, a)$. None of the approaches (1, 2 or 3) are found in papers, just pure speculations. I've searched a lot, but I cannot find papers directly regarding this matter. **Does anyone know any paper regarding this subject? Are there other approaches to deal with variable action spaces?**<issue_comment>username_1: > > Does anyone know any paper regarding this subject? > > > I'm not familiar with any off the top of my head. I do know that the vast majority of Reinforcement Learning literature focuses on settings with a fixed action space (like robotics where your actions determine how you attempt to move/rotate a particular part of the robot, or simple games where you always have the same set of actions to move and maybe ''shoot'' or ''use'' etc.). Another common class of settings is where the action space can easily be treated as if it always were the same (by enumerating all actions that ever could be legal in some state), and filtering out illegal actions in some sort of post-processing steps (e.g. RL work in board games). So, there might be something out there, but it's certainly not common. Most RL people like to involve as little domain knowledge as possible, and I suppose that a function that generates a legal set of actions given a particular state can very much be considered to be domain knowledge. > > Are there other approaches to deal with variable action spaces? > > > The problem you describe is mostly a problem in **Reinforcement Learning with function approximation**, in particular, function approximation using Neural Networks. If you can get away with using tabular RL algorithms, the problem instantly disappears. For example, a table of $Q(s, a)$ values as commonly used in the tabular, value-based algorithms does not need to contain entries for all possible $(s, a)$ pairs; it's fine if it only contains entries for $(s, a)$ pairs such that $a$ is legal in $s$. Variable action spaces primarily turn into a problem in Deep RL approaches, **because we normally work with a fixed neural network architecture**. A DQN-style algorithm involves neural networks that take feature vectors describing states $s$ as inputs, and provide $Q(s, a)$ estimates as outputs. This immediately implies that we need one output node for every action, which means you have to enumerate all the actions, which is where your problem comes in. Similarly, policy gradient methods traditionally also require one output node per action, which again means you have to be able to enumerate all the actions in advance (when determining the network architecture). If you still want to use Neural Networks (or other kinds of function approximators with similar kinds of inputs and outputs), the key to addressing your problem (if none of the suggestions you've already listed in the question are to your liking) is to **realize that you'll have to find a different way to formulate your inputs and outputs, such that you are no longer required to enumerate all actions in advance**. The only way I can think of doing that really is if you are able to compute meaningful input features for complete state-action pairs $(s, a)$. If you can do that, then you could, for example, build neural networks which: * Take a feature vector $x(s, a)$ as input, which describes (hopefully in some meaningful way) the full pair of the state $s$ **and** the action $a$ * Produce a single $\hat{Q}(s, a)$ estimate as output, for the specific pair of state + action given as input, rather than producing multiple outputs. If you can do that, then in any given state $s$ you can simply loop through all the legal actions $A(s)$, compute $\hat{Q}(s, a)$ estimates for them all (**note**: we now require $\lvert A(s) \rvert$ passes through the network rather than just a single pass as would normally be required in DQN-style algorithms), and otherwise proceed similarly to standard DQN-style algorithms. Obviously, the requirement of having good input features for actions is not always going to be satisfied... but I doubt there are many good ways to get around that. It's very similar to the situation with states really. In tabular RL, we enumerate all states (and all actions). With function approximation, we usually still enumerate all actions, but avoid the enumeration of all states by replacing them with meaningful feature vectors (which enables generalization across states). If you want to avoid enumerating actions, you'll in a very similar way have to have some way of generalizing across actions, which again means you need features to describe actions. Upvotes: 4 <issue_comment>username_2: > > 3. Another approach that came across was to, assuming the number of different action set $n$ is quite small, have functions $f\_{\theta\_1}$, $f\_{\theta\_2}$, ..., $f\_{\theta\_n}$ that returns the action regarding that perticular state with $n$ valid actions. In other words, the performed action of a state $s$ with 3 number of actions will be predicted by $\underset{a}{\text{argmax}} \ f\_{\theta\_3}(s, a)$. > > > That sounds pretty complicated and the number of different action sets is usually very high, even for the simplest games. Imagine checkers, ignore promotions and jumping, for simplicity, and there are some $7 \cdot 4 \cdot 2=56$ possible actions (which is fine), but the number of different sets of these actions is much higher. It's actually difficult to compute how many such sets are possible in a real game - it's surely much less than $2^{56}$, but also surely far too big for being practical. > > Are there other approaches to deal with variable action spaces? > > > Assuming the number of actions is not too big, you can simply ignore actions which don't apply in a given state. That's different from learning - you don't have to learn to return negative reward for illegal actions, you simply don't care and select the *legal* action returning the best award. --- Note that your expression $$\forall s \in S: \exists s' \in S: A(s) \neq A(s') \wedge s \neq s'$$ can be simplified to $$\forall s \in S: \exists s' \in S: A(s) \neq A(s')$$ or even $$|A(s)|\_{s \in S} > 1$$ Upvotes: 2
2018/12/13
880
3,776
<issue_start>username_0: When adding dropout to a neural network, we are randomly removing a fraction of the connections (setting those weights to zero for that specific weight update iteration). If the dropout probability is $p$, then we are effectively training with a neural network of size $(1−p)N$, where $N$ is the total number of units in the neural network. Using this logic, there is no limit how big I can make a network, as long as I proportionately increase dropout, I can always effectively train with the same sized network, and thereby just increasing the number of "independent" models working together, making a larger ensemble model. Thereby **improving generalization** of the model. For example, if a network with 2 units already achieves good results in the training set (but not in unseen data -i.e validation or test sets-), also a network with 4 units + dropout 0.5 (ensemble of 2 models), and also a network with 8 units + dropout 0.75 (ensemble of 4 models)... and also a network with 1000 units with a dropout of 0.998 (ensemble of 500 models)! In practice, it is recommended to keep dropout at $0.5$, which advises against the approach mentioned above. So there seem to be reasons for this. What speaks against blowing up a model together with an adjusted dropout parameter?<issue_comment>username_1: There is no incentive to increase the size of the model for not reason. If a model of size x gives the best possible performance, there is no reason to use a model of size 2\*x with 0.5 dropout during training. Usually we want to find the smallest possible model with the best performance. Inflating the model just results in higher computational requirements. You are basically suggesting to use dropout to allow the network to learn the same features more than once (creating a redundancies in the model). That is not the purpose of dropout. Dropout is used to enable the network break unnecessary correlations which occur in the training set. For example if class 1 is the only one that contains in it features A and B, but all the training samples always feature them together. The dropout process can make the model realize that even just one of them is enough to point to class 1. Upvotes: 2 <issue_comment>username_2: Increasing layer size while increasing dropout is possible, but will not lead to more effective learning when taken to the extreme. Dropout is a regularization technique which actually makes the model "worse" for the sake of increasing generalization capabilities. With increased dropout you increase the negative impacts of dropout (learning less), while not significantly increasing the upsides (reducing overfitting). When using double the neurons and increasing dropout respectively, you will have to show the model double the amount of data to learn the same amount, since only half the neurons get updated each iteration. If you always use the same amount of data, this means you would have to show the model each sample twice to achieve the same results. This is much worse than simply training one iteration with less dropout. Additionally, with high dropout the rate of neurons "firing together" is reduced to a minimum, meaning the neurons are almost independent of each other, resulting in a great loss of computational power. The highest Dropout values reccommended are no higher than 0.8: > > A good value for dropout in a hidden layer is between 0.5 and 0.8. Input layers use a larger dropout rate, such as of 0.8. > > > <https://machinelearningmastery.com/dropout-for-regularizing-deep-neural-networks/> Also check out [this question](https://stackoverflow.com/questions/47892505/dropout-rate-guidance-for-hidden-layers-in-a-convolution-neural-network) for a more detailed answer. Upvotes: 0
2018/12/14
1,406
6,109
<issue_start>username_0: I've been re-reading the [Wikipedia article on the Chinese Room argument](https://en.wikipedia.org/wiki/Chinese_room) and I'm... actually quite unimpressed by it. It seems to me to be largely a semantic issue involving the conflation of various meanings of the word "understand". Of course, since people have been arguing about it for 25 years, I doubt very much that I'm right. However... the argument can be thought of as consisting of several layers, each of which I can explain away (to myself, at least). * **There is the assumption that being able to understand (interpret a sentence in) a language is a prerequisite to speaking in it.** Let's say that I don't speak a word of Chinese, but I have access to a big dictionary and a grammar table. I could work out what each sentence means, answer it, and then translate that answer back into Chinese, all without speaking Chinese myself. Therefore, being able to interpret (parse) a language is not a prerequisite to speaking it. (Of course, by [the theory of extended cognition](https://en.wikipedia.org/wiki/Extended_cognition) I *can* interpret the language, but we can all agree that the books and lookup tables are simply a source of information and not an algorithm; I'm still the one using them.) Nevertheless, this task can be removed by a dumb natural language parser and a dictionary, converting Chinese to the set of concepts and relationships encoded in it and vice versa. There is no understanding involved at this stage. * **There is the assumption that being able to understand (identify and maintain a train of thought about concepts in) a language is a prerequisite to speaking in it.** We've already optimised away the language, to a set of concepts and relationships between concepts. Now all we need is another lookup table: a sort of verbose dictionary that maps concepts to other concepts and relationships between them. For example, one entry for "computer" might be "performs calculations" and another might be "allows people to play games". An entry for "person" might be "has opinions", and another might be "has possessions". Then an algorithm (yes, I'm introducing one now!) would complete a simple optimisation problem to find a relevant set of concepts and relationships between them, and turn "I like playing computer games" into "What is your favourite game to play on a computer?" or, if it had some entries on "computer games", "Which console do you own?". The only "understanding" here, apart from the dumb optimisation algorithm, is the knowledge bank. This could conceivably be parsed from Wikipedia, but for a good result it would probably be at least somewhat hand-crafted. Following this would fall down, because this process wouldn't be able to talk about itself. * **There is the assumption that being able to understand ("know" how information in affects one's self) a language is a prerequisite to speaking in it.** A set of "opinions" and such associated with the concept "self" could be implemented into the knowledge bank. All meta-cognition could be emulated by ensuring that the knowledge bank had information about cognition in it. However, this program would still just be a mapping from arbitrary inputs to outputs; even if the knowledge bank was mutable (so that it could retain the current topics from sentence to sentence and learn new information) it would still, for example, not react when a sentence is repeated to it verbatim 49 times. * **There is the assumption that being able to have effective meta-cognition is a prerequisite to speaking in a language.** Except... there's not. The program described would probably pass the Turing Test. It certainly fulfils the criteria of speaking Chinese. And yet it clearly doesn't think; it's a glorified search engine. It'd probably be able to solve maths problems, would be ignorant of algebra unless somebody taught it to it (in which case, with sufficient teaching, it'd be able to carry out algebraic formulae; Haskell's type system can do this without ever touching a numerical primitive!), and would probably be Turing-complete, and yet wouldn't think. And that's OK. So why is the Chinese Room argument such a big deal? What have I misinterpreted? This program understands the Chinese language as much as a Python interpreter understands Python, but there is no conscious being to "understand". I don't see the philosophical problem with that.<issue_comment>username_1: If you check the Wikipedia article on the argument that you linked, in the [History](https://en.wikipedia.org/wiki/Chinese_room#History) section, you'll note the following statement: > > Most of the discussion consists of attempts to refute it. > > > I think this directly answers the question, > > Why is the Chinese Room argument such a big deal? > > > The Chinese Room Argument was a relatively early attempt in the intermingling of Philosophy and Computer Science to make as concrete an argument on the definition of a "mind", "understanding", and whether or not these can be created with a program. That is, it conjectures that a "mind" cannot. It's famous in part because the concreteness of this argument means that a counter-argument can be made in kind. That is, the argument spawned a large quantity of refutations, attacking the argument from a large number of vectors, outlined later in the argument. Put another way, > > The Chinese Room Argument is such a big deal because of how many people in the field have found value in refuting it. > > > Incidentally, your post provides more evidence to this point. Upvotes: 4 [selected_answer]<issue_comment>username_2: The Chinese room argument is such a big deal because it takes the concept of the Turing machine and Turing's conception of the electronic digital computer (so-called) as a practical version of the universal Turing machine, and shows that the resulting concept of machine computation does not allow the creation of an internal semantics (knowledge). Explaining why this is the case is is a bit of a fraught task, though. Upvotes: 1
2018/12/15
586
2,440
<issue_start>username_0: I'm completely new at ML, but really interested. To be honest, read many articles about it, but still don't understand the workings of it. I just started to understand this example: <https://storage.googleapis.com/tfjs-examples/mnist/dist/index.html> My thinking about it is that TF has some resources, some examples of how numbers look like, and try to match them with the ones in the test. I saw that sometimes the test changes a right prediction to a wrong, but makes better and better predictions. But how? I think that the program doesn't know the right predictions (and this way it won't know the wrong ones). In the training how it makes better predictions? Test by test, from what exceptions it will change it's predictions? What happens in a new test?<issue_comment>username_1: If you check the Wikipedia article on the argument that you linked, in the [History](https://en.wikipedia.org/wiki/Chinese_room#History) section, you'll note the following statement: > > Most of the discussion consists of attempts to refute it. > > > I think this directly answers the question, > > Why is the Chinese Room argument such a big deal? > > > The Chinese Room Argument was a relatively early attempt in the intermingling of Philosophy and Computer Science to make as concrete an argument on the definition of a "mind", "understanding", and whether or not these can be created with a program. That is, it conjectures that a "mind" cannot. It's famous in part because the concreteness of this argument means that a counter-argument can be made in kind. That is, the argument spawned a large quantity of refutations, attacking the argument from a large number of vectors, outlined later in the argument. Put another way, > > The Chinese Room Argument is such a big deal because of how many people in the field have found value in refuting it. > > > Incidentally, your post provides more evidence to this point. Upvotes: 4 [selected_answer]<issue_comment>username_2: The Chinese room argument is such a big deal because it takes the concept of the Turing machine and Turing's conception of the electronic digital computer (so-called) as a practical version of the universal Turing machine, and shows that the resulting concept of machine computation does not allow the creation of an internal semantics (knowledge). Explaining why this is the case is is a bit of a fraught task, though. Upvotes: 1
2018/12/16
925
3,999
<issue_start>username_0: I have multiple pictures that look exactly like the one below this text. I'm trying to train `CNN` to read the digits for me. Problem is isolating the digits. They could be written in any shape, way, and position that person who is writing them wanted to. I thought of maybe training another `CNN` to recognize the position/location of the digits, but I'm not sure how to approach the problem. But, I need to get rid of that string and underline. Any clue would be a great one. Btw. I would love to get the 28x28 format just like the one in `MNIST`. Thanks up front. [![enter image description here](https://i.stack.imgur.com/wOMma.jpg)](https://i.stack.imgur.com/wOMma.jpg)<issue_comment>username_1: I think one approach you can try to segment the digits and Connected Components Labeling (<https://en.wikipedia.org/wiki/Connected-component_labeling>). With it, you'll end up with a label for each letter and then you can try to find the convex hull of the letter. After that, just crop a square for each convex hull and input it to your CNN. Notice that it will only if there is at least one pixel between the letters... Upvotes: 1 <issue_comment>username_2: Use of CNNs to recognize digits is a reasonable approach as of this answer's writing, the effectiveness of which can be enhanced via [*Sensitive Error Correcting Output Codes*](https://link.springer.com/chapter/10.1007%2F11503415_1), (2005, <NAME>, <NAME>) according to Shuo Yang et. al. in [*Deep Representation Learning with Target Coding*](https://www.aaai.org/ocs/index.php/AAAI/AAAI15/paper/viewFile/9773/9821). Given a sufficient CNN depth, it can be trained to recognize the digits with the field name and underscore intact. Automatically removing them would generally only be possible after they are recognized using the CNN approach anyway. Isolating the digits from the field name and the underscore would be accomplished via the same approach used to isolate the digits from one another. There is no reason to perform these two conceptual tasks in series and consume additional development time and resources, when a single deep CNN can locate the digits and dismiss the field name and underscore. This is similar to animal vision. A mosquito's visual pathway distinguishes an oncoming object from the background to avoid a swat using the same network it uses to recognize the object. What would be helpful would be to normalize the input by finding a two dimensional plateau (much like a geological one) representing the distribution of black pixels in horizontal and vertical dimensions. Summing rows and columns of pixels and using a heuristic algorithm to find a rectangle outside of which there is only noise may be sufficient. Then trim and scale, which removes redundancy and may improve CNN training speed, accuracy, and/or reliability by distributing the image more widely over the input layer and likely reducing the layer count by at least one. Another approach is to use overall features of the form in which the field resides to rotate, position, and scale the image so that the field name and underscore is within a fraction of a pixel from an expected location on the form. In this case training a separate CNN is less redundant and has a higher return on development investment. In such a design, the field name and underscore can be removed by subtraction, however this may disturb field value recognition because the handwriting may overlap items blanked. It will require experimentation to determine the accuracy and reliability hit (diminution) from such disturbance. **Addendum in Response to Comment** For the first approach, a Field Name and Underscore Superimposer will need to be designed and implemented to transform the training example set features, the pixel arrays, but preserve the labels corresponding to each example. The hyper-parameter values that work best without the superimposition may need modification to work best with it. Upvotes: 0
2018/12/16
1,132
4,125
<issue_start>username_0: I've been reading up on how NEAT (Neuro Evolution of Augmenting Topologies) works and I've got the main idea of it, but one thing that's been bothering me is how you split the different networks into species. I've gone through the algorithm but it doesn't make a lot of sense to me and the paper I read doesn't explain it very well either so if someone could give an explanation of what each component is and what it's doing then that would be great thanks. The two equations are: $\delta = \frac{c\_{1}E}{N} + \frac{c\_{2}D}{N} + c\_{3} .\overline{W}$ $f\_{i}^{'} = \frac{f\_i}{\sum\_{j=1}^{n}sh(\delta(i,j))}$ By the way, I can understand the greek symbols so you don't need to explain those to me [The original paper](http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf)<issue_comment>username_1: The first equation deals with distance. **Delta**, or distance, is the measure of how **compatible** two genomes are with each other. `c1`, `c2` and `c3` are parameters you set to dictate the importance of `E`, `D` and `W`. Note that if you change c`c1`, `c2` or `c3`, you will most likely also have to change dt, which is the distance threshold, or the maximum distance apart 2 genomes can be before they are separated into different species. `E` represents the total number of **excess** genes. `D` represents the total number of **disjoint** genes in both genomes, `W` represents the total **weight difference** between genes that match, and finally, `N` represents the number of connections / genes the genome with the larger number of connections has. For example, take the following 2 genomes: ``` [[1,.25][2,.55],[4,.78],[6,.2]] and [[1,.15][3,.92],[5,.37]] ``` Where the 0 index represents innovation number and the 1 index represents weight value. `E` would be 1, since there is 1 excess gene, gene `6`. `D` would be 4, since connections `2` and `4` are not in genome 2, and connections `3` and `5` are not in genome 1. `W` would be .10, since only connection `1` is shared between the two genomes. The second formula is a bit more complicated. From my understanding, correct me if I'm wrong, this is a formula for adjusting fitness. `f′i` is the adjusted fitness, which will replace the original fitness, `fi`. For every genome `j` in the **entire population**, yes, entire population and not just every genome in its specie, it will calculate the distance between `j` and `i`, `i` being the genome of fitness `fi`. Then it will sum up all the distance values, and divide the original fitness `fi` by the total distance sum, and set `f'i` to that. Next, > > Every species is > assigned a potentially different number of offspring in proportion to the sum of adjusted fitnesses `f`i` of its member organisms. > > > This assigning of number of species offspring is used so that one specie can't take over the entire population, which is the whole point of speciation in the first place, so in conclusion, these two formulas are vital to the function and efficiency of the NEAT algorithm. Upvotes: 4 [selected_answer]<issue_comment>username_2: Even if this thread is old i want to add something to your answer, regarding to the second formula. The fitness sharing mechanism works like this: ``` foreach(s in species): foreach(i in s.individuals): i.fitness /= s.Count; ``` So in each species, the adjusted fitness of an individual is divided by the "clients" in that species. Why? This is how the formula works: * f'[i] is the adjusted/shared fitness of agent i * f[i] is the current fitness of agent i * sh(i,j) returns 1 if both i & j are compatible (considering the first formula your provided does not exceed the threshold) or 0 otherwise. * Sum(sh(i,j)) just counts how many individuals are in the same species with i, plus itself (because i can be equal to j while parsing through Sigma). So if you have a Species class with a List of clients, Sum(...) is just list.Count. Everything is explained clearly in Stanley's paper at page 110. In this situation, the average fitness of a species is just the sum of all clients' adjusted fitness. Upvotes: 0
2018/12/17
468
2,094
<issue_start>username_0: If I got well the idea of dropout, it allows improving the sparsity of the information that comes from one layer to another by setting some weights to zero. On the other hand, pooling, let's say max-pooling, takes the maximum value in a neighborhood, reducing as well to zero, the influence of values apart from this maximum. Without considering the shape transformation due to the pooling layer, can we say that pooling is a kind of a dropout step? Would the addition of a dropout (or DropConnect) layer, after a pooling layer, make sense in a CNN? And does it help the training process and generalization property?<issue_comment>username_1: Dropout and Max-pooling are performed for different reasons. Dropout is a regularization technique, which affects only the training process (during evaluation, it is not active). The goal of dropout is reduce unnecessary feature dependencies in the network, allowing it to be simpler and improves its generalization abilities (reduces overfitting). In simple terms, it helps the model to learn that some features are an "OR" and not an "AND" requirements. Max-pooling is not a regularization technique and it is part of the model's architecture, so it is also used during evaluation. The goal of max-pooling is to down-sample an input representation. As a result the model becomes less sensitive to some translations (improving translation invariance). As for your last question, yes. dropout can be used after a pooling layer. Upvotes: 4 [selected_answer]<issue_comment>username_2: I think we would consider regularization and downsampling better in this way: 1. dropout it puts some input value (neuron) for the next layer as 0, which makes the current layer a sparse one. So it reduces the dependence of each feature in this layer. 1. pooling layer the downsampling directly remove some input, and that makes the layer "smaller" rather than "sparser". The difference can be subtle but clear enough. That's the root reason why the former also affect the evaluation/test process but the later does not. Upvotes: 2
2018/12/18
759
2,844
<issue_start>username_0: I've been given an assignment to create a neural network that will suggest a Croatian word for a word given in any other European language (out of those found [here](https://www.indifferentlanguages.com/words/beer)). The words are limited to drinks you can find on a bar menu. I've looked at many NN examples, both simple and complex, but I'm having trouble with understanding how to normalize the input. For example, words "beer", "birra" and "cervexa" should all translate to "pivo". If I include those 3 in the training set, and after the network has finished training I input the word "bier", the output should be "pivo" again. I'm not looking for a working solution to this problem, I just need a nudge in the right direction regarding normalization.<issue_comment>username_1: So, the `normalization` as you call it is just encoding the word into some vector of fixed length. After you encode it, you should be able to decode it and match the words. You should google a little, for a `seq2seq` problems and `Encoder/Decoder` structure. There are encoder-decoder frameworks out there and lots of resources. You don't care about a language so just pretend that words like "beer" and "birra" have the same meaning in Croatian and in this case, it is "pivo". Upvotes: 0 <issue_comment>username_2: The training examples are not mentioned, but, assuming the assignment involves supervised learning, normalization is, in this case, mapping the inputs and outputs to binary values. Translation, in this simplified context, is a map of strings to strings, which isn't really an AI device by contemporary standards. Since an artificial network is given as a requirement for the solution, the goal is to train the network to act like a hash map. $$ \Big\{..., \; \big( [\text{"beer", "birra", "cervexa"}]: \text{"pivo"} \big) , \; ...\Big\} $$ $$ \Downarrow $$ $$ \Big\{..., \; \big(\text{"beer" : "pivo"}), (\text{"birra" : "pivo"}), (\text{"cervexa" : "pivo"}\big), \; ...\Big\} $$ Assuming there is a list of pairs $(\mathcal{X}, \mathcal{Y})$, where $\mathcal{X}$ is the word in any of the source languages and $\mathcal{Y}$ is the word in the target language, and the vocabulary of both is known to have word counts of $X$ and $Y$ respectively, one can determine the input and output layer widths (cell counts) $w\_1$ and $w\_{\ell}$, where $\ell$ is the number of network layers. $$w\_1 = \text{ceiling} ( \log\_2{X} )$$ $$w\_{\ell} = \text{ceiling} ( \log\_2{Y} )$$ The assignment of source words to binary values is arbitrary. You can sort them by language and then by whatever common character encoding used (such as UTF-8) just for debugging purposes. The same is true of target words. A simple MLP (multi-layer perceptron) with mini-batch training using basic propagation map be appropriate. Upvotes: 1
2018/12/18
2,030
7,654
<issue_start>username_0: I am learning Reinforcement Learning from the lectures from <NAME>. I finished lecture 6 and went on to try SARSA with linear function approximator for MountainCar-v0 environment from OpenAI. A brief explanation of the MountainCar-v0 environment. The state is denoted by two features, position, and velocity. There are three actions for each state, accelerate forwards, don't accelerate, accelerate backward. The goal of the agent is to learn how to climb a mountain. The engine of the car is not strong enough to power directly to the top. So speed has to be built up by oscillating in the cliff. I have used a linear function approximator, written by myself. I am attaching my code here for reference :- ``` class LinearFunctionApproximator: ''' A function approximator must have the following methods:- constructor with num_states and num_actions get_q_value get_action fit ''' def __init__(self, num_states, num_actions): self.weights = np.zeros((num_states, num_actions)) self.num_states = num_states self.num_actions = num_actions def get_q_value(self, state, action): return np.dot( np.transpose(self.weights), np.asarray(state) )[action] def get_action(self, state, eps): return randint(0, self.num_actions-1) if uniform(0, 1) < eps else np.argmax( np.dot(np.transpose(self.weights), np.asarray(state)) ) def fit(self, transitions, eps, gamma, learning_rate): ''' Every transition in transitions should be of type (state, action, reward, next_state) ''' gradient = np.zeros_like(self.weights) for (state, action, reward, next_state) in transitions: next_action = self.get_action(next_state, eps) g_target = reward + gamma * self.get_q_value(next_state, next_action) g_predicted = self.get_q_value(state, action) gradient[:, action] += learning_rate * (g_target - g_predicted) * np.asarray(state) gradient /= len(transitions) self.weights += gradient ``` I have tested the gradient descent, and it works as expected. After every epoch, the mean squared error between current estimate of Q and TD-target reduces as expected. Here is my code for SARSA :- ``` def SARSA(env, function_approximator, num_episodes=1000, eps=0.1, gamma=0.95, learning_rate=0.1, logging=False): for episode in range(num_episodes): transitions = [] state = env.reset() done = False while not done: action = function_approximator.get_action(state, eps) next_state, reward, done, info = env.step(action) transitions.append( (state, action, reward, next_state) ) state = next_state for i in range(10): function_approximator.fit(transitions[::-1], eps, gamma, learning_rate) if logging: print('Episode', episode, ':', end=' ') run_episode(env, function_approximator, eps, render=False, logging=True) ``` Basically, for every episode, I fit the linear function approximator to the current TD-target. I have also tried running fit just once per episode, but that also does not yield any winning episode. Fitting 10 times ensures that I am actually making some progress towards the TD-target, and also not overfitting. However, after running over 5000 episodes, I do not get a single episode where the reward is greater than -200. Eventually, the algorithm choses one action, and somehow the Q-value of other actions is always lesser than this action. ``` # Now, let's see how the trained model does env = gym.make('MountainCar-v0') num_states = 2 num_actions = env.action_space.n function_approximator = LinearFunctionApproximator(num_states, num_actions) num_episodes = 2000 eps = 0 SARSA(env, function_approximator, num_episodes=num_episodes, eps=eps, logging=True) ``` I want to be more clear about this. Say action 2 is the one which is the action which gets selected always after say 1000 episodes. Action 0 and action 1 have somehow, for all states, have their Q-values reduced to a level which is never reached by action 2. So for a particular state, action 0 and action 1 may have Q-values of -69 and -69.2. The Q-value of action 2 will never drop below -65, even after running the 5000 episodes.<issue_comment>username_1: On doing some research on why this problem might be occurring, I delved into some statistics of the environment. Interestingly, after a small number of episodes (~20), the agent always chooses to take only one action (this has been mentioned in the question too). Also, the Q values of the state-action pairs do not change a lot after just about 20 episodes. Same is the case for policy of environment, as may be expected. The problem is that, although all the individual updates are being done correctly, the following scenario occurs. The update equation used is the following :- ``` Q(s1, a1) <- r1 + gamma * Q(s2, a2) ``` Now, any update to function approximator means that the Q value changes not just for the updated (state, action) pair, but for all (state, action) pairs. How much it changes for any specific (state, action) pairs is another issue. Now, since our function approximator is altered, next time we use the previous equation for updating any other state, we use the following equation :- ``` Q(s3, a3) <- r3 + gamma * Q(s4, a4) ``` But since Q has itself been changed, the target value of the record 3 changes. This is not desirable. Over time, all the changes cancel each other and Q value remains roughly the same. By using something known as the target function approximator(target network), we can maintain an older version of function approximator, which is used to get the Q-value of next state-action pair while the time of update. This helps avoid the problem and can be used to solve the environment. Upvotes: 2 [selected_answer]<issue_comment>username_2: One possible cause of SARSA with a linear approximator failing to learn a good policy for the Mountain Car problem is that you are not encoding the environment state, the position and velocity. In David Silver's Lecture 6 that you mention in your question, he describes the state encoding, which in this case is a tile coding, here: <https://youtu.be/UoPei5o4fps?t=3626>. This coarse coding is described in more detail in the Sutton and Barto book, Reinforcement Learning: An Introduction (<http://incompleteideas.net/book/the-book.html>), in Chapter 9, where different state encodings for linear approximators are described, and Chapter 10, where the Mountain Car problem is discussed. In my experience, using a tile coding worked in combination with a linear function to solve the Mountain Car task. Using no encoding did not work. The following plot shows the max q-values (the policy) when using Sarsa with no encoding. The points are colored with the corresponding action of the max q-value to more clearly show the policy the agent will follow. [![Sarsa q-values with no encoding](https://i.stack.imgur.com/VG9oW.png)](https://i.stack.imgur.com/VG9oW.png) This planar policy produces an average score of -200.0 per episode, averaged over 100 episodes. Contrast that policy with the following graph of q-values produced by using Sarsa in combination with a tile encoding. [![Sarsa q-values with tile encoding](https://i.stack.imgur.com/Nbb3V.png)](https://i.stack.imgur.com/Nbb3V.png) The policy of this agent scores -102.9 per episode, averaged over 100 episodes. It might be hard to see in the graph, but it has the characteristic "spiral" of the learned graph from Figure 10.1 of the Sutton and Barto book. Upvotes: 2
2018/12/18
959
3,890
<issue_start>username_0: Once a book is published in a language, why can't the publishers use Google Translate AI or some similar software to immediately render the book in other languages? Likewise for Wikipedia: I'm not sure I understand why we need editors for each language. Can't the English Wikipedia be automatically translated into other languages?<issue_comment>username_1: Google has achieved significant progress in AI translation, but it's still no-where near a qualified human translator. Natural language translation is already very challenging, adding domain knowledge to the equation is too much even for Google. I don't think we have the technology to translate an arbitrary book from one language to another reliably. Upvotes: 3 [selected_answer]<issue_comment>username_2: This is an good question and I have to wonder if someday we might. It may simply be a matter of formalizing all of the concepts conveyed by humans, which is [emergent](https://en.wikipedia.org/wiki/Emergence), but has to be finite. *The present algorithms do not understand the content* in a human sense of meaning, but are refining a statistical model to continually produce more accurate output. You could do it today, and it actually has been done I am sure. There was a period back in the aughts of machine translated movie subtitles that were serviceable, but so bad as to be comical. (Humor that can be found in bad random translation is highly underrated;) A key difficulty is linguistic. The same word or phrase (or symbol) can mean many things, [see: [polysemy]](https://en.wikipedia.org/wiki/Polysemy) so often the sense in which you mean it is required. Another part of this is that words and symbols and [idioms](https://en.wikipedia.org/wiki/Idiom) may not have a direct counterpart in another language. If the literal meaning is different from the figurative meaning, but the algorithm only knows how to translate the literal meaning, it's a bad translation. As an example, try translating "[hair of the dog](https://en.oxforddictionaries.com/explore/what-is-the-origin-of-the-phrase-hair-of-the-dog/)" into [Chinese and back to English on Google translate](https://translate.google.com/#view=home&op=translate&sl=en&tl=zh-CN&text=hair%20of%20the%20dog). The result is "dog hair" which is not the intended meaning. The algorithm can learn that there is a figurative usage, but still has to know when to apply it as opposed to the literal. Without understanding the meaning of a phrase and the phrases leading to and from it (the [context](https://en.oxforddictionaries.com/definition/context)), the algorithm must rely on statistics. So it may be a function of [time](https://en.wikipedia.org/wiki/Time_complexity), [memory](https://en.wikipedia.org/wiki/Computational_resource) [algorithms sufficiently complex](https://ai.stackexchange.com/questions/2642/how-can-one-distinguish-between-an-ai-and-a-sufficiently-advanced-algorithm), and a sufficient [sample size](https://en.wikipedia.org/wiki/Sample_(statistics)). But, because language is continually evolving, there will always be instances in which the sample size is insufficient (new concepts or usage, new words.) My sense is that the present algorithms will become very good at translating in certain contexts, especially where the meaning is literal (asking for directions, asking the price, customary social interactions, etc.) but will never reach fully human capability without the capability to grasp the meaning. [Semantics](https://en.wikipedia.org/wiki/Semantics) vs. [syntactics](https://en.oxforddictionaries.com/definition/syntactics). Whether algorithms will ever be able to understand in the sense of humans is still very theoretical and a [subject of fierce debate](https://en.wikipedia.org/wiki/Symbol_grounding_problem), but until they do, human translators will likely be preferred. Upvotes: 1
2018/12/19
758
3,333
<issue_start>username_0: In short, imitation learning means learning from the experts. Suppose I have a dataset with labels based on the actions of experts. I use a simple binary classifier algorithm to assess whether it is good expert action or bad expert action. How is this binary classification different from imitation learning? Imitation learning is associated with reinforcement learning, but, in this case, it looks more like a basic classification problem to me. What is the difference between imitation learning and classification done by experts? I am getting confused because imitation learning relates to reinforcement learning while classification relates to supervised learning.<issue_comment>username_1: Imitation learning *is* supervised learning applied to the RL setting. In any general RL algorithm (such as Q-learning), the learning is done on the basis of the reward function. However, consider a scenario where you have available the optimal policy in the form of a table, mapping each state to each action. In this scenario you will not care about the rewards received - rather, you'd simply do a table lookup to decide the optimal action. This scenario is impractical in most settings because the table for the optimal policy will be too big. However, if you have enough entries from the table, you can use a general function approximator such as a neural network to find the optimal action. Again, you do not need to look at the rewards, but only at the state $\rightarrow$ action mappings. I do not know imitation learning in detail beyond this, but I suspect in the case of discrete actions (such as in Chess, Go), it would be trained with a cross-entropy objective as is typical of classification tasks. I suspect that the reason this has a different name in the RL setting is because this is different than how the conventional RL algorithms work. Also, much of RL thinking is inspired from everyday interaction / biology. Think of how we learn how to drive, or play sports such as soccer. Typically there is a coach who tells you what actions to take under different conditions, and you imitate those actions. Upvotes: 4 [selected_answer]<issue_comment>username_2: I also had the same question, but after looking at this two links: [this article](https://smartlabai.medium.com/a-brief-overview-of-imitation-learning-8a8a75c44a9c) and [this lecture](https://web.stanford.edu/class/cs237b/pdfs/lecture/lecture_10111213.pdf) I think we can say that behavioral cloning (which is the simplest way for doing imitation learning) is just normal supervised learning. But imitation learning could be associated with RL because it has other types (improvements) that involve learning while interacting with the environment like Dataset Aggregation, where you have an interactive expert that you can query for optimal actions to label observations obtained by rolling out the learned policy in the environment, and you repeat collecting the data and training the policy. This is done to mitigate the known problem of distributional drift in BC. More about it can be found [here](https://web.stanford.edu/class/cs237b/pdfs/lecture/lecture_10111213.pdf). Even with this interactive expert, I still think it is supervised learning, but I can understand why some people might associate it with RL. Upvotes: 2
2018/12/20
2,257
5,636
<issue_start>username_0: In the policy gradient method, there's a trick to reduce the variance of policy gradient. We use causality, and remove part of the sum over rewards so that only actions happened after the reward are taken into account (See here <http://rail.eecs.berkeley.edu/deeprlcourse/static/slides/lec-5.pdf>, slide 18). Why does it work? I understand the intuitive explanation, but what's the rigorous proof of it? Can you point me to some papers?<issue_comment>username_1: An important thing we're going to need is what is called the ["Expected Grad-Log-Prob Lemma here"](https://spinningup.openai.com/en/latest/spinningup/rl_intro3.html#expected-grad-log-prob-lemma) (proof included on that page), which says that (for any $t$): $$\mathbb{E}\_{\tau \sim \pi\_{\theta}(\tau)} \left[ \nabla\_{\theta} \log \pi\_{\theta}(a\_t \mid s\_t) \right] = 0.$$ Taking the analytical expression of the gradient (from, for example, slide 9) as a starting point: $$\begin{aligned} \nabla\_{\theta} J(\theta) &= \mathbb{E}\_{\tau \sim \pi\_{\theta}(\tau)} \left[ \left( \sum\_{t=1}^T \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) \right) \left( \sum\_{t=1}^T r(s\_t, a\_t) \right) \right] \\ % &= \sum\_{t=1}^T \mathbb{E}\_{\tau \sim \pi\_{\theta}(\tau)} \left[ \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) \sum\_{t'=1}^T r(s\_{t'}, a\_{t'}) \right] \\ % &= \sum\_{t=1}^T \mathbb{E}\_{\tau \sim \pi\_{\theta}(\tau)} \left[ \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) \sum\_{t'=1}^{t-1} r(s\_{t'}, a\_{t'}) + \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) \sum\_{t'=t}^T r(s\_{t'}, a\_{t'}) \right] \\ % &= \sum\_{t=1}^T \left( \mathbb{E}\_{\tau \sim \pi\_{\theta}(\tau)} \left[ \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) \sum\_{t'=1}^{t-1} r(s\_{t'}, a\_{t'}) \right] \\ + \mathbb{E}\_{\tau \sim \pi\_{\theta}(\tau)} \left[ \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) \sum\_{t'=t}^T r(s\_{t'}, a\_{t'}) \right] \right) \\ \end{aligned}$$ At the $t^{th}$ "iteration" of the outer sum, the random variables $ \sum\_{t'=1}^{t-1} r(s\_{t'}, a\_{t'}) $ and $ \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) $ are independent (we assume, by definition, the action only depends on the most recent state), which means we are allowed to split the expectation: $$\nabla\_{\theta} J(\theta) = \sum\_{t=1}^T \left( \mathbb{E}\_{\tau \sim \pi\_{\theta}(\tau)} \left[ \sum\_{t'=1}^{t-1} r(s\_{t'}, a\_{t'}) \right] \mathbb{E}\_{\tau \sim \pi\_{\theta}(\tau)} \left[ \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) \right] \\ + \mathbb{E}\_{\tau \sim \pi\_{\theta}(\tau)} \left[ \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) \sum\_{t'=t}^T r(s\_{t'}, a\_{t'}) \right] \right)$$ The first expectation can now be replaced by $0$ due to the lemma mentioned at the top of the post: $$ \begin{aligned} \nabla\_{\theta} J(\theta) % &= \sum\_{t=1}^T \mathbb{E}\_{\tau \sim \pi\_{\theta}(\tau)} \left[ \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) \sum\_{t'=t}^T r(s\_{t'}, a\_{t'}) \right] \\ % &= \mathbb{E}\_{\tau \sim \pi\_{\theta}(\tau)} \sum\_{t=1}^T \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) \left( \sum\_{t'=t}^T r(s\_{t'}, a\_{t'}) \right). \\ \end{aligned} $$ The expression on slide 18 of the linked slides is an unbiased, sample-based estimator of this gradient: $$\nabla\_{\theta} J(\theta) \approx \frac{1}{N} \sum\_{i=1}^N \sum\_{t=1}^T \nabla\_{\theta} \log \pi\_{\theta} (a\_{i, t} \mid s\_{i, t}) \left( \sum\_{t'=t}^T r(s\_{i, t'}, a\_{i, t'}) \right)$$ --- For a more formal treatment of the claim that we can pull $\sum\_{t'=1}^{t-1} r(s\_{t'}, a\_{t'})$ out of an expectation due to the Markov property, see this page: <https://spinningup.openai.com/en/latest/spinningup/extra_pg_proof1.html> Upvotes: 4 [selected_answer]<issue_comment>username_2: A correct proof is given at <https://spinningup.openai.com/en/latest/spinningup/extra_pg_proof1.html>. It uses, among other techniques, the probability chain rule. On the contrary, an attempt to prove "reward to go" by applying $ X, Y \: independent \implies E[XY] = E[X]E[Y]$ does not work. The random variables $ \sum\_{t'=1}^{t-1} r(s\_{t'}, a\_{t'}) $ and $ \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) $ are generally not independent. They would be independent, if $ P[ \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) \mid \sum\_{t'=1}^{t-1} r(s\_{t'}, a\_{t'}) ] = P[ \nabla\_{\theta} \log \pi\_{\theta} (a\_t \mid s\_t) ] $ but this does not follow from $ \pi\_{\theta}(a\_t \mid s\_t) = \pi\_{\theta}(a\_t \mid s\_t, s\_{t-1},...,s\_1,a\_{t-1}, ..., a\_1) $ Consider the following setup as an example for the dependency between the two random variables in question. times = {1, 2, 3, ..., T} states = {1, 2, 3, ..., T} actions = {0, 1} $ \pi(a\_t = 0 \mid s\_t) = \frac{1}{s\_t} $ $ r(s\_t, a\_t) = 1 $ i.e. the event reward at time t equals 1 and the total reward from time 1 to time t-1 equals t-1 $ P(s\_1 = 1) = 1 $ i.e. all trajectories start in state 1 $ P(s\_{t+1} = s\_t + 1 \mid s\_t, a\_t) = 1 $ i.e. the next state, given the current state and the current action, is always the current state + 1 As a result, the higher time $ t $, the higher the state $ s\_t $, the higher the probability for action $ a\_t = 1 $ and the higher the total reward from time $ 0 $ to time $ t-1 $, i.e. the values of $ \pi(a\_t \mid s\_t) $ and thus the values of $ \nabla\_{\theta} \log \pi (a\_t \mid s\_t) $ are highly correlated with the total rewards from time $ 0 $ to time $ t-1 $, hence respective random variables are not independent of each other. Upvotes: 1
2018/12/20
1,454
6,688
<issue_start>username_0: Problem: Fraud detection Task : classifying transactions as either fraud/ Non-fraud using GAN<issue_comment>username_1: Yes, although the traditional technique is to use Anomaly Detection for this sort of problem. The reason for that is that the space of possible frauds is very much larger than the space of legitimate transactions and so it is difficult to model the former. The usual idea is to thoroughly explore the smaller space of legitimate transactions and flag as fraudulent anything outside of that space. Using the GAN method could be interesting as it might identify novel fraud techniques, and those are always useful to know. Upvotes: -1 <issue_comment>username_2: Generative networks was the first popular class of topologies that had compound feedback, corrective signaling at more than one layer. In popular network designs such as MLPs (multilayer perceptrons), CNNs (convolutional neural networks), and LSTM (long short term memory) networks, the backpropagation is a single layer mechanism. The mechanism distributes corrective a signal creating a closed loop that ideally converges to an optimal network behavior. The speed, accuracy, and reliability of convergence of networks in an AI system depend on a number of engineering choices at a lower level of design and development. * Selection of algorithm variants and extensions * Selection of data set * Drawing of the training samples * Data normalization * Initialization * Assignment of learning rate or learning rate policy * Other hyper-parameters Generative networks are designed to achieve a higher level balance between two networks, each of which have their own backpropagation, and thus have a compound feedback topology. Considering the original GAN approach in the context of fraud detection, a discriminative network $D$, in a way, detects fraudulence originating from the generative network $G$, and, in a way, $G$ learns authenticity from the corrective signal provided by $D$, even if the authenticity learned is superficial. However, in the case of credit card fraud detection from a numerical set of data, the fraudulence is not internal to the system to be designed as in the case of GAN. Without both the $G$ and $D$ networks, the design is not a generative network. Since the comment stated, "I have to explore GAN for this problem," the key question is this. > > If this system is to benefit from a GAN, what would the GAN generate that could contribute to the solution? > > > If the answer is nothing, then a GAN is not the correct approach. A discriminative network without a generative network is not a GAN. If this question is from an assignment to train a network using a static and already existing data set, a MLP may suffice, depending on the expectations of the teaching staff. If that is the case, the goal will be to analyze the data set using statistical tools to determine if it is already normalized well enough to lead to excellent convergence accuracy, speed, and reliability. If normalization is indicated, find ways to present the data to the input layer of the MLP in such a way that each input is relevant and has a well distributed range of values across the data type. Ensure there is no data loss in this process, and remove redundancy where it can easily be removed. By redundancy removal is meant, if one of the dimensions of data have only four possible values of between 10 and 1,000 bytes, encode the four possible values in two bits because to do so removes unnecessary burden from the training. Similarly, the output layer must be chosen to produce an encoded set of possible output values and the decoding must be written to produce usable output. In this case, it appears that the labels are, Fraudulent and Authentic. Which means that the last layer would be a single binary threshold cell. For this simple MLP approach and for many of the approaches mentioned next, there are examples available in Python, Java, C++ and other languages from which implementation can be initiated. If the design must stand up to a more realistic fraud detection scenario, either for credit cards, junk mail, banking, log-in, or communications those experienced with fraud detection know that the above approach is entirely insufficient except as a starting point for learning. In such a case, these considerations further complicate the design of the solution. * Fraudulence and authenticity is not necessarily sufficient information for investigators. The likelihood of fraudulence and the reason why fraudulence is suspected is also pertinent for end users of production output, so that security holes can be blocked and investigation may be directed toward prosecution or some other set of remedies. * Fraudulence is usually a security breach phenomena that involves continuous improvement in the attacks until the attackers are located and their work is interrupted by arrest. What initially works as fraud detection may not work a week, a day, an hour, or a minute later. * Fraud detection, if it to be useful in a real financial context, must be part of a fraud prevention system, and training on a static data set may be meaningless in that larger usage environment. In AI systems that work in real production environments, it may be worth investigating using an LSTM network in combination with a reinforcement learner. Such may be over a beginner's level of design and implementation experience, but using either an LSTM network or a basic Q-learning approach instead of both of them together may be a reasonable starting point for dedicated students. If the answer to the question about what a GAN could generate that would be of use must be yes, the following ideas may be helpful. * A generative network could generate transaction data with a distribution that resembles authentic transactions, and such has been successful in the past. * A generative network could generate transaction data with a distribution that resembles attacks on an account by a fraudulent user. That has been done too. * A generative network could theoretically generate hacker agents, although this may not have yet been done. * A generative network could be used to generate patterns of authentic transactions based on some authenticity measure other than the data set mentioned, and the trained discriminative network could then be employed in some way in a fraud detection system in production, although it is unclear what advantage would be gained. The reason a GAN was suggested would need to be clarified before this answer could provide a more exact direction for AI system topology and project approach. Upvotes: 2 [selected_answer]
2018/12/21
633
2,310
<issue_start>username_0: This question was asked in an AI exam. How would you answer such question?<issue_comment>username_1: If the game is not [sequential](https://en.wikipedia.org/wiki/Sequential_game), there would be no game tree and no need for pruning. Alpha-beta is a technique applied to look-ahead search. Alpha-beta has demonstrated utility in algorithms that play [combinatorial games](https://en.wikipedia.org/wiki/Combinatorial_game_theory). (Even in iterated dilemmas, it doesn't really branch because it's simultaneous, more of a vine than a tree. Decisionmaking would be based on mathematical analysis of the payoff matrix and statistical analysis of competitor behavior over time.) Upvotes: 2 <issue_comment>username_2: Symmetry indicates that a single role definition is shared among the players. Zero-sum indicates that the aggregated gain over all players for any possible disposition of game play is zero. Alpha-beta is a search thrift strategy invented in 1956 by <NAME>. It is used by an individual player to maximize the probability of favorable game disposition by selecting from move options based on the permutations of game play dependent on each possible selection. These do not seem, *prima facie*, to be mutually exclusive. Alpha-beta may be an effective computing cost reduction strategy on symmetric zero-sum games. An example is chess game play automation. Furthermore, Reinfield (1983) quotes Knuth and Moore (1975): "The most widely used method for pruning trees of two-person zero-sum games like chess is the alpha-beta algorithm." If the values of the chess game play dispositions of win, draw, and loss are assigned 1, 0, and -1 respectively, then chess is a zero-sum game. If a single random bit is used to determine which player moves first, chess is symmetric. The various machine players in the winner's circle from 1978 to 2017 that used alpha-beta to achieve their victory confirms. **References** [*An analysis of alpha-beta pruning*](https://www.ime.usp.br/~rbrito/docs/1-s2.0-0004370275900193-main.pdf), DE Knuth, RW Moore, Artificial intelligence, 1975 [*An improvement of the Scout tree-search algorithm*](http://www.top-5000.nl/ps/An%20improvement%20to%20the%20scout%20tree%20search%20algorithm.pdf), A Reinefeld, ICCA Journal, 1983 Upvotes: 0
2018/12/23
792
2,863
<issue_start>username_0: I have a steady hex-map and turn-based wargame featuring WWII carrier battles. On a given turn, a player may choose to perform a large number of actions. Actions can be of many different types, and some actions may be performed independently of each other while others have dependencies. For example, a player may decide to move one or two naval units, then assign a mission to an air unit or not, then adjust some battle parameters or not, and then reorganize a naval task force or not. 
Usually, boardgames allow players to perform only one action each turn (e.g. go or chess) or a few very similar actions (backgammon). Here the player may select * Several actions * The actions are of different nature * Each action may have parameters that the player must set (e.g. strength, payload, destination) **How could I approach this problem with reinforcement learning? How would I specify a model or train it effectively to play such a game?** Here is a screenshot of the game. [![enter image description here](https://i.stack.imgur.com/21wjd.png)](https://i.stack.imgur.com/21wjd.png) Here's another. [![enter image description here](https://i.stack.imgur.com/vgUiV.png)](https://i.stack.imgur.com/vgUiV.png)<issue_comment>username_1: The master's thesis [Action space representation in combinatorial multi-armed bandits](https://project.dke.maastrichtuniversity.nl/games/files/msc/Roelofs_thesis.pdf) (2015) seems to provide an answer to my question. Several algorithms can be used * Naive Monte-Carlo Sampling (NMC) * Linear Side Information (LSI) * Monte Carlo Tree Search with Hierarchical Expansion (MCTS-HE) * MCTS with Dimensional Expansion The idea is to divide and conquer. Here's a screenshot of the HE algorithm from [section 4.2](https://project.dke.maastrichtuniversity.nl/games/files/msc/Roelofs_thesis.pdf#page=32). [![enter image description here](https://i.stack.imgur.com/X7ABX.png)](https://i.stack.imgur.com/X7ABX.png) Upvotes: 1 <issue_comment>username_2: One very popular RL algorithm that is capable of predicting multiple action outputs concurrently is [Proximal Policy Optimization](https://arxiv.org/abs/1707.06347). In that algorithm, one or more, say $n$, tuples of outputs, $(\mu, \sigma)$, can be predicted at once (having $2\*n$ output nodes), where each tuple is used to parameterize a Gaussian distribution from which a respective action value is sampled. The thus sampled action values are then applied in the simulation/game. By slightly modifying this procedure, this can of course also be applied to discrete action spaces equally well. To get you started, multiple high-quality implementations of PPO are available for rapid prototyping, e.g. [OpenAI baselines](https://github.com/openai/baselines) or [stable-baselines](https://stable-baselines.readthedocs.io/en/master/). Upvotes: 0
2018/12/25
759
2,978
<issue_start>username_0: How can I use a 2-dimensional feature matrix, rather than a feature vector, as the input to a neural network? For a WWII naval wargame, I have sorted out the features of interest to approximate the game state $S$ at a given time $t$. * they are a maximum of 50 naval task forces and airbases on the map * each one has a lot of features (hex, weather, number of ships, type, distance to other task forces, distance to objective, cargo, intelligence, combat value, speed, damage, etc.) The output would be the probability of winning and the level of victory. [![enter image description here](https://i.stack.imgur.com/Gh2U5.png)](https://i.stack.imgur.com/Gh2U5.png)<issue_comment>username_1: The most obvious way to do this would be to simply "unroll" your matrix into a vector. Your example input matrix would get turned into the following input vector: $$\left( \begin{array}{} a\_1 & a\_2 & \dots & a\_t & b\_1 & b\_2 & \dots & b\_t & c\_1 & c\_2 & \dots & c\_t \end{array} \right)$$ I don't think there are any other clear ways to use an "input matrix" really. The only benefit I could see in using an input matrix rather than an unrolled vector (if it were possible to do so in whatever way) would be if doing so would somehow enable the learning algorithm to exploit the "domain knowledge" that certain input features are related to each other in special ways (i.e. features in the same row belong to the same unit, and features in the same column are the same "type" of feature, or other way around). Intuitively, I suspect something like this could be accomplished by restricting the number of connections you make to the next layer. For example, you could make a part of the next layer only be connected to all the $a\_i$ features, a different part connected only to all the $b\_i$ features, etc. Similarly, you could have a part that is connected only to the $a\_1, b\_1, c\_1, \dots$ features, a different part only connected to the $a\_2, b\_2, c\_2, \dots$ features, etc. I don't know for sure how well this would work though... just think that it could. Upvotes: 2 <issue_comment>username_2: (Split the answer from Dennis in two) A very different approach would be to use a network architecture with recurrence, for example an LSTM. You could treat your input as a "sequence" rather than a matrix (just like a sentence in language processing would be a sequence of inputs), providing your feature vectors for different units as inputs one at a time. This would remove the need of having a giant input layer (with support for 50 units) in cases where only a small portion of them would be used (e.g., if you only have 5 units). There is not really a concept of "time" in your inputs though... ideally the output of your network would be invariant to the order in which you provide it with the different inputs for the different units, but that would not typically be the case with these kinds of architectures in practice. Upvotes: 0
2018/12/26
1,329
4,913
<issue_start>username_0: I am a novice developer in AI. Any help appropriated. I have a set of images and from that I want to predict position(x,y co-ordinates) of the Ball.[![enter image description here](https://i.stack.imgur.com/bXjN9.jpg)](https://i.stack.imgur.com/bXjN9.jpg) Thanks in advance.<issue_comment>username_1: There are so many challenges here for a novice or even a very seasoned AI developer! There hasn't been a lot of development in this area. I assume you are working with broadcast video. Your biggest challenges will involve occlusions of the ball and changes in the view as broadcasters constantly switch cameras which have very different positions on the field or around the stadium. You will need to track the ball and the players that take action on the ball. The ball can be in motion from a player heading, kicking, or throwing the ball. The ball can also be in motion from a bounce off a player or the ground. To get started I recommend building off some work that at least can track the players and the ball and can identify certain actions such as a kick. If you start there you can build some type of ball trajectory predictor. The following paper [Soccer Event Detection](https://www.researchgate.net/publication/325030263_Soccer_Event_Detection), by <NAME>, <NAME>, <NAME> and <NAME>, presents an event detector for "Ball possession" and "Kicking the ball". A paper entitled [The Newton Scheme for Deep Learning](https://arxiv.org/ftp/arxiv/papers/1810/1810.07550.pdf) by <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, and <NAME>, addresses predicting the trajectory of a ball in sports. They address the complexities of a ball in motion. They address situations where "the ball is flying with a self-spinning, resulting in a Magnus force on it, which makes it difficult to predict the position by traditional methods". [![enter image description here](https://i.stack.imgur.com/CkglF.png)](https://i.stack.imgur.com/CkglF.png) Some related articles and papers you might find of interest: * [Identifying Player Possession in Spatio-Temporal Data](https://squared2020.com/2017/05/07/identifying-player-possession-in-spatio-temporal-data/) * [Deep Learning using CNNs for Ball-by-Ball Outcome Classification in Sports](http://cs231n.stanford.edu/reports/2016/pdfs/273_Report.pdf) * [Detecting events and key actors in multi-person videos](https://arxiv.org/pdf/1511.02917.pdf) * [Learning to Track and Identify Players from Broadcast Sports Videos](https://www.cs.ubc.ca/~murphyk/Papers/weilwun-pami12.pdf) * [Video Artificial Intelligence Powers Creation](http://blog.infinigraph.com/category/deep-learning/) * [AI predicts how athletes will react in certain situations](https://www.engadget.com/2017/03/06/deep-learning-studies-athlete-decisions/) * [How AI-Based Sports Analytics Is Changing the Game](https://adtmag.com/blogs/dev-watch/2017/07/sports-analytics.aspx) Upvotes: 2 <issue_comment>username_2: **Requirements Analysis** The term prediction has a temporal element, but the other text in comments indicates that the position of the ball relative to the field of play and goals at the time the image is taken is desired. Predicting where the ball is likely to be in some number of seconds is a much more difficult problem. We can consider the problem of determining ball position $(x, y, z)$ relative to a coordinate system superimposed onto the field where $(0, 0, 0)$ is the center point in team A's goal line and $(1, 0, 0)$ is the center of team B's goal line and distances in $x$ are scaled similarly in $y$ and $z$. Since some of the images may have the ball in the field of view, the beginnings of a solution may be available. The number of images would need to be large. If a sufficiently large set of images, some of which have the ball in view, were available, this process would likely produce a viable solution with satisfactory accuracy and reliability characteristics. 1. Develop an unsupervised system that recognizes round objects in the air based on a model of balls. 2. Locate the ball in all frames that have one and assign the ball position as a label for those frames. 3. Use face recognition AI to locate eyes and label them. 4. Use CNN feature extraction and a deep network to train functional correlation between eye features and ball position 5. Use the functional correlation on frames without a ball in the frame to locate it There are two dimensional challenges in using these techniques * Lack of depth perception * Orienting players in the field It is possible to train the trigonometric relations as part of item 4, however orienting players in the field may be untenable, rendering the entire project infeasible. The solution of this problem is dependent upon the solution of this one: <https://ai.stackexchange.com/search?q=user%3A4302+field+boundary>. Upvotes: 0
2018/12/27
2,755
8,912
<issue_start>username_0: **Description** I have designed this robot in URDF format and its environment in pybullet. Each leg has a minimum and maximum value of movement. What reinforcement algorithm will be best to create a walking policy in a simple environment in which a positive reward will be given if it walks in the positive X-axis direction? **I am working in the following but I don´t know if it is the best way:** The expected output from the policy is an array in the range of (-1, 1) for each joint. The input of the policy is the position of each joint from the past X frames in the environment(replay memory like DeepQ Net), the center of mass of the body, the difference in height between the floor and the body to see if it has fallen and the movement in the x-axis. **Limitations** left\_front\_joint => lower="-0.4" upper="2.5" id=0 left\_front\_leg\_joint => lower="-0.6" upper="0.7" id=2 right\_front\_joint => lower="-2.5" upper="0.4" id=3 right\_front\_leg\_joint => lower="-0.6" upper="0.7" id=5 left\_back\_joint => lower="-2.5" upper="0.4" id=6 left\_back\_leg\_joint => lower="-0.6" upper="0.7" id=8 right\_back\_joint => lower="-0.4" upper="2.5" id=9 right\_back\_leg\_joint => lower="-0.6" upper="0.7" id=11 The code below is just a test of the environment with a set of movements hardcoded in the robot just to test how it could walk later. The environment is set to real time, but I assume it needs to be in a frame by frame lapse during the policy training. (*p.setRealTimeSimulation(1) #disable and p.stepSimulation() #enable*) **A video of it can be seen in:** <https://youtu.be/j9sysG-EIkQ> **The complete code can be seen here:** <https://github.com/rubencg195/WalkingSpider_OpenAI_PyBullet_ROS> **CODE** ``` import pybullet as p import time import pybullet_data def moveLeg( robot=None, id=0, position=0, force=1.5 ): if(robot is None): return; p.setJointMotorControl2( robot, id, p.POSITION_CONTROL, targetPosition=position, force=force, #maxVelocity=5 ) pixelWidth = 1000 pixelHeight = 1000 camTargetPos = [0,0,0] camDistance = 0.5 pitch = -10.0 roll=0 upAxisIndex = 2 yaw = 0 physicsClient = p.connect(p.GUI)#or p.DIRECT for non-graphical version p.setAdditionalSearchPath(pybullet_data.getDataPath()) #optionally p.setGravity(0,0,-10) viewMatrix = p.computeViewMatrixFromYawPitchRoll(camTargetPos, camDistance, yaw, pitch, roll, upAxisIndex) planeId = p.loadURDF("plane.urdf") cubeStartPos = [0,0,0.05] cubeStartOrientation = p.getQuaternionFromEuler([0,0,0]) #boxId = p.loadURDF("r2d2.urdf",cubeStartPos, cubeStartOrientation) boxId = p.loadURDF("src/spider.xml",cubeStartPos, cubeStartOrientation) # boxId = p.loadURDF("spider_simple.urdf",cubeStartPos, cubeStartOrientation) toggle = 1 p.setRealTimeSimulation(1) for i in range (10000): #p.stepSimulation() moveLeg( robot=boxId, id=0, position= toggle * -2 ) #LEFT_FRONT moveLeg( robot=boxId, id=2, position= toggle * -2 ) #LEFT_FRONT moveLeg( robot=boxId, id=3, position= toggle * -2 ) #RIGHT_FRONT moveLeg( robot=boxId, id=5, position= toggle * 2 ) #RIGHT_FRONT moveLeg( robot=boxId, id=6, position= toggle * 2 ) #LEFT_BACK moveLeg( robot=boxId, id=8, position= toggle * -2 ) #LEFT_BACK moveLeg( robot=boxId, id=9, position= toggle * 2 ) #RIGHT_BACK moveLeg( robot=boxId, id=11, position= toggle * 2 ) #RIGHT_BACK #time.sleep(1./140.)g #time.sleep(0.01) time.sleep(1) toggle = toggle * -1 #viewMatrix = p.computeViewMatrixFromYawPitchRoll(camTargetPos, camDistance, yaw, pitch, roll, upAxisIndex) #projectionMatrix = [1.0825318098068237, 0.0, 0.0, 0.0, 0.0, 1.732050895690918, 0.0, 0.0, 0.0, 0.0, -1.0002000331878662, -1.0, 0.0, 0.0, -0.020002000033855438, 0.0] #img_arr = p.getCameraImage(pixelWidth, pixelHeight, viewMatrix=viewMatrix, projectionMatrix=projectionMatrix, shadow=1,lightDirection=[1,1,1]) cubePos, cubeOrn = p.getBasePositionAndOrientation(boxId) print(cubePos,cubeOrn) p.disconnect() ``` ![robot](https://github.com/rubencg195/WalkingSpider_OpenAI_PyBullet_ROS/raw/master/images/PyBullet.png) ![robot](https://github.com/rubencg195/WalkingSpider_OpenAI_PyBullet_ROS/raw/master/images/spider(8).jpeg)<issue_comment>username_1: There are so many challenges here for a novice or even a very seasoned AI developer! There hasn't been a lot of development in this area. I assume you are working with broadcast video. Your biggest challenges will involve occlusions of the ball and changes in the view as broadcasters constantly switch cameras which have very different positions on the field or around the stadium. You will need to track the ball and the players that take action on the ball. The ball can be in motion from a player heading, kicking, or throwing the ball. The ball can also be in motion from a bounce off a player or the ground. To get started I recommend building off some work that at least can track the players and the ball and can identify certain actions such as a kick. If you start there you can build some type of ball trajectory predictor. The following paper [Soccer Event Detection](https://www.researchgate.net/publication/325030263_Soccer_Event_Detection), by <NAME>, <NAME>, <NAME> and <NAME>, presents an event detector for "Ball possession" and "Kicking the ball". A paper entitled [The Newton Scheme for Deep Learning](https://arxiv.org/ftp/arxiv/papers/1810/1810.07550.pdf) by <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, and <NAME>, addresses predicting the trajectory of a ball in sports. They address the complexities of a ball in motion. They address situations where "the ball is flying with a self-spinning, resulting in a Magnus force on it, which makes it difficult to predict the position by traditional methods". [![enter image description here](https://i.stack.imgur.com/CkglF.png)](https://i.stack.imgur.com/CkglF.png) Some related articles and papers you might find of interest: * [Identifying Player Possession in Spatio-Temporal Data](https://squared2020.com/2017/05/07/identifying-player-possession-in-spatio-temporal-data/) * [Deep Learning using CNNs for Ball-by-Ball Outcome Classification in Sports](http://cs231n.stanford.edu/reports/2016/pdfs/273_Report.pdf) * [Detecting events and key actors in multi-person videos](https://arxiv.org/pdf/1511.02917.pdf) * [Learning to Track and Identify Players from Broadcast Sports Videos](https://www.cs.ubc.ca/~murphyk/Papers/weilwun-pami12.pdf) * [Video Artificial Intelligence Powers Creation](http://blog.infinigraph.com/category/deep-learning/) * [AI predicts how athletes will react in certain situations](https://www.engadget.com/2017/03/06/deep-learning-studies-athlete-decisions/) * [How AI-Based Sports Analytics Is Changing the Game](https://adtmag.com/blogs/dev-watch/2017/07/sports-analytics.aspx) Upvotes: 2 <issue_comment>username_2: **Requirements Analysis** The term prediction has a temporal element, but the other text in comments indicates that the position of the ball relative to the field of play and goals at the time the image is taken is desired. Predicting where the ball is likely to be in some number of seconds is a much more difficult problem. We can consider the problem of determining ball position $(x, y, z)$ relative to a coordinate system superimposed onto the field where $(0, 0, 0)$ is the center point in team A's goal line and $(1, 0, 0)$ is the center of team B's goal line and distances in $x$ are scaled similarly in $y$ and $z$. Since some of the images may have the ball in the field of view, the beginnings of a solution may be available. The number of images would need to be large. If a sufficiently large set of images, some of which have the ball in view, were available, this process would likely produce a viable solution with satisfactory accuracy and reliability characteristics. 1. Develop an unsupervised system that recognizes round objects in the air based on a model of balls. 2. Locate the ball in all frames that have one and assign the ball position as a label for those frames. 3. Use face recognition AI to locate eyes and label them. 4. Use CNN feature extraction and a deep network to train functional correlation between eye features and ball position 5. Use the functional correlation on frames without a ball in the frame to locate it There are two dimensional challenges in using these techniques * Lack of depth perception * Orienting players in the field It is possible to train the trigonometric relations as part of item 4, however orienting players in the field may be untenable, rendering the entire project infeasible. The solution of this problem is dependent upon the solution of this one: <https://ai.stackexchange.com/search?q=user%3A4302+field+boundary>. Upvotes: 0
2018/12/28
3,957
16,767
<issue_start>username_0: I've inherited a neural network project at the company I work for. The person who developed gave me some very basic training to get up and running. I've maintained it for a while. The current neural network is able to classify messages for telcos: it can send them to support people in different areas, like "activation", "no signal", "internet", etc. The network has been working flawlessly. The structure of this neural network is as follows: ``` model = Sequential() model.add(Dense(500, input_shape=(len(train_x[0]),))) model.add(Activation('relu')) model.add(Dropout(0.6)) model.add(Dense(250, input_shape=(500,))) model.add(Activation('relu')) model.add(Dropout(0.5)) model.add(Dense(len(train_y[0]))) model.add(Activation('softmax')) model.compile(loss='categorical_crossentropy', optimizer='Adamax', metrics=['accuracy']) ``` This uses a Word2Vec embedding, and has been trained with a "clean" file: all special characters and numbers are removed from both the training file and the input data. Now I've been assigned to make a neural network to detect if a message will be catalog as "moderated" (meaning it's an insult, spam, or just people commenting on a facebook post), or "operative", meaning the message is actually a question for the company. What I did was start from the current model and reduce the number of categories to two. It didn't go very well: the word embedding was in spanish from Argentina, and the training data was spanish from Peru. I made a new embedding and accuracy increased by a fair margin (we are looking for insults and other curse words. In spanish a curse word from a country can be a normal word for another: in Spain "coger" means "to take", and in Argentina it means "to f\_\_k". "concha" means shell in most countries, but in Argentina it means "c\_\_t". You get the idea). I trained the network with 300.000 messages. Roughly 40% of these were classified as "moderated". I tried all sorts of combinations of cycles and epochs. The accuracy slowly increased to nearly 0.9, and loss stays around 0.5000. But when testing the neural network, "operative" messages generally seem to be correctly classified, with accuracy around 0.9, but "moderated" messages aren't. They are classified around 0.6 or less. At some point I tried multiple insults in a message (even pasting sample data as input data), but it didn't seem to improve. Word2Vec works fantastically. The words are correctly "lumped" together (learned a few insults in Peruvian spanish thanks to it). I put the neural network in production for a week, to gather statistics. Basically 90% of the messages went unclassified, and 5% were correctly classified and 5% wrong. Since the network has two categories, this seems to mean the neural network is just giving random guesses. So, the questions are: * Is it possible to accomplish this task with a neural network? * Is the structure of this neural network correct for this task? * Are 300k messages enough to train the neural network? * Do I need to clean up the data from uppercase, special characters, numbers etc?<issue_comment>username_1: First your questions: Yes, it is possible to accomplish this with a neural network, this is actually very similar to your current working model (the idea is the same, just different classes). So, there are no real reasons to start changing the architecture, especially if from what I understand, you are not a deep-learning expert. I mean, I'm sure that you can poke and play with the model to improve it, but that is not your current concern. Right now it seems that your model isn't training properly. I do think that 300k messages should be enough at least for a decent model (way better than random choice). There are some standard preprocessing steps that you should perform on your input text (if you haven't already), in general you should normalize (convert to lower case) and remove noise from your text (like special characters). You can read more about different methods in the following link: [Text Preprocessing in Python: Steps, Tools, and Examples](https://medium.com/@datamonsters/text-preprocessing-in-python-steps-tools-and-examples-bf025f872908) Suggestions and questions: From your initial explanation, your new model has 2 outputs (moderated and operative), however later you mention that 90% of the input was not classified. So do you have a third class (no-classification) or are you just using some threshold of probability, that only above it the massage is classified? Because if you only have 2 classes, I would suggest to use a binary cross-entropy loss and not categorical. I have a strong suspicion that there is something wrong with either your training dataset or process. Please provide more info about the dataset (number of samples from each class, how was it labeled) and your training process (are you using part of the data for validation? how many epochs? etc.). Upvotes: 2 <issue_comment>username_2: **The Project Summarized** The project goal appears to be a common one: Routing correspondence in an efficient manner to maintain good but low cost customer and public relations. A few features of the project were mentioned. * Neural network project * Received some design and project history from predecessor * Classifies messages for telcos * Sends results to support groups at appropriate locales * Uses 2 relu layers, ending with a softmax * Word2Vec embedding * Trained with a clean language file * All special characters and numbers removed The requirements for current development were indicated. The current work is to develop an artificial network that places incoming messages into one of two categories accurately and reliably. * Moderated — insulting, fraudulent in purpose (spam), trivial routine * Operative — relevant question requiring internal human attention Research and development is beginning along reasonable lines. * Trained with 300,000 messages * Word2Vec used * 40% of classified as moderated * Permuted cycles and epochs * Achieved 90% accuracy * Loss stays near 0.5 * In test, operative accuracy 0.9, moderated accuracy max of 0.6 **First Obstacle and Feasibility** The first obstacle encountered is that in QA using production environment data, 90% of the messages where left unclassified, 5% of the classifications were accurate, and the remaining 5% were inaccurately classified. It is correct that the even split of 5% accuracy and 5% inaccuracy indicates that information learned is not yet transferable to the quality assurance test phase using real production environment messages. In information theory phraseology, no bits of usable information were transferred and entropy remained unchanged on this first experiment. These kinds of disappointments are not uncommon when first approaching the use of AI in an existing business environment, so this initial outcome should not be taken as a sign that the idea won't work. The approach will likely work, especially with foul language, which is not dependent on cultural references, analogies, or other semantic complexity. Recognizing notices that are for audit purposes only, from a social network accounts or purchase confirmations, can be handled through rules. The rule creation and maintenance can theoretically be automated too, and some proprietary systems exist that do exactly that. Such automation can be learned using the appropriate training data, but real time feedback is usually employed, and those systems are usually model based. That is an option for further down the R&D road. The scope of the project is probably too small, but that's not a big surprise either. Most projects suffer from early overoptimism. A pertinent quote from Redford's *The Melagro Beanfield War* illuminates the practical purpose of optimism. > >         APPARITION > > > I don't know if your friend knows what he's in for. > > >         AMARANTE > > > Nobody would do anything if they knew what they were in for. > > > **Initial Comments** It is not necessary to reduce the number of message categories to two, but there is nothing wrong with starting R&D by refining approach and high level design with the simplest case. The last layer may be more training efficient if a binary threshold is used for the activation function instead of softmax, since there is only one bit of output needed when there are only two categories. This also forces the network training objective to be the definitive selection of a category, which may benefit the overall rate of R&D progress. There may be ways of improving outcomes by adding more metrics in the code to beyond just 'accuracy'. Others who work with such details every day may have more domain specific knowledge in this regard. **Culture and Pattern Detection** Insults and curse words are entirely different kinds of things. Foul language is a linguistic symbol or phrase that fits into a broadcasting or publishing category of prohibition. The rules of prohibition are well established in most languages and could be held in a configuration file along with the permutations of each symbol or phrase. In the case of *sh\*t*, related forms include *sh\*tty*, *sh\*thead*, and so on. It is also useful to distinguish the sub-sets of foul language. * Cursing (expressing the wish for calamity to befall the recipient) * Swearing (considered blasphemy by some) * Exclamations that are considered foul by publishers and broadcasters * Additional items parents don't want their children to hear * Edge cases like *crap* The term *foul language* is a super-set of these. **Distribution Alignment** Learning algorithms and theory are based on probabilistic alignment of feature distributions between training and use. The distribution of training data must closely resembles the distribution found when the trained AI component is later used. If not, the convergence of learning processes on some optimal behavior defined by gain or loss functions may succeed but the execution of that behavior in the business or industry may fail. **Internationalization** Multilingual AI should usually be fully internationalized. Training and use of training with two distinct dialects will almost always perform poorly. That creates a data acquisition challenge. As stated above, classification and learning depend on the alignment of statistical distributions between data used in training and data processing relying on the use of what was learned. This is also true of human learning, so this requirement will not likely be overcome any time soon. All these forms of foul language must be programmed flexibly across these cultural dimensions. * Character set * Collation order * Language * Dialect * Other locale related determinants * Education level * Economic strata Once one of these is included in the model (which will be imperative) then there is no reason why the others cannot be included at little cost, so it is wise to begin with standard dimensions of flexibility. The alternative will likely lead to costly branching complexity to represent specific rules, which could have been made more maintainable by generalizing for international use up front. **Insult Recognition** Insults require comprehension beyond the current state of technology. Cognitive science may change that in the future, but projections are mere conjecture. Use of a regular expression engine with a fuzzy logic comparator is achievable and may appease the stakeholders of the project, but identifying insults may be infeasible at this time, and the expectations should be set with stakeholders to avoid later surprises. Consider these examples. * The nose on your face looks like a camel. * Kiss the darkest part of my little white. (From *Avatar* screenplay) The word combinations in these are not likely to be in some data set you can use for training, so Word2Vec will not help in these types of cases. Additional layers may assist with proper handling of the at least some of the semantic and referential complexity of insults, but only some. **Explicit Answers to Explicit Questions** > > Is it possible to accomplish this task with a neural network? > > > Yes, in combination with excellence in higher level system design and best practices for internationalization. > > Is the structure of this neural network correct for this task? > > > The initial experiments look like a reasonable beginning toward what would later be correct enough. Do not be discouraged, but don't expect the first pass at something like this to look much like what passes user acceptance testing a year from now. Experts can't pull that rate of R&D progress off, unless they hack and cobble something together from previous work. > > Are 300k messages enough to train the neural network? > > > Probably not. In fact, 300m messages will not catch all combinations of cultural references, analogies, colloquialisms, variations in dialect, plays on words, and games that spammers play to avoid detection. What would really help is a feedback mechanism so that production outcomes are driving the training rather than a necessarily limited data set. Canned data sets are usually restricted in the accuracy of their probabilistic representation of social phenomena. None will likely infer dialect and other locale features to better detect insults. A Parisian insult may have nothing in common with a Creole insult. The feedback mechanism must be based on impressions in some way to become and remain accurate. The impressions must be labelled with all the locale data that is reasonably easy to collect and possibly correlated to the impression. This implies the use of rules acquisition, fuzzy logic control, reinforcement learning, or the application of naive Bayesian approaches somewhere appropriate within the system architecture. > > Do I need to clean up the data from uppercase, special characters, numbers etc? > > > Numbers can be relevant. Because of historical events and religious texts, 13 and 666 might be indications of something offensive, respectively. One can also use numbers and punctuation to convey word content. Here are some examples of spam detection resistant click bait. * I've got a 6ex opportunity 4u. * Wanna 69? * Values are rising 50%! We have 9 investment choices 4 you to check out. The meaning of the term *special character* is vague and ambiguous. Any character in UTF-8 is legitimate for almost all Internet communications today. HTML5 provides additional entities beginning with an ampersand and ending with a semicolon. (See <https://dev.w3.org/html5/html-author/charref>.) Filtering these out is a mistake. Spammers leverage these standards to penetrate spam detection. In this example, the stroke similarities of a capital ell (L) and those of the British pound symbol can be exploited to produce spam detection resistant click bait. * Do you like hot £egs? Removing special characters that fit within the Internet standards of UTF-8 and HTML entities will likely lead to disaster. It is recommended not to follow that part of the predecessor's design. Regarding emoticons and other ideograms, these are linguistic elements that may represent in text encoding the volume, pitch, or tone modulation of phonetics, or they may represent face or body language. In many languages ideograms are used in place of words. For a global system running in parallel with the blogsphere, emoticons are part of linguistic expression. For that reason, they are not significantly different than word roots, prefixes, suffixes, conjugations, or word pairs as linguistic elements which can also express emotion as well as logical reasoning. For the learning algorithm to learn categorization behavior in the presence of ideograms, the ideograms must remain in training features and later in real time processing of those features using the results of training. **Additional Information** Some additional information is covered in this existing post: [Spam Detection using Recurrent Neural Networks](https://ai.stackexchange.com/questions/3472/spam-detection-using-recurrent-neural-networks/8397#8397). Since spam detection is closely related to fraud detection, the spammer fraudulently acting like a relationship already exists with their recipients, this existing post may be of assistance too: [Can we implement GAN (Generative adversarial neural networks) for classication problem like Fraud detecion?](https://ai.stackexchange.com/questions/9624/can-we-implement-gan-generative-adversarial-neural-networks-for-classication-p/9683#9683) Another resource that may help is this: <https://www.tensorflow.org/tutorials/representation/word2vec> Upvotes: 2
2018/12/29
1,637
6,527
<issue_start>username_0: I have been reading a few papers ([paper1](https://www.sciencedirect.com/science/article/abs/pii/S003132030000114X), [paper2](https://arxiv.org/abs/1410.2474)) on stereo matching using genetic algorithms. I understand how genetic algorithms work in general and how stereo matching works, but I do not understand how genetic algorithms are used in stereo matching. The first paper by Han et al says that "1) individual is a disparity set, 2) a chromosome has a 2D structure for handling image signals efficiently, and 3) a fitness function is composed of certain constraints which are commonly used in stereo matching". Does it mean that an individual is a disparity map with random numbers? Then a chromosome is a block within the individual's disparity map. The constraint used for fitness function could be the famous epipolar line. I dont seem to understand how this works and even *WHY* you should use genetic algorithm on an algorithm that at its simplest form uses 5 for loops, for example, like in [here](https://github.com/davechristian/Simple-SSD-Stereo/blob/master/stereomatch_SSD.py).<issue_comment>username_1: This is what I understood so far from the paper in [arxiv](https://arxiv.org/abs/1410.2474) named "Genetic Stereo Matching Algorithm with Fuzzy Fitness": Let's say we have 2 images (left and right taken by a stereo camera) of size 28x28. The images are in grey scale. The individual becomes a disparity map. Let's say, we look at the pixel at row 2, column 3 and it has a number 5. That means that the pixel at (2,3) on the left image (*reference image*) corresponds to the pixel at (2, 8) on the right image (*target image*). The author of the paper created three classes black, average, and white pixels classes where they take the 0, 127.5, and 255 values respectively in the grey image scale. Then the author calculates the likelikehood of each pixel on both left and right images belonging to the same class by calculating the mean and standard deviation of the class in consideration. The matching possibility metric is calculated by choosing the max likelikehood of both images belonging to the same class. Author also added Sobel gradient normalization to the fitness value. Genetic operators seem to work in an easy way where you just swap some parts of the individual (disparity map) with another disparity map to create new individuals and the mutation is just randomly changing the number in the disparity map. Upvotes: 1 <issue_comment>username_2: > > Do not understand how genetic algorithms are used in stereo matching. > > > The first paper referenced in the question is [*Stereo matching using genetic algorithm with adaptive chromosomes*](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.473.6886&rep=rep1&type=pdf), <NAME>, <NAME>, <NAME>, <NAME>, Yeong-HoHac, 2000. It summarizes an approach this way. 1. An individual is a disparity set, 2. A chromosome has a 2D structure for handling image signals efficiently, and 3. A fitness function is composed of certain constraints which are commonly used in stereo matching. The paper also states, "Genetic algorithms are efficient search methods based on principles of population genetics, i.e. mating, chromosome crossover, gene mutation, and natural selection." The extension to genetic algorithm purity is contained in this statement in the paper. > > To improve the convergence, an informed generation, that a higher selected possibility is assigned to the chromosome including a smaller intensity difference, is adopted. The informed generation uses several random generations plus a selection. In a random generation, only a value is randomly generated. Yet, the informed generation of the proposed algorithm selects the gene which has the minimum intensity difference among the randomly generated genes. > > > The question inquires along a few lines. > > Does it mean that an individual is a disparity map with random numbers? > > > The goal is to produce order from chaos through successive mutations, combinations, and tests, arriving at genetic code that represents distances of objects that correspond to a left region of pixels and a right region of pixels. Those two regions are identified through alignment of brightness categories, with some permissible sprinkling of outliers. An individual in this context is a simulation of a sample from a population with a particular aggregation of genetic codes. The codes indicate disparity between matching image features in the left and right images, measured in horizontal pixels. > > [Don't] understand how this works and even WHY you should use genetic algorithm on an algorithm that at its simplest form uses 5 for loops. > > > The five loops referenced in the question, [*in the source at github.com/davechristian/Simple-SSD-Stereo*](https://github.com/davechristian/Simple-SSD-Stereo), are as follows. ``` for y in range(kernel_half, h - kernel_half): for x in range(kernel_half, w - kernel_half): for offset in range(max_offset): for v in range(-kernel_half, kernel_half): for u in range(-kernel_half, kernel_half): ``` This exhaustive search has gross shortcomings in relation to the genetic algorithm with informed generation. * The simulation of meiosis in genetic algorithms is essentially a search for hybrids where the best genetic sequences of two parents are preserved in the offspring. * Genetic algorithms are easy to scale across computer clusters without developing specialized hardware acceleration. * Components of failed compositions are not eliminated in an exhaustive search, so there is considerable redundancy in trials. The second paper referenced in the question is [*Genetic Stereo Matching Algorithm with Fuzzy Fitness*](https://arxiv.org/pdf/1410.2474.pdf), <NAME>, 2014. It proposes, "To get around [convergence speed] limitations, we propose a new encoding for individuals, more compact than binary encoding and requiring much less space. This approach and the use of three lightness classes is shared with the methodology of the first paper. This second paper introduces fuzzy matching and the use of the Sobel gradient norms to penalize (dismiss) pixels which project onto uniform regions, [and are therefore] less significant pixels. This paper also provides some comparison results with Han's, Dong's, and Nguyen's algorithms as define in the second paper's bibliography. Upvotes: 2
2018/12/30
1,415
5,892
<issue_start>username_0: I am trying to understand what channels mean in convolutional neural networks. When working with grayscale and colored images, I understand that the number of channels is set to 1 and 3 (in the first conv layer), respectively, where 3 corresponds to red, green, and blue. Say you have a colored image that is $200 \times 200$ pixels. The standard is such that the input matrix is a $200 \times 200$ matrix with 3 channels. The first convolutional layer would have a filter that is size $N \times M \times 3$, where $N,M < 200$ (I think they're usually set to 3 or 5). Would it be possible to structure the input data differently, such that the number of channels now becomes the width or height of the image? i.e., the number of channels would be 200, the input matrix would then be $200 \times 3$ or $3 \times 200$. What would be the advantage/disadvantage of this formulation versus the standard (# of channels = 3)? Obviously, this would limit your filter's spatial size, but dramatically increase it in the depth direction. I am really posing this question because I don't quite understand the concept of channels in CNNs.<issue_comment>username_1: > > Say you have a colored image that is 200x200 pixels. The standard is such that the input matrix is a 200x200 matrix with 3 channels. The first convolutional layer would have a filter that is size $N×M×3$, where $N,M<200$ (I think they're usually set to 3 or 5). > > > Would it be possible to structure the input data differently, such that the number of channels now becomes the width or height of the image? i.e., the number of channels would be 200, the input matrix would then be 200x3 or 3x200. What would be the advantage/disadvantage of this formulation versus the standard (# of channels = 3)? Obviously, this would limit your filter's spatial size, but dramatically increase it in the depth direction. > > > The different dimensions (width, height, and number of channels) do have different meanings, the intuition behind them is different, and this is important. You could rearrange your data, but if you then plug it into an implementation of CNNs that expects data in the original format, it would likely perform poorly. The important observation to make is that the intuition behind CNNs is that they encode the "prior" assumption or knowledge, the "heuristic", the "rule of thumb", of **location invariance**. The intuition is that, when looking at images, we often want our Neural Network to be able to consistently (in the same way) detect features (maybe low-level features such as edges, corners, or maybe high-level features such as complete faces) **regardless of where they are**. It should not matter whether a face is located in the top-left corner or the bottom-right corner of an image, detecting that it is there should still be performed in the same way (i.e. likely requires exactly the same combination of learned weights in our network). That is what we mean with location invariance. That intution of location invariance is implemented by using "filters" or "feature detectors" that we "slide" along the entire image. These are the things you mentioned having dimensionality $N \times M \times 3$. The intuition of location invariance is implemented by taking the exact same filter, and re-applying it in different locations of the image. If you change the order in which you present your data, you will break this property of location invariance. Instead, you will replace it with a rather strange property of... for example, "width-colour" invariance. You might get a filter that can detect the same type of feature regardless its $x$-coordinate in an image, and regarldess of the colour in which it was drawn, but the $y$-coordinate will suddenly become relevant; your filter may be able to detect edges of any colour in the bottom of an image, but fail to recognize the same edges in the top-side of an image. This is not an intuition that I would expect to work successfully in most image recognition tasks. --- Note that there may also be advantages in terms of computation time in having the data ordered in a certain way, depending on what calculations you're going to perform using that data afterwards (typically lots of matrix multiplications). It is best to have the data stored in RAM in such a way that the inner-most loops of algorithms using the data (matrix multiplication) access the data sequentially, in the same order that it is stored in. This is the most efficient way in which to access data from RAM, and will result in the fastest computations. You can generally safely expect that implementations in large frameworks like Tensorflow and PyTorch will already require you to supply data in whatever format is the most efficient by default. Upvotes: 4 [selected_answer]<issue_comment>username_2: If you have a gray scale image, that means you are getting data from one sensor. If you have an RGB image, that means you are getting data from three sensors. If you have a CMYK image, that means you are getting data from four sensors. So, channels can be considered as same information seen from different perspective. (here color) If you see how the kernel (for example 5\*5\*3) moves, it moves only in XY direction and not in the channel direction. So, you are trying to learn features in XY direction from all the channels together. But, if you exchange the dimensions like you mentioned your XY dimensions become 200\*3 or 3\*200 and your channels become 200. In this case you are moving kernel not in the actual XY spatial space of image. So, it doesn't make any sense according to me. You are contradicting the basic concept of CNN by doing so. The concept of CNN itself is that you want to learn features from the spatial domain of the image which is XY dimension. So, you cannot change dimensions like you mentioned. Upvotes: 1
2018/12/31
244
1,067
<issue_start>username_0: If deep learning is a black box, then why are companies still investing in it?<issue_comment>username_1: Easy answer: **utility**. The strength and applicability of "black box" NNs has been regularly validated in the past few years, and business is concerned with results. *(i.e. they don't care [how the sausage is made](https://en.wiktionary.org/wiki/how_the_sausage_gets_made), so long as it gets made.)* Upvotes: 3 <issue_comment>username_2: I think that the universal approximation theorem plays a large role in why companies and governments are investing in deep learning, it states that theoretically an ann can approximate any continuous function with n-dimension input variables. Specifically it states that feed forward nets with a single hidden layer can do this lending credence to the implication that rnns and cnns are also capable of universal function approximation. So they are investing because they have continuous functions that need to be approximated and really the best tool for the job is neural networks. Upvotes: 2
2018/12/31
938
3,516
<issue_start>username_0: I'm reading this really interesting article [CycleGAN, a Master of Steganography](https://arxiv.org/pdf/1712.02950.pdf). I understand everything up until this paragraph: > > we may view the CycleGAN training procedure as continually mounting an **adversarial attack** on $G$, by optimizing a generator $F$ to generate adversarial maps that force $G$ to produce a desired image. Since we have demonstrated that it is possible to generate these adversarial maps using gradient descent, it is nearly certain that the training procedure is also causing $F$ to generate these adversarial maps. As $G$ is also being optimized, however, $G$ may actually be seen as cooperating in this attack by learning to become increasingly susceptible to attacks. We observe that the magnitude of the difference $y^{\*}-y\_{0}$ necessary to generate a convincing adversarial example by Equation 3 decreases as the CycleGAN model trains, indicating cooperation of $G$ to support adversarial maps. > > > How is the CycleGAN training procedure an adversarial attack? I don't really understand the quoted explanation.<issue_comment>username_1: > > [Adversarial examples](https://arxiv.org/abs/1312.6199) are inputs to machine learning models that an attacker has intentionally designed to cause the model to make a mistake; they’re like optical illusions for machines. > > > Source: [Attacking Machine Learning with Adversarial Examples](https://blog.openai.com/adversarial-example-research/) You create an input and test against the output, tuning the input to maximize the error. There are different criteria for tuning the input, sometimes you might want the shortest possible input to create the largest error, often you would want very similar input to cause the greatest error. Example: I take a \$1 bill and write a few more zeros after the one; you accept it as a \$1000 bill. Upvotes: 2 <issue_comment>username_2: Simple answer is tweaking an image in unnoticeable ways that completely fool software. Eg a cat that is identified as 99% likely "to be guacamole" <https://mashable.com/2017/11/02/mit-researchers-fool-google-ai-program/#CU7dSAfQ5sqY> Upvotes: 0 <issue_comment>username_3: I guess they are talking about adversarial attacks in the same way that Szegedy et al. did in ["Intriguing properties of neural networks"](https://arxiv.org/abs/1312.6199) They described "adversarial attacks" or "adversarial examples" as images with hardly perceptible perturbations that change the network's prediction. For example, imagine you've trained a CNN to classify between a variety of classes. You take a picture of a dog $X\_1$, and your CNN correctly classified it as a "dog", everything is fine so far. Then you can add some small perturbation $p$ to your image $X\_1$, so now you have a new image $X\_2 = X\_1 + p$. This new image still looks like a dog, because your perturbation was so small that is almost imperceptible. The problem is that your CNN will classify your picture $X\_2$ as something that is not a dog, for example, "fish". Here, $X\_2$ is an **adversarial example** created after using an adversarial perturbation $p$. What is interesting about these adversarial perturbations $p$ is that they are not random. Actually, CNNs are very robust to random perturbations (noise), but adversarial perturbations $p$ are not like them. They are computed to fool a classifier (not only CNNs). You can refer to figure 5 of the aforementioned paper for more examples. Upvotes: 1
2019/01/03
1,399
5,915
<issue_start>username_0: I understand the minimax algorithm, but I am unable to understand deeply the minimax algorithm with alpha-beta pruning, even after having looked up several sources (on the web) and having tried to read the algorithm and understand how it works. Do you have a good source that explains alpha-beta pruning clearly, or can you help me to understand the alpha-beta pruning (with a simple explanation)?<issue_comment>username_1: Suppose that you have already search a part of the complete search tree, for example the complete left half. This may not yet give you the true game-theoretic value for the root node, but it can already give you some bounds on the game-theoretic value that the player to play in the root node (let's say, the max player) can guarantee by moving into that part of the search tree. Those bounds / guarantees are: * $\alpha$: the **minimum** score that the **maximizing** player already knows it can **guarantee** if we move into the part of the search tree searched so far. Maybe it can still do better (get higher values) by moving into the unsearched part, but it can already definitely get this value. * $\beta$: the **maximum** score that the **minimizing** player already knows it can **guarantee** if we moves into the part of the search tree searched so far. Maybe it can still do better (get lower values) by moving into the unsearched part, but it can already definitely get this value. The intuitive idea behind alpha-beta pruning is to prune chunks of the search tree that become uninteresting for either player because they already know they can guarantee better based on the $\alpha$ or $\beta$ bounds. --- For a simple example, suppose $\alpha = 1$, which means that the maximizing player already has explored a part of the search tree such that it can **guarantee at least** a value of $1$ by playing inside that part (the minimizing player has no options inside that entire tree to reduce the value below $1$, if the maximizing player plays optimally in that part). Suppose that, in the current search process, we have arrived at a node where the minimizing player is to play, and it has a long list of child nodes. We evaluate the first of those children, and find a value of $0$. This means that, under the assumption that we reach this node, the minimizing player can already guarantee a value of $0$ (and possibly get even lower, we didn't evaluate the other children yet). But this is worse (for the maximizing player) than the $\alpha = 1$ bound we already had. Without evaluating any of the other children, we can already tell that this part of the search tree is uninteresting, that the maximizing player would make sure that we never end up here, so we can prune the remaining children (which could each have large subtrees below them). Upvotes: 2 <issue_comment>username_2: **Minimax** As the question author may already understand, minimax is an approach before it is an algorithm. The goal is to minimize the advantage of a challenger and maximize the advantage of the participant presently applying the minimax approach. This is a subset of a wider strategy of summing benefits and subtracting the sum of costs to derive a net value. **Alpha-beta Pruning** The strategic goal of alpha beta pruning is to produce uncompromized decision making with less work. This goal is usually driven by the cost of computing resources, the impatience of the person waiting on results, or a missed deadline penalty. The principle involved is that if there is a finite range to the net gain that can aggregate as a result of traversing any subtree in a search. It can be proven, using the algebra of inequalities, that no knowledge can be lost in the search if the subtree cannot, under any conditions, show any net advantage over the other options. **Some Graph Theory to Clarify Pruning** Vertices are the graph theory name for what are often called tree nodes. They are represented as $\nu$ below, and they correspond to states. The connections between vertices are called edges in graph theory. They are represented as $\epsilon$ below, and they correspond to actions. The minimax net gain thus far accumulated at an vertex can be calculated as the tree is traversed. As the limitations to net gain at further depths are applied to these intermediate net gain values, it can be inferred that one edge (action) will, in every case, be advantageous over another edge. If an algorithm reveals that one edge leads to disadvantage in every possible case, then there is no need to traverse that edge. Such dismissal of never-advantageous edges saves computing resources and likely reduces search time. The term pruning is used because edges are like branches in a fruit orchard. **The Condition of Pruning and the Algorithm To Accomplish It** Initialization for the algorithm begins by setting the two Greek letter variables to their worst case values. $$ \alpha = - \infty \\ \beta = \infty $$ The pruning rule for edge $\epsilon$ leading to a vertex $\nu$ is simply this. $$ \alpha\_\nu \geq \beta\_\nu \Rightarrow \text{prune}(\epsilon\_\nu) $$ Source code doesn't usually directly implement this declaration, but rather produces its effect in the algorithm, which can be represented in simplified pseudo-code. The algorithm to do such is simple once recursion is understood. That is an conceptual prerequisite, so learn about recursion first if not already known. ``` ab_minimax ν, α, β if ν.depth = search.max_depth or ν.is_leaf return ν.value if ν.is_maximizing for ε in ν.edges x = max(β, ab_minimax ε.child, α, β) if α ≥ β ν.prune ε return α return α else for ε in ν.edges x = min(α, ab_minimax child, α, β) if α ≤ β ν.prune ε return β return β ``` Upvotes: 0
2019/01/03
1,373
5,165
<issue_start>username_0: In [the DQN paper](https://storage.googleapis.com/deepmind-media/dqn/DQNNaturePaper.pdf), it is written that the state-space is high dimensional. I am a little bit confused about this terminology. Suppose my state is a high dimensional vector of length $N$, where $N$ is a huge number. Let's say I solve this task using $Q$-learning and I fix the state space to $10$ vectors, each of $N$ dimensions. $Q$-learning can easily work with these settings as we need only a table of dimensions $10$ x number of actions. Let's say my state space can have an infinite number of vectors each of $N$ dimensions. In these settings, Q-learning would fail as we cannot store Q-values in a table for each of these infinite vectors. On the other hand, DQN would easily work, as neural networks can generalize for other vectors in the state-space. Let's also say I have a state space of infinite vectors, but each vector is now of length $2$, i.e., small dimensional vectors. Would it make sense to use DQN in these settings? Should this state-space be called high dimensional or low dimensional?<issue_comment>username_1: Yes, it makes sense to use DQN in state space with small number of dimensions as well. It doesn't really matter how big your state dimension is, but if you have state with 2 dimensions for instance you wouldn't use convolutional layers in your neural net like its used in the paper you mentioned, you can use ordinary fully connected layers, it depends on the problem. Upvotes: 2 <issue_comment>username_2: Usually when people write about having a high-dimensional state space, they are referring to the state space actually used by the algorithm. > > Suppose my state is a high dimensional vector of $N$ length where $N$ is a huge number. Let's say I solve this task using $Q$-learning and I fix my state space to $10$ vectors each of $N$ dimensions. $Q$-learning can easily work with these settings as we need only a table of dimensions $10$ x number of actions. > > > In this case, I'd argue that the "feature vectors" of length $N$ are quite useless. If there are effectively only $10$ unique states (which may each have a very long feature vector of length $N$)... well, it seems like a bad idea to make use of those long feature vectors, just using the states as identity (i.e. a tabular RL algorithm) is much more efficient. If you end up using a tabular approach, I wouldn't call that a high-dimensional space. If you end up using function approximation with the feature vectors instead, that would be a high-dimensional space (for large $N$). > > Let's also say I have a state space of infinite vectors but each vector is now of length $2$ i.e. very small dimensional vectors. Would it make sense to use DQN in these settings ? Should this state-space be called high dimensional or low dimensional ? > > > This would typically be referred to as having a low-dimensional state space. Note that I'm saying low-**dimensional**. The **dimensionality** of your state space / input space is low, because it's $2$ and that's typically considered to be a low value when talking about dimensionality of input spaces. The state space may still have a large **size** (that's a different word from **dimensionality**). As for whether DQN would make sense in such a setting.. maybe. With such low dimensionality, I'd guess that a linear function approximator would often work just as well (and be much less of a pain to train). But yes, you can use DQN with just 2 input nodes. Upvotes: 3 [selected_answer]<issue_comment>username_3: In addition to [this answer](https://ai.stackexchange.com/a/9830/2444), here's a more formula-based answer, which attempts to clarify the difference between the **dimensionality** of a state and the **size** of the state space. Let's denote our state space, i.e. the space of states, by $\mathcal{S}$. Let's say that $\mathcal{S}$ is a subset of $\mathbb{R}^N$, i.e. $\mathcal{S} \subseteq \mathbb{R}^N$. So, in this case, a state $s \in \mathcal{S}$ is a vector of $N$ real numbers. Depending on $N \in \mathbb{N}$, the dimensionality of the states can be big or not. If $N = 1$, then a state is a real number, so the dimensionality of the state is small. If $N = 10^{40}$, the dimensionality of the state is huge. To be more concrete, let $\mathcal{S} = \{a, b \}$, $a, b \in \mathbb{R}^N$ and $N= 10^{40}$, then the state space is small, i.e. it contains only 2 states ($a$ and $b$), but the dimensionality of $a$ and $b$ is huge. You could also have $\mathcal{S} = \{a, b \}$, but $a, b \in \mathbb{R}$. In that case, both the state space and the dimensionality of the states is small. In machine learning (and in the case of DQN), images, unless they are very small (e.g. $5 \times 5$), are typically considered high dimensional *feature vectors* (or *observations* in the case of the DQN). [In the case of DQN (figure 1)](https://storage.googleapis.com/deepmind-media/dqn/DQNNaturePaper.pdf), the input was a $84 \times 84 \times 4$ multi-dimensional array, so each state was relatively high dimensional (i.e. you need $28224$ real numbers to represent each state). Upvotes: 0
2019/01/03
1,611
6,958
<issue_start>username_0: This is a question related to [Neural network to detect "spam"?](https://ai.stackexchange.com/questions/9725/neural-network-to-detect-spam). I'm wondering how it would be possible to handle the emotion conveyed in text. In informal writing, especially among a juvenile audience, it's usual to find emotion expressed as repetition of characters. For example, "Hi" doesn't mean the same as "Hiiiiiiiiiiiiiii" but "hiiiiii", "hiiiiiiiii", and "hiiiiiiiiii" do. A naive solution would be to preprocess the input and remove the repeating characters after a certain threshold, say, 4. This would probably reduce most long "hiiiii" to 4 "hiiii", giving a separate meaning (weight in a context?) to "hi" vs "long hi". The naivete of this solution appears when there are combinations. For example, haha vs hahahahaha or lol vs lololololol. Again, we could write a regex to reduce lolol[ol]+ to lolol. But then we run into the issue of hahahaahhaaha where a typo broke the sequence. There is also the whole issue of Emoji. Emoji may seem daunting at first since they are special characters. But once understood, emoji may actually become helpful in this situation. For example, may mean a very different thing than , but may mean the same as and . The trick with emojis, to me, is that they might actually be easier to parse. Simply add spaces between to convert to in the text analysis. I would guess that repetition would play a role in training, but unlike "hi", and "hiiii", Word2Vec won't try to categorize and as different words (as I've now forced to be separate words, relying in frequency to detect the emotion of the phrase). Even more, this would help the detection of "playful" language such as , where the emoji might imply there is anger, but alongside and especially when repeating multiple times, it would be easier for a neural network to understand that the person isn't really angry. Does any of this make sense or I'm going in the wrong direction?<issue_comment>username_1: These kinds of repetitions in text can place recurrence demands on learning algorithms that may or may not be handled without special encoding. * Hi. * Hiiii! * HIIIIIIIII * Hi!!!!!!!!!!!!!! These have the same meaning on one level, but different emotional content and therefore different correlations to categories when detecting the value of an email, which in the simplest case is the placement of a message in one of two categories. * Pass to a recipient * Archive only This is colloquially called spam detection, although not all useless emails are spam and some messages sent by organizations that broadcast spam may be useful, so technically the term *spam* is not particularly useful. The determinant should usually be the return on investment to the recipient or the organization receiving and categorizing the message. > > Is reading the message and potentially responding likely of greater value than the cost of reading it? > > > That is a high level paraphrase of what the value or cost function must represent when AI components are employed to learn about or track close to (in continuous learning) some business or personal optimality. The question proposes a normalization scheme that truncates long repetitions of short patterns in characters, but truncation is necessarily destructive. Compression of some type that will both preserve nuance and work with the author's use of Word2Vec is a more flexible and comprehensive approach. In the case of playful sequences of characters it is anthropomorphic to imagine that an artificial network will understand playfulness or anger, however existing learning devices can certainly learn to use character sequences that humans would call playful or angry in the function that emerges to categorize the message containing them. Just remember that model free learning is not at all like cognition, so the term *understanding* is placing an expectation on the mental capacities of the AI component that the AI component may not possess. Since no indication that a recurrent or recursive network will be used but rather the entire message is represented in a fixed width vector, so the question becomes which of these two approaches will produce the best outcomes after learning. * Leaving the text uncompressed so that an 'H' character followed by ten 'i' characters is distinct as a word from an 'H' character followed by five 'i' characters * Compressing the text to "Hi [9xi]" and "Hi [4xi]" respectively or some such word bifurcation. This second approach produces reasonable behavior with other cases mentioned, such as "" pre-processed into " [2x]". What the algorithm in Word2Vec will do with each of these two choices and how its handling of them will affect outcomes is difficult to predict. Experiments must be run. Three things are advisable courses of action. * Build a test fixture to allow quick evaluation of outcomes for various trials. * Experiment with dilligence. Don't leave any potentially interesting case untried. * Label as much production data as reasonably possible and use that as well as the canned data so that the above options can be evaluated in permuted combinations with the differences in pattern distribution between the canned and live data. Upvotes: 1 <issue_comment>username_2: My sense is that this would require a statistical approach with a large dataset. The algorithm would need to "translate" the slang into formal terms (discrete words or phrases expressing a single concept.) The trick would be vetting the algorithms decisions, which would require a sufficient sample of humans to evaluate the given translation for each novel instance of slang. (This would likely require some form of crowdsourcing, similar to Captcha.) This would determine whether 4⇔ 5⇔ 6 where 4x, 5x, 6x of the symbol are equivalent, and whether spacing between the emoji's is meaningful. Most likely these would be fuzzy associations in that the same slang can be interpreted differently by different people, and the meaning can vary when used in different contexts: could mean "I'm laughing super-hard because what you say is so absurdly incorrect." [Adversarial] could mean "I'm laughing super-hard because the joke is extremely funny." [Cooperative] *Informally, my experience of 5 has always been in adversarial, but that could be a function of the contexts in which I've encountered it, which reinforces the need for a large samples.* It occurs to me that you could reduce the sample size by using a friendly chatbot that parses social media posts for any symbolic information that is non-standard, then queries the posters asking for clarification. (This way, you'd get the intent of the slang from the person using it, as opposed interpretations of those viewing it.) For informal text (as opposed to emojis) the algorithm would want to be able to distinguish between intentional or unintentional mis-spellings. Upvotes: 0
2019/01/04
794
3,286
<issue_start>username_0: What are the strengths of the Hierarchical Temporal Memory model compared to competing models such as 'traditional' Neural Networks as used in deep learning? And for those strengths are there other available models that aren't as bogged down by patents?<issue_comment>username_1: IMO, the greatest "strength" of HTM is that it is modeled after the human neocortex, which is the most intelligent thing we know of. But to understand the importance of this simple idea one must contrast it with the most familiar form of AI - Neural Networks (NNs). Traditional Neural Network AI has been under development for a long time and has many more people working on it than HTM. NNs are capable of performing a bewildering number of tasks, and the list of its accomplishments grows with every passing day. However, NNs are *not thinking*. They perform their magic only after being trained on (typically) massive amounts of training data. Training a NN is essentially an advanced form of curve-fitting. If your training data encompasses closely enough what it encounters in new data then it will likely perform very well. However, if it encounters something new (which is sometimes difficult to know beforehand) then it can fail abysmally, and often in a way that humans would never fail. One example I heard about was on a NN trained on millions of images that could briefly describe what was in new images it had never seen before. It performed fabulously - something like 95-97% accuracy. However, when it was shown an image of a baby holding a toothbrush, it said, "A boy holding a baseball bat." This is not a human-like error. Humans know the difference between a boy and a baby, and a bat and a toothbrush. This is just an example, but it reveals a fundamental problem of NNs - they are not thinking. Useful? Yes. Thinking? No. Back to HTM. HTM is new and currently has only a handful of researchers working on it. It is "better" than NNs in only a small number of cases - it has a long way to go. So if by "strengths" you're thinking about what tasks can currently be done better with HTM than with NNs, then most people should still chose NNs. However, if by "strengths" you're thinking about what has the best chance of achieving general intelligence someday, then I would say hands-down it is HTM. Upvotes: 2 <issue_comment>username_2: HTM is a credible theory about how the brain works, and how brain-like systems could be constructed in software. It includes: * SDR (Sparse Distributed Representation), a means for representing just about any kind of sensory, intermediate or motor data, innately noise resistant and suited to recognising patterns * TM (Temporal Memory), which can recognise SDRs in the context of other preceding SDRs, to learn new patterns "on the job" with no separate training phase * SM (Sequence Memory), which can learn, remember and replay arbitrarily long sequences of SDRs. ANNs are mature, commercially valuable pattern recognisers made possible by the confluence of vast amounts of computing power, data and commercial opportunity. HTM is immature and just a fascinating toy, for now. But HTM might just put us on the path to the Holy Grail, true artificial general intelligence, and ANNs will never do that. Upvotes: 0
2019/01/04
2,035
7,986
<issue_start>username_0: After reading an excellent BLOG post [**Deep Reinforcement Learning: Pong from Pixels**](http://karpathy.github.io/2016/05/31/rl/) and playing with the code a little, I've tried to do something simple: use the same code to train a logical XOR gate. But no matter how I've tuned hyperparameters, the reinforced version does not converge (gets stuck around -10). What am I doing wrong? Isn't it possible to use Policy Gradients, in this case, for some reason? The setup is simple: * 3 inputs (1 for bias=1, x, and y), 3 neurons in the hidden layer and 1 output. * The *game* is passing all 4 combinations of x,y to the RNN step-by-step, and after 4 steps giving a reward of +1 if all 4 answers were correct, and -1 if at least one was wrong. * The *episode* is 20 *games* The code (forked from original and with minimal modifications) is here: <https://gist.github.com/Dimagog/de9d2b2489f377eba6aa8da141f09bc2> **P.S. Almost the same code trains XOR gate with *supervised* learning in no time (2 sec).**<issue_comment>username_1: Reinforcement learning is used when we know the outcome we want, *but not how to get there* which is why you won't see a lot of people using it for classification (because we already know the optimal policy, which is just to output the class label). You knew that already, just getting it out of the way for future readers! As you say, your policy model is fine - a fully connected model that is just deep enough to learn XOR. I think the reward gradient is a little shallow - when I give a reward of +1 for "3 out 4" correct and +2 for "4 out of 4", then convergence happens (but very slowly). Upvotes: 2 <issue_comment>username_2: **Maybe *Deep* Reinforced Learning?** I am not sure but AND gate could be solved by your implementation. I have other feeling with OR gates. Just think - first we need to have information about two conditions and *then* we can check for complex solutions. First of all I thought about Neural Network with one hidden layer. Sounds perfect. I think you will understand when you check this Tensorflow-Keras code: ``` iterations = 50 model = Sequential() model.add(Dense(16, input_shape=(None, 2), activation='relu')) # our hidden layer for OR gate problem model.add(Dense(2, activation='sigmoid')) model.summary() opt = Adam(0.01) model.compile(optimizer=opt, loss='categorical_crossentropy', metrics=['acc']) # mean_squared_error categorical_crossentropy binary_crossentropy for iteration in range(iterations): x_train = np.array([[0, 0], [0, 1], [1, 0], [1, 1]]) # table of inputs y_train = np.array([[1, 0], [0, 1], [0, 1], [1, 0]]) # outputs in categorical (first index is 0, second is 1) r = np.random.randint(0, len(x_train)) # random input r_x = x_train[r] r_x = np.array([[r_x]]) result = model.predict(r_x)[0] # predict best_id = np.argmax(result) # get of index of "better" output input_vector = np.array([[x_train[r]]]) isWon = False if (best_id == np.argmax(y_train[r])): isWon = True # everything is good else: # answer is bad! output = np.zeros((2)) output[best_id] = -1 output = np.array([[output]]) loss = model.train_on_batch(input_vector, output) print("iteration", iteration, "; has won?", isWon) ``` When "answer" of agent is good - we are not changing anything (but we could train network with best action as 1 for stability). When answer is bad, we set action as bad - other actions have more probability for be chosen. Sometimes learning need to have more than 50 iterations but it is only my proposition. Play with hidden layer neuron count, learn rate and iterations. Hope will help you :) Upvotes: -1 <issue_comment>username_3: There is some confusion between reinforcement and convergence in this question. The XOR problem is of interest in a historical context because the reliability of gradient descent is *identity* (no advantage over an ideal coin toss) for a single layer perceptron when the data set is are the permutations representing the Boolean XOR operation. This is an information theory way of saying a single layer perceptron can't be used to learn arbitrary Boolean binary operations, with XOR and XAND as counterexamples where convergence is not only not guaranteed but productive of functional behavior only by virtue of luck. That is why the MLP was an important extension of the perceptron design. It can be reliably taught an XOR operation. [Search results for images related to deep reinforced learning](https://www.google.com/search?q=deep+reinforcement+learning&source=lnms&tbm=isch) provide a survey of design diagrams representing the principles involved. We can note that the use case for a reinforcement learning application is distinctly different from that of MLPs and their derivatives. Parsing the term and recombining to produce the conceptual frameworks that were originally combined to produce DRL, we have *deep learning* and *reinforcement learning*. Deep learning is really a set of techniques and algorithmic refinements for the combination of artificial network layers into more successful topologies that perform useful data center tasks. Reinforcement learning is Sutton states in [his slides for the University of Texas](https://login.cs.utexas.edu/sites/default/files/legacy_files/research/documents/1%20intro%20up%20to%20RL%3ATD.pdf) (possibly there to get away from the Alberta winters), "RL is learning to control data." His is an overly broad definition, since MLPs, CNNs, and GRU networks all learn a function which is controlling data processing when the learned parameters are then leveraged in their intended use cases. This is where the perspective of the question may be based on the misinformative nature of these excessively broad definitions. The distinction of reinforced learning is the idea that a behavior can be reinforced during use. There may be actual parallel reinforcement of beneficial behavior (as in more neurologically inspired architectures) or learning may occur in a time slicing operating system and share the processing hardware with processes that use what is learned (as in Q-learning algorithms and their derivatives). Some define RL as machine learning technique that direct the selection of actions along a path of behavior such that some cumulative value of the consequences of actions take is maximized. That may be an excessively narrow definition, biased by the popularity of Markov processes and Q-learning. This is the problem with the perspective expressed in the question. An XOR operation is not an environment through which a path can be blazed. If one were to construct an XOR maze, where the initial state is undefined and the one single action is to fall into either the quadrant 10 or 01, it is still not representing an XOR because the input was not a Boolean vector $\vec{B} \in \mathbb{B}^2 \; \text{,}$ and the output is not a 1 or 0 resulting from XOR operation, as would be the case for a multilayer perceptron learning of XOR operation. There is no cumulative reward. If there was no input and the move was to divide in half and chose both 10 or 01 because their reward was higher than 00 or 11, then that might be considered a reinforcement learning scenario, but it would be an odd one. That the described setup leads to, "Getting stuck," is no surprise when the tool is a wrench for the turning of a screw. If the design looses the reinforcement and the artificial network is reduced to a two layer perceptron, the convergence will be guaranteed given a labeled data set of sufficient size or an unsupervised arrangement where the loss function is simply the evaluation of whether the result is XOR. To experiment with reinforced learning, the agent must interact with the environment and make choices that have value consequences that direct subsequent behavior. Boolean expressions are not of this nature, no matter how complex. Upvotes: 2
2019/01/07
1,968
7,775
<issue_start>username_0: I'm trying to understand how the dimensions of the feature maps produced by the convolution are determined in a ConvNet. Let's take, for instance, the VGG-16 architecture. How do I get from 224x224x3 to 112x112x64? (The 112 is understandable, it's the last part I don't get) I thought the CNN was to apply filters/convolutions to layers (for instance, 10 different filters to channel red, 10 to green: are they the same filters between channels ?), but, obviously, 64 is not divisible by 3. And then, how do we get from 64 to 128? Do we apply new filters to the outputs of the previous filters? (in this case, we only have 2 filters applied to previous outputs) Or is it something different? [![vgg 16 archictecutre](https://i.stack.imgur.com/AJo0w.png)](https://i.stack.imgur.com/AJo0w.png)<issue_comment>username_1: Reinforcement learning is used when we know the outcome we want, *but not how to get there* which is why you won't see a lot of people using it for classification (because we already know the optimal policy, which is just to output the class label). You knew that already, just getting it out of the way for future readers! As you say, your policy model is fine - a fully connected model that is just deep enough to learn XOR. I think the reward gradient is a little shallow - when I give a reward of +1 for "3 out 4" correct and +2 for "4 out of 4", then convergence happens (but very slowly). Upvotes: 2 <issue_comment>username_2: **Maybe *Deep* Reinforced Learning?** I am not sure but AND gate could be solved by your implementation. I have other feeling with OR gates. Just think - first we need to have information about two conditions and *then* we can check for complex solutions. First of all I thought about Neural Network with one hidden layer. Sounds perfect. I think you will understand when you check this Tensorflow-Keras code: ``` iterations = 50 model = Sequential() model.add(Dense(16, input_shape=(None, 2), activation='relu')) # our hidden layer for OR gate problem model.add(Dense(2, activation='sigmoid')) model.summary() opt = Adam(0.01) model.compile(optimizer=opt, loss='categorical_crossentropy', metrics=['acc']) # mean_squared_error categorical_crossentropy binary_crossentropy for iteration in range(iterations): x_train = np.array([[0, 0], [0, 1], [1, 0], [1, 1]]) # table of inputs y_train = np.array([[1, 0], [0, 1], [0, 1], [1, 0]]) # outputs in categorical (first index is 0, second is 1) r = np.random.randint(0, len(x_train)) # random input r_x = x_train[r] r_x = np.array([[r_x]]) result = model.predict(r_x)[0] # predict best_id = np.argmax(result) # get of index of "better" output input_vector = np.array([[x_train[r]]]) isWon = False if (best_id == np.argmax(y_train[r])): isWon = True # everything is good else: # answer is bad! output = np.zeros((2)) output[best_id] = -1 output = np.array([[output]]) loss = model.train_on_batch(input_vector, output) print("iteration", iteration, "; has won?", isWon) ``` When "answer" of agent is good - we are not changing anything (but we could train network with best action as 1 for stability). When answer is bad, we set action as bad - other actions have more probability for be chosen. Sometimes learning need to have more than 50 iterations but it is only my proposition. Play with hidden layer neuron count, learn rate and iterations. Hope will help you :) Upvotes: -1 <issue_comment>username_3: There is some confusion between reinforcement and convergence in this question. The XOR problem is of interest in a historical context because the reliability of gradient descent is *identity* (no advantage over an ideal coin toss) for a single layer perceptron when the data set is are the permutations representing the Boolean XOR operation. This is an information theory way of saying a single layer perceptron can't be used to learn arbitrary Boolean binary operations, with XOR and XAND as counterexamples where convergence is not only not guaranteed but productive of functional behavior only by virtue of luck. That is why the MLP was an important extension of the perceptron design. It can be reliably taught an XOR operation. [Search results for images related to deep reinforced learning](https://www.google.com/search?q=deep+reinforcement+learning&source=lnms&tbm=isch) provide a survey of design diagrams representing the principles involved. We can note that the use case for a reinforcement learning application is distinctly different from that of MLPs and their derivatives. Parsing the term and recombining to produce the conceptual frameworks that were originally combined to produce DRL, we have *deep learning* and *reinforcement learning*. Deep learning is really a set of techniques and algorithmic refinements for the combination of artificial network layers into more successful topologies that perform useful data center tasks. Reinforcement learning is Sutton states in [his slides for the University of Texas](https://login.cs.utexas.edu/sites/default/files/legacy_files/research/documents/1%20intro%20up%20to%20RL%3ATD.pdf) (possibly there to get away from the Alberta winters), "RL is learning to control data." His is an overly broad definition, since MLPs, CNNs, and GRU networks all learn a function which is controlling data processing when the learned parameters are then leveraged in their intended use cases. This is where the perspective of the question may be based on the misinformative nature of these excessively broad definitions. The distinction of reinforced learning is the idea that a behavior can be reinforced during use. There may be actual parallel reinforcement of beneficial behavior (as in more neurologically inspired architectures) or learning may occur in a time slicing operating system and share the processing hardware with processes that use what is learned (as in Q-learning algorithms and their derivatives). Some define RL as machine learning technique that direct the selection of actions along a path of behavior such that some cumulative value of the consequences of actions take is maximized. That may be an excessively narrow definition, biased by the popularity of Markov processes and Q-learning. This is the problem with the perspective expressed in the question. An XOR operation is not an environment through which a path can be blazed. If one were to construct an XOR maze, where the initial state is undefined and the one single action is to fall into either the quadrant 10 or 01, it is still not representing an XOR because the input was not a Boolean vector $\vec{B} \in \mathbb{B}^2 \; \text{,}$ and the output is not a 1 or 0 resulting from XOR operation, as would be the case for a multilayer perceptron learning of XOR operation. There is no cumulative reward. If there was no input and the move was to divide in half and chose both 10 or 01 because their reward was higher than 00 or 11, then that might be considered a reinforcement learning scenario, but it would be an odd one. That the described setup leads to, "Getting stuck," is no surprise when the tool is a wrench for the turning of a screw. If the design looses the reinforcement and the artificial network is reduced to a two layer perceptron, the convergence will be guaranteed given a labeled data set of sufficient size or an unsupervised arrangement where the loss function is simply the evaluation of whether the result is XOR. To experiment with reinforced learning, the agent must interact with the environment and make choices that have value consequences that direct subsequent behavior. Boolean expressions are not of this nature, no matter how complex. Upvotes: 2
2019/01/08
2,972
13,556
<issue_start>username_0: Is "emotion" ever used in AI? Psychologists have a lot to say about emotion and it's functional utility for survival - but I've never seen any AI research that uses something resembling "emotion" inside an algorithm. (Yes, there's some work done on trying to classify human emotions, called "emotional intelligence", but that's extrememly different from /using/ emotions within an algorithm) For example, you could imagine that a robot might need fuel and be "very thirsty" - causing it to prioritize different tasks (seeking fuel). Emotions also sometimes don't just focus on objectives/priorities - but categorize how much certain classifications are "projected" into a particular emotions. For example, maybe a robot that needs fuel might be very "afraid" of going towards cars because it's been hit in the past - while it might be "frustrated" at a container that doesn't open properly. It seems very natural that these things are helpful for survival - and they are likely "hardcoded" in our genes (since some emotions - like sexual attraction - seem to be mostly unchangeable by "nurture") - so I would think they would have a lot of general utility in AI.<issue_comment>username_1: Not a bad question but we can solve this with a little thought experiment. Consider what it means to be "afraid", or to even "feel". It's a DESIRE for something. That something is what pushes us towards general survival. It forces us to focus on what is important right now. And it's relative to our immediate environment & generalized to our abstract conceptualization. The difference with modern ai paradigms is that they are very structured/rigid in their objectives. There's no general sense of "okayness" or generalized sense of guidance on what it should do. This would require a radically different approach to AI design & infrastructure. Being that most companies are trying to make money, there's not a lot to be gained by experimenting with "feeling" machines. Upvotes: 0 <issue_comment>username_2: **Current Simulation of Emotional Behavior** Emotion is used in AI in very limited ways in leading edge natural language systems. For instance, advanced natural language systems can calculate the probability that a particular segment of speech originates from an angry human. This recognition can be trained using labels from bio-monitors. However, the mental features of a human with soft skills tuned from years of experience with people is not nearly simulated in computers as of this writing. We will not see computers becoming counselors (as once believed) or directors of movies or courtroom judges or customs officials any time soon. Nonetheless, the processes behind emotion are not entirely undiscovered, and there is definite interest in simulating them in computers. Much of that work is company confidential. The emergence of emotional sophistication in computers likely to begin in the context of sexuality, primarily because flirtation is powerful and primordial emotional expression will probably be easier to simulate in natural language than higher emotional expressions such as love or chaotic ones like rage. Sexy AI will likely be exploited by what businesses might consider legitimate marketing activity. It is also going to be exploited by the sex industry. The ethical and moral analysis of sexy AI beyond the scope of the question but will probably gain the attention of public media as it unfolds, and that has already begun on FaceBook, originating from third party attacks using fictitious identities. **The Science of Emotion** Emotion isn't a scientific quantity. From an AI perspective, emotion is a quality an individual might recognize through visual and audio queues, specifically through the natural language and affect of another individual. (Affect is a visual clue about a person's emotional and general mental state.) An individual can also learn to recognize those clues in her or his self. They can be detected by replaying one's own speech as heard through the ear, by linguistic analysis of thoughts not spoken, or through the detection of muscle tension or vital signs. Those skilled in meditation can detect emotional predecessors closer to their causal centers in the brain and control them more directly before emotions even arise. In the brain, emotion is not in a single geometric location. We cannot say, "That emotion of compassion comes from this group of neurons in Jerome's brain." We cannot say, "Sheri is angry at this 3D coordinate in her cerebral cortex." Emotions are also not strictly system wide either. An individual can be annoyed without going into rage, leaving most of the brain chemistry and electrical signaling unaffected. Emotions are not entirely electrical and not entirely chemical. On the electric side, emotional states can occur simultaneously through separate circuit pathway connecting distinct and only distantly related regions of the brain. On the chemical side, there is the synaptic chemistry that is part of the electrical signal pathways. There are also many regional signaling systems using specialized pathways that are neither circulatory (blood) nor primary electrical (neuron) pathways. Serotonin is one of dozens of chemical signaling compounds that operate regionally in this way. Emotions, being a largely social set of phenomena, should not be characterized as purely Darwinian. Although related to survival, emotional processing and communications impact mate selection and, more generally, social patterns within a community, including altruistic and collaborative activity. Emotions don't always lead to survival. In some cases, emotional states may lead to death prior to reproduction. One could say that emotional balance and the ability to interact on emotional levels may improve odds of having offspring. Imbalance to the degree of any of hundreds of emotional extremes can lead to childlessness. Emotional intelligence is different than using emotions within an algorithm, but not extremely so. Discussion of emotional intelligence is one of many advancements in the concept of intelligence since the formation of one-dimensional conceptions of intelligence. Those nineteenth century conceptions, such as IQ and G-factor are poorly supported by genetic evidence and anthropological theory. Mathematically unproven and naive concepts like general intelligence rest on those one-dimensional concepts. Emotional intelligence is a form of mental capability related to emotional balance. If a person's cognitive skills are honed with respect to their emotions and the assessment of the emotional states of others, then they have greater emotional intelligence than someone who cannot read the affect and linguistic clues of another and cannot integrate cognitive and emotional skill to balance of their own emotions. **Cybernetic Analysis** The interface between natural emotion and artificial emotion fits within the realm of cybernetics, the conceptual study of the interface between humans and machines. Such interaction is clearly related to both algorithms and topology, two important concepts in AI research and development. Emotion has an algorithmic context because there is clearly some combination of neurons and chemistry that produce this algorithmic difference between a reactive person and one who has developed emotional intelligence. ``` emotion[person] = recognize_emotion[person] if emotion[person] = anger be_in_responses(angry) emotion[person] = recognize_emotion[person] if emotion[person] = anger be_in_responses(extra_calm) ``` The former is reactive and the later exhibits emotional intelligence. The acquisition of the later skill may be cognitive and conscious or it may be intuitive and unconscious. In either case, the actual algorithms at a lower level may be entirely different than those shown above, yet the external behavior of the person as marshaled by the brain is essentially one of those shown. The plural, algorithms, is used rather than the singular, algorithm, because it is unlikely that a single synchronous algorithm is involved. The brain is a massively parallel processor. Emotional processing is likely best expressed in artificial form as hundreds of thousands of algorithms operating in parallel and forming millions of balances within the system — multidimensional and highly parallel stasis. This is why emotional recognition and emotional responses are not very sophisticated in computer systems as of this writing. The balances have much social nuance. It may be easier to simulate rational thought than emotional thought. **Desire as a Systemic Behavior** Hunger and thirst may sometimes be called feelings, but they are not strictly emotional. The detection of the need for air, energy, nutrients, and water may stimulate emotional states if the needs are unmet and other emotional states if met. A person may become frustrated and irritable when lacking something essential and confronted with another person's less important agenda. A robot may someday do the same. A person may become elated and generous when all such essentials have recently been made available in surplus. A robot may someday do the same. These relationships are expressed in the question this way. > > Emotions also sometimes don't just focus on objectives/priorities — but categorize how much certain classifications are "projected" into a particular emotions. > > > That statement in the question and its explanation is true in some respects. If a robot that needs fuel but is afraid of passing in front of a moving vehicle because it has been hit in the past can be seen in more than one way. * Probabilistic risk management based on past experiences * Fuzzy logic that produces control behavior * Feeling fear because of past experience In AI design, these three would be handled in different ways. * Development of a function that ties visual and auditory information to a model of collision and produces a projected likelihood of injury based each of a number of paths to obtaining fuel * Rules that relates to travel risk with learned probabilities for each along with rules that relate to energy depletion risk with learned probabilities for each and a fuzzy logic rules engine * Artificial networks that have no audit trail but simulate reptilian emotional circuitry and simulate base instinct **Maintaining Scientific Perspective** Emotion is not hard coded into the brain circuitry or DNA. The reality is significantly more complex. The DNA provides parameters to a genetic expression system that leads to protein synthesis that leads to brain structure and function that leads to the ability to learn emotional responses that lead to improved social behavior that may lead to higher probabilities of gene pool survival. Applying digital system traditions to biological process can be counter productive, like anthropomorphic views of programs. Artificial networks don't actually learn; they converge. Nothing is hard coded into biology because the term *code* applied to DNA isn't anything like a page of Java or Python code. It is true that some behavioral predispositions are strong forms of stasis within the course of a species. An organism will normally exhibit a strong desire to acquire resources from the biosphere, such as oxygen, proteins, nutrients, carbs, fats, and water. A robot might replace those with a voltage to use for a charge and lubricants for moving parts. An organism will normally exhibit a string desire to reproduce. A robot might be given a simulation of that recursive process and wish to build another like itself. These are not hard coded in biology. They form a kind of stasis within a population. Some humans don't want children. Some are hospitalized for anorexia nervosa. Some commit suicide by asphyxiation. The statistical mean produces the behavior of the species, not a fixed behavior identical across individuals within the species. **Nature and Nurture** Nature and nurture are useful umbrella terms for general categories of causality in biology and may have equivalents in future robotic products, but they are broad generalities. There are no nature algorithms or nurture algorithms or algorithms that balance nature and nurture. That is where topology is of paramount conceptual importance. **Topology of Algorithmic Components** There is massive interaction between many systems operating independently in multiple dimensions. The visualization of such interactive structure would look more like the topology of all the web sites in a country than a machine learning block diagram. If somehow coded into one algorithm it is possible that all the silicon from all the sand on earth converted to random access memory (RAM) might be insufficient to hold the code expressing the algorithm. Perhaps not. Perhaps a simplicity underlies the interactive system design of life. Perhaps we'll someday know. Perhaps not. The elegance in the design of life on earth is that multiple independent processes are tuned by billions of years of trial and error to inter-operate and support complex organic processes with billions of moving parts at a molecular level. **Veins of Interdisciplinary Research** Study of these are important for biology, for bioinformatics, for cognitive science, and for artificial intelligence. Emotional recognition and integration of emotional reaction and control into natural communications is part of this research and development. Upvotes: 2
2019/01/09
1,217
5,110
<issue_start>username_0: When trying to map artificial neuronal models to biological facts it was not possible to find an answer regarding the **biological justification** of randomly initializing the weights. Perhaps this is not yet known from our current understanding of biological neurons?<issue_comment>username_1: I am not an DL expert but these are my short thoughts on it: I think this is because it is believed (from an information theoretic point of view) to be the good way to avoid that the network falls into some wired state from beginning on. Remember: DNNs are nonlinear approximators for continuous functions. So they have some storage capacity to learn an amount of n function to map from input to output. When you look on topic like data leakage you will see that NNs quickly try to cheat you if they can :D. The optimization applied during training will heavily be affected by the init state. So starting with an random initialization at least avoids that your neurons do all the same at the beginning etc. **Biological reasoning:** From the viewpoint of a neurobiologist I can recommend you to read [Hebbian rule](https://en.m.wikipedia.org/wiki/Hebbian_theory) and how neural systems work (eg. [google how neurons find targets](https://www.quora.com/How-do-axons-branching-out-from-neurons-find-their-targets)) in general and then to compare it to what is known about how dendrite cells in the cerebrum develop their interconnections in the first 3 years after birth. In summary there are behavioral patterns in nature which could look similar, inspiring and even reasonable. But, I would say the reason why this random init. is recommend is backed by mathematical and information theoretical assumptions rather then pure biological arguments. Upvotes: 0 <issue_comment>username_2: **In short** I mentioned [in another post](https://psychology.stackexchange.com/a/10886/4055), how the Artificial Neural Network (ANN) weights are a relatively crude abstraction of connections between neurons in the brain. Similarly, **the random weight initialization step in ANNs is a simple procedure that abstracts the complexity of [central nervous system development](https://en.wikipedia.org/wiki/Development_of_the_nervous_system) and [synaptogenesis](https://en.wikipedia.org/wiki/Synaptogenesis#Central_nervous_system_synapse_formation).** **A bit more detail** (with the most relevant parts *italicized* below) The neocortex (one of its columns, more specifically) is a region of the brain that somewhat resembles an ANN. It has a laminar structure with layers that receive and send axons from other brain regions. Those layers can be viewed as "input" and "output" layers of an ANN (axons "send" signals, dendrites "receive"). Other layers are intermediate-processing layers and can be viewed as the ANN "hidden" layers. When building an ANN, the programmer can set the number of layers and the number of units in each layer. In the neocortex, the number of layers and layer cell counts are determined mostly by genes (however, see: [Human echolocation](https://en.wikipedia.org/wiki/Neuroplasticity#Human_echolocation) for an example of post-birth brain plasticity). Chemical cues guide the positions of the cell bodies and create the laminar structure. They also seem to guide long term axonal connections between distant brain regions. The cells then sprout dendrites in certain characteristic "tree-like" patterns (see: [NeuroMorpho.org](http://www.neuromorpho.org/index.jsp) for examples). *The dendrites will then form synapses with axons or other cell bodies they encounter along the way, generally based on the encountered cell type.* This last phase is probably the most analogous to the idea of random weight initialization in ANNs. Based on where the cell is positioned and its type, *the encountered other neurons will be somewhat random and so will the connections to them*. These connections are probably not going to be very strong initially but will have room to get stronger during learning (probably analogous to initial random weights between 0 and ~0.1, with 1 being the strongest possible connection). Furthermore, most cells are either inhibitory or excitatory (analogous to negative and positive weights). Keep in mind this randomization process has a heavy spatial component in real brains. The neurons are small and so they will make these connections to nearby neurons that are 10-200 microns away. The long-distance connections between brain regions are mostly "programmed-in" via genes. In most ANNs, there is generally no distance-based aspect to the initialization of connection weights (although convolutional ANNs implicitly perform something like distance-based wiring by using the sliding window). There is also the [synaptic pruning](https://en.wikipedia.org/wiki/Synaptic_pruning) phenomenon, which might be analogous to creating many low weight connections in an ANN initially (birth), training it for some number of epochs (adolescence), and then removing most low-weight connections (consolidation in adulthood). Upvotes: 3 [selected_answer]
2019/01/09
1,930
6,884
<issue_start>username_0: I'm doing a research on a finite-horizon Markov decision process with $t=1, \dots, 40$ periods. In every time step $t$, the (only) agent has to chose an action $a(t) \in A(t)$, while the agent is in state $s(t) \in S(t)$. The chosen action $a(t)$ in state $s(t)$ affects the transition to the following state $s(t+1)$. In my case, the following holds true: $A(t)=A$ and $S(t)=S$, while the size of $A$ is $6 000 000$ (6 million) and the size of $S$ is $10^8$. Furthermore, the transition function is stochastic. Would Monte Carlo Tree Search (MCTS) an appropriate method for my problem (in particular due to the large size of $A$ and $S$ and the stochastic transition function?) I have already read a lot of papers about MCTS (e.g. progressive widening and double progressive widening, which sound quite promising), but maybe someone can tell me about his experiences applying MCTS to similar problems or about appropriate methods for this problem (with large state/action space and a stochastic transition function).<issue_comment>username_1: MCTS is often said to be a good choice for problems with large branching factors... but the context where that sentiment comes from is that it originally became popular for playing the game of Go, as an alternative to older game-playing approaches such as alpha-beta pruning. The branching factor of Go is more like 250-300 though, which is often viewed as a large branching factor for board games. It's not such an impressive branching factor anymore when compared to your branching factor of $6,000,000$... I don't see MCTS working well out of the box when you have 6 million choices at every step. Maybe it could do well if you have an extremely efficient implementation of your MDP (e.g. if you can simulate millions of roll-outs per second), and if you have a large amount of "thinking time" (probably in the order of hours or days) available. --- To have any chance of doing better with such a massive branching factor, you really need generalization across actions. Are your 6 million actions really all entirely different actions? Or are many of them somehow related to each other? If you gather some experience (a simulation in MCTS, or just a trajectory with Reinforcement Learning approaches), can you generalize the outcome to other actions for which you did not yet collect experience? If there is some way of treating different actions as being "similar" (in a given state), you can use a single observation to update statistics for multiple different actions at once. The most obvious way would be if you can define meaningful features for actions (or state-action pairs). Standard Reinforcement Learning approaches (with function approximation, maybe linear or maybe Deep Neural Networks) can then relatively "easily" generalize in a meaningful way across lots of actions. They can also be combined with MCTS in various ways (see for example AlphaGo Zero / Alpha Zero). Even with all that, a branching factor of 6 million still remains massive... but generalization across actions is probably your best bet (which may be done inside MCTS, but really does need a significant number of bells and whistles on top of the standard approach). Upvotes: 1 <issue_comment>username_2: The question is whether MCTS is an appropriate method given these conditions. * Action $a\_t \in A\_t$ * State $s\_t \in S\_t$ * $[a\_t, s\_t] \Rightarrow s\_{t+1}$ * $t\_i \land i \in [1, 40]$ * $A(t) \in \text{set} \, A \; \land \; \text{size} (A) = 6 x 10^6$ * $S(t) \in \text{set} \, S \; \land \; \text{size} (S) = 1 x 10^8$ * Transition function is stochastic MCTS focuses on the most promising sub-trees and is therefore asymmetric and well suited for some systems with a high branching factor, but the set sizes can be prohibitive unless some symmetries are exploited. The original MCTS algorithm does not converge quickly. This is why alpha–beta pruning and other search strategies that focus on the minimization of the search space are often used, but they have limitations with regard to branching breadth too. Pruning heuristics can help with reducing the combinatoric explosion but may lead to the most advantageous action options being missed. Some variants of MCTS, such as those among the articles below and in the case of AlphaZero used to learn Go from only the game rules, show excellence in search speed, but perhaps not to the degree needed in this case without parallelism in the form of a computing cluster or significant hardware acceleration. An excellent characteristic of MCTS is that highly promising actions found early may be selected without exhausting all the sub-tree evaluations, but again, that may not be enough. A possibly constraining consideration is whether the Marcov property will be upheld, how, and whether it should be. Another consideration is whether the system involves an opposing intelligent participant. All sampling or pruning search strategies involve the risk of not reliably identifying a single branch in a sub-tree that leads readily to an irreversible (or difficult to reverse) loss. These are some excellent papers that discuss these considerations and provide a high level of experience in the form of research results. The computational challenge of tree searches with high branching is covered by the articles discussing approximate solvers, an area of high research intensity. * [*An online POMDP solver for uncertainty planning in dynamic environment*](http://robotics.itee.uq.edu.au/~hannakur/dokuwiki/papers/isrr13_abt.pdf), <NAME>, <NAME>, 2016 * [*An online and approximate solver for pomdps with continuous action space*](http://robotics.itee.uq.edu.au/dokuwiki/cache/ICRA15_GoldenABT.pdf), <NAME>, <NAME>, 2015 * [*Hindsight is Only 50/50: Unsuitability of MDP based Approximate POMDP Solvers for Multi-resolution Information Gathering*](https://arxiv.org/pdf/1804.02573), <NAME>, <NAME>, <NAME>, 2018 * [*α-min: A Compact Approximate Solver For Finite-Horizon POMDPs*](http://www.aaai.org/ocs/index.php/IJCAI/IJCAI15/paper/download/10985/11024), <NAME>, <NAME>, <NAME>, 2015 * [*Reinforcement Learning as a Framework for Ethical Decision Making*](http://www.aaai.org/ocs/index.php/WS/AAAIW16/paper/download/12582/12346), <NAME>, <NAME>, <NAME>, 2016 * [*On the Complexity of Iterative Tropical Computation with Applications to Markov Decision Processes*](https://arxiv.org/pdf/1807.04920), <NAME>, <NAME>, <NAME>, <NAME>, 2018 * [*Optimizing over a Restricted Policy Class in Markov Decision Processes*](https://arxiv.org/pdf/1802.09646), <NAME>, <NAME>, 2018 * [*Probabilistic inference techniques for scalable multiagent decision making*](https://www.jair.org/index.php/jair/article/download/10944/26075/), <NAME>, <NAME>, <NAME>, 2015 Upvotes: -1
2019/01/09
1,272
4,805
<issue_start>username_0: In the book [Reinforcement Learning: An Introduction (2nd edition)](http://incompleteideas.net/book/RLbook2020.pdf) Sutton and Barto define at [page 104 (p. 126 of the pdf), equation (5.3),](http://incompleteideas.net/book/RLbook2020.pdf#page=126) the importance sampling ratio, $\rho \_{t:T-1}$, as follows: $$\rho \_{t:T-1}=\prod\_{k=t}^{T-1}\frac{\pi(A\_k|S\_k)}{b(A\_k|S\_k)}$$ for a target policy $\pi$ and a behavior policy $b$. However, on page 103, they state: > > The target policy $\pi$ [...] may be deterministic [...]. > > > When $\pi$ is deterministic and greedy it gives $1$ for the greedy action and 0 for all other possible actions. So, how can the above formula give something else than zero, except for the case where policy $b$ takes a path that $\pi$ would have taken as well? If any selected action of $b$ is different from $\pi$'s choice, then the whole numerator is zero and thus the whole result.<issue_comment>username_1: You're correct, when the target policy $\pi$ is deterministic, the importance sampling ratio will be $\geq 1$ along the trajectory where the behaviour policy $b$ happened to have taken the same actions that $\pi$ would have taken, and turns to $0$ as soon as $b$ makes one "mistake" (selects an action that $\pi$ would not have selected). Before importance sampling is introduced in the book, I believe the only off-policy method you will have seen is one-step $Q$-learning, which can only propagate observations back along exactly one step. With the importance sampling ratio, you can often do a bit better. You're right, there is a risk that it turns to $0$ rather quickly (especially when $\pi$ and $b$ are very different from each other), at which point it essentially "truncates" your trajectory and ignores all subsequent experience... but that still can be better than one-step, there is a chance that the ratio will remain $1$ for at least a few steps. It will occasionally still only permit $1$-step returns, but also sometimes $2$-step returns, sometimes $3$-step returns, etc., which is often better than only having $1$-step returns. Whenever the importance sampling ratio is not $0$, it can also give more emphasis to the observations resulting from trajectories that would be common under $\pi$, but are uncommon under $b$. Such trajectories will have a ratio $> 1$. Emphasizing such trajectories more can be beneficial, because they don't get experienced often under $b$, so without the extra emphasis it can be difficult to properly learn what would have happened under $\pi$. --- Of course, it is also worth noting that your quote says (emphasis mine): > > The target policy $\pi$ [...] **may** be deterministic [...] > > > It says that $\pi$ **may** be deterministic (and in practice it very often is, because we very often take $\pi$ to be the greedy policy)... but sometimes it won't be. The entire approach using the importance sampling ratio is well-defined also for cases where we choose $\pi$ **not** to be deterministic. In such situations, we'll often be able to propagate observations over significantly longer trajectories (although there is also a risk of excessive variance and/or numeric instability when $b$ selects actions that are highly unlikely according to $b$, but highly likely according to $\pi$). Upvotes: 3 [selected_answer]<issue_comment>username_2: Good question. I think this part of the book is not well explained. Off-policy evaluation of $V$ by itself doesn't make sense, IMO. I think there are two cases here 1. is if $\pi$ is deterministic, as we probably want in the case of "control", i.e. we will determine $\pi$ to be deterministic and in every state choose the action that most likely to maximize the rewards/returns. In that case, then evaluating $V$ from a different distribution might not be so useful, as $W$ becomes $0$ with high likelihood. I don't see any sense in it. 2. if $\pi$ is not deterministic. And it's a good question why would we want to evaluate $V\_\pi$ from $V\_b$, instead of just evaluating it from $V\_\pi$ directly. So, IMO, off-policy evaluation of $V\_\pi$ doesn't make any sense. However, I think the goal here is actually the **control algorithm** given in the book (using $q(s,a)$, p. 111 of the book [133 of the pdf]). The idea here is to use some arbitrary behavior/exploratory policy and, while it runs, update ("control") the policy $\pi$. In there, you use the update rule for $W$, which uses the idea of importance sampling - i.e. how to update the expected value of $\pi$ based on $b$. But there it ACTUALLY makes sense. So, I suspect the evaluation was given by itself just so the reader can better understand how to do the evaluation, though it really doesn't make sense outside the control algorithm. Upvotes: 1
2019/01/10
1,427
5,791
<issue_start>username_0: Disclaimer: I'm not a student in computer science and most of my knowledge about ML/NN comes from YouTube, so please bear with me! --- Let's say we have a classification neural network, that takes some input data $w, x, y, z$, and has some number of output neurons. I like to think about a classifier that decides how expensive a house would be, so its output neurons are bins of the approximate price of the house. Determining house prices is something humans have done for a while, so let's say we know *a priori* that data $x, y, z$ are important to the price of the house (square footage, number of bedrooms, number of bathrooms, for example), and datum $w$ has no strong effect on the price of the house (color of the front door, for example). As an experimentalist, I might determine this by finding sets of houses with the same $x, y, z$ and varying $w$, and show that the house prices do not differ significantly. Now, let's say our neural network has been trained for a little while on some random houses. Later on in the data set. it will encounter sets of houses whose $x, y, z$ and price are all the same, but whose $w$ are different. I would naively expect that at the end of the training session, the weights from $w$ to the first layer of neurons would go to zero, effectively decoupling the input datum $w$ from the output neuron. I have two questions: 1. Is it certain, or even likely, that $w$ will become decoupled from the layer of output neurons? 2. Where, mathematically, would this happen? What in the backpropagation step would govern this effect happening, and how quickly would it happen? For a classical neural network, the network has no "memory," so it might be very difficult for the network to realize that $w$ is a worthless input parameter. Any information is much appreciated, and if there are any papers that might give me insight into this topic, I'd be happy to read them.<issue_comment>username_1: You're correct, when the target policy $\pi$ is deterministic, the importance sampling ratio will be $\geq 1$ along the trajectory where the behaviour policy $b$ happened to have taken the same actions that $\pi$ would have taken, and turns to $0$ as soon as $b$ makes one "mistake" (selects an action that $\pi$ would not have selected). Before importance sampling is introduced in the book, I believe the only off-policy method you will have seen is one-step $Q$-learning, which can only propagate observations back along exactly one step. With the importance sampling ratio, you can often do a bit better. You're right, there is a risk that it turns to $0$ rather quickly (especially when $\pi$ and $b$ are very different from each other), at which point it essentially "truncates" your trajectory and ignores all subsequent experience... but that still can be better than one-step, there is a chance that the ratio will remain $1$ for at least a few steps. It will occasionally still only permit $1$-step returns, but also sometimes $2$-step returns, sometimes $3$-step returns, etc., which is often better than only having $1$-step returns. Whenever the importance sampling ratio is not $0$, it can also give more emphasis to the observations resulting from trajectories that would be common under $\pi$, but are uncommon under $b$. Such trajectories will have a ratio $> 1$. Emphasizing such trajectories more can be beneficial, because they don't get experienced often under $b$, so without the extra emphasis it can be difficult to properly learn what would have happened under $\pi$. --- Of course, it is also worth noting that your quote says (emphasis mine): > > The target policy $\pi$ [...] **may** be deterministic [...] > > > It says that $\pi$ **may** be deterministic (and in practice it very often is, because we very often take $\pi$ to be the greedy policy)... but sometimes it won't be. The entire approach using the importance sampling ratio is well-defined also for cases where we choose $\pi$ **not** to be deterministic. In such situations, we'll often be able to propagate observations over significantly longer trajectories (although there is also a risk of excessive variance and/or numeric instability when $b$ selects actions that are highly unlikely according to $b$, but highly likely according to $\pi$). Upvotes: 3 [selected_answer]<issue_comment>username_2: Good question. I think this part of the book is not well explained. Off-policy evaluation of $V$ by itself doesn't make sense, IMO. I think there are two cases here 1. is if $\pi$ is deterministic, as we probably want in the case of "control", i.e. we will determine $\pi$ to be deterministic and in every state choose the action that most likely to maximize the rewards/returns. In that case, then evaluating $V$ from a different distribution might not be so useful, as $W$ becomes $0$ with high likelihood. I don't see any sense in it. 2. if $\pi$ is not deterministic. And it's a good question why would we want to evaluate $V\_\pi$ from $V\_b$, instead of just evaluating it from $V\_\pi$ directly. So, IMO, off-policy evaluation of $V\_\pi$ doesn't make any sense. However, I think the goal here is actually the **control algorithm** given in the book (using $q(s,a)$, p. 111 of the book [133 of the pdf]). The idea here is to use some arbitrary behavior/exploratory policy and, while it runs, update ("control") the policy $\pi$. In there, you use the update rule for $W$, which uses the idea of importance sampling - i.e. how to update the expected value of $\pi$ based on $b$. But there it ACTUALLY makes sense. So, I suspect the evaluation was given by itself just so the reader can better understand how to do the evaluation, though it really doesn't make sense outside the control algorithm. Upvotes: 1
2019/01/11
2,407
8,537
<issue_start>username_0: I have checked out many methods and papers, like YOLO, SSD, etc., with good results in detecting a rectangular box around an object, However, I could not find any paper that shows a method that learns a rotated bounding box. Is it difficult to learn the rotated bounding box for a (rotated) object? Here's a diagram that illustrates the problem. [![](https://i.stack.imgur.com/Ljimz.png)](https://i.stack.imgur.com/Ljimz.png) For example, for this object (see [this](https://stackoverflow.com/q/40404031/9277245)), its bounding box should be of the same shape (the rotated rectangle is shown in the 2nd right image), but the prediction result for the YOLO will be Ist right. Is there any research paper that tackles this problem?<issue_comment>username_1: [Here's](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6112046/#sec3-sensors-18-02702title) a recent paper that does what you're looking for. It looks like they achieve this simply by adding a couple rotated prior boxes and regressing the angles in between. This is similar to what standard object detectors do in terms of creating a bunch of prior box shapes and regressing the actual sizes. Upvotes: 2 <issue_comment>username_2: **Cartesian Bias and Pipeline Efficiency** You are experiencing a techno-cultural artifact of Cartesian-centric imaging running all the way back to the dawn of coordinate systems. It is the momentum of practice as a consequence of applying Cartesian 2D coordinates to rasterize images appearing at the focal planes of lenses from the dawn of television and the earliest standards of raster based capture and display. Although some work was done toward adding tilt to bounding rectangles in the late 1990s and since, from a time and computing resource conservation perspective, it is computationally and programmatically less costly to include the four useless triangles of pixels and keep the bounding box orthogonal with the pixel grid. Adding a tilt angle to the bounding boxes is marginally competitive when detecting ships from a satellite only because two conditions offset the inefficiencies in that narrow domain. The ship appears as an oblong rectangle with rounded corners from a satellite positioned in geosynchronous orbit. In the general case, adding a tilt angle can slow recognition significantly. **Biology Less Biased** An interesting side note is that the neural networks of animal and human vision systems do not have that Cartesian-centricity, but that doesn't help this question's solution, since non-orthogonal hardware and software is virtually nonexistent. **Early Non-Cartesian Research and Today's Rasterization** Gerber Scientific Techonology research and development in the 1980s (South Windsor, Connecticut, U.S.) investigated vector capture, storage, and display, but the R&D was not financially sustainable for a mid-side technology corporation for the reasons above. What remains, because it is economically viable and necessary from an animation point of view, is rasterization on the end of the system that converts vector models into frames of pixels. We see this in on the rendering SVG, VRML, and the original intent of CUDA cores and other hardware rendering acceleration strategies and architectures. On the object and action recognition side, the support of vector models directly from imaging is much less developed. This has not been a major stumbling block for computer vision because the wasted pixels at one tilt angle may be of central importance at another tilt angle, so there are no actual wasted input pixels if the centering of key scene elements is widely distributed in translation and tilt, which is often the case in real life (although not so much in hygienically pre-processed datasets). **Conventions Around Object Minus Camera Tilt and Skew from Parallax** Once edge detection, interior-versus-exterior, and 3D solid recognition come into play, the design of CNN pipelines and the way kernels can do radial transformation without actually requiring $\; \sin, \, \cos, \, \text{and} \, \arctan \;$ functions evaporate the computational burden of the Cartesian nature of pixel tensors. The end result is that the bounding box being orthogonal to the image frame is not as problematic as it initially appears. Efforts to conserve the four triangles of pixels and pre-process orientation is often a wasted effort by a gross margin. **Summary** The bottom line is that efforts to produce vector recognition from roster inputs have been significantly inferior in terms of resource and wait time burden, with the exception of insignificant gains in the narrow domain of naval reconnaissance satellite images. Trigonometry is expensive, but convolution kernels, especially now that they are moving from software into hardware accelerated computing paths in VLSI, is computable at lower costs. **Past and Current Work** Below is some work that deals with tilting with regard to objects and the effects of parallax in relation to the Cartesian coordinate system of the raster representation. Most of the work has to do with recognizing 3D objects in a 3D coordinate system to project trajectories and pilot or drive vehicles rationally on the basis of Newtonian mechanics. [*Efficient Collision Detection Using Bounding Volume Hierarchies of k-DOPs*](ftp://crack.seismo.unr.edu/downloads/russell/trees/klosowski_1998_efficient_collision_k-DOPs.PDF), <NAME>, <NAME>, <NAME>, <NAME>, and <NAME>, 1998 [*Sliding Shapes for 3D Object Detection in Depth Images*](https://pdfs.semanticscholar.org/832e/eaede4f697f005b007798fe0d04829f656b7.pdf), <NAME> and <NAME>, 2014 [*Amodal Completion and Size Constancy in Natural Scenes*](https://www.cv-foundation.org/openaccess/content_iccv_2015/papers/Kar_Amodal_Completion_and_ICCV_2015_paper.pdf), <NAME>, <NAME>, <NAME> and <NAME>, 2015 [*HMD Vision-based Teleoperating UGV and UAV for Hostile Environment using Deep Learning*](https://arxiv.org/pdf/1609.04147.pdf), <NAME>, <NAME>, <NAME>, <NAME>, <NAME> and <NAME>, 2016 [*Ship rotated bounding box space for ship extraction from high-resolution optical satellite images with complex backgrounds*](http://172.16.31.10/bitstream/173211/14544/1/Ship%20Rotated%20Bounding%20Box%20Space%20for%20Ship%20Extraction%20from%20High-Resolution%20Optical%20Satellite%20Images%20with%20Complex%20Backgrounds.pdf), <NAME>, <NAME>, <NAME>, <NAME>, 2016 [*Amodal Detection of 3D Objects: Inferring 3D Bounding Boxes from 2D Ones in RGB-Depth Images*](http://www.dnnseye.com/publications/papers/zhuo_3det_cvpr17.pdf), <NAME>, 2017 [*3D Pose Regression using Convolutional Neural Networks*](http://openaccess.thecvf.com/content_ICCV_2017_workshops/papers/w31/Mahendran_3D_Pose_Regression_ICCV_2017_paper.pdf0), <NAME>, 2017 [*Aerial Target Tracking Algorithm Based on Faster R-CNN Combined with Frame Differencing*](https://www.mdpi.com/2226-4310/4/2/32/htm), <NAME>, <NAME>, <NAME> and <NAME>, 2017 [*A Semi-Automatic 2D solution for Vehicle Speed Estimation from Monocular Videos*](http://openaccess.thecvf.com/content_cvpr_2018_workshops/papers/w3/Kumar_A_Semi-Automatic_2D_CVPR_2018_paper.pdf), <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, 2018 Upvotes: 3 [selected_answer]<issue_comment>username_3: It should not be much more difficult to predict a rotated rectangle compared to a bounding box. A bounding box can be parameterized with 4 floats: $x\_c$, $y\_c$, width, height. A rotated rectangle can be parameterized with 5 floats: $x\_c$, $y\_c$, width, height, angle. However, to avoid the wrap-around issue with predicting the angle with one value (0° is same as 360°), **it should be better to predict sine and cosine instead**. It is actually useful to predict rotated rectangles for text detection (each text field is a rotated rectangle). Indeed, in the wild, text can be in any orientation, and it is important to predict precisely rotated rectangles for OCR to work well. It is especially true for long text boxes near 45° (an axis-aligned bounding box around this would be useless because too big). Here are 2 links I found about this topic: * [Rotated Bounding boxes training](https://github.com/ultralytics/yolov3/issues/345) * [Arbitrary-Oriented Scene Text Detection via Rotation Proposals](https://arxiv.org/abs/1703.01086) Upvotes: 2
2019/01/11
705
3,142
<issue_start>username_0: If I'm performing a text classification task using a model built in Keras, and, for example, I am attempting to predict the appropriate tag for a given Stack Overflow question: > > How do I subtract 1 from an integer? > > > And the ground-truth tag for this question is: > > [objective-c](/questions/tagged/objective-c "show questions tagged 'objective-c'") > > > But my model is predicting: > > [c#](/questions/tagged/c%23 "show questions tagged 'c#'") > > > If I were to retrain my model, but this time add the above question and tag in both the training and testing data, would the model be guaranteed to predict the correct tag for this question in the test data? I suppose the tl;dr is: Are neural networks deterministic if they encounter identical data during training and testing? I'm aware it's not a good idea to use the same data in both training and testing, but I'm interested from a hypothetical perspective, and for gaining more insight into how neural networks actually learn. My intuition for this question is "no", but I'd really be interested in being pointed to some relevant literature that expands/explains that intuition.<issue_comment>username_1: After training, all standard models are deterministic (the process each input goes thru is set). In essence, during training the model attempts to learn the distribution of the training dataset. Whether it is able to depends on the size of the model, if it is big enough, it can simply "memorize" all the training samples and result in perfect accuracy on the training set. Normally this is considered to be terrible (called overfitting) and many regularization techniques attempt to prevent it. Eventually when training a model, you are giving it the training distribution as an example but you hope that it will be able to estimate the real distribution out of it. Upvotes: 1 <issue_comment>username_2: No, Neural Networks do not have such a guarantee. In fact, I don't believe **any** kind of classifier in the entire field of Machine Learning has such a guarantee, though some may be slipping my mind... For an easy counterexample, consider what happens if you have two instances with precisely identical inputs, but different output labels. If your classifier is deterministic (in the sense that there is no stochasticity in the procedure going from input to output **after training**), which a Neural Network is (unless, for example, you mess up a Dropout implementation and accidentally also apply dropout after training), it cannot possibly generate the correct output for both of those instances, even if they were presented as examples thousands of times during training. Of course the above is an extreme example, but similar intuition applies to more realistic cases. There can be cases where getting the correct prediction on one instance would reduce the quality of predictions on many other instances if they have somewhat similar inputs. Normally, the training procedure would then prefer getting better predictions on the larger number of instances, and settle for failure on another instance. Upvotes: 2
2019/01/12
555
2,393
<issue_start>username_0: Some examples of low-variance machine learning algorithms include linear regression, linear discriminant analysis, and logistic regression. Examples of high-variance machine learning algorithms include decision trees, k-nearest neighbors, and support vector machines. **Source:** [![](https://i.stack.imgur.com/s2m9z.png)](https://i.stack.imgur.com/s2m9z.png) **What makes a machine learning algorithm a low variance one or a high variance one?** For example, why do decision trees, k-NNs and SVMs have high variance?<issue_comment>username_1: What this is talking about is how much a machine learning algorithm is good at "memorizing" the data. Decision trees, for their nature, tend to overfit very easily, this is because they can separate the space along very non-linear curves, especially if you get a very deep tree. Simpler algorithms, on the other hand, tend to separate the space along linear hyper surfaces, and therefore tend to under-fit the data and may not give very good prediction, but may behave better on new unseen data which is very different from the training data. Upvotes: 3 [selected_answer]<issue_comment>username_2: An algorithm's bias and variance can be thought of as its property, this can be tweaked with things that we call as hyperparameters, but every algorithm has its own set of assumptions that it makes which if fulfilled, the algorithm performs better. Some algorithms such as Logistic Regression, linear-SVMs (not the kernel SVMs, because they can be used for non-linear problems as well) etc are linear models and work well if the data is linearly separable. If the data can not be separated by a linear plane, then no matter how much you tweak and fine-tune them, it won't work, because the data simply can not be separated by a linear plane, and that is the bias everyone talks about for these kinds of algorithms. On the other hand, Decision Trees can split the whole space into several hypercubes and based on which hypercube a datapoint is in, they classify that datapoint. KNNs on the other hand, use the neighbours of a datapoint and their types/properties to make predictions. Thus, a change in the positions of those datapoints will largely affect both the decision boundary(s) of both of these algorithms, and that is why they can be very easily overfitted and have a high variance. Hope this helps. Upvotes: 1