text:
How can I suppress a CNN’s translation invariant or translation equivariant?
I am trying to understand this post, but I get confused by the definitions and the differences. What's definition of equivariant?
If I remove all the pooling layers from a CNN, will it make the network to detect features in pixel resolution? For example, detecting the local maximum of a pixel. For example, can a CNN be designed to return True for the following case?

And False for the shifted window:

In the second case it returns false because the 3x3 submatrix isn't centered (yellow dash line) around the local maximum.
Will an architecture that is
from keras.layers import Dense, Conv2D, Flatten
model = Sequential()
model.add(Conv2D(128, kernel_size=2, activation=’relu’, padding='same', input_shape=(3,3,1)))
model.add(Conv2D(64, kernel_size=2, activation=’relu’, padding='same'))
model.add(Flatten())
model.add(Dense(10, activation=’softmax’))

be able to differentiate between the tiling of the larger grayscale image?

Hi! Can you please ask one question per post? Just ask about the difference between invariance and equivariance in this post and ask the other question in another post.

Question 1
To make it simple

You have a transformation $T$ and an operator $C$ acting on a given input $x$
Let's say you do this experiment

compute $y_{1} = C(T(x))$
compute $y_{2} = C(x)$

You can get three different results:

$y_{1} = y_{2}$ then you can say the operator is invariant with respect to the given transformation
$y_{1} = T(y_{2})$ then you can say the operator is equivariant to the given transformation as applying it to the input basically reflects its effect completely on the output
none of the 2

Questions 2
Q2.1

Spatial Pooling is not the only way to perform dimensionality reduction. You can achieve it even simply applying the Conv Kernel with no padding.

For example, let's say your input is a WxHxC tensor and you are applying a kernel which is KxKxC the result will have spatial domain size (W-(K/2))x(H-(K/2)) with K/2 the integer truncation so if K=5 then K/2=2.
Alternatively you can reduce the spatial domain with stride.
Q2.2

It seems to me you are talking about a sort of Non Max Suppression Operator rather an emergent behaviour, but certainly with the proper supervision signal you can train a CNN to do this work (even if practically it does not make sense as you can explicitly define it).

I don't think I can use Non-Max Suppression, because what I want is a network that will detect if it's centered around the local maximum or not.

The point is you do not need to teach the network (via supervised learning) how to do this (even if you can certainly do this) as you can easily code an algorithm (if you do not want to call this algo NMS it is not a problem for me :) )

so you suggest to have 3x3 CNN with pooling and then use NMS to locate the exact pixel after running the cnn on each pixel.

If you just want local max you do not need any complete CNN, it seems you just need a sort of max pooling which, instead of returning the value, returns the pixel with max value position: you can easily code it yourself
(and if you can not, just post a question here or on SO and me / somebody else in the community will be happy to help)

my data set is more complicated. It needs to be a max in some subgraph adjacency matrix

I think it's easier if you DM me on Twitter with more details @NicolaBernini


text:
Using UMAP, PCA or t-SNE to find the separating hyperplane?
Is it possible to use t-SNE, PCA or UMAP to find separating hyperplane?
Assume we have data points in high dimensional space and we want to phase separate it into two sets of points?
Is there a way to use t-SNE, PCA or UMAP for such a task?

All the methods are basically manifold methods which are used to squeeze hyper dimensions to two or three dimensions with a certain amount of information loss. So whatever you "see" with these methods are not real and deceiving. You may see a separation of data points in 3D but when they are mapped onto the actual dimensions it may be complete rubbish.
By definition, these methods do not provide a way to find separating hyperplane. They just tell you some condensed information about the whole data. It is generally advised to use methods like t-SNE with caution.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
How to apply EOT algorithm to 3d model
Many of you have probably seen the turtle from LabSix that gets mistaken for a rifle in Google's InceptionV3 image classifier. I read the paper and I understand how they apply EOT to 2d images and on the individual pixel values, but I am still unsure how they implement the EOT algorithm to the 3d model.

Are they using EOT to perturb the individual coordinates in the 3d model's mesh? Or are they perturbing images of a turtle and then printing the turtle from the images?
How do they check the InceptionV3 output iteratively without having to 3d print the object each time and check the probabilities given?

Any examples that someone can point to would also be very helpful.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Create captions based on a series of images
I'd like to generate subtitles for a silent film. Is there an open source project out there capable of creating captions based on a series of images (such as a scene from a movie)?
EDIT: thanks for the comments below. To clarify, what i'm looking for is an algorithm which can generate a caption for a sequences of images within a movie  describing what happens in the sequence. This is for preliminary research, so accuracy is less important.

This is a really cool question.  My guess, based on current limitations, is that there is no AI in existence that could come close to providing this function... today.  But even as AI advances, this particular function will be challenging.  The AI has to understand the context AND subtext of the silent scenes.  (Many humans seem not to get subtext;)  Both are far beyond current capabilities, but I'm sure facial recognition related to emotions will be a major part of the puzzle.

What does a subtitle mean for a silent film?  Silent films don't have spoken dialogue.  If the actors are not speaking what is there to put in a subtitle?  Are you asking how to summarize the actions of video segments into words?  If that is the case you may find the following video of interest although it does not directly address your question: https://www.youtube.com/watch?time_continue=1&v=AR3hY9iB5-I

Check out Amazon's Rekognition which combines algorithms like object detection, tracking,facial recognition, activity detection, and celebrity recognition: https://aws.amazon.com/rekognition/ and https://www.youtube.com/watch?v=SNONL4IecHE

Added a clarification

What you might want to look for is called video captioning. Earlier examples from this line of research is:

Venugopalan et. al. Sequence to Sequence – Video to Text, in ICCV 2015
Pasunuru et.al. Multi-Task Video Captioning with Video and
Entailment Generation, in ACL 2017

Below is a screenshot of the results (positive and negative) reported in those papers:

For the ICCV paper, it's not hard to find some implementations, e.g. here.
For more recent results, I would suggest to look into the ActivityNet 2017 Challenge - dense captioning or its 2018 version. Some winning solutions include:

Jointly Localizing and Describing Events for Dense Video Captioning
RUC+CMU: System Report for Dense Captioning Events in Videos

However I am not sure whether any open-source implementation has been released.

No , even generating brief summary of a video is out of scope as of current state of the art. Training such a model is a tough task. Video understanding is pretty far from the research as of now.
But you could try generating descriptions of some keyframes of the video , and align them to form meaningful passages.
check this https://arxiv.org/abs/1611.06607

Here is one open-source implementation. Temporal Tessellation: A Unified Approach for Video Analysis
For more you can dig into some research publications and see if they give a link to their implementation. Most researchers put up their work for public.
Here is a list of publications that present their work related to video captioning using machine learning. Awesome Deep Vision
Here is another publication that shows how to generate captions for videos. Video Paragraph Captioning Using Hierarchical Recurrent Neural Networks

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Periodic Pattern in Validation Loss Curve
I am currently trying to solve a regression problem using neural networks. I want to detect movement patterns in images over time (video) and output a continuous value.
During the training process I noticed a strange behaviour for the validation loss curve and I was wondering if anyone has noticed this kind of periodic pattern on some of their own work. What might cause this?
The model looks like the following:
- TimeDistributed(Conv2D(32, (3,3)))
- TimeDistributed(Conv2D(16, (3,3)))
- TimeDistributed(Flatten())
- GRU(64, stateful=True)
- Dropout(0.5)
- Dense(64, activation='relu')
- Dense(1)

I trained the model using the mean squared error as the loss function, a batch size of 1 and the AdamOptimizer with an initial learning rate of 10^(-6). Obviously, the loss curve for the training data is not very good, but I am currently just wondering about the pattern of the val_loss. The plots below represent the loss of 65 epochs.
Thanks!

Edit:
The way I try to solve my task relies on a sliding window approach where I try to predict a continuous value for the next second based on the last 20 seconds (400 frames) of the time-series input data. But I don't think this information is needed to solve my initial question since the periodic patterns appear over several epochs (one "peak" for about every 15 epochs) which is strange. Although the stateful-version of the GRU is used (btw: using TensorFlow and Keras), the internal state of the GRU is reset after every epoch to maintain a clean start. The stateful keyword is used to indicate a dependency between batches.

To add some more clarity, can you explain more about how you set up your dataset and training pipeline? Perhaps there's a link to a tutorial or a source code you were following?

Are you sure that you're going over all your dataset in one epoch? The fact that the loss also has these spikes suggests that you might be seeing new training data you haven't trained on before?

your model is giving a high loss for start of the video frame , later its loss is getting decreased as it runs through several frames of the "same" video, but again after a new video occurs its loss again peaks to certain point.


text:
Is it possible to learn the number of layers?
Is it possible, in a transformer or other deep architecture, to include the number of layers as a parameter of the model so it could be learned?
In fact, I have a keras layer that I use to change the final layer without rebuilding the model, so I can just change a parameter between epochs (The original use was to try to train deep networks starting from shallower ones, increasing the number of layers after each epoch).
class LayerSelect(tf.keras.layers.Layer):
    def __init__(self,nlevels,**kwargs):
        super(LayerSelect,self).__init__(**kwargs)
        self.nlevels = nlevels
        self.range=tf.range(self.nlevels,dtype=tf.float32)

    def build(self, input_shape):
        self.kernel=self.add_weight(shape=(1,),
                                    initializer=tf.keras.initializers.Constant(min(self.nlevels,14.0)/1.9),
                                    trainable=True, dtype=tf.float32,
                                    constraint=lambda x: tf.clip_by_value(x,1.0,self.nlevels))

    def call(self,inputs):
        selector=tf.math.maximum([0.0], 1.0 - 1.0 *(self.range-self.kernel)**2 )
        final=tf.reduce_sum(inputs*selector,axis=-1)
        return final

