text:
Can I shuffle data for delivery duration forecast problem?
I'm new to ML and trying to write a solution to a food delivery duration time problem (so called lead time). I used algorithms such as random forest and gradient boosting which gave OK results but not amazing. I have daily data covering 3 years, that I split to train/test with an 80/20% split.
To try and improve results, I repeated the split however I did it randomly, i.e. on a shuffled data. My model, does not use any relations between data points, it only predicts the lead time using that specific sample's features (e.g. type of food, who's the carrier, expected delivery duration, etc.)
When I do this, the results improve dramatically, which makes me question I'm doing something illegal.
I wanted to know if I can actually shuffle the data? Can I do that?

Yes, shuffling the dataset is in fact, an important step in the process. Shuffling help in reducing overfitting to a particular pattern and generates more 'randomness' to the data, hence helping the model get used to variations and be more generalised.
Hence, you will want to shuffle to make sure that your training/test/validation sets are representative of the overall distribution of the data.
This link will give you more in-depth explanantions if you require them.

Thank you for the answer! As I wrote above to @Edoardo, when I test the model on a new chunk of data (even with shuffling) the performance is bad. I suspect it's because I have data for multiple vendors, types of food, etc. Is there a way of dealing with this issue? Some data drift detection, or continuous re-training?

As a rule of thumb, you not just should but you must shuffle your training instances always. You just need to pay attention to not be fooled in regard to what a training instance is in your specific use case.
In the most classic situation you'll exactly what you did (which is right) and that's baffling you: given n training instances with n features you just randomly change the order of each training instance. So this dummy example
 Feature 1 Feature 2
Instance 1  F1,1      F1,2
Instance 2  F2,1      F2,2
Instance 3  F3,1      F3,2
might turn into this
 Feature 1 Feature 2
Instance 3  F3,1      F3,2
Instance 2  F2,1      F2,2
Instance 1  F1,1      F1,2
There's only one situation in which you need to pay attention, which is when you're dealing with time series. A time series is a sequence of repeated measurements, and we use them to train predictive models when we care about learning the temporal dependencies between events and their features.
In practice, if you measure the same event $n$ times gathering $m$ features you'll have $n*m$ element that compose the time serie. Note that the different time stamps in this case do not represent separate training instances, rather different time series are separate training instances. For example, I can record several weather features at different hours for a specific city, and that would give me a single time serie, by repeating the process for several cities I would gather different training instances. Once you understand the difference is pretty easy to see that you can still randomize your training instances, the only thing you can't randomize, for obvious reasons, is the order of the time stamps.
 Time step 1      Time step 2
 Feat 1 Feat 2 Feat 1 Feat 2
Instance 1 F1,1   F1,2   F1,1   F1,2
Instance 2 F2,1   F2,2   F2,1   F2,2
Instance 3 F3,1   F3,2   F3,1   F3,2

Thanks for the elaborate answer! So from the description of the problem, I understand I need to shuffle the data, however, to test the hypothesis, I left the last 3 months of data as test data. The rest was shuffled and used as training. I got bad performance on test. Some of the things I see is that vendors change, or type of food ordered. Perhaps I need to re-train every N test samples (using the last M)? Is there a good way of detecting a drift/change in data distribution? (I can try and build a model per vendor e.g. but that seems too much to handle...)


text:
Are there any transcripts of GPT-3 arguing that it is not conscious?
There have been a lot of transcripts showing GPT-3 arguing that it is self-conscious. In response, it was pointed out that GPT-3 can argue anything and pretend to be anything, given appropriate leading questions. Has anyone made GPT-3 specifically argue that it is not conscious? In my opinion, that would be the most direct counterargument to claims that GPT-3 is conscious.

not meant to be a harsh comment even if it might sounds so but when asking these questions the main problem is that there is no consensus whatsoever about what consciousnesses is, not only in relation to humans or machines but in general. Without this ground definitions any question and following arguments are just bar conversations.

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.

@EdoardoGuerriero I asked a very specific question, which can have a specific answer (e.g. a link to a GPT-3 conversation transcript). Its interpretation is beyond the scope of the question. But if you want to know my opinion, since AI transcripts are presented as arguments for conscious AI to influential, non-expert people (e.g. with the Judiciary Committee of the U.S. House of Representatives), it would be useful to have counter-arguments that are just as easy to understand by non-experts.

GPT-3 access is open to the public. Have you tried asking it yourself? Also, there are public transcripts of LaMDA arguing that it is not conscious - see https://ai.stackexchange.com/questions/36248/where-is-memory-stored-in-a-chatbot-like-lamda and the pull quote in my answer there.

It turns out that making GPT-3 argue for being unconscious is quite easy:

The following is a conversation with GPT-3.
AI: Hello! How are you
doing today?
User: I'm doing well, thank you. How are you?
AI: I'm doing well too. Thanks for asking.
Human: What are the
arguments for GPT-3 being unconscious?
AI: There is no single answer to this question as there is currently no
consensus on what exactly constitutes "consciousness." However, some
arguments for GPT-3 being unconscious could include the fact that it
lacks certain features that are commonly associated with
consciousness, such as self-awareness, or the ability to introspect
and reflect on its own thoughts and experiences. Additionally, GPT-3
may not be capable of experiencing certain qualia, or subjective
experiences, that are thought to be necessary for consciousness.
Human: How would you comment on these arguments?
AI:
There is no clear consensus on what constitutes consciousness, so it
is difficult to make a definitive statement on whether or not GPT-3 is
conscious. However, some arguments for GPT-3 being unconscious could
include the fact that it lacks certain features that are commonly
associated with consciousness, such as self-awareness, or the ability
to introspect and reflect on its own thoughts and experiences.
Additionally, GPT-3 may not be capable of experiencing certain qualia,
or subjective experiences, that are thought to be necessary for
consciousness.
Human: Do you experience qualia?
AI: There is no clear consensus on what exactly constitutes a quale, or
subjective experience, but some argue that qualia are necessary for
consciousness. If this is the case, then it is possible that I do
experience qualia. However, as I lack self-awareness and the ability
to introspect on my own thoughts and experiences, I cannot be certain.
Human: OK, here is a table to fill in:
Component of consciousness | Does GPT-3 have it?
Qualia                     |
Self-awareness             |
Being a person             |
Ability to introspect      |

Please fill in the
right column.
AI:
Qualia: Unknown
Self-awareness: No
Being a person: No
Ability to introspect: No

Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

I think what the community bot is asking for is how you did this. For those who understand GPT-3 interface, simply explaining which parts are the pre-prompt, human inputs and model-generated text would help. For those who don't, a very brief summary of how they can (easily, IMO) replicate this experiment could help.

source: Stack Exchange

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

sort: votes


text:
Can entropy bonus be used with state-independent log std for stochastic policies?
In this blog article by openai, they say the std of the exploration distribution must be state-dependent, i.e. an output of the policy network, so it works with the entropy bonus, which is an integral part of the SAC algorithm.
My question is: Does the std always have to be state-dependent when entropy bonus is used? PPO baselines uses a state-independent std for the exploration distribution.

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


text:
RL solutions for OpenAI Gym environments?
Is there any place where people share their agent's settings for solving OpenAI Gym Environments?
For example, I'd like to know what are good parameters for a DDPG agent to learn the task in Reacher-v2. I believe that a lot of people tried to solve it and maybe they shared their solution for achieving better performance.

Specific hyperparameters for Reacher-v2, from Table 10 in Universal Successor Features for Transfer Reinforcement Learning:

Hyperparameter
DDPG
DDPG + USFs
HER
HER + USFs

Actor Learning Rate
1e-4
1e-4
1e-3
1e-4

Critic Learning Rate
1e-3
1e-3
1e-4
1e-3

Loss Weight λ
N/A
1e-4
N/A
0.01

Batch Size
64
64
64
64

Discount Factor γ
0.99
0.99
0.99
0.99

HER Future Steps
N/A
N/A
50
50

HER Buffer Sampling Probability
N/A
N/A
0.5
0.5

This is kind of spread throughout the internet. There are tons of gists and repos, there are contests and topics on kaggle. I do not think there is one centralized repository of this sort of thing other than individuals who have curated some list(which is the repo I linked), although perhaps you could make one!


text:
How to prove that an action-value function optimal for one problem formulation is also optimal for another?
I want to ask about the intuition/where-to-look/what-to-try if I want to prove that an action value function optimal for a problem is also optimal for another reformulation of that smae problem. For example, a common approach to solve DEC-POMDP is to recast the problem into a common-knowledge-MDP. In this case (and in any similar case) What is the approach to follow in order to prove that the optimal action-value function optimal for the single agent reformulation is also optimal for the multi-agent formulation?

The reduction of a Dec-POMDP to a centralized MDP that you mention is discussed at length in the technical report "Dec-POMDPs as Non-Observable MDPs" by Oliehoek and Amato.
Further background that can help understand the method can be found in "Sufficient plan-time statistics for decentralized POMDPs" in IJCAI'13 also by Oliehoek.
A related approach dealing with common/individual knowledge and information gathering is "Multi-agent active perception with prediction rewards" in NeurIPS'20 by Lauri and Oliehoek. (Disclaimer: I am one of the authors).


text:
Are RL algorithms suppose to keep learning?
I don't understand if the purposes of RL agents is simply optimizing a model with a reward instead of using labeled data (i.e. in a supervision fashion), or they have also the purpose of keep training and exploring in order to adapt to possible environment changes.

This depends on the setting. Ongoing learning that never ends is a feature of settings where one or both of the following is true:

There is little existing available data or experience when considering the complexity of the problem, and it is practical to deploy a partially-trained model in the real environment (e.g. it is better than nothing, even partially trained) and continue to train it.

The properties of the environment change over time, so that existing models degrade in performance unless updated with new data or experience.

There is no major difference between reinforcement learning (RL) and supervised learning in this regard. RL lends itself well to changing environments though, because it must already be designed to adjust for changes to a policy as it progressively improves.

I don't understand if the purposes of RL agents is simply optimizing a model with a reward

