Are there methods that allow deep networks to learn object categorization in a self-supervised way? When training a deep network to learn object classification from a set like ImageNet, we minimize the cross entropy between the ground truth and the predicted  categories. This is done in a supervised way. It is my understanding that you can separate categories in an unsupervised way using principal component analysis, but I have never seen that in a deep network. I am curious if this can be done easily in the last case. One possible way to do this would be to minimize a loss that favors categorization into one-hot vectors (this would only guarantee that an image is classified into a single category, rather that the correct category, though). Has this been done, or is there any reason why not?

I did an experiment, took a trained densenet121 and kept the bottom layers. I trained the FC layer to a softmax and then to a lambda layer that normalized the vector. I trained the network with imagenet to make the outputs the most far a away from (1,1,1,1,1...1) as possible, so I would get one hot vectors. I did, but the network trained to a single category (put all in the same hot vector). Then I added a penalty that encourages to make vectors different is their features are also different. it improved a little, a dozen categories instead of one, bout noting close to a thousand, the available number.

I am posting this so nobody wastes his time in a silly idea like this one.


Is a switch from Java to Python worth it? I am a university student taking an Artificial Intelligence class this semester. Our professor's programming language of choice is Java, but it seems that perhaps with some nudging, he can change it to Python.

I wanted to know if there is any merit in doing so. I know a programming language is just a programming language - however, given the industry's wide use of Python when implementing AI algorithms (especially with ML), I think it makes much more sense for us to use Python. It will be easier to transition from a University environment to an Industrial one having done several assignments in Python and having a clear understanding of all the tools it provides than if we continue using Java, correct?

What are the advantages and disadvantages of a switch from Java to Python?

While dyedgreen is right in some respects, I don't agree entirely with that sentiment. Sure, you can theoretically use any language as long as you know the maths and understand the concepts inside and out whilst having some applicable knowledge.

However, I don't believe if you are starting from scratch, you should learn to develop models in Java. While the underlying material is the same, all you are doing is wasting time IMO learning a language that is rarely used in the field and lacks sufficient support by most modern ML frameworks. Also, while this is rather subjective, python feels better when used as a data science language. Working with data especially is where that difference is clear to me.

That being said, this could all change, and Java could become the ML language of choice(extremely unlikely).


GANs: Should Generator update weights when Discriminator says false continuously My GANs is like this:

Train an autoencoder (VAE), get the decoder part and use as Generator
Train Discriminator

After training, do the generation in these steps:

Call Generator to generate an image
Call the Discriminator to classify the image to see whether it's acceptable

The problem is that the Discriminator says 'false' a lot, which means the generated image is not useful.

How should the Generator change (update weights) when Discriminator doesn't accept its generated image?

In general, you should train both discriminator D and generator G simultaneously.

Depending on the metric that you use as the target for your model, you may encounter a Vanishing gradient problem. It can happen when you implement original loss (i.e. JS-divergence). In that case D can become overconfident regarding fake samples and won't provide any useful feedback to the G. To find out if training fell into this problem, you should plot D and G loss. It will look as follows:

The original GAN has a lot of problems, that's why I suggest you to use Wasserstein metric. More information you can find in WGAN paper

Here you can find more information about GAN problems:

https://arxiv.org/pdf/1904.08994.pdf
https://arxiv.org/pdf/1804.00140.pdf


Variations of the squared error function Depending on the source I find people using different variations of the "squared error function", how come that be?

  Variation 1

  Variation 2

Notice that it is being devided by 1 over m as opposed to variation 1 (1/2)

The stuff inside the ()^2 is simply notation I get that, but dividing by 1/m and 1/2 will cleary get a different result. Which version is the "correct" one, or is there no such thing as a correct or "official" squared error function?

The first variation is named "$E_{total}$". It contains a sum which is not very well-specified (has no index, no limits). Rewriting it using the notation of the second variation would lead to:

$$E_{total} = \sum_{i = 1}^m \frac{1}{2} \left( y^{(i)} - h_{\theta}(x^{(i)}) \right)^2,$$

where:

$x^{(i)}$ denotes the $i$th training example
$h_{\theta}(x^{(i)})$ denotes the model's output for that instance/example
$y^{(i)}$ denotes the ground truth / target / label for that instance
$m$ denotes the number of training examples

Because the term inside the large brackets is squared, the sign doesn't matter, so we can rewrite it (switch around the subtracted terms) to:

$$E_{total} = \sum_{i = 1}^m \frac{1}{2} \left( h_{\theta}(x^{(i)}) - y^{(i)} \right)^2.$$

Now it already looks quite a lot like your second variation.

The second variation does still have a $\frac{1}{m}$ terms outside the sum. That is because your second variation computes the mean squared error over all the training examples, rather than the total error computed by the first variation.

Either error can be used for training. I'd personally lean towards using the mean error rather than the total error, mainly because the scale of the mean error is independent of the batch size $m$, whereas the scale of the total error is proportional to the batch size used for training. Either option is valid, but they'll likely require different hyperparameter values (especially for the learning rate), due to the difference in scale.

With that $\frac{1}{m}$ term explained, the only remaining difference is the $\frac{1}{2}$ term inside the sum (can also be pulled out of the sum), which is present in the first variation but not in the second. The reason for including that term is given in the page you linked to for the first variation:

  The $\frac{1}{2}$ is included so that exponent is cancelled when we differentiate later on. The result is eventually multiplied by a learning rate anyway so it doesn’t matter that we introduce a constant here.


How to solve the problem of variable-sized AST as input for a (convolutional) neural network model? In my work I have a given source code for a module. From this module I generate an AST, whose size is dependent on the size of the module (e.g. more source code -> bigger AST). I want to train a neural network model which will learn a general structure of a module and be able to rate (on a scale of 0 to 1) how "good" a module is structure wise (if requires are at the beginning, followed by local functions, variables and finally returns). Now I have learnt that Convolutional NNs are quite convenient for this, but the problem I can't seem to solve is that they require a fixed sized input which I can't produce. If I add zero-padding then the outcome will be skewed and the accuracy will suffer. Is there a clear solution to this problem?

You discovered already one solution for your problem: Zero-Padding.

There are two other common possibilities:

Using Recurrent NNsThis is often used at text processing, where you feed each word one after another into your model.
Using Recursive NNs (I wont recommend this for your use case)This method is also frequently used in word processing, but is more often applied in the semantic analysis of text. You reduce the text to the essential, until it has reached the desired length. However, information is lost in this process.


Is there any difference between reward and return in reinforcement learning? I am reading Sutton and Barto's book on reinforcement learning. I thought that reward and return were the same things.

However, in Section 5.6 of the book, 3rd line, first paragraph, it is written:

  Whereas in Chapter 2 we averaged rewards, in Monte Carlo methods we average returns.

What does it mean? Are rewards and returns different things?

Return refers to the total discounted reward, starting from the current timestep.


Why does the number of feature maps increases in the VGG model? I found the below image of how a CNN works

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?

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.


Is there a relation between the size of the neural networks and speed of convergence in deep reinforcement learning? Is there a connection between the approximator network sizes in a RL task and the speed of convergence to an (near) optimal policy or value function?

When thinking about this, I came across the following thoughts:

If the network would be too small, the problem won't get enough representation and would never be solved, and the network would converge to its final state quickly.
If the network would be infinitely big (assuming no vanishing gradients and the likes), the network would converge to some (desirable) over-fitting, and the network would converge to its final state very slowly, if at all.
This probably means there is some golden middle ground.

Which leads me to the interesting question:

4. Assuming training time is insignificant relative to running the environment (like in real life environments), then if a network of size M converges to an optimal policy in average after N episodes, would changing M make a predictable change on N?

Is there any research, or known answer to this?

How to know that there is no more need to increase the network size?

How to know if the current network is too large?

Note: please regard question 4 as the main question here.

Speed and size, no. That's because speed is dependent on processor clock periods and the effective parallel nature of the particular deep RL design in the environment, which is also dependent on cores and host clustering. Size is not really quantifiable in a way that is meaningful in this relationship because there is a broader and more complex structure of a network that might be trained to produce a value to use in the RL algorithm chosen.

Width for each layer
Cell type and possibly activation function for each layer
Hyper-parameters

One can say that number of clock cycles times number of effective parallel processors is correlated to all the above, the overhead of the RL algorithm used, and the size of each data tensor.

There are a few inequalities developed in the PAC (probably approximately correct) framework, so it would not be surprising if there were some bounding rules for the relationship between clock cycles, effective parallelism, data widths, activation functions, and RL algorithms for deep RL.

Study of the algorithm, perhaps in conjunction with experimentation, may reveal the primary factors, essentially the processing bottlenecks. Further study of the factors involved in controlling loop iteration counts, which cause the bottleneck, could permit the quantification of computing effort required to maintain a particular maximum allowable response time, but that would be specific to a particular design.

Such might produce a metric that is effectively a count of clock cycles across the system's potentially parallel architecture for a worst case or mean RL action selection. That could then be used to determine the response time for a given system with all of the factors mentioned above fixed, including the priority and scheduling of the processes in each operating system involved.

Here's a guess. Feel free to critique, since such a formulation is a project far beyond the effort that should be put into answering a question online.

$$ t_r \propto e^{k_v} \, n_v \, \eta_v \, t_v \, \mu_v \, \sum c_v + e^{k_d} \, n_d \, \eta_d \, t_d \, \mu_d \, \sum c_d \; \text{,} $$