The layer expects an stack of hidden layers to choose from:
allEncoders=tf.stack([encoder[level] for level in range(layers)],axis=-1)
finalEncoderRaw=adhoc.LayerSelect(layers)(allEncoders)

So that by calling set_weights during the training I can choose as output any layer, or a combination of two, being the layer variable a float and using a wider selector, say 1.0 - 0.25 *(self.range-self.kernel)**2
And as you can expect, if I set the weight to be trainable, the optimiser moves the variable. But it keeps either moving randomly some small percent or moving backwards towards smaller values. So it is possible that this approach is a dead end?
If not a way to patch this method, is there another successful method to train the number of layers without using meta-parameter (hyperparameter grids) farms?

What do you mean by "without using meta-parameter farms"? Everything has a cost. Unfortunately, hyper-parameter optimization is very costly, usually.

I mean without using hyper parameter searches across a grid of values.

I like the idea, but I fear this approach may be a dead end. I see a few problems:
Layers in front of (closer to the output than) the currently selected layer(s) don't affect the output, so they won't change and they can't learn to be good predictors for the true output.
Layers behind the currently selected layer won't be trained to predict the final output (they'll be trained to provide outputs are useful inputs for the selected layer) so switching to those layers is unlikely to improve the output.
And if another layer did provide a better approximation of the final output, the network is unlikely to switch to it unless it's next to the currently selected layer (i.e. the selection is likely to get stuck in a local minimum). For example, if layer 3 is selected, and 1 is a better prediction than 3, but 3 is better than 2, the network would stick with 3.

is there another successful method to train the number of layers without using meta-parameter farms?

I haven't heard of one, and that seems like something that would be widely shared if it worked well.
I have seen genetic algorithms for selecting neural network architecture, but as far as I know they don't perform better than grid search for choosing the number of layers.

A possible answer to the problem of switching could be to combine all the layers, but there is no assurance that the weights will converge to a Kronecker delta :-(

The work had been done before, take a look at this paper. The author not only search for the number of layers but also the whole model architecture.
By using reinforcement learning, the system makes a loop, generates a model by a sequence of LSTM then validates the reward by the accuracy of the test set. It's a famous paper but not widely used because of the high complexity and huge computation cost.

Hey thanks! It is still a meta-learning, if it generates different models for different sets of hyperparameters, but at least it is "machine learned meta learning" and not just a grid search. And a good pointer for references.

It is always possible to use a Dense layer to allow the network to built its own menu of layers
allEncoders=tf.stack([encoder[level] for level in range(1+nlayers)],axis=-1)
layerSelect=tf.keras.layers.Dense(1,activation=None, use_bias=False,
    kernel_initializer=tf.keras.initializers.Constant(0.5),
    kernel_constraint=tf.keras.constraints.MinMaxNorm(axis=1))
almostFinalEncoder=tf.keras.layers.Reshape([-1,layerUnits])(layerSelect(allEncoders))
finalEncoder=tf.keras.layers.LayerNormalization()(almostFinalEncoder)

but one must be careful with the initializer, and the vector layerSelect.get_weights()[0]needs to be monitorised.
Generically this layer will not converge to a Kronecker delta, and it must keep some extra weights open just for the sake of overfitting.
Still, the evolution seems to have some information. See here the contourplot for a 64 layers, 256 units, transformer that has reached overfitting at epoch 18 but keeps learning slowly.  It seems to prefer to increase weights of layers 1 to 24, and it moves as the learning progresses, decreasing the use of the first layers.

(Sorry the colour scheme is confusing. Basically we have a descending trend in the first layers, ascending in the middle layer, then descending again in the tail)
Generically most plots show a trend to zero the two first layers (or not raising them at all if the starting vector is [0.1,0.0,...] and the growing of some peaks that can be related to the structure of the network. One of such peaks can be due to finite size, of course we can not try with an infinite number of layers and I can not imagine how to compensate for the long tail.
But it does not converge to a delta, or a set of deltas. And for few epochs it is not granted that the best peak is the best layer. You have three nearby definitions that do not seem to coincide:

The layer with greatest weight in the Dense fusion of layers.
The layer with best result when evaluated with a Kronecker weight (w[l]=1, w[!l]=0) in the LayerSelect class.
The number of layers that give the best training in the usual, unfusioned, training.

Yep, that looks like a plausible way to combine the layers. Or you could use a residual (skip) connection, allowing the output of any layer to skip all the way to the final output. But off-hand I don't think they could be used to train the number of layers.

Yep, so I keep thinking about some way using only one parameter... a whole vector is a lot of freedom to combine layers, even if it shows interesting behaviours depending on the initializer.


text:
Is it possible to write an adaptive parser?
I am working on a js library which focuses on error handling. A part of the lib is a stack parser which I'd like to work in most of the environments.
The hard part that there is no standard way to represent the stack, so every environment has its own stack string format. The variable parts are message, type and frames. A frame usually consists of called function, file, line, column.
In some of the environments there are additional variable regions on the string, in others some of the variables are not present. I can run automated tests only in the 5 most common environments, but there are a lot more environments I'd like the parser to work in.

My goal is to write an adaptive parser, which learns the stack string format of the actual environment on the fly, and after that it can parse the stack of any exception of that environment.

I already have a plan how to solve this in the traditional way, but I am curious, is there any machine learning tool (probably in the topic of unsupervised learning) I could use to solve this problem?
According to the comments I need to clarify the terms "stack string format" and "stack parser". I think it is better to write 2 examples from different environments:
A.)
example stack string:
Statement on line 44: Type mismatch (usually a non-object value used where an object is required)
Backtrace:
  Line 44 of linked script file://localhost/G:/js/stacktrace.js
    this.undef();
  Line 31 of linked script file://localhost/G:/js/stacktrace.js
    ex = ex || this.createException();
  Line 18 of linked script file://localhost/G:/js/stacktrace.js
    var p = new printStackTrace.implementation(), result = p.run(ex);
  Line 4 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html
    printTrace(printStackTrace());
  Line 7 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html
    bar(n - 1);
  Line 11 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html
    bar(2);
  Line 15 of inline#1 script in file://localhost/G:/js/test/functional/testcase1.html
    foo();

stack string format (template):
Statement on line {frames[0].location.line}: {message}
Backtrace:
{foreach frames as frame}
  Line {frame.location.line} of {frame.unknown[0]} {frame.location.path}
    {frame.calledFunction}
{/foreach}

extracted information (json):
{
    message: "Type mismatch (usually a non-object value used where an object is required)",
    frames: [
        {
            calledFunction: "this.undef();",
            location: {
                path: "file://localhost/G:/js/stacktrace.js",
                line: 44
            },
            unknown: ["linked script"]
        },
        {
            calledFunction: "ex = ex || this.createException();",
            location: {
                path: "file://localhost/G:/js/stacktrace.js",
                line: 31
            },
            unknown: ["inline#1 script in"]
        },
        ...
    ]
}

B.)
example stack string:
ReferenceError: x is not defined
    at repl:1:5
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)

stack string format (template):
{type}: {message}
{foreach frames as frame}
{if frame.calledFunction is undefined}
    at {frame.location.path}:{frame.location.line}:{frame.location.column}
{else}
    at {frame.calledFunction} ({frame.location.path}:{frame.location.line}:{frame.location.column})
{/if}
{/foreach}

extracted information (json):
{
    message: "x is not defined",
    type: "ReferenceError",
    frames: [
        {
            location: {
                path: "repl",
                line: 1,
                column: 5
            }
        },
        {
            calledFunction: "REPLServer.self.eval",
            location: {
                path: "repl.js",
                line: 110,
                column: 21
            }
        },
        ...
    ]
}

The parser should process the stack strings and return the extracted information. The stack string format and the variables are environment dependent, the library should figure out on the fly how to parse the stack strings of the actual environment.
I can probe the actual environment by throwing exceptions with well known stacks and check the differences of the stack strings. For example if I add a whitespace indentation to the line that throws the exception, then the column and probably the called function variables will change. If I detect a number change somewhere, then I can be sure that we are talking about the column variable. I can add line breaks too, which will cause line number change and so on...
I can probe for every important variables, but I cannot be sure that the actual string does not contain additional unknown variables and I cannot be sure that all of the known variables will be added to it. For example the frame strings of the "A" example contain an unknown variable and do not contain the column variable, while the frame strings of the "B" example do not always contain the called function variable.

Welcome to AI!  I took the liberty of editing for readability, and added a javascript tag (very happy to see a js/ML question:)  I'd suggest including the name of js library you're using because someone may have direct experience with it.

Definitions of "stack string format", "stack parser", ... should be clarified.

@pasabaporaqui updated

@DukeZhou I haven't used any ML library yet. I need to decide first what tool I could use to complete this task. I am afraid that using some kind of hardcoded approach for the parser will be too rigid, and won't work in some of the environments, that's why I am thinking on using ML, but I have zero experience with it. What I need is some pattern recognition algorithm, which will be able to recognize the variable and constant regions of the stack string, and if the pattern does not match by a new stack string or probably by a frame string, then it will adapt to it.

Interesting question. One approach is  "grammar induction". All strings you present they have the form " Header Frame ... Frame "  where "Frame" contains common parts / structures as "Line N", "of F". Grammar induction will find how to extract these items from the string.