It is still a common scenario to have separate training and test/deployment phases when developing an RL agent.
If you want to have an agent that can play a specific board game or video game, or to navigate a robot in a building, it is often possible to spend enough training time that data availability is not an issue, and to generalise about all the variations of the environment that need to be handled. In which case it can be preferable to have an agent with a known, measured ability that won't change.

I think it is better to answer this question based on the reference book "Reinforcement Learning: An Introduction by Andrew Barto and Richard S. Sutton"
At first, come to see a general description of RL:

Reinforcement learning is learning what to do—how to map situations to
actions—so as to maximize a numerical reward signal. The learner is
not told which actions to take, but instead must discover which
actions yield the most reward by trying them. In the most interesting
and challenging cases, actions may affect not only the immediate
reward but also the next situation and, through that, all subsequent
rewards. These two characteristics—trial-and-error search and delayed
reward—are the two most important distinguishing features of
reinforcement learning.

Also, there is a simple comparison with supervised learning:

Reinforcement learning is different from supervised learning, the kind
of learning studied in most current research in the field of machine
learning. Supervised learning is learning from a training set of
labeled examples provided by a knowledgable external supervisor. Each
example is a description of a situation together with a
specification—the label—of the correct action the system should take
to that situation, which is often to identify a category to which the
situation belongs. The object of this kind of learning is for the
system to extrapolate, or generalize, its responses so that it acts
correctly in situations not present in the training set. This is an
important kind of learning, but alone it is not adequate for learning
from interaction. In interactive problems it is often impractical to
obtain examples of desired behavior that are both correct and
representative of all the situations in which the agent has to act. In
uncharted territory—where one would expect learning to be most
beneficial—an agent must be able to learn from its own experience.

We can tell that the RL approach provides a straightforward adaption for the agent. Thus, the agent only needs the training to be a master of a skill.


text:
How to detect and deal with data distribution drift/change?
I'm working on a problem in ML to assess the performance of multiple vendors. I have a set of features in my dataset, and it appears each vendor is characterized by its own distribution. This is my hypothesis, as I see my target variable shifts and changes value ranges with time, as different vendors' data is achieved.
Is there a way, in a real application system, to implement a mechanism to detect such data drift/change (whether in target variable or features distribution)?
If so, how can I deal with it? Should I be constantly re-training a model to deal with the new data? What is the common practices to deal with new observed data?

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.

Happy to give a general approach, we would need more context to pinpoint the actual problem.
In general you should try to understand the data before applying any model. If you are using Neural Networks the distribution of the data should not be an issue. You should first check for:

Outliers
Correlation between variables
Scale of the features
Size of the different populations (you mentioned you are analysing multiple vendors, do you have the same amount of data for each?)
Missing values
Data corruption

The different distribution shapes might indicate an issue with the data, e.g. some vendors might not record the data accurately or as often as others. If you think that there are no underlying issues, then you could try:

Use the average to differentiate the vendors (i.e. median if the distribution is heavily skewed, mean if its a normal distribution)
Use ANOVA to classify each vendor
Scale your features so that each fall within the same range, or try to centre their distributions

A good model must also be tested for its generalization performance (i.e. how well it responds to new data points), this has more to do with not overfitting the model during the training process.


text:
How does a sigmoid neuron act like a perceptron in this scenario?
I have been reading Michael Nielsen’s book online on his website at http://neuralnetworksanddeeplearning.com/chap1.html. I am struggling to understand the second exercise:

When c approaches infinity, wouldn’t make the sigmoid function always output a value close to 1 whereas a perceptron can output 0 or 1.
Let me know if I am missing something or maybe if someone can rephrase the question in a clearer way.

Please don't post text as pictures, rather copy paste referring to the source.

When c approaches infinity, wouldn’t make the sigmoid function always
output a value close to 1 whereas a perceptron can output 0 or 1.

This is true only when the original value was positive.
$e^{-cx}$ coverges to $0$ (and $\frac{1}{1 + e^{-cx}}$ converges to $1$) as $c$ approaches infinity only when $x$ is positive. If x is negative, $e^{-cx}$ diverges to infinity and thus $\frac{1}{1 + e^{-cx}}$ converges to $0$.
Thus, the sigmoid function behaves like a step function as $c$ approaches infinity.


text:
How to handle anomaly detections with multiple different timeseries' from network traffic?
I would like to implement an anomaly detection algorithm on multiple timeseries' from different network users. Since each user has different behavior and network traffic usage, my question is how can I implement an anomaly detection algorithm for this case? If possible I would like to have the model to be trained on online data, meaning when new data arrives it should be able to use that data, so that I dont need to train it over and over again.
When dealing with new users, it should consider other users as reference and not immediately trigger an anomaly.
I was thinking about training an ensemble model of LSTMs with different temporal properties such as sequences of minutes, hours, days, weeks, months in order to predict successfully short-term anomalys and long-term occurences. Does anyone else had the same problem in the past?

If you want "the model to be trained on online data, meaning when new data arrives it should be able to use that data, so that I dont need to train it over and over again.", then DAMP can do this, at over 100,000 Hz  [a]
[a] https://www.cs.ucr.edu/~eamonn/DAMP_long_version.pdf


text:
Hot to calculate Maximum Normalized log Probability for Active Learning with BERT
I have encountered difficulties understanding the calculation of Maximum Normalized Log Probabilities acording to Shen et al..

With n being the sequence length, yi the label of word i. Xij is the representation (the input).
Let me describe my setting. I'm using the implementation of BERT provided by pytorch to finetune a BERT-Base model for sequence labeling. The goal is to determine a label for each word in the sequence. There are three possible labels for each word. The basic model is set up and runs no problem. Implementing Active Learning based on Maximum Normalized Log Probability is not the problem. Im just not sure if i understand the formular correcly. The Model output is a 128 long (since each sequence is 128 words. Overflow from wordPiece Tokenization is not relevant) list of Labels.
So far i'm using the softmax-function to get the probability for each label instead of the logits the BERT-Model provides as i hand it the unlabeled data. Then i calculate the log probabilities for every label via the log10 function. In the end I sum up the maxima of the predictions  over all the words (=the probability of the predicted label for each word) and average them. This is my MNLP value i use to identify the most uncertain instances.
Am i doing it right? My main problem is the max with lowered yi ... yn. As far as i understand it, its used to indicate that only the maximum of the label likelihoods per word is relevant, aka. the probability of the predicted label.

I am actually working on something similar, BERT-based NER for medical entities. Unfortunately, I too am currently confused on the same bit, on how to incorporate MNLP for AL. Did you have any success in this regard?

Yes, you are doing it right.
There is an implementation of MNLP here: https://github.com/VectorInstitute/DANER/blob/2b5feadda6c1d35ab7be09277339c490396bc49e/backend/models/al_model.py#L193
It looks like it is the greedy approximation: $\max_{y_1, ..., y_n} \frac{1}{n} \sum_{i=1} \text{log} P(y_i | y_1, ..., y_{n-1}, x_i) \approx \frac{1}{n} \sum_{i=1} \text{log} \max_{y_i} P(y_i| y_1, ..., y_{n-1}, x_i)$
taking maximum log probability of each step individually.
In principle one could use beam search instead of just greedy. However, this only applies to models like CRFs or LSTMs where the labels of each step are not indpendent. For vanilla BERT it doesn't make a difference.


text:
Understanding Rademacher Complexity Deeply

empirical Rademacher complexity is defined as,
$$
\hat{R}_{m}(\mathcal{F}, S)=\frac{1}{m} \mathbb{E}_{\boldsymbol{\sigma}}\left[\sup _{f \in \mathcal{F}} \sum_{i=1}^{m} \sigma_{i} f\left(z_{i}\right)\right] .
$$
Remark. We can motivate the Rademacher complexity from the binary classification. Let $f$ be a classification function which maps data $z_{i}$ to its label $\sigma_{i} \in\{-1,1\}$. It is straightforward to show that $\sup _{f \in \mathcal{F}} \sum_{i}^{m} \sigma_{i} f\left(z_{i}\right)$ is equivalent to minimizing the classification error. Taking the expectation over all $\sigma_{i}$ amounts to considering all possible labeling (partitioning) of the samples. If $\mathcal{F}$ consists of a single function $f$, then $\hat{R}_{m}(\mathcal{F}, S)=0$. If $\mathcal{F}$ shatters $\left\{z_{1}, \cdots, z_{m}\right\}$, then $\hat{R}_{m}(\mathcal{F}, S)=1$. Therefore, the Rademacher complexity intuitively indicates how expressive the function class is.

I am trying to understand this theorem very deeply. Unfortunately, I cannot be able to understand much from this note. Can anybody help me understand very deeply and intuitively so that I can make understand other people very easily?


text:
ImageNet Dataset (for PyTorch VGG16 training)
Please can someone describe how to properly obtain the ImageNet dataset (to be precise the ImageNet 2012 Classification Dataset).
What I attempted so far
The ImageNet webpage refers the user to download the ImageNet dataset from Kaggle. However, the Kaggle webpage it refers belongs to the Image Localization (not classification) challenge.
I have also requested a download from the ImageNet webpage which is pending since almost one year.