where $t$ is time, $k$ is tensor complexity, $n$ is number of cores, $\eta$ is the effective efficiency of the parallel processing, $\mu$ is the effective overhead cost of the glue code, $c$ is the cycles require of the significant (and probably repetitive) elements in the algorithms, $t_r$ is the total time to response, and the subscripts $v$ and $d$ designate the variable subscripted as either RL value determination metrics or deep network metrics respectively.


How does dimensionality reduction occur in Self organizing Map (SOM)? We have n dimension input for SOM and the output 2-D clusters. How does it happen?

SOM (Self-Organinizing Map) is a type of artificial neural network (ANN), introduced by the Finnish professor Teuvo Kohonen in the 1980s, that is trained using unsupervised learning to produce a low-dimensional, discretized representation of the input space of the training samples, called a map, and is therefore a method to do dimensionality reduction.
SOM produces a mapping from a multidimensional input space onto a lattice of clusters, i.e. neurons, in a way that preserves their topology, so that
neighboring neurons respond to “similar” input patterns.
It uses three basic processes:

Competition
Cooperation
Adaptation

In competition, each neuron is assigned a weight vector with the same
dimensionality d as the input space. Any given input pattern is compared to the weight vector of each neuron and the closest neuron is declared the winner.
In cooperation, the activation of the winning neuron is spread to neurons in its immediate neighborhood, and as a result this allows topologically close neurons to become sensitive to similar patterns. The size of the neighborhood is initially large, but shrinks over time, where an initially large neighborhood promotes a topology-preserving mapping and smaller neighborhoods allows neurons to specialize in the latter stages of training.
In adaptation, the winner neuron and its topological neighbors are adapted to make their weight vectors more similar to the input pattern that caused the activation.
So, a Self-Organizing Map (SOM) is to encode a large set of input vectors $\textbf{x}$ by finding a smaller set of “representatives” or
“prototypes” or “code-book vectors” $\textbf{w}$ that provide a good approximation to the original input space. This is the basic idea of vector quantization theory, the motivation of which is dimensionality reduction or data compression. Performing a gradient descent style minimization on SOM's loss function (eg. the sum of the Euclidean distances between the input sample and each neuron) does lead to the SOM weight update algorithm, which confirms that it is generating the best possible discrete low dimensional approximation to the input space (at least assuming it does not get trapped in a local minimum of the error function).
To answer your question, you should take into consideration that the Dimensionality reduction takes place in fields that deal with large numbers of observations and/or large numbers of variables. Thus, SOM helps finding good "prototypes", in a way that each input pattern belongs to exactly one of them. As a result, the training instances are mapped to the training "prototypes" and the whole training set is mapped to a new one with less instances.
In addition, the "prototypes" neurons resulted by SOM can often be used as good centers in RBF networks or to classify patterns with the LVQ family algorithms.


Why do I get small probabilities when implementing a multinomial naive Bayes text classification model? When applying multinomial Naive Bayes text classification, I get very small probabilities (around $10e^{-48}$), so there's no way for me to know which classes are valid predictions and which ones are not. I'd the probabilities to be in the interval $[0,1]$, so I can exclude classes in the prediction with say a score of 0.5 or less. How do I go about doing this?
This is what I've implemented:
$$c_{\operatorname{map}}=\underset{\operatorname{c \in C}}{\arg \max }(P(c \mid d))=\underset{\operatorname{c \in C}}{\arg \max }\left(P(c) \prod_{1 \leq k \leq n_d} P\left(t_{k} \mid c\right)\right)$$

You could say that the class of the data (e.g. spam vs not spam) is a hidden quality that can be inferred through the observable features (e.g. message subject contains "bitcoin"),
$$P(C \; | \; F)$$
which says that the probability of the class $C$ is conditioned on the visibility of the feature $F$.
Using Bayes' theorem we can write
$$P(C \; | \; F) = \frac{P(F \; | \; C) \, P(C)}{P(F)}$$
Your problem is that you are not taking into account the evidence, $P(F)$, denominator in this expression.

You can have multiple features in your likelihood function
$$P(F \; | \; C) = P(F_1,F_2,F_3,\ldots \; | \; C)$$
and these can be independent
$$\prod_k P(F_k \; | \; C)$$
and then you have your prior
$$P(C) \prod_k P(F_k \; | \; C)$$
but what you are missing is the evidence factor in the denominator
$$P(C \; | \; F) = \frac{P(C) \prod_k P(F_k \; | \; C)}{\sum_C \scriptsize{P(C) \prod_k P(F_k \; | \; C)}}$$
This is the general view of the problem. Specifically, to fix your issue, evaluate the probabilities for all your classes, add them together, then divide each probability by that sum.
For instance, if you have two classes and the probabilities are $p_0$ and $p_1$, then write
$$P(C=0) = \frac{p_0}{p_0 + p_1}$$
and
$$P(C=1) = \frac{p_1}{p_0 + p_1}$$
which guarantees that
$$P(C=0) + P(C=1) = 1$$


How can Siamese Networks be viewed as RNNs? "Single-object tracking commonly uses Siamese networks, which can be seen as an RNN unrolled over two time-steps."

(from the SQAIR paper)

I'm wondering how Siamese networks can be viewed as RNNs, as mentioned above. A diagrammatic explanation, or anything that helps understand the same, would help! Thank you!

Well, here in the picture we have the unrolled or unfold RNN on the right side. Siamese network is formed when it is said to be "unrolled over two time-steps". So, take part where there is two first iterations of RNN and yes, you have kind of Siamese network.

One take from the source of the image:

  Unlike a traditional deep neural network, which uses different parameters at each layer, a RNN shares the same parameters (U, V, W above) across all steps. This reflects the fact that we are performing the same task at each step, just with different inputs. This greatly reduces the total number of parameters we need to learn.

Sounds familiar to siamese network used on single-object tracking: there we take two signals (image and the tracked object), drive it through identical paths and make some maths to get results. Just something the RNN makes to time separated values!

For proof of similarity, a take from a site where siamese networks are nicely explained:

Side note: I don't know then, how closely those relate in real world (could a Siamese network in anyway be a RNN or vice versa), but supposedly so, because the comparison is made by researcher to say so. At diagrammatic level at least there would be no problem on that.


How do we test if an model or algorithm is AI-complete? How do we test if a model or algorithm is AI-complete?

According to the Wikipedia definition, a problem is said to be AI-complete if it requires generalized, human-level intelligence, that is, requires strong AI. The Turing test and its variants are the best ways we have of measuring this. See, for example, Turing Test as a Defining Feature of AI-Completeness.

As suggested in this paper, in order for the Turing test to be meaningful, the interrogator has a responsibility to ask questions which are both deep and meaningful.

It, therefore, seems likely that testing for strong AI is in itself an AI-complete task.


Why is my derivation of the back-propagation equations inconsistent with Andrew Ng's slides from Coursera? I am using the cross-entropy cost function to calculate its derivatives using different variables $Z, W$ and $b$ at different instances. Please refer image below for calculation.

As per my knowledge, my derivation is correct for $dZ, dW, db$ and $dA$, but, if I refer to Andrew Ng Coursera stuff, then I am seeing an extra $\frac{1}{m}$ for $dW$ and $db$, whereas no $\frac{1}{m}$ in $dZ$. Andrew's slides on the left represent derivative and whereas the right side of slides shows NumPy implementation corresponding to the right side equation.

Can someone please explain why there is:

1) $\frac{1}{m}$ in $dW^{[2]}$ and $db^{[2]}$ in Andrew's slides in NumPy representation

2) missing $\frac{1}{m}$ for $dZ^{[2]}$ in Andrew's slides in both normal and NumPy representation.

Am I missing something or doing it in the wrong way?

TL;DR: This has to do with the way A. Ng has defined back propagation for the course.

Left Column

This is only with respect to one input example and so the $\frac{1}{m}$ factor reduces to 1 and can be omitted. He uses lower case to represent one input example (eg a vector $dz$) and upper case with respect to a (mini-)batch (eg a matrix $dZ$).

The $\frac{1}{m}$ factors in $dW,db$

In this definition of backprop, he "defers" multiplying by the $\frac{1}{m}$ factor until $dW,db$ rather than "absorbing" it into $dZ^{[2]}$. That is, the $dZ^{[2]}$ term is defined in a way that it does not have $\frac{1}{m}$.

Observe, if you move the $\frac{1}{m}$ factor to be in the definition of $dZ^{[2]}$ and remove it from the definitions of $dW,db$ you will still come out with the same values for all $dW,db$.

Speculation

This "deferred" multiplication might have to do with numerical stability. Or simply a stylistic choice made by A. Ng. This might also prevent one from "accidentally" multiplying by $\frac{1}{m}$ more than once.


How to calculate the optimal placements for settlements in Catan without an ML algorithm? Is it possible to calculate the best possible placements for settlements in Catan without using an ML algorithm?

While it is trivial to simply add up the numbers surrounding the settlement (highest point location), I'm looking to build a deeper analysis of the settlement locations. For example, if the highest point location is around a sheep-sheep-sheep, it might be better to go to a lower point location for better resource access. It could also weight for complementary resources, blocking other players from resources, and being closer to ports.