@pasabaporaqui Yes, there are rules we can assume, for example every stack has a possibly multiline header (or footer) with at least the message. Every frame contains at least a path. Frame string formats can be different depending on the variables, e.g. in example B. if the called function is not set, then there are no parentheses around the location variables. I think the hardest part is separating a different frame string template from an unknown variable.

What I am looking for appears to be "sequential pattern discovery". There are several algorithms so I still need to read a lot more. It is an interesting topic, because you can use the same to find temporal patterns, which means I will be able to use it for medical research too.

@pasabaporaqui Splitting up to 1 or 2 lines based on probing with more or less known exceptions and using a modified SPADE algorithm with constraints like parameter count looks the most promising so far. I'll try to implement it. I guess it will take a week at least to figure this out. At least I have found something after 2 months... http://www.philippe-fournier-viger.com/spmf/index.php?link=algorithms.php I don't think this pattern mining is considered machine learning, but the results can be useful for learning algorithms.

I wrote a relatively simple adaptive parser in Prolog. The parser is essentially a string rewriting system that learns new rewrite rules from its input, such as "A implies that B" means "A implies B", or "neither A nor B" means "not (A or B)", using a simple bottom-up parsing algorithm.
Using the grammar rules that it has learned, the parser is able to convert English phrases such as C is not less than D percent of E and R implies that Q is not true into Prolog terms, such as (C<D/100*E)=false,(R->Q\=true).
In addition to the parser that I described here, there is an adaptive parser generator called dypgen. There also are several programming languages that allow user-defined syntax extensions, including Coq and Agda.
The Nearley parser generator also allows grammar rules to be added at runtime, though this feature isn't documented yet.

The parsing of linguistic units from streams of speech by the human brain is an existing system that can be studied, and it is a legitimate proof of concept.  A working brain adapts to changes in volume, tone frequency, information rate, rhythm, accent, dialect, and background sound as it parses sequences of vocal sounds originating from the initial tone and transient processing of signals from the vestibulocochlear nerve.
The later evolution of written symbol recognition from signals originating from the optic nerve is a related proof of concept.
Simple adaptive parsing is running in the lab as a part of social networking automation, but only for limited sets of symbols and sequential patterns.  It does scale without reconfiguration to an arbitrarily large base linguistic units, prefixes, endings, and suffixes, limited only by our hardware capacities and throughput.
The existence of regular expression libraries was helpful to keep the design simple.  We use the PCRE version 8 series library fed by a ansiotropic form of DCNN for feature extraction from a window moving through the input text with a configurable windows size and move increment size.  Heuristics applied to input text statistics gathered in a first pass produce a set of hypothetical PCREs arranged in two layers.
Optimization occurs to apply higher probabilistic weights to the best PCREs in a chaotically perturbed text search.  It uses the same gradient descent convergence strategies used in NN back propagation in training.  It is a naive approach that does not make assumptions like the existence of backtraces, files, or errors.  It would adapt equally to Arabic messages and Spanish ones.
The output is an arbitrary directed graph in memory, which is similar to a dump of an object oriented database.  JSON hierarchies were too restrictive four our purposes, since the directed graphs we were parsing from a serial text stream had cases of multiple incoming directed edges into vertices and some circular edge sequences.
قنبلة -> dangereux -> 4anlyss
bomba -> dangereux
ambiguïté -> 4anlyss -> préemption -> قنبلة

Although a re-entrant algorithm for a reinforcement version is stubbed out and the wellness signal is already available, other work preempted furthering the adaptive parser or working toward the next step to use the work for natural language:
Matching the directed graphs to persisted directed graph filters representing ideas, which would mimic the idea recollection aspect of language comprehension.

For the formats above you could write a one normal CFG parser what would extract AST tree. That actualy you want as output?

The formats are unknown, they should be detected somehow. Yepp, I ended up working on a parser and pattern mining lib, so I can do this.


text:
How can I have a computer learn the equation with known dependent variables?
I'm trying to design an orbital rendezvous program for Kerbal Space Program.  I'm focusing on when to launch my spacecraft so that I can end up in the general vicinity of the target.  If I can control the ascent profile, the remaining dependent variables are the ship's twr and the target's altitude.  I want to try a computer learning solution.
What is the best way to formulate the problem of learning the time to launch based on some twr?
How can I make an algorithm to compute the general equation of launch time to a altitude based on my ability to accelerate?  What type of learning problem could this be classified as?  What are some approaches to solve problems with known dependent variables?
This may be an obvious question, I kind of expect the answer is regression?  But it seemed a general enough question to be sure about to get a solid foothold in computer learning with this type of problem, which seems to come up a lot.

Question is how to calculate the trajectory of an object?

No, powered flight is involved.  Also the approach was NOT to calculate the trajectory of ONE (powered)object, but to have a learning algorithm take a good guess at the equation for time as a function of twr for ALL objects.

Meaning of "twr" ? Not in my lost of acronyms

thrust to weight ratio.

Could you post involved equations?

That's what I want to know.  Usually you have dependent variables, an equation and you solve to get independent variables.
What I'm asking is if I have the dependent variables, and experimental independent variables, what is the best way to learn the equation?

What you mean by "learning" is not clear, are you trying to optimize a process or find an optimum point of data which you can reuse?  or are you seeking a way to feed data into an AI object (ie NN) which will give more precision based on how much data it is given?

I would like the program find an equation or at least the coefficients of an equation that would correspond to the general case of the time to get to orbit.

I'm not sure that I'll get an answer to this one,  but no one commenting seems to understand what I'm getting at.  I am more interested in a general solution at this point, but in terms of the variables already mentioned:
You launch 5 spacecraft into space.  Each has different parameters.  You can control the ascent profile generally.  Each has a different time because there are different designs.
The question I'd like to ask a program is what is the equation that best matches the various launches?

Another way to put it is how much weight do each of the variables we know about matter.  For instance, how much does twr matter?  does it scale linearly?  Is it directly proportional to some other variable?  Another part of this is the unknown variables.  What is the nature of the unknown variables?   It is kind of a solver.  Once again, I know the variables, some experimental, some, like thrust is easily knowable.  How can i develop a system to analyze the remaining parts of the equation?

You might want to try symbolic regression. This is a machine learning approach that tries to generate an equation with arbitrary form that best fits a set of examples. I've used it before when working with physicists who wanted an equation in terms of known numeric constants and specific variables, but didn't expect the equation to be linear or one of the other shapes for which we have standard regression models.
Symbolic regression often (usually?) uses genetic programming for the underlying optimization. A decent tool is Eureka. It used to be free, but I think they want a payment now. You can also do it yourself from any genetic programming toolkit with a little know-how.


text:
Classification Learning - Normalization of time series and live usage

UPDATE: The tables look messed up so i put them on pastebin for better
  visibility. https://pastebin.com/gDX28uVF

I am using Neural Network with different learning types (for example Standard Backpropagation) to classify trends in time series. As stated in several papers, data normalization is a very important factor for successful / efficient learning. I am trying to be clear and precise as possible in the description.
Problem / Learning Goal:
The network gets trained with time series and 2 indicators to predict a specific cluster.  Here is a very simple (madeup) example of raw data to understand the problem:
Example RAW Data
Timestamp;DensityX;WaveLengthY;Temperature (K)
1;0.1;2;200
2;0.9;3;150
3;-0.5;1;175
4;0;6;154
5;1;8;155
6;1.3;1.5;220
7;-0.5;3.4;250
8;0.2;2;255
9;0.1;1;180

see https://pastebin.com/gDX28uVF for better visual

I use the following process to generate suitable sample data for training:
The neural network receives n time slices with the indicators and tries to check if a future trend in the temperature occurs (for x future time slices).
For example n = 2; x=3.
The input and output are defined as follows:
Input vector:

In1 =  Density_(t-2)
In2 =  Wavelength_(t-2)
In3 = Density_(t-1)
In4 = Wavelength_(t-1)