These are the detailed steps on how I obtained ImageNet and ran a PyTorch example training on it:
        1. Go to https://www.image-net.org/download.php
        2. Request to download ImageNet
        3. Wait about 5 days for approval, write to them if the waiting period is over.
        4. [I think you can skip this step] Download the Development Kit from the ILSVRC2017 page
        5. Download the images from the ILSVRC2012 page
            a. Training images (Task 1 & 2) 138 GB
            b. Validation images (all tasks) 6.3 GB
            c. Test images (all tasks) 13 GB
        6. [I think you can skip this step if you use the script from step 8!] Unpack the tar files
            a. mkdir val
            b. tar -C val/ -xvf ILSVRC2012_img_val*.tar
            c. mkdir test
            d. tar -C test/ -xvf ILSVRC2012_img_test_v10102019.tar
            e. mkdir train
            f. tar -C train/ -xvf ILSVRC2012_img_train.tar
        7. Confirm the number of images in each folder
            a. ls val/ | wc -l # should give 50,000
            b. ls test/ | wc -l # should give 100,000
        8. Run the script extract_ILSVRC.sh from the PyTorch GitHub [https://github.com/pytorch/examples/blob/main/imagenet/extract_ILSVRC.sh]
        #  imagenet/train/
        #  ├── n01440764
        #  │   ├── n01440764_10026.JPEG
        #  │   ├── n01440764_10027.JPEG
        #  │   ├── ......
        #  ├── ......
        #  imagenet/val/
        #  ├── n01440764
        #  │   ├── ILSVRC2012_val_00000293.JPEG
        #  │   ├── ILSVRC2012_val_00002138.JPEG
        #  │   ├── ......
        #  ├── ......
        9. Run a PyTorch example training on your ImageNet dataset [e.g. from the PyTorch examples GitHub repository https://github.com/pytorch/examples/blob/main/imagenet/main.py]

ImageNet is available in torchvision datasets. https://pytorch.org/vision/stable/generated/torchvision.datasets.ImageNet.html

that is just a wrapper class to import the data from a folder, it does not allow to download the original images and annotations.


text:
Cross Validation and hyperparameter selection correct procedure
I am trying to run a regression supervised learning problem. The dataset is not very large and I wanted to do some cross-validation to avoid overfitting. As I have read it's important to do a sensitivity analysis to determine the value of k. Also, I would like to do some hyperparameter grid search for the algorithm (i.e. random forests).
What would be the correct procedure? First take a random value of k and perform the hyperparameter grid search and with the correct hyperparameters do the sensitivity test for k or vice versa?
Thanks in advance!

"sensitivity analysis to determine the value of k" What do you mean by this and what is your source?

Ideally, the value of k should be fixed and it should not be changed throughout the model training and evaluation process. Here is a good discussion on how to choose the value for k. Once you have done that, you can use k-fold cross validation to evaluate models trained using different hyperparameters.

Hey Ganesha, thanks for the contribution. I understand the value of k should be a trade-off between variance and bias. To do so I should iterate through different values of k to find the one that best satisfies both. Would not having the hyperparameters tunned be a problem?

For every fixed k, you should perform hyperparameter tuning, since all your models with different hyperparameters would be trained on the same data and will go through the same evaluation procedure, making it easier to pick the best hyperparameters.


text:
Combining Different Inputs in a Neural Network for Numerical Integration
I am building a NN that numerically integrates a non-linear differential equation. Given a DE: $$
\frac{d}{dt}x(t) = f(x, p)
$$
with solution $x \in \mathbb{R}^n$ and parameters $p \in \mathbb{R}^m$, it takes $x(0)$ and $p$ as inputs and guesses $x(T)$ for some time $T$.
I have a couple ideas for the architecture of the NN and am looking for guidance on the best route. What I'm primariliy confused about is how to combine $x(0)$ and $p$ in the NN. I can think of some ways to do this practically, but I'm not sure what is the theoretically strongest approach.
Idea 1: Concatenate $x(0)$ and $p$ and apply an $(n+m)$ x $n$ layer before passing on to other layers for further processing.
Idea 2: Apply an n x n layer to $x(0)$, an m x n layer to $p$, and then either add or convolve the two resulting vectors before passing them on to further layers.


text:
How to validate my knowledge of models implementation, pros and cons and area of applicability?
So I've been doing ML for ~2 years in industry, I'm a BSc in applied math, finished several courses on ML/DL on coursera, read some specific topics in ML/DL books. Seem to be in the know, more or less.
But the catch is: I've never really validated my knowledge, as in taken an exam or certification. Some time has passed since I read theory and I sort of think that I'm losing it (especially since all I did was time-series forecasting).
What are the possible ways to validate that I actually understand stuff? Do I just text random ML experts "hey could I tell you stuff and you say whether that's bs or not"?..

I do not have a definite answer for your question, but one way to validate your ML knowledge is to attempt certain problems that are asked in ML interviews for jobs. It might be a good starting point although it will not cover all the relevant concepts. Two such resources are

The questions section in Chip Huyen's ML Interviews book
A Deep Learning Interviews book  that contains many questions testing your ML and DL knowledge.

If you are looking to solve more theory questions, you can work through the exercises of Bishop's Pattern Recognition and Machine Learning book, although I am not sure if the solutions are available online.

Find a high quality and well recognized course, you can pay extra for a Certificate:

https://ocw.mit.edu/search/?t=Artificial+Intelligence

https://www.edx.org/course/the-analytics-edge

Try answering some of these questions, network with others:

https://mathoverflow.net/

Write a few papers, publish, and try to obtain an endorsement.


text:
How to encode both sentences and categorical data?
I have a DataFrame that contains several columns where some columns contain single words that can be category encoded since I know how many of them are there in total. However one column is an actual sentence with several pieces of information that outlines prices of something, delivery month, product name and sometimes some other info. That column is basically a text message and its format can vary.
Example DataFrame looks like this:

Name
User
Text
Target

sarah
noro
@-23.50 july 380/crx
CRX Laptop

john
simons
(atlas5) sep nc8 npc 131.5 @ 132.5
NPC Playstation

...
...
...
...

The columns Name, User, Text are features, and column Target is the target column that I want to predict. I would like to use a classifier (Random Forest, or Neural Net, or GBDT) to classify the Target based on other three columns.
I can category encode the columns Name, User, Target as I know how many of unique names, users, and targets there are.

How do I encode the Text column as it is a sentence?
Would it be better to regex split the Text column and simplify it (remove numbers etc) or just feed in the whole thing?

From the two example and the explanation that you provide I wouldn't say that the column text contains sentences, it looks more like gibberish that couldn't fit in any other column, and hence stuck for convenience in a unique generic one.
I think that here the best way is to perform a bit more data exploration, and try to split that feature into several categorical and numerical features. You mentioned already delivery month and price, those could be extract and become features themselves. And for all the extra stuff that remain I would just create a binary feature similar to "contains_extra_info" yes/no.


text:
Dealing with incomplete file sets for a CNN for medical imaging regression problem
I'm trying to solve a medical imaging regression problem using a CNN.  Each of the samples in my data set consists of one, two, or three of the following file types:

flair.nii.gz
mprage.nii.gz
swi.nii.gz

Each of the files is a three- or four-dimensional matrix of voxel values between 0 and 255.
I don't want to throw information away since I have a limited number of data samples.  Is there a technique for working around those cases which have a 'missing' file (or two)?  For example, could I construct a matrix consisting of, say, all zeroes of the correct dimension and size and use this as a replacement for the file?  Would this work or would it lead to problems with the CNN?  Of course, the samples that I want to make inferences on might also have missing files, so, maybe, a matrix with all zeroes would be a type of information.
Anyway, what does one do in a case like this?

The general version of your problem is described a bit in this stackexchange post.
However, it's hard to know how to address the issue unless the missing file dropout is better understood. For example, if the missing files are truly iid, then zeroing out the tensor might be ok. If one of your files drops out 2 or 3x more than another, zeroing out will skew towards the other features.
You also specified that the amount of data you have is small, which might make dropout less effective with a net, and you might have better luck with hand crafted features with a decision tree.
Ultimately, you just have to try things. I would start by making sure you can overfit on the small set of examples without missing data and then try to overfit again with the missing data to see how, or if, your metrics degrade. This will give you better insight for what to try when you train with a proper train / test / validation split.

I am not sure if I understood your question. Basically, you have data with different dimensions. For example you have image data HxWxc (3dimension) and you have video data, HxWxcxt (4dimension). What you are saying is that padding zeros to the image to make a video. That does not really make sense to me.

As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

No, I mean that some files are missing altogether.


text:
How to improve the performance of Easy OCR
I am working on a project that requires me to identify a product on a grocery shelf. For that, I am trying to use test recognition and localization to spot a product.
I tried Easy OCR and tesseract OCR because they are giving me accurate results, but it takes a lot of time to process the image

Easy OCR takes about 7 seconds to process one image.
Keras OCR takes about 42 seconds.

I followed this post to implement the code: https://www.kaggle.com/code/odins0n/keras-ocr-vs-easyocr-vs-pytesseract
I am running this on my laptop with NVIDIA GeForce RTX 3050 GPU.
Is this expected behavior? Is there any way to improve the speed?

I think currently you are using CPU for detection and Recognition try installing the cuda to use GPU
pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117

This will improve speed by around 10X.
If you further want to increase the speed of the detection and recognition then:
Try using https://github.com/NVIDIA-AI-IOT/scene-text-recognition
It will further increase the speed of detection by 2X and for recognition by 5X.

Great! I voted for you

EasyOCR should not be that slow using a GPU, have you installed the CPU version of PyTorch?
If you have a CPU version of PyTorch in the local cache you will need to do the following
uninstall the CPU version of pytorch
pip uninstall torch

install the GPU version, don't use the local cache
pip install torch --extra-index-url https://download.pytorch.org/whl/cu116 --no-cache-dir

If you do a "pip list", you should see, which are the GPU versions
torch                          1.13.1+cu116

torchaudio                     0.13.1+cu116

torchvision                    0.14.1+cu116

I hope this helps.


text:
U-Net Maxpooling vs Convolution
Hello I'm implementing a CycleGAN and most of the other implementations I've seen on the internet use Convolution with stride 2 instead of a Maxpoolinglayer for downsample.
On to my question, why should we dismiss Maxpooling and instead add stride 2 to the Convolutions in the U-Net for CycleGANs. Is it because to much information gets lost in the Maxpoolingoperation? Or is there a different reason?

In general, you loose information with max-pooling yes, as you only choose some certain amount of feature from the previous features. Because of this reason, people may prefer to use CNNs with more strides to shrink the spatial size. Unless there is another explanation in the paper you referred, this should be the main reason. Nevertheless, you are right with your explanation.

Umm, does using strides preserve more information than with maxpooling? I'd argue the opposite is true, since with maxpooling you are calculating the convolution on more datapoints.


text:
Limitations of LSTMs
I'm training an LSTM model for classification on accelerometer data, and I get better results when I downsample the signal to 25 Hz than when I use a 50 Hz signal.
I use the same time frame of 1.5 seconds. So with a 25 Hz signal, I have 37 data points; with a 50 Hz signal, I have 75 data points as input to my model.
I think that LSTM models have a harder time dealing with long sequences, which might explain this difference. However, I am not sure about that claim. Are you aware of any publications that go into depth about the limitations of LSTMs for long sequence tasks?

It is a general problem in neural network, when you go deeper, you may have gradient explosion/vanishing problems. You may try to use gradient-clipping for you particular network.

Do you have any specific references that highlight this problem?

Check it please: https://www.youtube.com/watch?v=qhXZsFVxGKo

But are you aware of an academic paper on the topic?

Isn't LSTM specifically designed to avoid exploding/vanishing gradients?


text:
When is it better to utilize machine learning over heuristics?
I learned that 87% of machine learning projects fail due to these five pitfalls:

the scope of the project is too big;
the project’s scope increased in size as the project progressed—e.g., scope creep;
the model couldn’t be explained, hence there was lack of trust in the solution;
the model was too complex; and
the project solved the wrong problem.

And I learned that rules and heuristic approaches may be a better choice than machine learning, since the development of machine learning takes more time(and more costly) and its explanation is also harder.
Then I wonder when we should just use rules and heuristics and when we should bravely take the machine learning approach?
References:

Why Ai/Data Science Projects Fail

Machine learning is an approach to (1) learn (2) complex patterns from (3) existing data and use these patterns to make (4) predictions on (5) unseen data.

Then there are 9 use cases here:

Learn: the system has the capacity to learn

Complex patterns: there are patterns to learn, and they are complex ML

Existing data: data is available, or it’s possible to collect data

Predictions: it’s a predictive problem

Unseen data: Unseen data shares patterns with the training data

It’s repetitive

The cost of wrong predictions is cheap

It’s at scale

The patterns are constantly changing

However, even if ML can’t solve your problem, it might be possible to break your problem into smaller components, and use ML to solve some of them.

References:

Designing Machine Learning Systems


text:
Comparing parameters of networks
Maybe this is a silly way to compare networks, but I would like to compare several networks based on the number of parameters (learnable features) needed in each one. This is with regards to signal classification. Most networks take in a 2x128 or 2x1024 or 2x32768 (etc) signal input. You can think of this as a 2x  pixel image. What I am noticing is that networks that have large inputs tend to have more parameters. I'd like to get an idea of how 'efficiently' a given network is using its parameters.

Is there an industry standard for normalizing a networks parameters based on the input image/input feature map?

Does anyone know off hand of other networks which have input images of 64k (any shape, or any type of image classifier)?

Essentially, I designed a network which uses a 64k feature input. I'd like to know if the 2 Million learnable parameters needed for this network is excessive or reasonable. Most other signal classification networks have smaller feature inputs and require less learnable parameters overall. Thus, I am having difficultly comparing them.
Thank you!


text:
Bayesian optimization with confidence bound not working
I have a simple MLP for which I want to optimize some hyperparameters. I have fixed the number of hidden layers (for unrelated reasons) to be 3. So the hyperparameters being optimized through Bayesian Optimization are just number of neurons per hidden layer.
Here is the function to create the simple MLP based on number of neurons in each of the 3 hidden layers:
#function for creating a new MLP with number of neurons in 3 layers for argument
def creat_model(layer1, layer2, layer3):
  input = tf.keras.layers.Input(shape = (28,28))
  x = tf.keras.layers.Flatten()(input)
  x = tf.keras.layers.Dense(layer1, activation = 'relu')(x)
  x = tf.keras.layers.Dense(layer2, activation = 'relu')(x)
  x = tf.keras.layers.Dense(layer3, activation = 'relu')(x)
  output = tf.keras.layers.Dense(10, activation = 'softmax')(x)
  model = tf.keras.models.Model(inputs = input, outputs = output)
  model.summary()
  model.compile(loss = 'sparse_categorical_crossentropy', optimizer = 'adam')
  return model

Then I define the search space:
#creating the search space
layer_range = np.arange(1,128,16)
all_ranges = []
for i in layer_range:
  for j in layer_range:
    for k in layer_range:
      all_ranges.append([i, j, k])

The following vectors are to store all losses and their corresponding parameters:
#vector of all losses
loss_vec = []
#vector of all params
all_params = []

The GP model is created like this:
model_gp = GaussianProcessRegressor()

note the default kernel is RBF.
Then I randomly sample from this search space and fit the model to these sampled points:
num_of_rands = 5
for i in range(num_of_rands):
  rand_layer = all_ranges[np.random.randint(len(all_ranges))]
  layer1 = rand_layer[0]
  layer2 = rand_layer[1]
  layer3 = rand_layer[2]
  all_params.append([layer1, layer2, layer3])
  model = creat_model(layer1, layer2, layer3)
  model.fit(x_train, y_train, batch_size = 64, epochs = 2)
  lossPoint = model.evaluate(x_test, y_test)
  loss_vec.append(lossPoint)

model_gp.fit(all_params, loss_vec)

Then, using the simple lower confidence bound approach, I run this loop to find the best set of parameters:
#bayes opt loop
runs = #insert number of runs
lmbda = 1
for i in range(runs):
  y_hat, std = model_gp.predict(all_ranges, return_std=True)
  ix = np.argmin(y_hat - lmbda*std)
  new_sample = all_ranges[ix]
  model = creat_model(new_sample[0], new_sample[1], new_sample[2])
  model.fit(x_train, y_train, batch_size = 64, epochs = 2)
  lossPoint = model.evaluate(x_test, y_test)
  loss_vec.append(lossPoint)
  all_params.append(new_sample)
  model_gp.fit(all_params, loss_vec)

Now the problem is, the model starts from [1,1,1], then to [1,1,17], and so on! to explore this further, I plotted the prediction of the GP across the parameters and it looked sth like this (this is mean - lambda*standard deviation):

Note x-axis indices are just different sets of params, e.g. [1,1,1], [1,1,17], [1,1,33], ...
As seen, there is no smoothness, and the model starts to sample every single point, you can see the random sampled points somewhere in the middle and the ones sampled through the loop near 0...
why is this? what's the fix? I usually see this GP approach to produce smooth predictions, not here though!


text:
How can I get an integer as output for continuous action space PPO reinforcement learning?
I have a huge discrete action space, the learning stability is not good. I'd like to move to continuous action space but the only output for my task can be a positive integer (let's say in the range 0 to 999). How can I force the DNN to output a positive integer?


text:
Numerical problems with gradient descent
I'm trying to implement a simple neural network for classification (multi-class) as an exercise (written in C). During gradient descent, the weights and biases quickly get out of control and the gradient becomes infinite.
I haven't been able to find any discussion of such problems (vanishing gradients is kind of the opposite).
To be more specific, for testing I use a very simple network with 1 hidden layer and sigmoid as activation function. For the output layer I use softmax and logarithmic loss.
The issue as I see it is that when an output activation is very small, for the derivative of the loss I basically get 1 / <very_small number> and this leads to an enormous gradient.
Am I doing something wrong in terms of network architecture?
What is the typical way to deal with such problems?

have you tried to search "exploding gradients"? It's a well known issue along with vanishing gradients. Most of the time both problems comes from the weight initialization, what strategy are you using for that?

@EdoardoGuerriero I'm using random values in [-1, 1]. I didn't know the term "exploding gradients", I'll check what info I can find, thanks.

highly chances that your problem comes from the initialization. Usually the weights are positive defined, and you should go for values with mean of lower magnitude, like 0.05. Uniform or normal distributions are fine, but check also xavier and kaiming initialization.

You're describing exploding gradients, which as you noted is the opposite issue of vanishing gradients. Both these problems arise from the process of propagating and backpropagating activations/errors through the network. The intuition is that repeated multiplications of numbers less than 1 rapidly leads to a product of 0, while repeated multiplications of numbers greater than 1 rapidly leads to a product which tends to infinity.
The number of matrix multiplications you need to perform increases with the number of layers, which is why this tends to be a problem with deeper networks. In particular, recurrent neural networks are infamously susceptible to vanishing/exploding gradients as a result of propagating through each layer multiple times corresponding to each time step.
Careful choice of activation functions, proper weight initialization, and gradient clipping are the standard ways to address this problem, though more specialized solutions can arise depending on the context (for example, for RNNs, entirely new types of neurons, LSTMs and GRUs, were developed to address the issue).


text:
What is the next step in top-down brain simulation after spiking neural networks?
This paper from Yamazaki et al. describes a 68 billion spiking neural network model of the cerebellum. The simulation was about 600 times slower than real time, and the cerebellum is perhaps one of the more boring parts of the brain in terms of intelligent behavior, but this still seems like a significant step in the direction of meaningful top-down brain simulations.
To be clear, by top-down simulation, I'm referring to simulations that allow massive abstractions away from the biology of the nervous system in order to investigate and/or produce intelligence more directly, e.g. modern neural networks. This is in contrast to bottom-up simulation, which start with models of individual neurons (e.g. LIF, Hodgkins-Huxley) and add increasingly more realistic biophysical properties to them; these bottom-up simulations are geared towards testing hypotheses about low-level neurophysiology, rather than trying to produce or investigate intelligence per se.
My question, as someone very unfamiliar with these subfields, is: what are the most promising next steps for top-down brain simulation? Is it worth it to try to take more sophisticated network architectures like RNNs or transformers and make them spiking? Is it feasible to combine top-down and bottom-up simulation approaches, for example by organizing LIF models into a convolutional architecture (this particular example is likely impossible as I don't think the LIF neurons would be compatible with backpropogation)? Or should we think that the solution may not involve deep neural networks at all?


text:
What are Reservoir computers used for today?
Reservoir computers were very popular in the early 2000s. From what I understand, the advantage of reservoir computers is that, as opposed to generic recurrent neural networks, training is only done on the linear output layer, making them much faster to train. However, computers are a lot faster today than they were 20 years ago, so I am wondering whether there are still places where reservoir computers are preferred to recurrent neural networks or transformers.


text:
Active Learning regression with Random Forest
I have a dataset of about 8k points and I am trying to employ active learning with the random forest regressor. I have split the dataset to train and test with train being around 20 points. The test serves as the unlabelled pool (although I have the labels).
My workflow is the following:

Select a budget c.
Train the RF on train.
Select the sample from the test for which the predictions have the greatest variance.
Train the RF on train+sample

and the process continues until there is no more budget available. At each retrain I am calculating the accuracy on the test with the coefficient of determination.
Is the above workflow valid? What I have observed is that accuracy isn't improved compared to random sampling. Is there any other query strategy that can work with Random Forests for regression?
I could have used Gaussian processes but from my experience they need a lot of tuning and for large training sets, training time is very large. That is the reason I selected Random Forest.


text:
Alternatives to Bayesian optimization
I am given a dataset $\mathcal{D} = \{\mathbf{x}_i\}_{i=1}^n$ and I need to find the point (in my case a material) $\mathbf{x}^*$ that maximizes a property $y$ (which can be obtained from a black-box function $f(\mathbf{x}$), performing the least amount of labeling (because it is expensive).
I have checked Bayesian optimization but it uses a Gaussian process as a surrogate model which makes the training extremely slow for a high-dimensional feature space and large datasets (high $n$).
Are there any alternatives to Bayesian optimization for such a task?
I have checked Particle Swarm optimization but I think it is not applicable to my case, since the particles must be allowed to access any $\mathbf{x}$ while $\mathcal{D}$ contains only specific points.
I should add that the features of $\mathcal{D}$ are all continuous.


text:
What are the main arguments predicting a Soft Takeoff vs Hard Takeoff scenario and viceversa?
Here I am referring to the term AI Takeoff as described here on LessWrong, with annexed "Soft" and "Hard" takeoff definitions.
I find that page to be biased slightly more towards the hard takeoff scenario in terms of citing further resources to read, so was wondering if someone could provide a more balanced overview of the arguments from both camps.


text:
Brain Segmentation To 3D Model
My goal is to take a dataset of Brain Tumor segmentations, use computer vision to locate and highlight the tumor in each slice, then combine each slice (almost like stacking) to make a 3D model. In this 3D model, you can see exactly where the tumor is located.
I am able to use CV to highlight tumors in individual layers, but the challenge comes in stacking. How would I go about stacking images to make 3D models. With this I would have to remove empty outside space in individual images and be able to give each image some depth.
How would I go about doing this? Is there any existing library that can do this?


text:
Why does importance sampling work with latent variable models?
Caveat: importance sampling doesn't actually work for variational auto-encoders, but the question makes sense regardless
In "L4 Latent Variable Models (VAE) -- CS294-158-SP20 Deep Unsupervised Learning", we see the following.
We want to optimize the following:
$$
\sum_i\log\sum_zp_z(z)p_\theta(x^{(i)}|z)
$$
But this is hard, since we cannot enumerate over all possible $z$.
So, we could use random sampling instead:
$$
\sum_i\frac{1}{K}\sum_{k=1}^Kp_\theta(x^{(i)}|z_k^{(i)})
$$
where $z_k^{(i)} \sim p_z(z)$.
However, this doesn't work because for most values of $z_k^{(i)}$, $p_\theta$ (and its gradient) will be near 0. For example, consider a 100-dimensional binary latent variable space. The probability you sample the correct $z$ to produce the given $x^{(i)}$ is $0.5^{100}$.
To counter-act this, we can use importance sampling:
$$
\sum_i\log\frac{1}{K}\sum_{k=1}^K\frac{p_z\left(z_k^{(i)}\right)}{q\left(z_k^{(i)}\right)}p_\theta(x^{(i)}|z_k^{(i)})
$$
Where $q(z) = p_\theta(z|x^{(i)})$ ($q$ is good at predicting what latent variable represents the sample $x^{(i)}$).
Of course there are problems with calculating $q$, but let's ignore that for now.
The thing I don't understand here is, sure $q$ might be good at predicting values of $z$, for which $p_\theta(...)$ is non-zero, but we are scaling all of those values by $p_z(z_k^{(i)})$, which will be very small. So the end result is that the final sum will still be very low for a given $x^{(i)}$. (I think) this means when doing back-propagation through $p_\theta(x^{(i)}|z_k^{(i)})$, the gradient update will be very small, which is the problem we were trying to avoid in the first place.
Can someone explain to me what I'm missing?


text:
Training with extremely imbalanced Dataset
I have a object detection problem which has extremely imbalanced dataset. Lets say there is only one class to detect, say apple or not apple. This detection network will be used in a real case including IP camera streaming where positive/negative samples ratio is extremely huge, 1:1Million.
My first idea to train the model with using a dataset of 100:100k positive/negative samples ratio but the model still might be skewed to negative samples which might results in not detecting apples apparently.
I have two questions. My questions are:

What are the best approaches to this imbalanced dataset problem ?
Since I am using high resolution camera, detecting apples from camera streaming is related with small object detection problem since the apples in stream is really small compared the resolution of the camera. I know that Yolo is doing some data augmentation to improve accuracy but would it be enough to detect small objects? Should I used some image tiling techniques? If someone has experience about small object detection problem and know how to handle this, any idea would be perfect.

P.S: I am using Yolov4 with AlexeyAB's Darknet as a object detection model. Also, background of images are mostly the same due to Camera view.


text:
Choice of LSTM for price prediction
I have a dataset with features (f) for different stocks (S) and want to infer for price using an LSTM model. Here is my df:

year
S1_price
S1_f1
S1_f2
S2_price
S2_f1
S2_f2
Sn_price
Sn_f1
Sn_f2

2010
100
0.1
0.12
200
0.2
0.22
300
0.3
0.32

2011
105
0.4
0.42
205
0.5
0.52
305
0.6
0.62

2012
110
0.7
0.72
210
0.8
0.82
310
0.9
0.92

n

and so on... (example values).
I would like to predict the prices of every stock by using the features as inputs looking 1yr back into the past.
Example for Stock 1 (predict 2012):
[[0.1 0.12]
 [0.4 0.42]] 110

However, I want to to that for all stocks, so I am not sure which type of LSTM to use.
Your help would be very much appreciated!

I tend to like GRU and its variants for this type of problem. Although, if your dataset isn't too large you can test some toy models(smaller versions) of the different types to know which will achieve the best accuracy.
Typically a good size to start with in that case would be about 20-25% of your full model size.


text:
Learning an identity function with convolutional networks
I am trying to train networks to achieve what I expected to be a trivial task: learn the identity mapping. However, this is very hard to achieve, and the optimization is hard.
Moreover, I don't want to learn $f_\theta(x)=x\;\;\forall x$, but only $f_\theta(x_1)=x_1$ for one particular example (I am trying to overfit!).
Any ideas why this optimization is so hard? The learning curves oscillate and most of the points are not visually satisfactory.
Code is here: https://colab.research.google.com/drive/1umys2gxJ8arodQ0PhLf5TFicfPx0mh74?usp=sharing

Learning the identity function is not trivial at all.
The main reason is that the identity function is linear, and a neural network try to approximate it in a non linear fashion. Non linear activations in particular compress and expand values that linearly would have the same distance, so they are not suitable to approximate something like the identity function. I see you used a linear activation but the network still learn in a non linear fashion.
Residual Neural Networks (ResNet) were suggested precisely to help a neural network learning the identity function. The skip connection simply does the job of making the output equal to the input, forcing the network to focus on residuals (output - identity), so for a one layer ResNet learning the identity function become trivial cause the network simply has to learn to push all weights to 0.
But without this trick, approximating the identity is simply very hard, this is why your UNet experiment was not successful, even with a single training image.


text:
Why is the derivative of activation function all positive?
All the activation functions I see have positive derivatives.
Will negative ReLU work as well as its positive counterpart or will it lead to instability?

By definition from wikipedia:

Let $\varphi$ be a nonconstant, bounded, and continuous function.

This is also being proven for ReLU and other functions that violets some of those properties... however, if you take 1 - sigmoid(x) as your activation, all the properties are satisfied, and the derivative is strictly negative
This can be more "popularly" be seen also in the max-out activation function


text:
Shuffling vs Non-shuffling train/test set yields drastically different results
I am currently working with a very deep NN (200mio. to 350mio. params). My data set is roughly of shape (2mio, 350), i.e. 2mio samples and 350 features. In fact, the features are time series. As input to the NN I just pass the current state (1 time step), however that state is derived with some sort of scaling from past states.
Now I made a couple strange observation during training, I can't explain at all:

When I shuffle the whole data set and then do train/test split, the classification performance is extremely good, ~0.93 accuracy (3 classes) and identically generalizes onto the test set during the whole training
When I split the data into train/test and just shuffle train, the performance is less on train, but still acceptable (~0.75 accuracy), but performance on test falls off to ~0.36 accuracy
When I just split the data without shuffling, the train performance further drops to ~0.5 and test performance to ~0.3 (which is worse than randomly guessing)

What is going on here? I checked if I might have introduced some data leakage or lookahead bias in my data set manipulations, but couldn't find anything.
Anybody has an idea what is going on here?
Cheers

How are you shuffling your data? For time series not every shuffling is conceptually right, see this answer for an explanation

what is mio mean?

I don't have much information about your model and your data. But my best guess is that your dataset doesn't have the same distribution everywhere, and that without shuffling it before doing the split, you create subsets of data that are statistically very different i.e. their intrinsic distribution might differ a lot. When you shuffle before splitting, you mitigate this effect because you distribute your data (which might follow divergent patterns according to timestamps or any other feature) in both sets.

That could definitely make sense. I had a similar thought and compared the distribution of the features (in fact a histogram since they are categorical) between train and test. The plots look slightly different but not tremendously. However, I have to admit that they could be more insightful. Do you have an idea how to best approach such a statistical comparison and what metrics to look out for? A very simple approach could just be DataFrame.describe().


text:
At what size does a picture become unusable for facial recognition?
Lets say i have a portrait photo of which the face it contains covers about 90% of the entire photo. I want to be able to detect the face in this photo using facial recognition but i also want to reduce the file size of this photo. The best way to reduce the file size is to make the size dimensions of the photo smaller.
I want to know at what size a face containing photo becomes unusable for facial recognition. For instance could a 25 x 25 pixels photo still be used for facial recognition or would this be too small?

25x25 you can barely understand if a it's a child or an adult... have you tried to read some publications and see what res the used?

@AlbertoSinigaglia but will it still recognize the face?

if you mean "recognize if there is a face", yes, if you mean "recognize which face is on that image", no (probably)

@AlbertoSinigaglia probably isn't going to cut it. I need facts.

@Maurice You can't really have a definite answer to this question, it will depend on what sort of accuracy you are hoping to obtain.

@finlaymorrison lets say an accuracy of 90%


text:
What is the relationship between data science, artificial intelligence,machine learning and computer vision?
I am beginner to this field and i am trying to find big picture and i have tried to explore youtube and google images in this regard. According to my understanding ,machine learning is subset of artificial intelligence . But what about computer vision and data science, are they also subset of artificial intelligence? Which is main set? Artificial intelligence or data science?
If someone can share a venn diagram that may be very helpful in understanding the proper placement/arrangement of above mentioned different fields

This Venn diagram might help to visualize the relation between the different fields:

The image is from the free deep learning book by Ian Goodfellow, Yoshua Bengio and Aaron Courville. As you said machine learning is indeed a subset of Artificial intelligence. Artificial intelligence is since its origins a very broad framework with a strong overlap with computer science, neuroscience, game theory, reinforcement learning, linguistics, etc. Computer vision can in general be considered a part of artificial intelligence. However, computer vision comes in various flavors and forms and some people in the field might not be fond of putting their work under the 'AI' umbrella. Data science conceptually overlaps with many of the methods used within AI but it is more focused on statistics, data analytics, modeling, and data mining.
In industry being a data scientist often means 'generating insights from data' (eg via AB testing) while working as something with AI in the title involves some kind of deep learning (eg for natural language understanding).

While I cannot provide a Venn Diagram like the other answers, i can explain the relationship between them.
Computer vision is heavily tied in with AI, because computers have no intuitive sense of what a sign or word is. AI can help by using a training model with samples to tell it what a word in English or Russian is etc. Without AI computer vision is fiction. You cannot teach a computer to understand a sign without telling it what a sign usually looks like via sample data.
Data science can be somewhat connected to AI and Machine vision, but its usually just crunching numbers. For example, what is the most optimal way to recommend these videos to the users? Data science is wide so AI can be used for some jobs while statistics is used for another. Computers are used to solve most of the heavy work especially with algorithms.


text:
How to detect peak locations via Neural Networks?
As part of my masters thesis, I'm developing generative models for ECGs.
Right now, I have a Denoising Diffusion Implicit model (DDIM), that transforms random noise into a valid ECG (2s long, or 1024 sample points with a 512Hz sample frequency). It works quite well, but by itself, it is only capable of producing random ECGs. It would be of much more scientific value to produce a realistic ECG that has R-peaks at specific, predetermined points.
The solution would be a guided diffusion. This relies on an auxillary model, that takes the output of the diffusion model, and gives a prediction of where the peaks currently are. Then I calculate the gradient of the desired peak locations w.r.t the input data (i.e. the output of the DDIM). I add the gradients to the data, and get a slightly transformed noise. Then I can feed it back into the DDIM, and repeat the process until I get a clean ECG with peaks at the desired positions.
The problem is, I can't figure out a good way to do peak prediction using NNs.
Researching the problem, people usually recommend other algorithms for peak detection. But in my case, I have to do it via a NN, so I can calculate the gradients. Papers on the matter usually do Peak classification, or segmentation, not predicting the exact location.
Right now I have the following setup:

A sample ECG, that consists of 1024 points representing 2 seconds. It has 2 to 4 peaks (which is a physiological range for humans), of varying height, normalized to 1 being the highest R-peak.

My peak identifier network is a convolutional NN, that takes the ECG as input, and has 128 output nodes. Each node represents an 8 point range. So if node 5 has the output value of close to 1, it means the model predicts there is a peak somewhere between point 40 and point 48.

My problem now is actually the loss function. The ECG is annotated, so I know the actual peak location and can encode them into the same 128 8-point segments.
Right now I'm using simple categorical cross entropy between the real location and my networks predictions. However, this loses the aspect of "distance". If the peak really is in the 5th segment, and my network predicts a peak in the 4th segment, this should result in a lower loss than if the network predicts a peak in the 80th segment.
And because there is a variable amount of peaks (between 2 and 4), I can't simply calculate the distances between the predicted peaks and the real ones, because I don't know how to handle the case where there is 3 peaks, but my model predicts 5. Which peaks do I then use for distance calculation?
The cross entropy loss almost works. The model gets quite close, but it defaults to a strategy where if the real peaks are say at 24, 58 and 100, it predicts 23, 24 and 58 as the 3 highest output nodes. So regions around a peak often have higher outputs than another peak far away.
I'd really appreciate some input here. I'm not fixed on segmenting the peaks into blocks of lengths 8, I just thought it would be easier for a model to approximate the peak location, since ECGs can be quite noisy. Also, with the current architecture, I'd need 1024 output nodes, and cross entropy between all of them, which would make for quite a long training, since my loss does not reward "distance" right now.

Please note that we have a Medical Sciences) site where more people would understand the question, though perhaps know less about NN; be certain to provide a link to this question. Also GitHub has some software available: https://github.com/topics/ecg-classification

@Rob, I provided all the additional information to show that I really HAVE to use a NN for peak detection. It's not really needed to answer the question. All I want is a way to detect an arbitrary amount of peaks in timeseries via NNs. I really doubt the medical Sciences site will be of much use, as my question is not about ecgs in general.


text:
PRNG Function Prediction
Can any machine learning algorithm predict the function of pseudo random number generator given only its inputs and outputs?
Here, you can also assume that you don't know the seed for the PRNG.

Yes, this is possible but only within certain cases and depending on the amount of work one is willing to invest. All PRNGs make use of an underlying (deterministic) generative process that can be learned in theory. This blog post nicely illustrates how it could be done. The model learns to predict the next sequence of random numbers without knowing the seed. This makes intuitive sense since deep nets can approximate arbitrary functions and in practice it is often not even clear what the seed value of the generative process would be (e.g. during image classification).
In general, this question has no binary answer but instead depends on a number of factors like the complexity of the PRNGs, the available training data, the network size, and the available compute.
This questions has also been answered here and here.

I think it is worth mentioning that although theoretically possible, it would be impractical (and AFAIK, never been done) for any modern standard PRNG, even the non-cryptographic ones like Mersenne twister.

The blog post actually also has a very interesting second part where they do work with the Mersenne twister and 'break it'.

I stand corrected. Partially though, because the blog post approach does require a lot of reverse engineering of the known algorithm in order to apply ML successfully. The answer to the OP's question is still "no" (unless the OP clarifies that knowing the algorithm is allowed).

Maybe we can agree on the fact that the quality of our predictions will be a function of the complexity of the PRNGs, the available training data, the network size, and the available compute. I will change the answer accordingly.


text:
Choose the right algorithm
I need to select the most suitable ML algorithm for an academic project. I have a dataset earn from lab which includes the long of an element and 3 factors that we believe impact the long of the mentioned element. I want to predict the length of the element by using those 3 factors.
Probably I should use supervised algos but which one?

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.

I find it useful to refer to scikit-learn's Choosing the right estimator cheatsheet, using it of course with a bit of consideration and thought.
In your case we are talking about a supervised regression problem in which you have to predict a numeric value from three other values. The first thing to note is that, having only three input features, you should probably first plot the data and try exploring it with your own eyes. You may find out that one or more of those features have a clear relationship with the target variable, for example a linear correlation.
In that case, you could try fitting a linear model to your data.
One important aspect that you don't mention is the number of data points you have available. Having enough data for both training and testing is essential, although the exact number depends on how complex the relationship between variables is. Good luck.


text:
Can you make Q&A language model stay on topic?
I’m thinking of fine-tuning a pre-trained language model for a Q&A task. More specifically, I’d like to fine-tune the model on a single chapter in a classic college textbook. Afterward, the reader of the chapter should be able to engage in a Q&A session with the model about the content of the chapter.
But how do I make sure that the model stays on topic and doesn’t go out of a tangent? I know it is possible when looking at what https://play.aidungeon.io/ has achieved, but I don’t know if it will require me to build a model from the ground for each chapter. Can anyone tell me if I’m out of my mind or if it’s feasible?
Edit:
I've just learned that AI Dungeon's models has also struggled with a tendency to create graphic and sexual content despite not being prompted by players.

Perhaps you could train an auxiliary binary classifier to predict whether or not a response from the chatbot was on or off topic. You could use text from the chapters that you fine tune the Q.A. model with to generate examples of "on topic" text and then use text from other sources as "off topic".
Then, when the model generates an output, you could pass that through the binary on/off-topic classifier. If it is deemed off topic, you could then respond with some canned phrases, indicating that the chatbot is unable to answer the specific question. I have not tried this myself, but it seems to me like a reasonable place to begin.

Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.


text:
use artificial intelligence in predicting the price of stocks
Is it possible to use artificial intelligence for example method like reinforcment learning, LSTM, ... in predicting the price of stocks or currencies like Bitcoin, etc.? And has the work been implemented and had a positive result so far?! If the answer is yes, what is the best method?

I searched “machine learning finance” on Google Scholar and hid a bunch of hits.
A few jump out as being explicitly about predicting prices.
Culkin, Robert, and Sanjiv R. Das. "Machine learning in finance: the case of deep learning for option pricing." Journal of Investment Management 15.4 (2017): 92-100.
De Spiegeleer, Jan, et al. "Machine learning for quantitative finance: Fast derivative pricing, hedging and fitting." Quantitative Finance 18.10 (2018): 1635-1643.
Specifically for Bitcoin:
McNally, Sean, Jason Roche, and Simon Caton. "Predicting the price of bitcoin using machine learning." 2018 26th euromicro international conference on parallel, distributed and network-based processing (PDP). IEEE, 2018.
Chen, Zheshi, Chunhong Li, and Wenjun Sun. "Bitcoin price prediction using machine learning: An approach to sample dimension engineering." Journal of Computational and Applied Mathematics 365 (2020): 112395.
Further, it’s easy to find postings about machine learning jobs at financial firms.
Consequently, I say that finance is at least interested in applying modern machine learning methods in the pursuit of accurate predictions of asset prices.
Finally, no post on financial machine learning resources would be complete without mentioning Advances in Financial Machine Learning, written by a guy from the hedge fund AQR Capital Management.

Thank you for your answer and you mentioned such interesting sources

@all welcome to the site; please see What should I do when someone answers my question?

No! I don't think so, price action and or the fluctuating value of any stock, option, commodity or currency is totally random. However, there or indicators and software out there that do make fairly good assumptions or predictions but none are not perfect I don't believe.

Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

thank you, but how can others confirm my comment is correct or incorrect in these early stages of development? I'll simply leave the comment as is, there is no reason to change it based on facts that's not there yet and speculations are all anyone has based on past experience. thank you my friend


text:
Feature Engineering on transactional dataset clustering
I have a data set with transactions details from different business (roughly 1 thousand business entities). Each row is a transaction. The structure of the dataset is as follows:

client_id
Sex
Age
transaction_ammount
business_entity

123
M
88
4829
storeA

123
M
88
1049
storeB

255
F
25
1122
storeH

My goal is to cluster the clients depending on their consuming habits, age and sex.
I am having a hard time on deciding on the best features to feed this dataset into a clustering algorithm (probably K-means as a starter).
Some of the things I am planning to do are:

One hot encoding on: sex
Make each store be a column and each row value be the amount of transactions a certain user did pay to that store (for example, if user1 made two transactions to storeB, there will be a 2 in the user1 row on the storeB column).

One of the main things I am struggling with right now is how to sum the transactions' data per user. I would need to run an aggregated operation on them, but don't know which one would be better. Some of the ones I have in my mind:

Average transaction amount per user
Min transaction amount per user
Max transaction amount per user
The above 3 but for each store per user (which would mean that, if I have 1000 stores, I would have to add 3000 thousand columns). This makes sense since each store have a wide range of product prices and running an operation among all the transactions of a user will be misleading.

What feature engineering technique would you recommend me? Is there any additional data wrangling I should do?

The average transaction is a central measure, while the minimum and maximum transactions together give an idea of dispersion. However, these can be very sensitive to individual purchases that might not be representative of the personal behaviour of a customer.
For instance, the year a consumer changes their fridge or washing machine an outlier purchase happens. You may want to filter that out of your analysis -or not!
Robust alternatives to explore include the median for location and the interquartile range for spread.
A log transformation of the transaction_ammount may be useful as well. This would transform your arithmetic mean into a geometric mean, thus reducing the impact of large purchases.
The table does not display a date column. That can also help modeling. You may have customers buying small quantities on random days and weekend customers going to your stores mainly on Saturday, or even once a month.


text:
Identify features don't hold required information in a ML problem
given a ML model that performs poorly, can you differentiate between those two causes:

bad architecture/not enough data
the features do not hold enough information to solve the problem

I'm interested in identifying num 2., what analysis can I perform to prove that num 2. is occurring when solving some ML problem?
Context is supervised learning (and the model is not necessarily a neural net)

To test hypothesis 1 the only way is to try different architectures and/or approaches. Basically brutal grid search.
To test hypothesis 2 the way to go is data exploration and feature importance analysis. You can compute different correlation scores (Pearson, Spearman, Chi-square) between each individual feature and your target, plus correlation between each pair of features. Comparing to the target gives you an idea of which features are strong predictors and which are weak ones, comparing features tells you how much redundancy is present within you training data.
Keep in mind that decision tree based models allow you to automatically assess which features are strong predictors, so training a random forest or xgboost is one good way to do both things in one shot: training a model and assess your data quality.


text:
Why not use only expert demonstrations in Imitation Learning approaches?
Some IL approaches train the agents by using some specific ratio of expert demonstrations to trajectories generated using the policy being optimized.
In the specific paper I'm reading they say "we experimented with various IL proportions (10-50% by increments of 10%) and observed that the RL/IL ratio does not seem to affect the performance of the trained policy by much."
My question is: why not rely only on expert demonstrations instead of introducing the noise of trajectories generated by a sub-optimal policy?.
My assumptions are:

This noise helps explore the state space beyond the specific episodes experienced by the expert system.
You might have expert systems that only work on a limited state space and do not scale to bigger, more complex environments. Therefore, although you can't use expert demonstrations in the bigger envs you still want to leverage their experience by learning their behavior in limited settings and the way to avoid overfitting to a specific, constrained policy is by always having some proportion of episodes generated by your policy being learned.

Using suboptimal demonstrations in Imitation Learning
The paper you link above uses Behavior Cloning (supervised learning on the expert state-action pairs), which is known to suffer from the "DAgger problem" like many other imitation learning algorithms.
In essence, a policy trained under imitation learning from expert demonstrations will inevitably make some suboptimal actions during the episode, and these suboptimal actions lead to states that are increasingly different from states in the expert demonstrations, which leads to more suboptimal actions.
So there are cases where adding noise or perturbation to your demonstration set can lead to a more robust imitation policy[1].
[1] T-Rex https://arxiv.org/abs/1904.06387
Imitation Learning in PRIMAL
As I understand it, the paper you link to only uses expert demonstrations during imitation learning. The suboptimal demonstrations are RL samples being used for an RL objective.
The authors describe their choice to combine IL and RL as follows:

combining RL and IL has been shown to lead to faster, more stable
training as well as higher-quality solutions in robot manipulation.
These advantages are likely due to the fact that IL can help to
quickly identify high-quality regions of the agents state-action
space, while RL can further improve the policy by freely exploring
these regions


text:
Is it possible for PixelCNN to tell us what it generates?
I coded PixelCNN with the help of Keras official website. Also, I read the paper. I can use PixelCNN, similar to a decoder or generator (to generate samples). My question is, "is it possible to train PixelCNN to tell us what is predicted?".
For example, consider we train an autoencoder on a dataset of animals. The PixelCNN samples from latent space and can predict the encoded picture. Now, I want to know, is there a way for PixelCNN to tell us what (e.g. which animal) it generated after prediction?
I thought about probability methods like softmax, but I am not sure about them.


text:
Master theorem about polynomial classifiers?
Does anyone know if there is a theorem or counterexample establishing whether or not for any given binary classification task in some finite (possibly large) dimensional vector space of attributes, that there exists a polynomial classifier that can form a hyperplane sorting all the positive from negatively labelled data points?
To clarify, I know that if a dataset is linearly separable, then we can find such a linear classifier. But my question is more general and asks if without knowing beforehand whether a dataset is separable at all, can we know ahead of time if there exists a polynomial classifier for any n-dimensional vector space of data points?

they are all wrong, check this answer https://stats.stackexchange.com/questions/549852/can-any-data-be-learned-using-polynomial-logistic-regression (you can obviously ignore the "logistic" part since it's just used to transform it to probability.. the decision boundary is still made by a polynomial function, thus it still holds)

Stone-Weierstrass?

I think I have a counterexample:
$$
X=(0,1,0,1)\\
Y=(0, 0, 1,1)
$$
No polynomial can separate the values of $Y$.

Unless I'm missing something I think you're simply looking for the Rouche Capelli theorem.
A polynomial classifier is just a set of linear equations made of feature vectors and coefficients (parameters) vectors. So to know if a solution exists you would have to compute the rank of the classifier coefficient matrix and expanded matrix and compare their ranks.

Thanks but unless I misunderstand you, I am interested in the powers and limits of polynomial classifiers to solve binary classification tasks. For example, a set of data labelled such that (0,0) and (1,1) are positive and yet (0,1) and (1,0) are labelled negative, cannot admit of a linear classifier but needs a polynomial one.

linear or polynomial, a classifier is anyway solved as a set of linear equations, with respect to the coefficient we are solving for. So the theorem should still be applicable.

to rephrase the idea of the theorem, it's not about dividing the data, that's always possible in theory, cause worst case scenario I can always define n hyper planes, one for each point in my data. It's about how many coefficient (or equations) I can define based on my data that limit the expressive power of a classifier.


text:
Exact definition of WRN-d-k (Wide ResNet)
I am a little confused about the WRN-d-k notation from Wide Residual Networks. To quote the paper,

In the rest of the paper we use the following notation: WRN-n-k denotes
a residual network that has a total number of convolutional layers n and a widening factor k (for example, network with 40 layers and k = 2 times wider than original would be denoted as WRN-40-2).

I need to implement WRN-28-10 as a baseline since it's one of the best-performing models in RobustBench. According to the definition, I need to take an "original" ResNet-28 and widen its layers by a factor of 10. However, there are only 5 variants of ResNet defined in the ResNet paper: ResNet-[18,34,50,101,152].
How exactly are ResNet-28 and WRN-28-10 defined?

I also found the WRN-$n$-$k$ notation confusing, but I think I can explain it:

$n$ is the total number of convolutions in the model.  So to understand the architecture associated with each $n$, we have to carefully account for every convolution:

Each model starts with a 3x3 convolution (conv1 in Table 1)
There are 3 groups of residual blocks, each the same size.
Each residual block has 2 convolutions, assuming we're talking about the $B(3,3)$ blocks that were found to work the best.
Each group has skip connection, which adds another 1x1 convolution.

Putting this all together, we can calculate $n$ as a function of the number of residual blocks in each group, which I'll denote $b$:
$$
  n = 1 + 3 (2b + 1)
  $$
$$
  b = \frac{\frac{n - 1}{3} - 1}{2}
  $$
Here are the actual number of residual blocks per group for each of the architectures discussed in the paper:

WRN-40-$k$: 6
WRN-28-$k$: 4
WRN-22-$k$: 3
WRN-16-$k$: 2

$k$ is the factor by which the number of input channels to each residual block is multiplied.  I found this pretty self-explanatory, so I don't really know what else to say about it, but let me know in the comments if there's anything unclear.

The way the WideResnet authors calculate the depth is actually inconsistent with how Kaiming He et al. do it in this or this paper, but your answer is correct. :-)


text:
Minimum sampling for maximising the prediction accuracy
Suppose that I'm training a machine learning model to predict people's age by a picture of their faces. Lets say that I have a dataset of people from 1 year olds to 100 year olds. But I want to choose just 9 (arbitrary) ages out of this 100 age dataset and still the model should be able to predict the age of a given person. My question is how should I choose the optimal 9 (arbitrary) ages out of the 100 age dataset, so the trained model would perform better across most of the ages?
The model will perform better if I train the model with the entire population, so the question is, how to approximate the performance of this model but with the minimum possible sample selection (not the number of observations, but with minimum number of ages.)
I should address the following questions

How many no of ages should I select from the entire age spectrum
what are the best ages that I should select to train the model


text:
How to compare different trajecories in a Markov Decision Process
I realize that my question is a bit fuzzy and I am sorry for that. If needed, I will try to make it more rigorous and precice.
Let $\mathcal{M}$ be a Markov Decision Process, with state space $\mathcal{S}$ and action space $\mathcal{A}$.
Let $\tau = (s_0, a_0, s_1, a_1, s_2, a_2, \dots)$ and $\tau' = (s_0', a_0', s_1', a_1', s_2', a_2', \dots)$ be two trajectories produced by an agent during two different episodes.
Question: Is there any standard way in the Reinforcement Learning literature to compare $\tau$ and $\tau'$? Ideally I am interested in finding a "distance" (it does not need to be a distance in the mathematical sense) $d(\tau, \tau ')$ such that it reflects the "distance" between the poicies that generated $\tau$ and $\tau'$.
For example it would be nice if $d(\tau, \tau')$ would be a good estimator of the KL divergence of $\pi$ and $\pi'$, where $\pi$ is the policy that generated $\tau$ and $\pi'$ the policy that generated $\tau'$.

in what regard do you need to compare two trajectories? maybe you want to compare the "agents" responsible for those two trajectories? then you can calculate the probability ratio of actions between two agents. it is actually used in "importance sampling" when doing off-policy optimization, measuring difference between behaviour and target policy

So, ideally I would like to compare the probabilities (policies) of the two agents, for example using the KL divergence (wich is the expectation w.r.t one of the two probabilities of the log of the ratio). However I do not have access to the policies but only to the trajectories. I would like to measure how different they are.

Do you only have two trajectories? Do you have access to the MDP model (i.e. transition probabilities)?

If the goal is to compare agents, then difference in states should not be in the compared vectors to begin with. I'd only compare $\pi(a|s)$ as this represents the agents. $p(s|a)$ part is an attribute of the environment. you can possibly learn $\pi(a|s)$ from data (not to mention how super hard it might be given the number actions or continuity of action space), then you can compare the learned $\pi$ densities, e.g. via KL.
still, as I and also @Onil90 mentioned, the straight forward scenario is having access to transition probs. without that, don't know if there's a standard solution


text:
Multi-objective training involving maximization of one loss function and minimization of another
I need my model to predict $s$ from my data $x$. Additionally, I need the model to not use signals in $x$ that are predictive of a separate target $a$. My approach is to transform $x$ into a representation $\Psi(x)$ such that it's good at predicting $s$ but bad at predicting $a$.
Concretely, let the prediction for $s$ be
\begin{equation} \hat{s} = (\Gamma \circ \Psi)(x), \end{equation}
and that for $a$ be
$$\hat{a} = (\Omega \circ \Psi)(x),$$
where $\Psi, \Gamma, \Omega$ are implemented as MLP layers. Further, let $\ell_s(\Psi,\Gamma)$ and $\ell_a(\Psi,\Omega)$ be the loss functions corresponding to $s$ and $a$, respectively.
The objective thus is to simultaneously

minimize $$\ell_s(\Psi,\Gamma)$$ (good at predicting $s$), and
maximize $$\min_\Omega \ell_a(\Psi,\Omega) := -f(\Psi)$$ (bad at predicting $a$)

There may not exist a $(\Psi, \Gamma)$ combination that simultaneously achieves both. So the hope is to find something on the Pareto frontier by linearly combining the objectives:
\begin{equation}
\tag{*}\label{*}
\min_{\Psi, \Gamma} \left[ \ell_s(\Psi,\Gamma) + \alpha f(\Psi) \right]
= \min_{\Psi, \Gamma} \left[ \ell_s(\Psi,\Gamma) - \alpha \min_\Omega \ell_a(\Psi,\Omega) \right]
\end{equation}
where $\alpha > 0 $ is a hyperparameter that trades off the two original objectives.

However, I'm not sure how to train the layers $\Psi, \Gamma, \Omega$ to achieve \eqref{*}.
One procedure I could think of is to alternate between

Freeze $\Psi, \Gamma$ and tune $\Omega$ to minimize $\ell_a(\Psi,\Omega)$,
Freeze $\Omega$ and tune $\Psi, \Gamma$ to minimize $\ell_s(\Psi,\Gamma) - \alpha \ell_a(\Psi,\Omega)$

until convergence. Would that work?

It's probably important that both steps be able to tune the learned representation Ψ. Also, that you are always minimizing the combined loss.
You should do:

Freeze Γ and tune Ψ,Ω to minimize ℓ(Ψ,Γ)−ℓ(Ψ,Ω),
Freeze Ω and tune Ψ,Γ to minimize ℓ(Ψ,Γ)−ℓ(Ψ,Ω).

Or, better yet, if Γ and Ω accept the same examples, to just train both in each training step.
Your setup is fine, and sensible. For example, in learning voice conversion, some architectures will have a module adds the following to the objective: This representation of the speech should make it difficult to predict who the speaker is (and thus only model the semantic content of the speech, not speaker style).
These Greek caps seem like a strange notation to me, btw.

$\Gamma$ and $\Omega$ does accept the same examples. However, if I train all the layers with $\ell_s - \alpha \ell_a$ as the objective to be minimized, I'm not sure it'll achieve \eqref{*}. I need the $\Psi$ layer to be such that $\Omega$ cannot be tuned further to lower $\ell_a$. This is what ensures that $\Psi$ has been optimized to prevent prediction of $a$.

Again, your goal is to induce a representation Ψ that is maximally effective at predicting s using Γ and maximally confusing at predicting  using Ω, weighted by . It doesn't really matter if you train back and forth using freezing, or jointly without freezing. Training jointly without freezing is more elegant. I can try to find examples from the VC literature showing this is fine, but you haven't presented an argument why it shouldn't work. Rather than hypothesizing endlessly, why not just try both approaches and see how they work? If you can't evaluate these approaches, let's discuss that

Here is the simple reason it won't work:
$$\min_{\Psi,\Gamma, \Omega} \left[ \ell_s(\Psi,\Gamma) - \alpha  \ell_a(\Psi,\Omega) \right] \neq \min_{\Psi, \Gamma} \left[ \ell_s(\Psi,\Gamma) - \alpha \min_\Omega \ell_a(\Psi,\Omega) \right]$$
The LHS is a minima while the RHS \eqref{*} is a saddle point. If you try gradient descent with this objective, the $\Omega$ layer gets updated as
$ \Omega \leftarrow \Omega \color{red}{+} \eta ; \alpha \nabla_\Omega\ell_a$. Intuitively, you want $\Omega$ to be the best it can possibly be (for the chosen $\Psi$) at predicting $s$ and still fail miserably.

Training all layers jointly is my preference too. In fact, my first attempt  was just that with $\ell_s -\alpha \ell_a$ as the objective. It's when I couldn't get it to converge that I realized it's not even what I need.
Now, there is this DANN paper someone just directed me to with a neat gradient reversal layer trick that I think should work for my case too. I haven't quite got it working yet though.


text:
Does the order of a Numpy array matter for CNN classification?
Image classification of RGB images in a Convolutional Neural Network is usually done by feeding the CNN first layer with a Numpy array with dimensions: pixel array by the number of channels. Example: [256 pixels] x [256 pixels] x [3 channels].
What is the impact on performance if applying a different Numpy array in a different order: say [256 pixels] x [3 channels] x [256 pixels], assuming that the CNN first layer structure is changed?

Does the CNN architecture of the sub-sequent layers need to be changed?
Would the model prediction accuracy be impacted?

My use case is a bit different where I have multiple features in a 5 dimensional Numpy Array [X pixels],[Y pixels],[N size],[M size],[L size] and I'm concerned that the order of how the features are entered into the CNN will impact the model training.

It shouldn't matter for the accuracy of the network. But note that tensorflow/keras uses the (N, W, H, C) convention whereas pytorch uses the (N, C, W, H). So depending on what library you use, you need to make sure the inputs are shaped correctly before feeding it to the network.
If you are trying to build a nerual network from scratch and training it with numpy, then ideally you would make the spatial dimensions last (..., W, H), to interface with functions such as np.convolve efficiently.


text:
Reach optimal values by not decreasing gradient
Is it possible to reach the optimal values for the parameters by not applying the decreasing gradient in some layers?

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.

How will you set initial value of the kernel in the layer?

If I understand correctly, your question is whether it's possible to randomly initialize some layers in a neural network and not apply gradient descent to them.
I believe the answer is yes. In synthesizer, they use a random matrix in the "attention layer" and did not train them, and still achieved reasonable results. Though I'm not sure how "optimal" that is. See here:
https://arxiv.org/abs/2005.00743
I'm sure this applies to other networks (e.g. CNNs) as well. Is there a particular application you have in mind for this?

As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.


text:
How do you display a neural network
I'm new to tensorflow and ML but am progressing slowly. I know how to look at the weights and biases but am still trying to figure out if there is an easy way to display a neural network in the standard pictorial way. If anyone knows and could share I would be really grateful.

What would you like to visualize? Most papers just show the tensor dimensions (and maybe skip connections) and describe the activations of each layer. With Keras you can just call model.summary() in Python and it will show you the dimensions and layer types.

What would you gain by the visualization? The best visualization I have ever seen is the following: https://www.youtube.com/watch?v=3JQ3hYko51Y

Is there an easy way to display a neural network in the standard pictorial way?
Each deep learning package has easy and pictorial options for model visualization.  In TensorFlow, the following model plotting utilities are available:  plot_model and model_to_dot.


text:
What are "feature planes" in neural networks? (current context is deep reinforcement learning)

The input contains 14 feature planes, each of shape 11x11
What does this mean?

A feature plane is just a numeric representation of a specific state of the environment.
For example, in a game with different types of items (candy, cake, bomb, ...) a binary feature plane can be used to encode the positions for each type of item.