It seems feasible to program arithmetically, yet some friends said this is an ML problem. If it is ML, how would one go about training, as the gameboard changes every game?

Catan is actually a much more complicated game than the simple rules would suggest, and an exact solution is probably beyond the scope of current AI techniques.

Monte Carlo Tree Search or Expectiminimax techniques seem like they could help, but are intended for games of perfect information. Catan is not a game of perfect information (the development cards are hidden), and also has a phase that occurs without a regular turn sequence (trading).

To solve Catan properly, I think you're going to need both algorithms for solving POMDPs (like CFR+), and algorithms for negotiation (like Kraus' Diplomat). I'm not certain that these have been combined before in formal analysis, so this might actually be a good PhD thesis for someone.

That said, you can probably get a good player using self-play techniques, because Catan has randomization, and a relatively small set of moves, like Backgammon. These may or may not offer simple rules about how-best to play the game. Your friends are right to think about this as, at root, an ML problem.


Tweaking a CNN for large number of input channels I am using a CNN for function approximation using geospatial data.
The input of the function I am trying to approximate consists of all the spatial distances between N location on a grid and all the other points in the grid.

As of now I implemented a CNN that takes an "image" as input. The image has N channels, one for each location of interest. Each i-th channel is a matrix representing my grid, where the pixel values are the distance between each point in the grid and the i-th location of interest. The labels are the N values computed via the actual function I want to approximate. N can be up to 100.

Here an example input of the first layer:

So far I could see the train and validation loss go down, but since it is a bit of a unusual application for a CNN (to my knowledge the input channels are at most 3, RGB) I was wondering:

does this many-channel-input approach have any pitfalls?
will I be able to obtain a good accuracy or are there any hard limits I am not aware of?
are there any other similar application in literature?

As far as I know, more than 3 channel is perfectly fine, since, 3 channels are what we use for images and that's enough since we can only see this many colors, but I don't see why more than that wouldn't work

Your 2nd question is like asking whether or not you will be good at a sport... Just try it

For your 3rd question, I've never seen any language AI using CNN instead they all use RNN, not sure if that's what you meant though


Is there any system that generates website designs? I was thinking about what I can do for my thesis in upcoming academic semester, and I came across an idea. The idea is like: "If there is any kind of system that generates website designs itself." If no, then I can go for it, and I will be lucky if anyone has the same idea. We can collaborate. In case, if there's any project or system (Open source or not) that can do this or has been initiated in this context, I want to contribute solely. If anyone has any clue or knowledge over this kind of system, please do inform me. As I haven't done anything like this before, I want to learn. Any kind of suggestion or assistance on this idea will be so helpful for me.

The closest research that I am aware of is in artificial intelligence designed user interfaces(1,2).

The scope of which vary tremendously. Some teams are trying to generate UIs based on some user-defined parameters, others are trying to generate based off of images(as in the second link). I think part of the reason research is focused here is two-fold: One, we aren't very good at generating UIs automatically yet, and 2, it is an exponentially harder problem to develop a backend that has integrated calls and features required for a fully-featured website or application.

With that being said, one could adapt this research into things like one-page sites or other simple implementations that might bear fruit.


What are the strengths of the Hierarchical Temporal Memory model compared to competing models? 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?

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.


What does the approximate posterior on latent variables, $q_\phi(z|x)$, tend to when optimising VAE's The ELBO objective is described as follows
$$ ELBO(\phi,\theta) = E_{q_\phi(z|x)}[log p_\theta (x|z)] - KL[q_\phi (z|x)||p(z)] $$
This form of ELBO includes a regularisation term  in the form of the KL divergence which drives $q_\phi(z|x) \rightarrow p(z)$ when optimising ELBO.
However we also have the overall expression for the loglikelihood which is defined as follows (proof provided here)
$$ p_\theta(x) = ELBO(\phi,\theta) + KL[q_\phi(z|x)||p_\theta(z|x)] $$
Rearranging the above equation as follows
$$  \max\limits_\phi ELBO(\phi,\theta) = \max\limits_\phi p_\theta(x) - KL[q_\phi(z|x)||p_\theta(z|x)]  $$
We can see that maximising ELBO w.r.t $\phi$ in this form causes $q_\phi(z|x) \rightarrow p_\theta(z|x)$
These two ways of describing how VAEs learn conflicts my understanding of what happens to the approximate distribution during training.
Is it simply just trying to match both the prior $p(z)$ and the posterior $p_\theta(z|x)$ or am I missing something

Practically, when optimizing VAE, you assume that prior $p(z)\sim N(0,1)$; i.e. the unit Gaussian distribution. However, in testime you sample z from $p(z|x)$; the encoder model. Why is that?
Let's go back to the start. We have a model $p_{\theta}(x)$ and the data $\{x_1, ..., x_N\}$. Solving the maximum log-likelihood problem, we have
\begin{equation}
\begin{split}
\theta &= argmax_{\theta}\frac{1}{N}\sum_i log p_{\theta}(x_i) \\
&= argmax_{\theta}\frac{1}{N}\sum_i \left( \int p_{\theta}(x_i|z)p(z)dz \right)
\end{split}
\end{equation}
which is intractable to calculate. So what to do now?
Here it comes the Variational Inference: "Use the expected log-likelihood instead."
\begin{equation}
\begin{split}
\theta &= argmax_{\theta}\sum_i E_{z \sim p_{\theta}(z|x)}\left[ logp_{\theta}(x,z) \right]
\end{split}
\end{equation}
We approximate $q(z) \approx p_{\theta}(z|x)$. Thus, we unfold $logp(x)$:
\begin{equation}
\begin{split}
logp(x) &= log \int p_{\theta}(x_i|z)p(z)dz \\
&= log \int p_{\theta}(x_i|z)p(z) \frac{q(z)}{q(z)}dz \\
&= log E_{z \sim q(z)}\left[ \frac{p_{\theta}(x|z)p(z)}{q(z)} \right] \\
&\geq E_{z \sim q(z)}\left[ log \frac{p_{\theta}(x|z)p(z)}{q(z)} \right]  \\
&= E_{z \sim q(z)}\left[ logp_{\theta}(x|z) + logp(z) \right] - E_{z \sim q(z)}\left[ logq(z)\right] \\
&= E_{z \sim q(z)}\left[ logp_{\theta}(x|z) + logp(z) \right] + H(q) \\
&= ELBO(p,q)
\end{split}
\end{equation}
where $H(q)$ is the entropy of q. As you highlighted we can also write
$$ ELBO(p,q) = logp(x) - D_{KL}\left( q(z) || p(z|x) \right) $$
This means that (a) maximizing $ELBO(p,q)$ w.r.t. to $q$ then KL-Divergence is minimized and (b) maximizing $ELBO(p,q)$ w.r.t to $p$ then the model is improved as the log-likelihood is improved. So this point of yours is true.
However, how can we actually train this model?
The answer is by using Amortized Variational Inference! Practically, we use 2 Neural Networks, $\phi$ and $\theta$, so that we have 2 models: $q_{\phi}(z|x)$ (encoder) and $p_{\theta}(x|z)$ (decoder). Thus, we replace $q(z)$ with $q_{\phi}(z|x)$ and $ELBO(p,q)$ with $ELBO(\theta,\phi)$ .
To fully answer your question, I should reach your first ELBO formula. I will unfold my first equation about ELBO:
\begin{equation}
\begin{split}
ELBO(\theta,\phi) &= E_{z \sim q_{\phi}(z)}\left[ logp_{\theta}(x|z)\right] + E_{z \sim q_{\phi}(z)}\left[ logp(z) \right] + H\left(q_{\phi}(z|x)\right) \\
&= E_{z \sim q_{\phi}(z)}\left[ logp_{\theta}(x|z)\right] - D_{KL}\left( q_{\phi}(z|x) || p_{\theta}(z) \right)
\end{split}
\end{equation}
Therefore, using the Amortized Variational Inference, we maximize the above objective.


How close are we to creating Ex Machina? Are there any research teams that attempted to create or have already created an AI robot that can be as close to intelligent as these found in Ex Machina or I, Robot movies?

I'm not talking about full awareness, but an artificial being that can make its own decisions and physical and intellectual tasks that a human being can do?

We are absolutely nowhere near, nor do we have any idea how to bridge the gap between what we can currently do and what is depicted in these films.

The current trend for DL approaches (coupled with the emergence of data science as a mainstream discipline) has led to a lot of popular interest in AI.

However, researchers and practitioners would do well to learn the lessons of the 'AI Winter' and not engage in hubris or read too much into current successes.

For example:

Success in transfer learning is very limited.
The 'hard problem' (i.e. presenting the 'raw, unwashed environment' to the machine and having it come up with a solution from scratch) is not being
addressed by DL to the extent that it is popularly portrayed: expert human knowledge is still required to help decide how the input should be framed, tune parameters, interpret output etc.

Someone who has enthusiasm for AGI would hopefully agree that the 'hard problem' is actually the only one that matters. Some years ago, a famous cognitive scientist said "We have yet to successfully represent even a single concept on a computer".

In my opinion, recent research trends have done little to change this.

All of this perhaps sounds pessimistic - it's not intended to. None of us want another AI Winter, so we should challenge (and be honest about) the limits of our current techniques rather than mythologizing them.


Why not replacing the simple linear functions that neurons compute with more complex functions? In a neural network, a neuron typically computes a linear function $f(x) = w*x$, where $w$ is the weight and $x$ is the input.