Output vector:
Output Vector is a classification encoded by Effects Encoding or Dummy Encoding (Details in “Neural Networks using C# Succinctly”)
Calculation:

Classification “Down” :  Temperature drops 3 times in a row (Encoded as 0;1)
Classification: “Stable”:    Temperature does neither drop nor raises 3 times in a row (1;0)
Classification: “Up”:    Temperature raises 3 times in a row. (-1;-1;)

So the “processed” training sample would look like this:
Processed Data
Pattern;I1;I2;I3;I4;O1;O2;Class;Used TS
1;0.1;2;0.9;3;0;1;Down;1 to 5
2;0.9;3;-0.5;1;-1;-1;Up;2 to 6
3;-0.5;1;0;6;-1;-1;Up;3 to 7
4;0;6;1;8;1;0;Stable;4 to 8
5;1;8;1.3;1.5;1;0;Stable;5 to 9

see https://pastebin.com/gDX28uVF for better visual

As you can see due to the different indicators ranges I want to normalize the data.
Basically I found the following propositions in literature and research:
Min/Max Normalization
Requires the following values to calculate
 - dataHigh: The highest unnormalized observation.

dataLow: The lowest unnormalized observation.
normalizedHigh: The high end of the range to which the data will be normalized.
normalizedLow: The low end of the range to which the data will be normalized.

Reciprocal normalization
Every value is processed to its reciprocal (x=1/x). Calculated values for density x would be:
Timestamp;Reciprocal Density
1;10
2;1.111111111
3;-2
4;#DIV/0!
5;1
6;0.769230769
7;-2
8;5
9;10

see https://pastebin.com/gDX28uVF for better visual

Percentage normalization
The percentual delta is calculated using the value from the previous time stamp.
The starting point was Timestamp 1 where the Delta equals 0.
For each timestamp the delta percentage is calculated evaluating the previous value. So calculating the time series delta percentages would turn out to:
Timestamp;"Delta Density X"
1;0
2;0.9
3;-0.555555556
4;0
5;#DIV/0!
6;1.3
7;-0.384615385
8;-0.4
9;0.5

see https://pastebin.com/gDX28uVF for better visual

As you can see there are errors with handling zero values and the range is still a problem in my opinion. The Min/Max approach is generally leads to a good normalization but I think there is a problem as well, because live data may breach the max and min values of the training set.
My questions are:

What are your thoughts about the general idea how I process the raw data?
How would you normalize the given data – if at all?
a) Does it make sense for MinMax Normalization to propose a min max value which will include live data (And throw some error in case it happens)
b) How to handle 0 values (maybe convert it to a small positive or negative value?
Are there other ideas or concepts to conduct this problem?

I am looking forward to your input. Everything is appreciated. Thanks in advance! I also apologize for errors in the example values. Anyways, thanks for your time.
Cheers, hob.

Can you please correct up your errors in the question body?

I updated to csv-semic-sep.

Thank you for the input DuttA. It is none of the problems you have mentioned. What do you mean by increasing the precision in regards of the questions?\


text:
How am I getting same results 30 times faster than in original HER paper?
I am reproducing the results from Hindsight Experience Replay by Andrychowicz et. al. In the original paper they present the results below, where the agent is trained for 200 epochs.
200 epochs * 800 episodes * 50 time steps = 8,000,000 total time steps.

I try to reproduce the results but instead of using 8 cpu cores, I am using 19 CPU cores.
I train the FetchPickAndPlace for 120 epochs, but with only 50 episodes per epoch. Therefore 120 * 50 * 50 = 300,000 iterations. I present the curve below:
￼
and logger output for the first two epochs:
￼
Now, as can be seen from my tensorboard plot, after 30 epochs we get a steady success rate very close to 1. 30 epochs * 50 episodes * 50 time steps = 75,000 iterations. Therefore it took the algorithm 75,000 time steps to learn this environment.
The original paper took approximately 50 * 800 * 50 = 2,000,000 time steps to achieve the same goal.
How is it that in my case the environment was solved nearly 30 times faster? Are there any flaws in my workings above?
NB: This was not a one off case. I tested again and got the same results.
Post on Reddit: https://www.reddit.com/r/reinforcementlearning/comments/dpjwfu/getting_same_results_with_half_the_number_of/


text:
Reinforcement learning number of episodes per epoch not matching with paper
I am trying to reproduce results presented in this paper. On page 4, the authors state:

... we train for 50 epochs (one epoch consists of 19*2*50 = 1900 full
  episodes), which amounts to a total of 4.75*10^6 timesteps.

The 1900 episodes are broken down into Rollouts per MPI worker (2) * Number of MPI Workers (19) * Cycles per epoch (50), as shown in the hyper parameters section on page 10.
When testing on my local machine, using the GitHub Baselines repo, I am using 1 MPI worker and the following hyperparams:
'n_cycles': 50,  # per epoch
'rollout_batch_size': 2,  # per mpi thread

By the same calculation, this means that I should have 1*50*2 = 100 episodes per epoch.
However when I run her on FetchReach-v1 turns out I only have 10 episodes per epoch. Here is a log sample:
Training...
---------------------------------
| epoch              | 0        |
| stats_g/mean       | 0.893    |
| stats_g/std        | 0.122    |
| stats_o/mean       | 0.269    |
| stats_o/std        | 0.0392   |
| test/episode       | 10       |
| test/mean_Q        | -0.602   |
| test/success_rate  | 0.5      |
| train/episode      | 10       |  <-- 10 episodes/epoch
| train/success_rate | 0        |
---------------------------------

Why is there this discrepancy? Any suggestions would be appreciated.


text:
How to use DQN to handle an imperfect but complete information game?
I'm currently having troubles to win against a random bot playing the Schieber Jass game. It is a imperfect card information game. (famous in switzerland https://www.schieber.ch/)
The environement I'm using is on Github https://github.com/murthy10/pyschieber
To get a brief overview of the Schieber Jass I will describe the main characteristics of the game.
The Schieber Jass consists of four players building two teams.
At the beginning every player gets randomly nine cards (there are 36 cards).
Now there are nine rounds and every player has to chose one card every round. Related to the rules of the game the "highest card" wins and the team gets the points.
Hence the goal is to get more points then your opponent team.
There are several more rules but I think you can image how the game should roughly work.
Now I'm trying to apply a DQN approach at the game.
To my attempts:

I let two independent reinforcement player play against two random players
I design the input state as a vector (one hot encoded) with 36 "bits" for every player and repeated this nine times for every card you can play during a game.
The output is a vector of 36 "bits" for every possible card.
If the greedy output of the network suggest an invalid action I take the action with the highest probability of the allowed actions
The reward is +1 for winning, -1 for losing, -0.1 for a invalid action and 0 for an action which doesn't lead to a terminal state

My question:

Would it be helpful to use a LSTM and reduce the input state?
How to handle invalid moves?
Do you have some good ideas for improvements? (like Neural-Fictitious Self-Play or something similar)
Or is this the whole approach absolute nonsense?

Welcome to AI!  Sounds like an interesting project.

Would it be helpful to use a LSTM and reduce the input state?

I'd bet, no. LSTM is more complicated and harder to learn, while the input is 4 * 9 * 36 bits is still rather limited.
However, you may want to aggregate the information somehow, e.g., add additional bits informing about what cards were already played (no matter when). This information is redundant, but by providing it, you may save the network quite some learning.
At the same time, you may want to use symmetries (all colors but trumps are equivalent and the therefore the weights should be the same).

How to handle invalid moves?

That's simple: There are no invalid moves. The network provides 36 outputs of how much it wants to play a given card. You simply take the one valid card having the greatest output value. You don't try to make the network learn what moves are valid as this is neither needed nor helpful.

Do you have some good ideas for improvements? (like Neural-Fictitious Self-Play or something similar)

I can't tell. But it should matter at the moment. First make you network clearly beat the random players, then you can look for more. Or start with Self-Play, as you want probably have both for comparison.

Or is this the whole approach absolute nonsense?

I don't think so, but ... (see below)

I design the input state as a vector (one hot encoded) with 36 "bits" for every player

This doesn't sound good. Every player has 9 of 36 cards and so should be the encoding. A player doesn't know the cards of other players.

The reward is +1 for winning, -1 for losing,

In most card games I know, it matters by how much you win (unlike e.g., in Go). Even when it doesn't matter, using this information at the early learning stages is IMHO useful.

-0.1 for a invalid action and

Drop the invalid action. Just transform anything the network produces to a valid action, add no penalty (as written above).

... 0 for an action which doesn't lead to a terminal state

All action but the last one lead to a non-terminal state. You can use some Temporal Difference Learning or use the fact that the game has a small fixed number of moves and reward/punish all actions takes in a the whole game.

Thank you very much for your detailed answer. I will try your hints a let you know if I have some achievements.


text:
Doubt regarding research paper on Crowd Counting using Convolutional neural networks and Markov Random Field
I am currently reading the research paper Image Crowd Counting Using Convolutional Neural Network and Markov Random Field  by Kang Han, Wanggen Wan, Haiyan Yao, and Li Hou.
I did not understand the following context properly:

Formally, the
  Markov random field framework for the crowd counting
  can be defined as follows (we follow the notation in [18]).
  Let P be the set of patches in an image and C be a possi-
  ble set of counts. A counting c assigns a count c p ∈ C to
  each patch p ∈ P. The quality of a counting is given by an
  energy function:
E(c) =
  ∑ D p (c p ) + ∑
  p∈P
  V (c p − c q )
  . . . (2)
  (p,q)∈N
where N are the (undirected) edges in the four-connected
  image patch graph. D p (c p ) is the cost of assigning count
  c p to patch p, and is referred to as the data cost. V (c p −c q )
  measures the cost of assigning count c p and c q to two
  neighboring patch, and is normally referred to as the dis-
  continuity cost.
  For the problem of smoothing the adjacent patches
  count, D p (c p ) and V (c p − c q ) can take the form of the
  following functions:
  D p (c p ) = λ min((I(p) − c p ) 2 , DATA K) . . . (3)
  V (c p − c q ) = min((c p − c q ) 2 , DISC K)
  . . . (4)
  where λ is a weight of the energy items, I(p) is the ground
  truth count of the patch p, DATA K and DISC K are the
  truncating item of D p (c p ) and V (c p − c q ), respectively.

Can anyone explain the above part in detail and give me a detailed insight on how should I implement this part of the project?

Is there any way in which you could come up with a more descriptive title? Particularly for others who face the same issue as you do. Right now the title is so generic and non-descriptive, that any great answers you may receive will not be found by others in a search.

@Bart I have edited the title.


text:
Mountain car problem with images - not converging
I'm trying to find the optimal policy for the mountain car problem using deep Q learning with images as input, however, I cannot find a way to get my Q function to give me good solutions (I followed multiple tutorials for similar problems (Atari games and Flappy bird)).
I'm working on Python with Keras.
The images are given in the following format :

400x400 pixels, where the bar on the bottom right corner represents the speed of the car.
To check where my problem might lie, I thought it would be best if I split the problem by first ensuring that I can find a network which would successfully find the state of the car (position and speed, since it's all we need to find it) by feeding my convolutional network images of random states (uniformly distributed within the state space).
After unsuccessful results, I decided to split it even more by only trying to find the two state variable separately.
This is the best kind of result that I get, when the network doesn't predict all the state to be the same (which seem to happen a lot with relu activation).
The state space is divided in 50x50 matrix to make my predictions. The predicted speed is on the left, and the absolute error is on the right
.
The images fed to the network are pre-processed the follow way :
 1. Gray scale
 2. Resize (I tried 50x50, 100x100 and 150x150)
 3. Values centered around 0 in [-1;1] (this seemed to help a bit with the relu activation)
The network I used to try to find the speed is first a convolution layer (I tried 32 windows of kernel_size=(4,4) (8,8) and (16,16), strides=(1,1) and (2,2), activation= relu, linear, tanh.
Optional additional convolution layers of kernel size half the previous layer.
And an optional last dense layer of dimension 32 or activation relu, linear or tanh.
The output layer is dimension one with linear activation.
The way I train the network is by feeding the fit function with 32 random samples and let the network train for 25 epochs with batch_size 32 and repeat  ad libitum.
It's becoming extremely frustrating, especially with my GPU not fitting the requirement for GPU computation to check if I get some results faster.
Can anyone tell me if I'm doing something wrong that I'm missing and what can I do to improve my method to eventually manage to get the reinforcement algorithm to work ?
Like the size of the training sample, batch size and epochs of the fit function, the structure of the network, ...
Edit : I finally found a way for my reinforcement learning to converge to the true Q value : each time I run a new episode and put it in my replay memory, I run many fits of different mini-batches. This is something I thought I did by increasing the number of epochs in the parameter of the fit function, but I guess it doesn't work as I thought it would.
I'm letting it train a bit and then I will try the same method for the sub-problems mentioned above.

Welcome to AI!  (I think there is a rendering error in the second set of graphics--I'm seeing the numbers overlap, resulting in illegibility.)

Can you please provide a figure of the resized image? Are you using a sliding window to find the car?

The solution in your edit is "re-work the experience replay logic", of which there was no hint that this was the problem before your edit . . . Your question is interesting. However, your edit is revealing that the solution is in the details of the project - hyperparameters and implementation details. It is unlikely anyone here can take even the quite long description here and analyse the fault which is essentially "my learning algorithm is performing badly". At best you can expect well-meaning answers that suggest something to check that you may or may not already be doing.

"there was no hint that this was the problem" If I knew it was the problem, I wouldn't have looked for help, would I ?;) Basically the reason why my protocol didn't work(or would take ages to converge (maybe because I use CPU ?)) is because I trained only one mini batch at a time in-between each episodes, which is what every algorithm I've looked at seemed to be doing (and why I didn't think about mentioning it). The change I made for it to work (in a reasonable amount of time) is to train over many random mini batches in-between episodes, since creating the image is time consuming.


text:
Can we code rules for an agent in python language other than predicate calculus?
I have a medical dataset with 14000 rows dataset with 900 attributes. I have to predict disease severity using that. I would like to know whether we can write rules in python language for training an agent for medical diagnostic using machine learning.
Can an agent make the decisions by the rules coded in python and that agent get trained with some machine learning algorithms? If so is there any agent architecture and model for the agent which is good in this context?
Edit: By the rule, I meant something like this.."if x>y output z as action". By the word "Training" I meant "how to tell this agent to do this action"?

You could formulate the problem of predicting disease severity as a classification one, you give the algorithm those 900 attributes and their corresponding labels (severe/not severe) after training, you give it a new data point with just the 900 attributes, it returns the correct label severe or not.
There is an enormous number of algorithms in the ML literature for classification, some of them formulate the problem explicitly as learnable rules, i.e. let the machine figure out the rules given the attributes.

Classification and Regression Trees by Breiman et al (1984)
Random forest by Ho in 1995
XGBoost

"it returns the correct label": not always.

yes, I mean in a probabilistic way


text:
Any models for text to json
There are many sequence to sequence (seq2seq) models and end to end models, like text to sql. I was wondering are there any text to json deep learning models?
For example:
Text
"Switch on the computer".

JSON:
{"actions":["switch on"], "object":"computer"}

Another Example:
Text:
"Lower the heater temperature to 25 degrees and before that play music for one hour".

JSON:
 {"actions": ["lower the heater temperature","play the music"],"order":[1,0]}

Note that JSON has different or some additional elements depending on the text. This is different from regular seq2seq models. Any suggestions on which models to use? Thank you!!

You may be asking for a semantic parsing model

Thank you, it looks something close to what I've been looking for.

@tiredandboreddev did you ever find anything? Also looking for something similar.

For my purpose, I could find seq2seq models work to some extent...


text:
Pipeline to Estimate Measurement of Human Body Point Cloud
I am developing a Body Measurement extraction application, my current stage is able to extract the point clouds of human body in a standing posture, from every angles.
Now, to be able to recognize shoulders, neck point etc, my research seems to fall into following flows:
Method A:

Obtain a lot of data, with labeled landmark points (shoulder left, shoulder right, neck line).
Use PointCNN / PointNet++ to perform segmentation for each landmark.
Once the landmarks are extracted, use Open3D / Point Cloud Library convex hull to obtain the measurement along point clouds.

Method A seems straight forward, but might depends on the quality of point cloud, especially 3rd step.

Method B:

Obtain a lot of data, with labeled landmarks and also measurement of shoulder length, chest circumference etc.
We first train the network to identify landmarks,
Then from landmark, we record the distance to the next nearest point, train the network to obtain the measurement that we want.

Method C:

Obtain a lot of data, with measurement of shoulder length, chest circumference etc ONLY.
Pick a random point, and we record the distance to the next nearest point, train the network to obtain the measurement that we want.

My questions:

How much data needed for this kind of learning?
If I obtain training data from somewhere online, and later validate using my own scanned data, will that valid?
Which method makes more sense?
Which existing problem with solution is similar to my case? (Facial recognition?) That I can refer to it to solve my problem.

This is technically my first machine learning project, so please bear with me if my questions seems too silly.


text:
Is there a way to predict points on a map?
I have a data set with historical information of some events (let's say event A and event B),these events describe the discovery of land mines, the coordinates of the event and the date of the event; is there a way I can use this historical information to predict points (coordinates) where event A or B could happen i.e. where might be still land mines that haven't been found?

How much data do you have about the events?  Can you predict if they are going to happen at all?

I'm facing a similar problem. I have lat,long,time as the three main dimensions of my event points.

Leaving aside the time aspect, you could do a cluster analysis on the event coordinates. If you use an algorithm that gives you a medoid (ie centre) of the clusters, you can then look at other points, and work out how close they are to the centres of the event clusters. It might be possible from this to predict which event could happen at those coordinates (which is the closest cluster medoid), and how likely it is (distance from the medoid).
This, however, depends very much on the shape of the data. If there is no discernible structure contained in it, then this will not work. But it is definitely worth trying.

You could go to three dimension, taking time as the third.

@DuttaA My answer tries to deal with the information given in the question. Of course it might be a much more difficult issue, but at least my suggestion is something the OP can try out. I am fully aware (and have mentioned that) that it might not work if the data doesn't fulfil certain requirements.


text:
Rescaling time-series data with very spiky pattern for training data in LSTM network
I am working with some time-series hydrology data. Our goal is to forecast the time series forward, meaning predicting the data 1 month, 3 months ,6 months into the future. The data itself(image below) is characterized by mostly 0 or very small rates of flow expect for brief periods that are characterized by high flow. So I get this crazy spiky pattern where the median is around 0 or 1-2 meters^3/min, but at the same time there are periods of 5000 meters^3/minute, etc. I am not sure of the exact scale dimensions, but the picture below tells the tale.

So I was trying to figure out a good way to scale this type of spiky data. I have been using a MinMaxScaler just to start with, to rescale the values between (-1, 1). But that approach is not going to work well, especially because at the top ends of the range, the difference between 1000 m^3/min and 5000 m^3/min will be like 0.001 difference.
Does anyone have a good suggestion of how to rescale data like this for time-series analysis in an LSTM or RNN network?

What is your objective? prediction or detect the spikes?

I want to get accurate predictions of future values. Sorry was I unclear about that?

And what is your input?

@xsari3x our input is the image above, meaning it is the daily hydrological flow data. There are daily measurements.

First, if your data has a minimum of 0 and maximum of 5000, 1000 will get rescaled to .2 and 5000 will get rescaled to 1. So it's not a .001 difference as you suggest.
If you just used a regular loss function (e.g. mean squared error), I'm not sure you'd be able to achieve good predictions. In the literature this type of data might be called "sharp". There are some special loss functions such as DILATE (link) or soft-DTW (link) which are specially designed for time series like the one you show.

oh thanks so much for pointing these papers out to me. I have seen the work of Cuturi before, especially with respect to optimal transport, but not with respect to time series. So that is excellent. I will check out these alternative loss functions. Thanks again.


text:
Why does "in-place" mutation cause automatic differentiation to fail, and how to write code to avoid this problem
I work with a few different automatic differentiation frameworks, including pytorch, Jax, and Flux in Julia. Periodically I run some code and I get errors about mutations or operations occurring "in-place." These errors generally cause the program to fail. My question is, what does this error mean--in the sense of the AD algorithm and not the specific programming framework?
So I wanted to understand from a very low level, what the problem is and how to get around it. I believe most AD frameworks focus on reverse mode AD because it is more efficient for a large number of parameters.
I am not sure how current AD algorithms are implemented. Older AD systems were based on Wengert lists, while more recent implementations use source-to-source transformations. So just to elaborate on my original equation, does in-place mutation create problems for both source-to-source AD packages and Wengert list/tape based AD packages?
Here is my guess at the issue, though I cannot confirm it. It seems like the whole mutation issue has something to do with computing either the forward pass or the backward pass of the AD algorithm. So to compute the gradient, the current value of each variable needs to be known. If we change the value of a variable in the chain in-place, then we compute the wrong gradient at that variable, in that time-step. So that makes sense. But I am not sure if my understanding is correct here. So any clarification is appreciated.
After that, how does one write code that avoids this kind of problem? I suppose this question can depend on the AD framework the user is using, but does any operation need to create a new variable instead of reusing existing variables? How smart are these frameworks in handling these types of mutations.

Please, ask only one question per post. Make sure that your question is on-topic (so programming questions are off-topic): https://ai.stackexchange.com/help/on-topic.

@nbro thanks for the response. The core question is "why do in-place mutations cause AD to fail?" I was trying to provide some context to the question meaning that I wanted to understand where in the reverse mode AD algorithm the problem occurs. I will update the question text to clarify my focus.


text:
How does the NEAT speciation algorithm work?
I've been reading up on how NEAT (Neuro Evolution of Augmenting Topologies) works and I've got the main idea of it, but one thing that's been bothering me is how you split the different networks into species. I've gone through the algorithm but it doesn't make a lot of sense to me and the paper I read doesn't explain it very well either so if someone could give an explanation of what each component is and what it's doing then that would be great thanks.
The two equations are:
$\delta = \frac{c_{1}E}{N} + \frac{c_{2}D}{N} + c_{3} .\overline{W}$
$f_{i}^{'} = \frac{f_i}{\sum_{j=1}^{n}sh(\delta(i,j))}$
By the way, I can understand the greek symbols so you don't need to explain those to me
The original paper

The first equation deals with distance. Delta, or distance, is the measure of how compatible two genomes are with each other. c1, c2 and c3 are parameters you set to dictate the importance of E,  D and W. Note that if you change cc1, c2 or c3, you will most likely also have to change dt, which is the distance threshold, or the maximum distance apart 2 genomes can be before they are separated into different species. E represents the total number of excess genes. D represents the total number of disjoint genes in both genomes, W represents the total weight difference between genes that match, and finally, N represents the number of connections / genes the genome with the larger number of connections has. For example, take the following 2 genomes:
[[1,.25][2,.55],[4,.78],[6,.2]]
and
[[1,.15][3,.92],[5,.37]]

Where the 0 index represents innovation number and the 1 index represents weight value. E  would be 1, since there is 1 excess gene, gene 6. D would be 4, since connections 2 and 4 are not in genome 2, and connections 3 and 5 are not in genome 1. W would be .10, since only connection 1 is shared between the two genomes.
The second formula is a bit more complicated. From my understanding, correct me if I'm wrong, this is a formula for adjusting fitness. f′i is the adjusted fitness, which will replace the original fitness, fi. For every genome j in the entire population, yes, entire population and not just every genome in its specie, it will calculate the distance between j and i, i being the genome of fitness fi. Then it will sum up all the distance    values, and divide the original fitness fi by the total distance sum, and set f'i to that. Next,

Every species is
  assigned a potentially different number of offspring in proportion to the sum of adjusted fitnesses f`i of its member organisms.

This assigning of number of species offspring is used so that one specie can't take over the entire population, which is the whole point of speciation in the first place, so in conclusion, these two formulas are vital to the function and efficiency of the NEAT algorithm.

This all makes so much sense now, thankyou. It's been a while since I've had a look at the paper or even done anything with NEAT so I'm going to have to have a refresher to get up to speed with the rest of it . Again, thanks very much.

This is a great explaination, although it should be noted that the divisor in the second function (the summation) reduces to the number of genomes in the same species as i, so you can speciate first and find the genomes shared fitness by simply dividing it by the number of genomes in this species, this prevents any one species from growing to large and taking over a population as reproduction is based of the shared fitness of the genomes. TLDR the larger a species gets the higher the divisor in the shared fitness function will be and thus will get a lower shared fitness.

Adding to this your correct on the S(i,j) part but the sh() function which applies the distance threshold from the speciation implies that this summation is reduced to the number of genomes in the species (apologies for not expounding on this above)

This is an awesome answer, very clear. There's still something that could be improved though: when defining W with only 1 gene in common, it's hard to understand whether it's just a sum or an average difference. The process of speciation is also not very clear, beyond just the distance formula, how does it work in a population at time t, and how do you progress from t to t+1?

Even if this thread is old i want to add something to your answer, regarding to the second formula. The fitness sharing mechanism works like this:
foreach(s in species):
   foreach(i in s.individuals):
      i.fitness /= s.Count;

So in each species, the adjusted fitness of an individual is divided by the "clients" in that species. Why? This is how the formula works:

f'[i] is the adjusted/shared fitness of agent i
f[i] is the current fitness of agent i
sh(i,j) returns 1 if both i & j are compatible (considering the first formula your provided does not exceed the threshold) or 0 otherwise.
Sum(sh(i,j)) just counts how many individuals are in the same species with i, plus itself (because i can be equal to j while parsing through Sigma). So if you have a Species class with a List of clients, Sum(...) is just list.Count.

Everything is explained clearly in Stanley's paper at page 110.
In this situation, the average fitness of a species is just the sum of all clients' adjusted fitness.


text:
How to implement AI/ML to classify various types of files
I am working on a task that requires me to classify a large amount of mixed files on a backup drive (more than 10 TB with more than 32 million files) based on content. The included file types are documents, images, videos, executable, and pretty much everything in between.
I am also required to create new tags or metadata that will allow for automatic classification of new files. It'd also allow for manual input of category. For each input I give to the system, the system would learn and improve its classification.
Here is what I have come up with so far:

Documents: classify using existing categories with packages like Nltk on Python. Alternatively, first run topic modeling using LDA or NMF and then classify.
Images: use CNN. In case of unknown label, use VAE to cluster the images.
Videos and other types of files: I do not know how to approach this.

Since I am not sure about my approach, any input is greatly appreciated.

What kind of classification scheme are you looking to implement? Is it about technical metadata ("this is a video file, this is an image from a camera") or about content ("this video is of a children's party, this image is a cat with a caption")? Or something else?

How many files are there? That's probably a more important measure of the size of your task compared to space used on disk.

It is content classification (probably it is only applicable to documents, images, and videos). And there are more than 32 million files in that drive.

For video classification you could also use a CNN and classify single frames of the video. Then you have to come up with some decision function that classifies your video depending on all the single frame classifications. Using a CNN for full video classification is still a reasearch topic and really not an easy task but there are some recent papers about it regarding this. I am also assuming that you have a trained CNN on your wanted classes.

Do you have any specific goals regarding the content classification? E.g. are the classes supposed to cover specific uses of the files, are they for indexing/finding files (like user-supplied tags), do you know in advance what the classes should be, or just looking for any kind of split that would make finding content better? E.g. if you found a free classifier that identified animals in images and video, would you just use it because adding that label helps for 1% of your content, or are your goals more specific?

@Marcel_marcel1991: I see. I have no model yet, I just want to know which are the good ways to approach this before I start building anything.

@NeilSlater: It is mainly for better indexing/finding files, and to some extent, determining if a file is valuable based on tags. I already know what kind of classes there are (product lines) but any kind of split that would make finding content easier is welcome

@KhangNguyen hm okay. So in general this task you are trying to solve is very complex and a lot of work if you don't have a pretrained model or anything since these are multiple task that are all very complex on its own. Also the variational autoencoder for generating your classes automatically might also not be that easy and is still ongoing research. You should maybe first start with supervised training on a labeled dataset like ImageNet for your classification.

@Marcel_marcel1991: thanks! I will look into that.


text:
What is the state of the art in models of how the human brain performs goal-directed decision making? Can these models' principles be applied to AI?
What is the state of the art in models of how the human brain performs goal-directed decision making? Can these models’ principles and insights be applied to the field of Artificial Intelligence, e.g. to develop more robust and general AI algorithms?


text:
Issue with simple game AI
A few months ago I made a simple game that is similar to the dinosaur game in Google Chrome - you jump over obstacles, or don't jump over levitating obstacles, and jump to collect bitcoins, which can be placed at 5 different heights. I used a very lightweight NN written by NYU professor Dan Shiffman, and within a few days the game and AI were done, starting off with a population of 200 jumpers, and a genetic algorithm (fitness function (points are given for avoiding obstacles and gathering bitcoins) and mutation), and it worked as it should.
However, this was only when the bitcoins and obstacles were not near each other, which I've been struggling with ever since.
So, I made a "training ground" where I put first a levitating obstacle, then a grounded one, and then a bitcoin after it, and then a bitcoin above a fourth grounded obstacle, and no matter how many times and how long I'd leave it to train, I'd always end up with identical behavior:
The first 3 obstacles are properly avoided, the first bitcoin is collected, and then jumpers would jump too early, land before the fourth "bitcoin" obstacle, and jump again, always crashing at almost the same place (across all generations, so even if I'd restart the training, they crash at the same place in the obstacle, with a deviation of a few pixels up or down).
I added multilayer support to the NN, no improvements.
Today I replaced the NN with tensorflow.js, and I am getting identical behaviour.
My inputs are:

distance to next obstacle
altitude of next obstacle
distance to next star

(for simplicity I removed the altitude of stars from the input, and keep them at a constant altitude)
I have 2 hidden layers (5 and 6 neurons), and 1 neuron in the output, which determines if the jumper should jump.
My only idea is that a neuron that decides when to jump because of the obstacle activates alongside the neuron that decides when to jump because of the bitcoin, their weights are summed up and a decision to jump too early is made.
I'll give somewhat of a (maybe bad) analogy:
If it takes you 1 month to prepare an exam, then, if you have 2 exams on the same day, you will start preparing them 2 months earlier. That logic works in this case, but not in my AI.
In the initial "toy neural network" I even added 8 layers of 12 neurons each, which I think is overkill for this case.
In tf.js I used both sigmoid and relu activation functions.
No matter what I did, no improvement.
Hope someone has an idea where I'm going wrong.

Did you try putting only one grounded obstacle and one neuron on top of it in an enviornment? Does it have a similar behavior as described here?

Are you feeding any temporal information into your neural network? What is the input going to the neural net?

Each jumper has its own NN and the inputs are in the bullet list above.
For your first question - in a way it has similar behavior. It learns to jump over that obstacle, it can also jump to get a bitcoin on its own, but cant learn to jump over a solo obstacle. It looks like it disregards the obstacle mostly and its actions are determined mostly by the distance to the next bitcoin

The issue is likely in how you estimate wellness, how the error function is constructed and from what data, since you have used two known good pieces of software and probably known good derivatives for your activation functions.  The second most likely is in now the components of wellness is aggregated.  Summing squares is sometimes not representative of a solid aggregation strategy.
I'm a bit confused about the game for three reasons.

Stars enter the description without telling us whether they are not obstacles, are obsticles, or the only obstacles
At one point bitcoins collection is the objective and obstacles are the challenge and at another point bitcoins are obstacles themselves
Your inputs have distance but not direction (Is this 2-D game?)

Based on textual hints, I'm going to assume five simple things, and you can correct any misconceptions I list.

Collecting all bitcoins is part of the objective
Running into bitcoins mid-jump is considered a crash
There is some radial tolerance to landing in at a bitcoin location with some imprecision
There are other things to crash into
Your outputs are jump magnitude and direction

I see that when the bitcoins are not in the vicinity of other things, the net can be trained effectively to jump to them, but when in the vicinity of other things, the training converges on a behavior that repeatedly fails prior to completion.  I'm assuming that the failure location is not 100% repeatable because the genetic algorithm has a pseudo-random seed that changes.  Again, correct me if I misunderstand in my piecing together the scenario.
One should consider the possibility that the distance to non-bitcoin obstacles is part of the error function and the difference between the jump destination and the bitcoin is also part of the error function.  (This second one is why I prefer to call the error contour a wellness measure.)
If the bitcoin incentive does not seem to be the crash cause, in that, had the other obstacle been moved, the bitcoin would have been collected, then the first of the two wellness criteria needs a higher order contribution from the distance to the other obstacle.
There are two simple functional forms that come to mind, which could be tried that increase the alarm represented in back propagation when the probability of collision is heightened to more effectively train against collision.  Both involve determining the direct jump line to the nearest bit coin and the distance from that line to its nearest other obstacle; call that x.

$x^y$, where $y > 1.0$
$e^{kx}$


text:
Machine learning approach to facial recognition
First of all I'm very new to the field. Maybe my question is a bit too naive or even trivial...
I'm currently trying to understand how can I go about recognizing different faces.
Here is what I tried so far and the main issues with each approach:
1) Haar Cascade -> HOG -> SVM:
  The main issue is that the algorithm becomes very indecisive when more than four people are trained... The same occurs when we change Haar Cascade for a pre-trained CNN to detect faces...
2) dlib facial landmarks -> distance between points -> SVM or Simple Neural Network Classification:
  This is the current approach and it behaves very well when when four people are trained... When more people are trained it becomes very messy, jumping from decision to decision and never resolves to a choice.
I've read online that Triplet loss is the way to go... But I very confused as to how I'd go about implementing it... Can I use the current distance vectors found using Dlib or should I scrap everything and train my own CNN?
If I can use the distance vectors, how would I pass the data to the algorithm? Is Triplet loss a trivial neural network only with its loss function altered?
I've took the liberty to show exactly how the distance vectors are being calculated:

The green lines represent the distances being calculated.
A 33 float list is returned which is then fed to the classifier.
Here is the relevant code for the classifier (Keras):
def fit_classifier(self):
    x_train, y_train = self._get_data(self.train_data_path)
    x_test, y_test = self._get_data(self.test_data_path)
    encoding_train_y = np_utils.to_categorical(y_train)
    encoding_test_y = np_utils.to_categorical(y_test)
    model = Sequential()
    model.add(Dense(10, input_dim=33, activation='relu'))
    model.add(Dense(20, activation='relu'))
    model.add(Dense(30, activation='relu'))
    model.add(Dense(40, activation='relu'))
    model.add(Dense(30, activation='relu'))
    model.add(Dense(20, activation='relu'))
    model.add(Dense(10, activation='relu'))
    model.add(Dense(max(y_train)+1, activation='softmax'))
    model.compile(loss='mse', optimizer='adam', metrics=['accuracy'])
    model.fit(x_train, encoding_train_y, epochs=100, batch_size=10)

I think this is a more theoretical question than anything else... If someone with good experience in the field could help me out I'd be very happy!


text:
Performance measure on windowed time series data
I have time series data where I use a sliding window to detect anomalies in those windows. A sliding window is an interval of the dataset that steps one datapoint for each iteration. Datapoints are seen multiple times in this way equal to the size of the window.
In short, the algorithm works like this:

Choose window length: wl
Learn normal data with sliding window
Try to detect anomalies on test data with sliding window

I want to keep the sliding window method since it is necessary for the performance of the algorithm.
However, one anomaly occurs multiple times in the sliding window. When the anomaly appears in the sliding window for the first time it's on the 'right' side of the window.
How do we measure accuracy of anomaly detection in this case?
We could say that detecting the anomaly once in the window is enough or detect it wl times. What's best practice?


text:
How do we actually sample an action from a policy in policy gradient methods?
Recently I started to look at policy gradient methods and policies are represented as functions with features for larger problems with many states. Many articles and pseudocodes of algorithms mention sampling an action from the policy, but it is unclear to me how.
Actions are something we do in the environment, like going left, right, etc... And functions take some feature values and parameters, make calculations, and 'spit out' some number. So how do we actually map that number to a certain action, and how do we know what action to take?

In those policy gradient algorithms, we typically have:

Input features $x(s)$ for any state $s$
A fixed action set $\mathcal{A}$ of a fixed size (in reinforcement learning (RL) it is often assumed that all actions are legal in all states. In some situations, like board games, we'll filter out illegal actions manually in a postprocessing step).
A function approximator $\pi(x)$ (often a neural network), which takes as input the features $x(s)$ of some state $s$, and produces as output a vector of probabilities, where the vector has a length equal to the size $\vert \mathcal{A} \vert$ of the action space.

Those bolded parts in the last point there are critical for your question. We do not normally have a function that "spits out some number" as you described, we typically have one that "spits out" multiple numbers; one for every action. Often, these numbers can also be directly interpreted as probabilities, because they are forced to all lie in $[0, 1]$ and sum up to $1$ (this is often done using a softmax layer at the end of a neural network for example).
Once you have such a vector of "probabilities", one for every action, it is relatively straightforward to sample from that. Just give every action a probability of being selected equal to its corresponding output.
Note that in some cases, people describe their function approximator as producing "logits" rather than "probabilities" as outputs. These are real-valued outputs which do not necessarily sum up to one, typically produced by a linear layer at the end of a neural network rather than a softmax layer (see e.g. AlphaGo Zero). It is then still implicitly assumed that we convert them into numbers that can be interpreted as probabilities through the application of a softmax, before sampling from it.


text:
What is batch / batch size in neural networks?
I have some problems with understanding of the batch concept and batch size. I messed something up. First I start it consider based on convolutional neural network I heard two versions:

When the batch size is set to 50, the first network is fed with 50 images and then learned / recalculated (it doesn't make sense to me, because in this case the network learns one of 50 images).
When the batch size is set to 50, one of 50 neurons is recalculated in the learning process on a single image.

Both of these explanations seem to be wrong to me, so I assume, that I completely don't understand this. What is batch / batch size in RNN? Could you show any example?
I can tell you how I would teach a recurrent neural network. Let's say, that I would like to teach a neural network to predict the weather the next day:

I would take weather data from an expected area from the last 30,000 days.
I would assume that my prediction would be based on measurements from the last 365 days.
I would take data from day 1 to 365 - feed RNN with it and learn.
Then I would take data from day 2 to 366 => feed + learn
Then day 3 to 367 => feed + learn
And so on.

Is this 365 measurement concept a batch size?

You are confusing two concepts, batch size and window size.
Batch Size
The concept of a batch is related to your data and not the number of neurons.  A batch is just a subset of your training data.  The size of the batch affects computational speed, quality, and accuracy.  Large batch sizes will train faster than smaller ones but the model's accuracy can suffer.
There is a rule of thumb that a batch size should be a power of two (e.g. 32, 64, 128, etc.).
Generally speaking larger batch sizes do not generalize as well as smaller batch sizes.  You will need to experiment with the batch size to achieve optimal performance.  Batch size is considered a hyperparameter.
The following video, Batch Size in a Neural Network explained should help clarify things.
Window Size
Window size applies to time series and sequences when using recurrent style networks.  For your case, 365 is the window size.  You did not mentioned how far in the future you are trying to predict.  If we assume that you are predicting one day in the future your output would be the 366th measurement.
Your Application
A batch for you would be a number of training sets.  For example, if we used 32 as a batch size, you would have 32 sets of input windows and outputs.  The first two batches might look like the following:
Batch 1, size 32
1 Data from days 1 to 365 as the input, day 366 as the output
2 Data from days 2 to 366 as the input, day 367 as the output
...
32 Data from days 32 to 396 as the input, day 397 as the output

Batch 2, size 32
1 Data from days 33 to 397 as the input, day 398 as the output
2 Data from days 34 to 398 as the input, day 399 as the output
...

Thank you for your answer, now it seems to be quite clear. I read more about it, and i found out, that values of weights will be updated after every batch, based on gradients calculated after every input window. So weights are the same for every 32 windows in batch, then gradient function is calculated for each window. The network is trained and weights / biasses updated based on gradient function created from all 32 gradients calculated after every window in batch. That helps to avoid local minimums. The bigger batch is, the less probability of getting stuck in local minimum and training goes


text:
Training an AI to recognize my voice (or any voice)
I want to start a project for my artificial intelligence class about speaker recognition. Basically, I want to train my AI to detect if it's me who's speaking or somebody else. I would like some suggestions or libraries to work with.

The human voice is based on the neural muscular control of vocal apparatus made up of many parts.

Diaphragm
Vocal cords
Throat (constrictors and anti-constrictors)
Nasal cavity
Cheek
Jaw
Tongue

These coordinated muscular manipulations produce envelopes (controlling) of audio that can be characterized by periodic and transient wave forms.

Volume
Pitch
Tone (relative volume of harmonics)
Consonant transients

Voices are unique to the learning state of neural activity and anatomic attributes, which is a way of saying that vocal habits and the physical attributes of the voice supports the distinguishing of vocal identity.

Strength of vocal muscles
Connectivity of muscles to bone, tendons, and cartilage
Shape of inner surface of vocal pathways
Neural coordination of those muscles
Neural production of phonetic control to produce linguistic elements
Neural serialization of semantic structures (ideas)

The detection of distinguishing features of voices by the ear is equally complex. In a room full of people talking, the brain can learn to track a single voice.
It is important to note that performing voice recognition to determine the identity of the human source is significantly different than performing voice recognition to produce text. To produce text accurately, the NLP must determine language elements and construct a semantic network that represents the vocal content or a text from that representation to be accurate in the case of like sounding words. Fortunately, the identification of the speaker is easier in some ways than the accurate voice to text. Unfortunately, the identification of the speaker has general limitations discussed below.
The first stage of hearing in the ear is mechanical, involving the length of hairs along the cochlear surface, which is like a radio tuner that discriminates all frequencies within a range simultaneously. The software equivalent is a spectrum derived by applying a root mean square to the result of an FFT (fast Fourier transform) to provide magnitudes.
$$ m_f := \sqrt{t_f^2 + {(it_f)}^2} $$
The phase component of the FFT results ($\, \arctan(t, it) \,)$ can be discarded, since it is not correlated with neural control of voice.
The application of the FFT to speech (as with any changing audio) requires windowing over the audio samples using one of the windowing tapers, such as the Hann window or Blackman window. The input is the audio stream or file contents as a sequence of pressure samples, the audio. The output is a sequence of spectra, each containing the volume of each frequency in the vocal range, from about 30 Hertz to 15 K Hertz.
This series of spectra can be fed into the initial layer of one of the more advanced RNNs (recurrent neural networks), such as the LSTM (long short term memory) networks, its bidirectional version, the B-LSTM, or a GRU (gated recurrent network), which is touted as training equally well with less time or computing resource consumption.
The identity of the speaker is the label. The series of spectra are the features.
Using the PAC (probably approximately correct) learning framework, it may be possible to estimate, in advance of experimentation, the minimum number of words the speaker must speak to produce a particular accuracy and reliability in use of the learned parameters from the network training.
It will take some study to set up the hyper-parameters and design the layers of the network in terms of depth (number of layers) and width sequence (number of cells per layer, which may vary from layer to layer).
The use case limitation of this system is that each speaker must read some text that provides adequate training example sequences of adequate length, so that there are sufficient number of overlapping windows for the FFT to transform into spectra so that the training converges reasonably.
There is no way around the individual user training as there is with recognition of linguistic content, which can be trained across a large set of speakers to recognize content somewhat independent of the speaker. The system can be adjusted and improved to minimize the amount of speech required, but information theory constraints keep that quantity from ever approaching zero.
No network, whether artificial or biological, can learn something from nothing. Claude Shannon and John von Neumann realized decades ago that there is a kind of conservation of information, just as there is a conservation of matter and energy in space below nuclear reaction thresholds. This led to the definition of a bit and the formulation of information as a quantity of bits corresponding to a narrowing of probability that the information provides.
$$ b_i = - \log_2 {\frac {P(x|i)} {P(x)}} $$


text:
Heavy loss and inaccurate answer in pytorch
As my first AI model I have decided to make an AI model to predict multiplication of two numbers EX - [2,4] = [8]. I wrote the following code, but the loss is very high, around thousands, and it's very inaccurate. How do I make it more accurate?
import torch
import torch.nn as nn
import torch.nn.functional as F

data = torch.tensor([[2,4],[3,6],[3,3],[4,4],[100,5]],dtype=torch.float)
values = torch.tensor([[8],[18],[9],[16],[500]],dtype=torch.float)
lossfun = torch.nn.MSELoss()
model=Net()
optim = torch.optim.Adam(model.parameters(),lr=0.5)

class Net(nn.Module):
    def __init__(self):

        super(Net,self).__init__();

        self.fc1 = nn.Linear(in_features=2,out_features=3)
        self.fc2 = nn.Linear(in_features=3,out_features=6)
        self.out = nn.Linear(in_features=6,out_features=1)

    def forward(self,x):
        x = self.fc1(x)
        x = F.relu(x)
        x = self.fc2(x)
        x = F.relu(x)
        x = self.out(x)
        return x
for epoch in range(1000):

    y_pred=model.forward(data)

    loss = lossfun(y_pred,values)

    print(loss.item())

    loss.backward()

    optim.step()

Note: I am a newbie in AI and ML.

There are a few things you could do to improve this NN, but are probably worth covering in different questions.
Your main problem though is that you forgot to reset the gradient after each training batch. You need to call optim.zero_grad() in order to do this, at the start of each training loop. Otherwise, using PyTorch, the gradient values keep accumulating inside the model's training data (sometimes you want this effect if you are adding gradients from multiple sources, that's why PyTorch is not clearing them automatically for you).
In addition, a learning rate of 0.5 is very high for the Adam optimiser - it is very common to leave it at the default value because Adam is an adaptive optimiser that will adjust step sizes depending on gradients seen so far.
Here is a working version of your code:
import torch
import torch.nn as nn
import torch.nn.functional as F

class Net(nn.Module):
    def __init__(self):

        super(Net,self).__init__();

        self.fc1 = nn.Linear(in_features=2,out_features=3)
        self.fc2 = nn.Linear(in_features=3,out_features=6)
        self.out = nn.Linear(in_features=6,out_features=1)

    def forward(self,x):
        x = self.fc1(x)
        x = torch.relu(x)
        x = self.fc2(x)
        x = torch.relu(x)
        x = self.out(x)
        return x

data = torch.tensor([[2,4],[3,6],[3,3],[4,4],[100,5]],dtype=torch.float)
values = torch.tensor([[8],[18],[9],[16],[500]],dtype=torch.float)

lossfun = torch.nn.MSELoss()
model=Net()
optim = torch.optim.Adam(model.parameters(),lr=0.001)

for epoch in range(20000):
    optim.zero_grad()
    y_pred=model.forward(data)
    loss = lossfun(y_pred,values)
    if (epoch % 1000 == 0):
        print(loss.item())
    loss.backward()
    optim.step()

This version can be tweaked to quite easily reach 0 loss for your data set.
This has not in really learned how to multiply two values. The approximation to multiplying will be very weak as there is very little data. However, playing with some very basic data and a simple NN is a first step towards understanding details like this . . .


text:
How can a language model keep track of the provenance of the main knowledge/sources used to generate a given output?
One of the main criticisms against the use of ChatGPT on Stack Exchange is that it doesn't attribute the main knowledge/sources used to generate a given output. How can a language model keep track of the provenance of the main knowledge/sources used to generate a given output?

Reddit user skyebreak pointed me to a relevant paper on that topic:
Gao, Luyu, Zhuyun Dai, Panupong Pasupat, Anthony Chen, Arun Tejasvi Chaganty, Yicheng Fan, Vincent Y. Zhao et al. "Attributed text generation via post-hoc research and revision." arXiv preprint arXiv:2210.08726 (2022).

Large language models (LLMs) have shown impressive results across a variety of tasks while requiring little or no direct supervision. Further, there is mounting evidence that LLMs may have potential in information-seeking scenarios. We believe the ability of an LLM to attribute the text that it generates is likely to be crucial for both system developers and users in this setting. We propose and study Attributed QA as a key first step in the development of attributed LLMs. We develop a reproducable evaluation framework for the task, using human annotations as a gold standard and a correlated automatic metric that we show is suitable for development settings. We describe and benchmark a broad set of architectures for the task. Our contributions give some concrete answers to two key questions (How to measure attribution?, and How well do current state-of-the-art methods perform on attribution?), and give some hints as to how to address a third key question (How to build LLMs with attribution?).