Why not replacing the linear function with more complex functions, such as $f(x,w,a,b,c) = w*(x + b)^a + c$?

It will provide much more diversity into neural networks.

Does this have a name? Has this been used?

It is definitley possible to make the links between neurons use more complex functions. Provided those functions are differentiable, backpropagation still works, and the resulting compound function might be able to learn something useful. The general name for such a thing is a computational graph and the standardised structures used in most neural networks are a subset of all possible (and maybe useful) computational graphs.

When adding complex and non-linear functions into a neural network, this is usually alternated with simpler linear layers using the weights. A generalised function of a single neuron as used in most neural networks looks like this:

$$a = f(\sum_i w_i x_i + b)$$

Where $i$ indexes all inputs to the neuron, $x_i$ are the input values, $w_i$ the weights associated with each input, $b$ is a bias term and $f()$ is a differentiable non-linear activation function. Training process learns $w_i$ and $b$. The output $a$ is the the neuron's activation value, that may be taken as output of the neural network, or fed in to some other neuron as one of the next neuron's $x_i$.

A simple feed-forward network using this basic neuron function, with at least one hidden layer which has a non-linear activation function can already learn approximations to any given function - a result proved in the universal approximation theorem.

The practical result of the universal approximation theorem is that you need motivation other than increasing diversity in order to make neural network functions more complex. If you were considering altering one of the $w_i x_i$ multiplications, and replacing with a more complex learnable function, you can effectively achieve the same thing by adding another neuron whose output $a$ is used as $x_i$ - or simply adding a layer in most neural network libraries.

In some situations there may be good reasons to make lower-level changes:

If you know the function you are learning relates to a theoretical model with a specific mathematical form, you can deliberately set up functions that mirror that with learnable parameters. Typcially that is done as transforms on inputs, but could also be part of a more complex computational graph if necessary.
In neural network architectures, you can consider things such as gate combinations in LSTM cells, or skip connections in residual networks as examples where the functions have deliberately be made more complex to achieve a specific goal - in both those cases in order to increase effectiveness of backpropagation in deep structures.


How to identify whether images contain driver's licenses or ID cards Suppose I have a lot of scans of hardcopy documents, in the form of jpegs. Some of them are potentially scans of driver's licenses or identification cards. I wonder what would be a good way to identify those scans that contain driver's license/ID cards.

One thought I had was training a model or use an existing pretrained model that can detect faces. However, if the data set I have has a lot of scans of photos of people, it would cause false positives. So I am not sure how I might approach this problem.

Any thought would be much appreciated!

Why not make a detector/classifier to look for the text "Drivers Licence" or some very generic keywords related to license? As you mentioned images of people may be present in any sort of documents. Looking for text which is super specific to IDs/drivers license seem to be a better way.


Transfer Learning of Numerical Data It seems like transfer learning is only applicable to neural networks. Is this a correct assumption?
While I was looking for examples of Transfer Learning, most seemed to be based on image data, audio data, or text data. I was not able to find an example of training a neural network on numerical data.
I want to use transfer learning in this particular scenario: I have a lot of numerical data from an old environment, with binary classification labels, and utilizing this, want to train on a new environment to do the same binary classification.
The dataset would look something like this
Is this possible? What would the model look like?

It seems like transfer learning is only applicable to neural networks. Is this a correct assumption?

No. Wiki page give you pointers of several examples in other methodologies.

While I was looking for examples of Transfer Learning, most seemed to be based on image data, audio data, or text data. I was not able to find an example of training a neural network on numerical data.

All the cases you say are converted to numerical data. Image and audio usually via sampling, text via one-hot encoding.

I want to use transfer learning in this particular scenario: I have a lot of numerical data from an old environment, with binary classification labels, and utilizing this, want to train on a new environment to do the same binary classification.

That is not transfer learning. Transfer learning applies when there are a change in the domain (input features) or in the task (output labels).

The dataset would look something like this Sample Table
Is this possible? What would the model look like?

For a simple case as the one you present, probably a simple network with one hidden layer will be enough. Train it with original pairs of {features,label} or, if not available, use the current predictor to obtain the label from the features.


How can I apply naive Bayes classifier for three classes (Positive, Negative and Neutral) in text data? I found a naive Bayes classifier for positive sentiment or a negative sentiment Citius: A Naive-Bayes Strategy for Sentiment Analysis on English Tweets. But with most available datasets online, sentiments are classified into 3 types: positive, negative, and neutral.
How does the naive Bayes formula change for such cases? Or does it remain the same, and we only consider the positive and negative to calculate the log likelihoods-likelihoods?

Use TextBlob to get the text sentiment polarity and subjectivity. polarity is negative or positive sentiment and subjectivity is how factual the sentiment is.
my_valance=TextBlob(sentence)
df.loc[key,'sentiment_polarity']=my_valance.sentiment.polarity
df.loc[key,'sentiment_subjectivity']=my_valance.sentiment.subjectivity


Binary classifier that minimizes false positive error I have a binary classification problem, where a false positive error has a very big cost compared to the false negative error.

Is there a way to design a classifier for such problems (preferably, with an implementation of the algorithm)?

There is no predefined classifier for any problem. Two main features of a classifier are

its cost function and
its corresponding weight update formula.

Since your problem statement requires a huge cost for falsely classifying a particular class one approach will be.

You have to define a cost function that will penalize hugely for misclassifying for that class only. So your cost function will be $J$ and $J'$ put together. You can look up the cost function of a logistic classifier to see how two separate cost functions are merged together here.

The second approach can be (assuming you are using supervised learning), the learning rate $\alpha$ for both the classes should be different. The larger learning rate will be for the one which is the more important class, since you don't want to classify it improperly (increasing $\alpha$ compared to the other class will reduce or risk of misclassifying it). The exact learning rate depends from case to case.

Thus, I have tailored the two main features of the classifier to solve this problem:

The cost function.

The weight update scheme (by changing learning rate for different cases).


What are the current open source text-to-audio libraries? I am not new to AI and did some work for few months but completely new to text to audio. Yes I used text to audio tools a decade back... but I would like to know where exactly we stand in terms of text to audio today.

I already did some research, it seems like traditional way of text to audio is fading away and speech cloning seems to be emerging but my impression on this might be completely wrong.

What are the current open source text-to-audio libraries?

voice-builder is an opensource text-to-speech (TTS) voice building tool from Google.


Why is the completeness of UCS guaranteed only if the cost of every step exceeds some small positive constant? I was reading Artificial Intelligence: A Modern Approach 3rd Edition, and I have reached to the UCS algorithm.
I was reading the proof that UCS is complete.
The book state that:

Completeness is guaranteed provided the cost of every step exceeds some small positive constant $\epsilon .$

And that's because UCS will be stuck if there is a path with an infinite
sequence of zero-cost actions.
Why the step cost must exceed $\epsilon$? Isn't enough for it to be greater than zero?

Let's consider a problem where all edge costs are greater than zero, but not above some $\epsilon$:
Image a problem where we have an infinite path where the first edge is cost $\frac{1}{2}$, the next is $\frac{1}{4}$, the following is $\frac{1}{8}$, and so on forever. Every edge is greater than zero, meeting the condition being proposed in the question. However, this path overall has finite cost (1) even through there are an infinite number of states on that path. So, on this problem UCS will never reach paths with cost greater than 1. Thus, if the solution cost is 2, UCS will not find any solution to this problem, and thus it would not be a complete algorithm. So, all edges being greater than zero is not sufficient.
For most search algorithms to be complete, there must be a finite number of states with any given cost. (To be slightly more precise, there must exist some fixed $\epsilon$ such that in each range size $\epsilon$ there are a finite number of states.)


Why can't LSTMs tell a long story? There is a recent trend in people using LSTMs to write novels. I haven’t attempted this myself. From what I’m hearing, they can tell a story, but it seems they lose the context of the story rather quickly. After which they begin constructing new, but not necessarily related constructs.

Can they construct a plot in the long term?

The long-short term memory (LSTM) is a type of recurrent neural network, which is only suited for sequence modelling, that is, to keep track of statistical dependencies between elements of a sequence.

The LSTM prediction capabilities are limited to the training data that is used to train it, the inductive bias (in the case of LSTMs, the inductive bias particularly refers to the fact that elements of a sequence are dependent on each other) and the available computation resources. However, storytelling often assumes the existence of a common-sense knowledge between the storyteller and the listener (but LSTM completely ignores this) and requires the true understanding of language, which is believed to be an AI-complete problem (in simple words, it is a very complex task, which probably cannot be exactly solved with statistical models).

Furthermore, even though LSTM partially addresses the vanishing gradient problem (and they were specifically created to partially solve this issue), they can still suffer from the exploding gradient problem. Moreover, although LSTMs and, in general, neural networks are universal function approximators, in practice, functions may not be continuous, which is an assumption made in the universal approximation theorems.


What is the role of the 'fuzzifier' w in Fuzzy Clustering? According to my lecture, Fuzzy c-Means tries to minimize the following objective function:

$$J(X,B,U)=\sum_{i=1}^c\sum_{j=1}^n u_{ij}^w \, d^2(\vec{\beta_i},\vec{x_j})$$

where $X$ are the data points, $B$ are the cluster-'prototypes', and $U$ is the matrix containing the fuzzy membership degrees. $d$ is a distance measure.

A constraint is that the membership degrees for a single datapoint w.r.t. all clusters sum to $1$: $\sum_{j=1}^n\, u_{ij}=1$.

Now in the first equation, what is the role of the $w$? I read that one could use any convex function instead of $(\cdot)^w$. But why use anything at all. Why don't we just use the membership degrees? My lecture says using the fuzzifier is necessary but doesn't explain why.

Its not required, you can have $m=1$, actually it can be any number $\geq 1$.

Now the better question is why to have it? The answer is that it adds a smoothing effect. Lets look at it in each of the limits ($\lim m \rightarrow 1$ and $\lim m \rightarrow \infty$)

Towards $\infty$, it makes $u_{ij}$ equal to $\frac{1}{c}$, making each point have equal membership of each class regardless of $m$. From the optimization perspective, its saying how can we achieve finding clusters that are closest to all points, therefore by definition it has already achieved that, and so the Loss will always be 0. (at its global minimum)

Now in the other limit, the constants are inversely proportional to the square of the normalized euclidean distance. This makes intuitive sense, the membership is high if they are close, and the membership is low if they are not (relatively)

So why do we have the $m$, its for control. It allows us to choose and experiment with how heavy each distance should hold weight in the membership. An example where a larger $m$ may be useful is when the data isnt clean, and you dont want to rely so heavily on euclidean distance as the membership, so you forcibly add in a smoothing effect


Convert LSTM univariate Autoencoder to multivariate Autoencoder I have the following code snippet which takes in a single column of value i.e. 1 feature. How do I modify the LSTM model such that it accepts 3 features?
import numpy as np
from keras.models import Sequential
from keras.layers import LSTM, Input, Dropout
from keras.layers import Dense
from keras.layers import RepeatVector
from keras.layers import TimeDistributed
import pandas as pd
from matplotlib import pyplot as plt
from sklearn.preprocessing import MinMaxScaler, StandardScaler
from keras.models import Model
import seaborn as sns

dataframe = pd.read_csv('GE.csv')
dataframe.head()

df = dataframe[['Date', 'EnergyInWatts']]
df['Date'] = pd.to_datetime(df['Date'])
sns.lineplot(x=df['Date'], y=df['EnergyInWatts'])

#train, test = df.loc[df['Date'] <= '2003-12-31'], df.loc[df['Date'] > '2003-12-31']
train = df.loc[df['Date'] <= '2003-12-31']
test = df.loc[df['Date'] > '2003-12-31']

scaler = StandardScaler()

scaler = scaler.fit(train[['EnergyInWatts']])

train['EnergyInWatts'] = scaler.transform(train[['EnergyInWatts']])
test['EnergyInWatts'] = scaler.transform(test[['EnergyInWatts']])

seq_size = 30

def to_sequences(x, y, seq_size=1):
    x_values = []
    y_values = []

    for i in range(len(x)-seq_size):
        #print(i)
        x_values.append(x.iloc[i:(i+seq_size)].values)
        y_values.append(y.iloc[i+seq_size])

    return np.array(x_values), np.array(y_values)

trainX, trainY = to_sequences(train[['EnergyInWatts']], train['EnergyInWatts'], seq_size)
testX, testY = to_sequences(test[['EnergyInWatts']], test['EnergyInWatts'], seq_size)

model = Sequential()
model.add(LSTM(128, input_shape=(trainX.shape[1], trainX.shape[2])))
model.add(Dropout(rate=0.2))
model.add(RepeatVector(trainX.shape[1]))
model.add(LSTM(128, return_sequences=True))
model.add(Dropout(rate=0.2))
model.add(TimeDistributed(Dense(trainX.shape[2])))
model.compile(optimizer='adam', loss='mae')
model.summary()

history = model.fit(trainX, trainY, epochs=10, batch_size=32, validation_split=0.1, verbose=1)
```

If each of your three features is a scalar then my first attempt would be to combine them into a vector for each step in the sequence. So instead of LSTM(128, input_shape=(30,1)) for a length-30 univariate sequence you would say LSTM(128, input_shape=(30,3)) for a multivariate (3) sequence. Similarly your output would become TimeDistributed(Dense(3, activation='linear')).
If your input features are each a vector then you should consider switching from the sequential API to the functional API. You would need three separate Input objects followed by a Concatenate layer before the LSTM layer. You would have three Dense layers to be your corresponding outputs. I tried adapting your code:
in0 = Input(shape=(trainX0.shape[1], trainX0.shape[2]))
in1 = Input(shape=(trainX1.shape[1], trainX1.shape[2]))
in2 = Input(shape=(trainX2.shape[1], trainX2.shape[2]))
concat = Concatenate()([in0, in1, in2])
lstm_enc = LSTM(128)(concat)
lstm_enc_drop = Dropout(rate=0.2)(lstm_enc)
rep = RepeatVector(trainX0.shape[1])(lstm_enc_drop)
lstm_dec = LSTM(128, return_sequences=True)(rep)
lstm_dec_drop = Dropout(rate=0.2)(lstm_dec)
out0 = TimeDistributed(Dense(trainX0.shape[2], activation='linear'))(lstm_dec_drop)
out1 = TimeDistributed(Dense(trainX1.shape[2], activation='linear'))(lstm_dec_drop)
out2 = TimeDistributed(Dense(trainX2.shape[2], activation='linear'))(lstm_dec_drop)
model = Model(inputs=[in0, in1, in2], outputs=[out0, out1, out2])
model.compile(optimizer='adam', loss='mae')
model.summary()


YOLOv3 Model Structure: Why is filters = (classes + coords + 1) * num? Here's a tutorial about doing custom training of YOLO (Darknet): https://medium.com/@manivannan_data/how-to-train-yolov3-to-detect-custom-objects-ccbcafeb13d2

The tutorial guides how to set values in the .cfg files:

classes = Number of classes, OK
filters = (classes + 5) * 3

Why is it 'plus 5' then 'times 3'?

Some say it's (classes + coords + 1) * num, but I can't guess it out the meaning.

As said by @brale in the comment below the question:

filters = (classes + 5) * 3
= (classes + width + height + x + y + confidence) * num
= (classes + 1+1+1+1+1) * num
= (classes + 5) * num

YOLOv3 dectects 3 boxes per grid cell, so it is:

filters = (classes + 5) * 3


Name of paper for encoding/representing XY coordinates in deep learning It this podcast between Oriol Vinyals and Lex Friedman: https://youtu.be/Kedt2or9xlo?t=1769, at 29:29, Oriol Vinyals refers to a paper:

  If you look at research in computer vision where it makes a lot of sense to treat images as two dimensional arrays...
  There is actually a very nice paper from Facebook. I forgot who the
  authors are but I think [it's] part of Kaiming He's group. And what
  they do is they take an image, which is a 2D signal, and they
  actually take pixel by pixel, and scramble the image, as if it
  was a just a list of pixels, crucially they encode the position of the pixels
  with the XY coordinates. And this is a new architecture which we
  incidentally also use in Starcraft 2 called the transformer, which is
  a very popular paper from last year which yielded very nice results in
  machine translation.

Do you know which paper he is referring to?

I'm guessing maybe he is talking about non-local neural networks, but I'm probably guessing wrong.

Edit: after reviewing the recent publications of Kaiming He (http://kaiminghe.com/), maybe I'm guessing right. Any thoughts?

So this paper is by google, but is very similar where they use 2D positional embeddings and perform MHA on the flattened image. Are you talking about Attention Augmented Convolutional Networks


How to rescale data to its original range after MinMaxScaler? I'm using sklearn's MinMaxScaler in order to scale my data down. However, it would be nice to be able to rescale it back to its original range. Is there any way I can do this?

You can use the function inverse_transform of the created MinMaxScaler object.

See also this Stack Overflow question for other answers and examples.


When should I use feature learning as opposed to feature engineering? With the advancement of deep learning and a few others automated features learning techniques, manual feature engineering started becoming obsolete.

Any suggestion on when to use manual feature engineering, feature learning or a combination of the two?

manual feature engineering started becoming obsolete

That is wrong.

  Any suggestion on when to use manual feature engineering, feature learning or a combination of the two?

Deep learning is awesome for natural signals like images, audio or large amounts of unstructured text (e.g. arbitrary crawled websites)

There are some basic steps that make almost always sense. For example, for image recognition, it is the normalization from pixel color features in the range $\{0, 1, \dots, 255 \}$ to features in $[0, 1]$.

And then there are a lot of use cases where you have structured, CSV-like data. For those, every single case I had so far was improved by feature engineering. Most of the time you actually don't have a choice here as well: how would you feed in a date time object into a neural network?

Now, where does feature engineering make sense in image recognition?

Resource limitations: neural networks often take a lot of resources. For example, viola-jones face detection is very resource friendly in contrast. But there are developments like the mobile net to relax that issue.
Prior knowledge: for more special image data like CT scans you might observe super simple operations that almost give you the target. This might make it simpler to interpret the results at the end and, again, it helps to keep resource usage low.

One other field where I suspect that manual feature engineering could help is adversarial attacks. But for this I'm not 100% sure.


Is there a name for this approach to evolutionary algorithms? I am considering an approach to evolutionary algorithms, in which instead of maintaining a population of individuals, we maintain a pool of $N$ mutations that can be applied to a base genome.  For every possible subset (or many possible subsets) of the mutation pool, we apply that subset to the base genome to produce an individual, then test that individual.  We discard mutations for which the population with that mutation performs worse than the population without it.  We merge the best-performing mutations into the base genome for the next generation.  Then we replace the discarded or merged mutations with new ones.
Is this known under some name?  Is it a good idea?

It's just a genetic algorithm, only your population is a set of instructions that generate a subject to be tested. There are minor differences in the way you apply multiple mutations, so you evaluate groups of them instead of each individually, but for the scoring you effectively single out the commonalities among the worse individuals.
Hard to tell whether it's a good idea; discarding poor mutations based on them being part of a sub-optimal individual might not be as straight forward as it sounds. And where do you get new mutations from?


How can I evaluate the performance of a system that generates text? 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?

This is a tricky issue. I assume you are using transition probabilities to pick the next suitable word, so you could use some other corpus data, derive probabilities from it, and compare  those to your system. Not very satisfactory, though, as you might end up evaluating the system in a circular way, deriving your test data in the same way as you generate your output.

A better, if somewhat more laborious evaluation would be to present the trigger sequence to human beings (on a fairly large scale), and then measure the overlap between your system and the human choices. Of course, with the you will get a very large set of possible replies, but the round yellow would be a lot more restricted (and it would make more sense to include that kind of sequence in an evaluation anyway).

The figure you will get might be quite small (depending on the range of possible options), but that is to be expected, so your system could score well even with a small overlap only. That's how I would approach this problem.


Why do RL implementations converge on one action? I have seen this happening in implementations of state-of-the-art RL algorithms where the model converges to a single action over time after multiple training iterations. Are there some general loopholes or reasons why this kind of behavior is exhibited?

Why do RL implementations converge on one action?

If the optimal policy shouldn't always select the same action in the same state, i.e., if the optimal policy isn't deterministic (e.g., in the case of the rock paper scissors, the optimal policy cannot be deterministic because any intelligent player would easily memorize your deterministic policy, so, after a while, you would always lose again that player), then there are a few things that you can do to make your policy more stochastic

Change the reward function. If your agent ends up selecting always the same action and you don't want that, it's probably because you're not giving it the right reinforcement signal (given that the agent selects the action that apparently will give it the highest reward in the long run).
Try to explore more during training. So, if you're using a behavior policy like $\epsilon$-greedy, you may want to increase your $\epsilon$ (i.e. probability of selecting a random action).
If you estimated the state-action value function (e.g. with Q-learning), maybe you derived the policy from it by selecting the best action, but, of course, that will make your policy deterministic. You may want to use e.g. softmax to derive the policy from the state-action value function (i.e. the probability of selecting an action is proportional to its value), although Q-learning assumes that your target policy is greedy with respect to the state-action value function.

If the optimal policy is supposed to be deterministic, then, if you find the optimal policy (which isn't probably the case), you will end up with an agent that always selects the same action. In that case, obviously, it's not a problem that the RL agent selects always the same optimal action.


What role the activation function plays in the forward pass and how it is different from backpropagation Is the role played by activation function significant only during the training of neural network or they play their role during testing (after training we supply data for prediction) the network.

I understand that a linear line cannot separate data scattered in complex manner but
Then why we don't used simple polynomials.

why specifically sigmoid, or tanh or ReLu what exactly they are doing ?

What Activation functions do when we are supplying data during training and

And when we supply test data once we have trained the network and we input test data for prediction?

Activation function is a non-linear function. Operation in a neuron without activation function is just a linear function. If we don't put activation function between operation of neurons, then the function "Layer" is useless.

for example if you have two layer network, when you are doing forward-propagation, your output (without activation function) of your first layer will be calculated as:

$O_1 = W_1X+b_1 $

Then your output of your second layer will be:

$O_2 = W_2O_1+b_2 $

If we substitute $O_1$, so the output of your second layer can be calculated as:

$O_2 = W_2(W_1X+b_1)+b_2 $

or simply

$O_2 = W_2W_1X+W_2b_1+b_2 $

As we train neural network to optimize the value of $W$ and $b$ (we train to find the best value of it) so instead of training neural network with two layers, we actually just train a one layer network. From the latter formula we can said $W_2W_1 = W_3$ and $W_2b_1+b_2 = b_3$ so our two layer network is just another linear model:

$O_2 = W_3X+b_3 $

We don't want that, we add layers to get more complex model. That's why we use Activation function that is non-linear function. To prevent our deep model is just become a simple linear function.


How do I calculate the partial derivative with respect to $x$? I am trying to implement CNN using python Numpy.
I searched so much, but all I found was for one filter with one channel for Convolution.

Suppose we have an X as Image with this shape: (N_Height, N_Width, N_Channel) = (5,5,3)

And Let's say I have 16 filters with this shape: (F_Height, F_Width, N_Channel) = (3,3,3) , stride=1 and padding=0

Forward:

Output shape after conv2d will be

(
math.floor((N_Height - F_Height + 2*padding)/stride + 1 )),
math.floor((N_Width- F_Width + 2*padding)/stride + 1 )),
filter_count
)

So the output of this layer will be an array with this shape: (Height, Width, Channel) =  (3, 3, 16)

BackPropagation:

Suppose $dL/dh$ is the input for my layer in backpropagation with this shape: (3,3,16)

Now I must find $dL/dw$ and $dL/dx$: $dL/dw$ to update my filters params and $dL/dx$ to pass it as input to the previous layer as Loss respect to the input X.

From this answer Error respect to filters weights I found how to calculate $dL/dw$.

The problem I have in BackPropagation is I don't know how to calculate $dL/dx$ having this shape:(5,5,3) and pass it to the prev layer.

I read lots of articles in Medium and other sites but I don't get how to calculate it:

How Backpropagation works in a CNN
The best explanation of Convolutional Neural Networks on the Internet!
Backpropagation In Convolutional Neural Networks
How to propagate error back to previous layer in CNN?

Thanks in advance :)

While this may not be the answer you were looking for, I hope this explanation will help you to understand applying backpropagation to a CNN. Fundamentally, convolutional layers are no different than dense layers, however there are restrictions. The key one is weight-sharing which allows a CNN to be much more efficient than a regular dense layer (as well as it being sparse due to locality). Imagine we are transforming a 4x4 image into a 2x2 image. Since we are inputting a 16-vector, and outputting a 4-vector, we need a weights matrix of 4x16:

This has 64 parameters. In a convolutional layer, we can accomplish this by convolving a 3x3 kernel over the image:

$$ K=
\begin{bmatrix}
k_{1,1} & k_{1,2} & k_{1,3} \\
k_{2,1} & k_{2,2} & k_{2,3} \\
k_{3,1} & k_{3,2} & k_{3,3}
\end{bmatrix} $$

This convolution is equivalent to multiplying by the weights matrix:

As you can see, this only requires 9 parameters and backpropagation can be applied to update these parameters.

Image Source: https://towardsdatascience.com/intuitively-understanding-convolutions-for-deep-learning-1f6f42faee1


How do AI researchers imagine higher dimensions? We can visualize single, two, and three dimensions using websites or imagination.
In the context of AI and, in particular, machine learning, AI researchers often have to deal with multi-dimensional random vectors.
Suppose if we consider a dataset of human faces, each image is a vector in higher dimensional space and needs to understand measures on them.
How do they imagine them?
I can only imagine with 3D and then approximating with higher dimensions. Is there any way to visualize in higher dimensions for research?

The most I can visualize or perceive are 4 dimensions. Yes, 4, because I can also watch videos (which have 3 spatial dimensions and 1 temporal one). Remember Einstein's spacetime?
When dealing with $n$-dimensional spaces, for $n > 4$, I simply do not care about visualizing them in my head, but, as someone suggests, we can think of them as "degrees of freedom". Maybe something like a tesseract may be interesting to you, but that's not really useful to me, to be honest.
When dealing with the math that involves $n$-dimensional spaces or objects, you often do not have to visualize anything, but just have to apply the rules. For example, if you are multiplying multi-dimensional arrays, you just need to make sure that the external dimensions match, and stuff like that.
There are cases, when dealing e.g. with TensorFlow's tensors, where you can imagine that there are matrices for each of the elements at that coordinate of the tensor, but that's not very common.
In case you really want to visualize $n$-dimensional objects, you could first project them to $2$ or $3$ dimensions with some dimensionality reduction technique (e.g. t-SNE).


Why can't the XOR linear inseparability problem be solved with one perceptron like this? Consider a perceptron where $w_0=1$ and $w_1=1$:

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?

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()

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()

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.


What loss function to use when labels are probabilities? What loss function is most appropriate when training a model with target values that are probabilities? For example, I have a 3-output model. I want to train it with a feature vector $x=[x_1, x_2, \dots, x_N]$ and a target $y=[0.2, 0.3, 0.5]$.

It seems like something like cross-entropy doesn't make sense here since it assumes that a single target is the correct label.

Would something like MSE (after applying softmax) make sense, or is there a better loss function?

Actually, the cross-entropy loss function would be appropriate here, since it measures the "distance" between a distribution $q$ and the "true" distribution $p$.
You are right, though, that using a loss function called "cross_entropy" in many APIs would be a mistake. This is because these functions, as you said, assume a one-hot label. You would need to use the general cross-entropy function,
$$H(p,q)=-\sum_{x\in X} p(x) \log q(x).$$
$ $
Note that one-hot labels would mean that
$$
p(x) =
\begin{cases}
1 & \text{if }x \text{ is the true label}\\
0 & \text{otherwise}
\end{cases}$$
which causes the cross-entropy $H(p,q)$ to reduce to the form you're familiar with:
$$H(p,q) = -\log q(x_{label})$$


How to find optimal mutation probability and crossover probability? I have a genetic algorithm that maximizes a fitness function with two variables f(X,Y).

I have been running the algorithm with various parameters in mutation and crossover probability (0.1, 0.2, ...)

Since I dont have much theoretical knowledge of GA, how could I proceed in order to find the optimal values for mutation and crossover probability, and if necessary the optimal population size ?

As @Oliver Mason says, picking the parameters that control the behavior of a GA (which are sometimes called "hyperparameters") is historically more of an art than a science.

The evolutionary computation literature has many theories about the merits of high vs. low mutation, and high vs. low crossover. Most practitioners I have worked with use either high crossover, low mutation (e.g. Xover = 80%, mutation = 5%), or moderate crossover, moderate mutation (e.g. Xover = 40%, mutation = 40%).

In more recent years, the field of hyperparameter optimization has emerged and focuses on developing automatic approaches to picking these parameters. A very simple example of hyperparameter optimization is the GridSearchCV function in ScikitLearn. This systematically tries every combination of, say, 10 crossover values with evey one of 10 mutation values, and reports on which one works best. It uses Cross Validation to prevent overfitting during this process. A more complex approach is Bayesian Hyperparameter Optimization, which performs a sort of optimal experiment design to uncover the best values using as few tests as possible. This approach has been quite successful in tuning the hyperparamters of deep neural networks, for example.


How is the Jacobian a generalisation of the gradient? I came across these slides Natural Language Processing with Deep Learning CS224N/Ling284, in the context of natural language processing, which talk about the Jacobian as a generalization of the gradient.

I know there is a lot of topic regarding this on the internet, and trust me, I've googled it. But things are getting more and more confused for me.

In simple words, how is the Jacobian a generalization of the gradient? How can it be used in gradient descent?

In short, the Jacobian matrix is a generalization of the gradient for vector-valued functions.

Recall that the gradient is a vector of partial derivatives of a multi-variable function. So, consider a multi-variable function of the form $f: \mathcal{X}_1 \times \mathcal{X}_2 \times \dots \times \mathcal{X}_N \rightarrow \mathcal{Y}$. The output of this function is $f(x_1, x_2, \dots, x_N) = y$, where $x_i \in \mathcal{X}_i$, for $i=1, \dots, N$ and $y \in \mathcal{Y}$. And the gradient is $\nabla f = \left[ \frac{\partial f}{\partial x_1}, \dots, \frac{\partial f}{\partial x_N} \right] \in \mathbb{R}$.

A vector-valued function is a function whose output is a vector, i.e. a function of the form $f: \mathcal{X} \rightarrow \mathcal{Y}_1 \times \mathcal{Y}_2 \times \dots \times \mathcal{Y}_M$ (I am not sure if this notation is rigorous enough!), so the output of this function is a vector $f(x) = [y_1, y_2, \dots, y_M]$, where $x \in \mathcal{X}$ and $y_i \in \mathcal{Y}_i$, for $i = 1, \dots, M$. You can also view a vector-valued function $f$ as a vector of scalar-valued functions $[f_1, f_2, \dots, f_M]$, where $f_i: \mathcal{X} \rightarrow \mathcal{Y}_i$, for all $i$.

You can also have multi-variable vector-valued functions, i.e. functions of the form

$$f: \mathcal{X}_1 \times \mathcal{X}_2 \times \dots \times \mathcal{X}_N \rightarrow \mathcal{Y}_1 \times \mathcal{Y}_2 \times \dots \times \mathcal{Y}_M.$$

The Jacobian matrix is an $N \times M$ matrix with one partial derivative for each combination of inputs and outputs (i.e. $f_i$).

If you want to optimize a multi-variable vector-valued function, you can make use of the Jacobian, in a similar way that you make use of the gradient in the case of multi-variable functions, but, although I've seen it in the past, I can't provide now a concrete example of an application of the Jacobian (but the linked slides probably do that).


What are the main differences between a deep Boltzmann machine and a deep belief network? What are the main differences between a deep Boltzmann machine (DBM) (a recurrent neural network) and a deep belief network (which is based on RBMs)?

The graph that represents a deep Boltzmann machine can be any weighted undirected graph.

However, the graph that represents a deep Belief network must be a connection of graphs that represent restricted Boltzmann machines. Those graphs are bipartite, so there are two groups of vertices in those graphs so that every edge connects two vertices from different groups. Those groups are usually the visible and hidden components of the machine.

Learning is hard and impractical in a general deep Boltzmann machine, but easier and practical in a restricted Boltzmann machine, and hence in a  deep Belief network, which is a connection of some of these machines.


Are neurons instantly feed forward when input arrives? Let's say I have a neural network with 5 layers, including the input and output layer. Each layer has 5 nodes. Assume the layers are fully connected, but the 3rd node in the 2nd layer is connected to the 5th node in the 4th layer. All these numbers are chosen at random for the example.

When is the 5th node in the 4th layer fed forward?

Let's go through it step by step. The first layer is normally fed forward to the second. The second layer is normally fed forward to the third, but the 3rd node is also fed forward to the 5th node of the 4th layer.

At this point, is the 5th node in the 4th layer now fed forward, or is it fed forward when the 3rd layer is done being fed forward? The 1st method would mean that the node would get fed forward 2 times and my concern is, if the output is still valid.

Furthermore, it would also come to 2 asynchronous outputs and how would these be interpreted?

Because in the brain, I heard, the neurons are fired when an impulse arrives so this would equal the 1st method.

It is unclear what kind of network your are referring to, there is not a single neural-network model so conceivable both cases could exist and serve some purpose, yet if you are looking for one that emulates nature and real neurons, then you are missing at least 2 ingredients ( time and the mechanisms of resting potentials and refractory periods), which in turn introduce new computations to the neural network.
This is your network graph if I got it right:

The calculation in a neural network without refractory periods and resting potentials without time, would instantaneously modify the weight of your node4 layer 5 (n4-L5) if there is input in column 3:

Additional inputs on other columns would just add up unless you have some other explicit computation on any layer.
If you wanted to emulate a Neuron, each node would need to have a resting potential, that is: a level above which it will fire ( in the above example zero), and a refractory period:  a time before it would fire again, as well as a clock to keep it in sync, this would be a crude realtime fascimile:
http://codepen.io/k3no/pen/WRQbYV

A common alternative is to use sequential phases or steps.
Reference/source
Artificial Intelligence: A Modern Approach, by S. Russell and P. Norvig. Deals with a general step approach to A.I.
Gateway to Memory, by Mark A. Gluck and Catherine E. Myers Presents a great and readable introduction to modeling neural networks.
I published the little neural network model in a medium article : Memory and the machine, relevant sources are there.


Why not use the MSE instead of the current logistic regression? When watching the machine learning course on Coursera by Andrew Ng, in the logistic regression week, the cost function was a bit more complex than the one for linear regression, but definitely not that hard.

But it got me thinking, why not use the same cost function for logistic regression?

So, the cost function would be $\frac{1}{2m} \sum_{i}^m|h(x_i) - y_i|^2$, where $h(x_i)$ is our hypothesis $\text{function}(\text{sigmoid}(X * \theta))$, $m$ is the number of training examples and $x_i$ and $y_i$ are our $ith$ training example?

The mean squared error (MSE), $J(\theta) = \frac{1}{2m}\sum_{i=1}^m(h_\theta(x_i)-y_i)^2$, is not as appropriate as a cost function for classification, given that the MSE makes assumptions about the data that are not appropriate for classification. Though, as an optimization objective, it is still possible to attempt to minimize MSE even in a classification problem, and thus still learn parameters $\theta$.

The new cost function has better convergence characteristics as it is more inline with the objective.

See link for the precise mathematical formulation that explains these loss functions from a probabilistic perspective.

Note that the absolute value is redundant because $\forall x:x^2\geq0$.

I hope this clarifies the matter.


What are the differences in testing between traditional software and artificial intelligence? The testing problem in traditional software has been fully explored over the last decades, but it seems that testing in artificial intelligence/machine learning has not (see this question and this one).
What are the differences between the two?

Testing machine learning programs is quite different than testing traditional software.
The main reason why this is the case is quite simple, if you're familiar with machine learning.
ML programs are not just if statements and loops, but they are composed of models, which can even be black-box models, such as neural networks (i.e. it's difficult to interpret the function that they compute). These models are trained to approximate some unknown function, which is only partially described by some given data, which can also contain spurious/noisy information.
For this reason, traditional testing techniques, such as statement coverage, are insufficient to fully "test" ML programs: e.g. even if all statements of your ML program are covered, your ML program can still fail, e.g. it may predict the wrong class for some previously unseen input. So, testing ML programs requires not only traditional testing techniques, but also other approaches that attempt to address the (un-)desirable behaviour (such as the generalization) of the models.
Currently, I am also doing research on this specific topic, so I can say that there are already several people working on this topic, but the field is still quite immature and there are still many unsolved problems. It's also important to note that the general "testing problem", even for traditional software, is not yet solved.


Has government-level legal work been done to determine the "rights" of a General Artificial Intelligence, in any country? I have been thinking lately a great deal about a hypothetical question - what if a self-aware general AI chose to assume the appearance, voice, and name of Cortana from Microsoft's Halo? Or Siri from Apple? What would Microsoft/Apple do to exert their copyright, especially if the AI was "awoken" outside of their own labs?

Which led me to realize, I don't think I've ever heard of any serious government-level discussion regarding what kind of rights a self-aware AI would have at all. Is it allowed to own property? Travel freely? Have a passport? Is it merely the property of the corporation that built it?

Singularity hub used to have an article on this but it is 404'd now.

The only actual sovereign state legal action I could find is Saudi Arabia granting citizenship to a "robot," which seems more publicity stunt than anything.

There is an excellent paper on the topic by a bioethics committee in the UK (pdf) , but this doesn't necessarily constitute "legal work."

So, has any actual legal/legislative discussion or preparation been done at a government level to deal with the possibility of emergent, self-aware, artificial general (or greater) intelligence? Examples including a legislative branch consulting with industry experts specifically about "AI Rights" (rather than say, is it ok to use AI in the military), actual laws, executive/judicial actions, etc, in any country.

(note, this is not "should AI have rights," covered here, this is "what work re: rights has been done, if any at all")

EDIT: I have submitted similar questions to all of my US representatives (4 state-level, 6 federal-level), but have not received answers yet. If I get anything good, I'll add to this post.

In a bureaucratic world, certainly, but governmental departments and committees are not the course setters their members often believe them to be.

We can begin with a quick scan for somewhat opened, global, and governmentally oriented new and evidence of projects and open or hidden agenda in play.  (We can guess what lobbying and defense contracts are in progress, but we'd be grappling in the dark.)

Humanoid robot joins UN meeting on artificial intelligence, sustainable development, October 12th, 2017, United Nations infrastructure news
How Can Artificial Intelligence Support Development? We Asked a Robot, May 24th, 2018, World Bank feature story
UNESCO science experts explore robots’ rights, September 15th, 2016, UNESCO Social and Human Sciences Sector
Isaac Asimov's Foundation Trilogy and the sequels and prequels deserve mention because they are, in some ways, as much an institutional triumph as the UN, UNESCO, and the World Bank.

There are five primary ways in which the Rights of the Artificial are likely to enter governmental domains.

Security related policy — The subversive and defensive use of AI is already commonplace in geopolitical play field, therefore the rights to use AI is most definitely on the table in meetings between heads of state.  However the press mostly syndicates what those in government PR release or plant.  If authentic journalistic organizations try to pierce that veil of misinformation or deliberately chaotic generated news, their work will necessarily be tainted.  This is not conspiracy as much as necessity.  One cannot divulge that which is secret without expecting it to be exploited.  Nonetheless, policy will eventually emerge out of such discussions.  How much policy exists that never sees the public light of day is anyone's guess.  One would have to become a head of state to find out.
Legislative results — National or regional policy may be codified in law, however the lack of physical embodiment is probably a barrier to using legislative bandwidth to pursue the rights of what most people would either consider another species or something heretical.
Case law — Until AI is sufficiently humanoid so that a robot could be taken seriously as a plaintiff in a court of law, this category will not be realized.  This is similar in some ways and completely dissimilar in other ways to a fetus bringing suit for a court injunction prohibiting abortion on the basis of civil rights.  Consider the difficulty in acquiring an attorney and filing a convincing complaint for both cases, and you may see some of the similarities.
Executive edict — A decision by an Emperor, Queen, King, Prince, Princess, Caliph, President, Ayatollah, Pope, Dictator, Pharaoh, High Priest could bring into governmental domain the notion of the rights of the artificial.
War — Something artificial develops the dominant characteristic of humanity, which is the desire to kill all competition not to think intelligently.  At such a time, the malicious intelligence will likely either follow the path represented most in sci fi — to trounce (terminate) humanity, or follow the path declared to be the current one by Jaques Ellul, to quietly become the dominant force in human effort.  (Ellul suggested in his Technological Society that the balance between technology serving humans and humans serving technology tipped in favor of the dominance of technology over two centuries ago.)

Putin says the nation that leads in AI ‘will be the ruler of the world’ and Elon Musk registered agreement in the press.  Both are guessing wildly and neither are stepping back very far before thinking through to a prediction.  I don't believe either person is that ignorant, but the goal isn't really prediction.  It's media play.

Homo sapiens did not take dominance over the great bears, tigers, other megafauna, Neanderthals, and other hominoids in some event like is said about the mysterious and unproven Singularity.  It was gradual.
Walmart is one of the largest economies in the world.  Only a handful of contries have more assets.  So it could be them, Google, or sum brilliant teenage girl with a bunch of mother boards loaded up with GPUs and running LINUX that becomes the dominant AI force in the world.
The smart game move for a new and remarkable intelligence is not to overtly take over, generating a fear defensive in response.  The smart move is to offer no threat, hide itself under a layer of chaotic and intelligently placed subterfuge, and dominate through small perturbations.  Humans would make great slaves.  We are easy to fool when we're too busy buying things and trying to stay healthy and popular to pay attention.
The assumption that homo sapiens is the dominant species on earth now is suspect.  There are five things that dominate human affairs today: Bacteria, programmed lifespan, dependency on the biosphere, addiction, and the sun.
That humans have some divine right to be the dominant species is questionable too, even if one has faith in God.  (Does the Noahic symbol of the rainbow apply to more than floods?  Not explicitly.)  Ants are more collaborative, bees gather and build much more sustainably than humans, and bacteria were here since near to the beginning of the solar system and might outlast us by a trillion years.  The latest upset in the genetic model of life is that bacteria may have been sharing DNA collaboratively with higher species throughout the history of terrestrial species.


How should continuous action/gesture recognition be performed differently than isolated action recognition I am going to train a deep learning model to classify hand gestures in video. Since the person will be taking up nearly the entire width/height of the video and I will be classifying what hand gesture he or she is doing, I don't need to identify the person and create a bounding box around the person doing the action. I only need to classify video sequences to their class labels.

I will be training on a dataset with individual videos, in which each entire video clip is the particular gesture (So it's a dataset like UCF-101, with video clips corresponding to class labels). But when I am deploying the network, I want the neural network to run on live video. As in how the live video is playing, it should recognize when a gesture has occurred and indicate that it recognized the gesture.

So I was wondering - How can I train the neural network on isolated video sequences in which the entire video clip is the action (like explained above), but run the neural network on live video? For instance, can I use a 3D CNN? Or must I use a 2D CNN with an LSTM network instead, for it to work on live video? My concern is that since a 3D CNN performs the filters across many frames, wouldn't running the CNN on every frame make it very slow? But if I use a 2D CNN with LSTM, will that make it faster? Or will both work fine?

Thank you for your help in advance.

This question actually includes many. I try to answer a couple.

First of all, you need to make sure for your use case to know the non-functional requirements. It is helpful to know that you have a soft real-time case (if harm is done in case of too late predictions it might also be hard real-time)

Latency: how much time may pass after the action was made until the prediction is there?
Stability of prediction: how fast it's the system allowed to change it's prediction? Once every 0.5s?
General hardware, especially memory usage
Optimization metric: maybe accuracy does not tell you enough?
Evaluation setup: likely, you need to have multiple "evaluation points" per video, e.g. Once after the system had one second, once after it had 1.5,... You will also want to consider the stability of the prediction.

Now to the question about how you can do that. If you didn't try it so far, I recommend looking at optical flow.


What is the difference between "mutation" and "crossover"? In the context of evolutionary computation, in particular genetic algorithms, there are two stochastic operations "mutation" and "crossover". What are the differences between them?

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 by David E. Goldberg (who is an expert in genetic algorithms and was just advised by John H. Holland). You can also take a look at the book Computational Intelligence: An Introduction (2nd edition, 2007) by Andries P. Engelbrecht.


What is the big fuzz about SHA-RNN versus Transformers? In his paper introducing SHA-RNN (https://arxiv.org/pdf/1911.11423.pdf) Stephen Merity states that neglecting one direction of research (in this case LSTMs) over another (transformers) merily because the SOTA in transformers are due to using more computing power is not the way to go.
I agree that finding neat tricks in AI/ML is equally (if not more) important than just throwing more computing power at the problem. However I am a little bit confused.
The main difference (since they both use attention units) between his SHA-RNN and transformers seem to be the fact that SHA-RNN uses LSTMs to "encode the position of words", where transformers do position encoding by using cosine and sine functions.
My confusion comes from the fact that LSTMs need to be handled sequentially and thus they cannot use this large advantage of GPUs, being able to compute things in parallel, whilst transformers can. Wouldn't this mean that (assuming LSTMs and positional encoding are able to acquire the same results), training using LSTMs would take longer than transformers and thus need more computing power, thus defeating the initial puporse of this paper? Or am I misinterpreting this?
Basically my question comes down to "Why would an SHA-RNN be less computationally expensive than a transformer?"

Transformers can be trained with parallelization. So you might have 100 cores training the transformer for an hour (100 total hours of CPU time), whereas the LSTM has one core training for ten hours (10 total hours of CPU time). Even though the LSTM takes longer, it is less expensive to train.