category stringclasses 107
values | title stringlengths 15 179 | question_link stringlengths 59 147 | question_body stringlengths 53 33.8k | answer_html stringlengths 0 28.8k | __index_level_0__ int64 0 1.58k |
|---|---|---|---|---|---|
neural network architectures | What are the possible neural network architecture for linear regression or time series regression? | https://ai.stackexchange.com/questions/13651/what-are-the-possible-neural-network-architecture-for-linear-regression-or-time | <p>I started modeling a linear regression problem using dense layers (layers.dense), which works fine. I am really excited, and now I am trying to model a time series linear regression problem using CNN, but from my research in this link <a href="https://machinelearningmastery.com/keras-functional-api-deep-learning/" r... | 12 | |
neural network architectures | How do you decide that you have tested enough hyper-parameter combinations for a specific neural network architecture? | https://ai.stackexchange.com/questions/31954/how-do-you-decide-that-you-have-tested-enough-hyper-parameter-combinations-for-a | <p><strong>How do you decide that you have tested enough hyper-parameter combinations for a specific neural network architecture to discard it and move on to a new model?</strong></p>
<p>Do you have a structured (generic) approach? In practice, what gives you the necessary performance (e.g. >= 80% accuracy) the fast... | 13 | |
neural network architectures | A neural network with peculiar architecture? | https://ai.stackexchange.com/questions/41340/a-neural-network-with-peculiar-architecture | <p>I ended up working with a neural network <span class="math-container">$N(\cdot)$</span> characterized by the following structure:<span class="math-container">$$N(x)=V[\text{ReLU}(Ax+b)+Cx+d],$$</span>
with input <span class="math-container">$x \in \mathbb{R}^n$</span> and parameters <span class="math-container">$V\i... | 14 | |
neural network architectures | How can one be sure that a particular neural network architecture would work? | https://ai.stackexchange.com/questions/22590/how-can-one-be-sure-that-a-particular-neural-network-architecture-would-work | <p>Traditionally, when working with tabular data, one can be sure(or at least know) that a model works because the included features could explain a target variable, say "<em>Price of a ticket</em>" good. More features can be then be engineered to explain the target variable even better.</p>
<p>I have heard p... | 15 | |
neural network architectures | Neural network architecture or code for style transfer with aligned data | https://ai.stackexchange.com/questions/42989/neural-network-architecture-or-code-for-style-transfer-with-aligned-data | <p>As a follow-up on <a href="https://ai.stackexchange.com/questions/39386/open-source-vocal-cloning-speech-to-speech-neural-style-transfer">Open-source vocal cloning (speech-to-speech neural style transfer)</a>, I want to create a voice clone. Unfortunately, the answers in the thread above do not apply to my language ... | 16 | |
neural network architectures | Best neural network algorithms/architectures for generating synthetic sequences of tuples of words | https://ai.stackexchange.com/questions/48485/best-neural-network-algorithms-architectures-for-generating-synthetic-sequences | <p>I would like to generate sequences of tuples using a neural network algorithm such that the model trains on a dataset of sequences of tuples and generates synthetic sequences of tuples. Each tuple <code>t_i</code> in a sequence is made of two words and has the following format <code>t_i=(a_i,d_i)</code> where <code>... | 17 | |
neural network architectures | Appropriate convolutional neural network architecture when the input consists of two distinct signals | https://ai.stackexchange.com/questions/25349/appropriate-convolutional-neural-network-architecture-when-the-input-consists-of | <p>I have a dataset consisting of a set of samples. Each sample consists of two distinct desctized signals S1(t), S2(t). Both signals are synchronous; however, they show different aspects of a phenomena.</p>
<p>I want to train a Convolutional Neural Network, but I don't know which architecture is appropriate for this k... | <p>I don't know what you mean by <em>desctized signals</em> but if I understand your question correctly, separating two signal and passing them through same architecture of CNN (even with different parameters) is not a good idea. Because when they are together (as different channels) they will be treated differently by... | 18 |
neural network architectures | How can I automate the choice of the architecture of a neural network for an arbitrary problem? | https://ai.stackexchange.com/questions/1391/how-can-i-automate-the-choice-of-the-architecture-of-a-neural-network-for-an-arb | <p>Assume that I want to solve an issue with a neural network that either I can't fit to existing architectures (perceptron, Konohen, etc) or I'm simply not aware of the existence of those or I'm unable to understand their mechanics and I rely on my own instead.</p>
<p>How can I automate the choice of the architecture/... | <p>I think in this case, you'll probably want to use a genetic algorithm to generate a topology rather than working on your own. I personally like <a href="http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf" rel="nofollow noreferrer">NEAT (NeuroEvolution of Augmenting Topologies)</a>.</p>
<p>The original NEAT p... | 19 |
neural network architectures | Which neural network should I use to distinguish between different types of defects? | https://ai.stackexchange.com/questions/22649/which-neural-network-should-i-use-to-distinguish-between-different-types-of-defe | <p>I want to teach a neural network to distinguish between different types of defects. For that, I generated images of fake-defects. The images of the fake-defect types are attached.</p>
<p><a href="https://i.sstatic.net/I0GO0.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/I0GO0.jpg" alt="border" /></a>... | 20 | |
neural network architectures | Why we use Convolutional Neural Network for image data and not the Feedforward Neural Network Draw and explain the architecture of Convolutional Netwo | https://ai.stackexchange.com/questions/43145/why-we-use-convolutional-neural-network-for-image-data-and-not-the-feedforward-n | <p>Why do we use Convolutional Neural Network (CNN) for image data and not the Feedforward Neural Network (FNN)? Draw and explain the architecture of Convolutional Network</p>
| <p>I highly recommend you read the seminal work on convolutional neural networks (CNNs):</p>
<p>Lecun, Y., & Bengio, Y. (1995). Convolutional networks for images, speech, and time-series. In M. A. Arbib (Ed.), The handbook of brain theory and neural networks MIT Press.</p>
<p>In summary, CNNs provide the following ... | 21 |
neural network architectures | What are some examples of LSTM architectures? | https://ai.stackexchange.com/questions/14280/what-are-some-examples-of-lstm-architectures | <p>I've been doing some class assignments recently on building various neural networks. For convolutional networks, there are several well-known architectures such as LeNet, VGG etc. Such "classic" models are frequently referenced as starting points when building new CNNs. </p>
<p>Are there similar examples for RNN/LS... | <p>In the paper, <a href="https://arxiv.org/pdf/1503.04069.pdf" rel="nofollow noreferrer">LSTM: A Search Space Odyssey</a> (2017), by Klaus Greff et al., eight LSTM variants on three representative tasks (<a href="https://en.wikipedia.org/wiki/Speech_recognition" rel="nofollow noreferrer">speech recognition</a>, <a hre... | 22 |
neural network architectures | Is this neural network architecture appropriate for CIFAR-10? | https://ai.stackexchange.com/questions/18073/is-this-neural-network-architecture-appropriate-for-cifar-10 | <p>I have a CNN architecture for CIFAR-10 dataset which is as follows:</p>
<blockquote>
<p>Convolutions: 64, 64, pool</p>
<p>Fully Connected Layers: 256, 256, 10</p>
<p>Batch size: 60</p>
<p>Optimizer: Adam(2e-4)</p>
<p>Loss: Categorical Cross-... | <p>To be honest, your model is not very clear. But basically after the convolution, you need to add non-linear layers. Otherwise, there is no point of Neural Networks.</p>
<p>You can add a Relu layer for sure. </p>
| 23 |
neural network architectures | What is the name of this neural network architecture with layers that are also connected to non-neighbouring layers? | https://ai.stackexchange.com/questions/17822/what-is-the-name-of-this-neural-network-architecture-with-layers-that-are-also-c | <p>Consider a feedforward neural network. Suppose you have a layer of inputs, which is feedforward to a hidden layer, and feedforward both the input and hidden layers to an output layer. Is there a name for this architecture? A layer feeds forward around the layer after it?</p>
| <p>This could be called a <a href="https://arxiv.org/pdf/1512.03385.pdf" rel="nofollow noreferrer">residual neural network (ResNet)</a>, which is a neural network with skip connections, that is, connections that skip layers. </p>
<p>Here's a screenshot of a figure from the paper <a href="https://arxiv.org/pdf/1512.033... | 24 |
neural network architectures | Is there any purpose of altering neural network architecture if validation loss does not decrease but training loss does? | https://ai.stackexchange.com/questions/45555/is-there-any-purpose-of-altering-neural-network-architecture-if-validation-loss | <p>I am training a transformer based neural network and the validation loss is not decreasing, but the training loss does decrease. I am wondering if it's possible to debug or change the architecture such that this is reversed, or if I definitely need to debug my dataset.</p>
| 25 | |
neural network architectures | How do I determine the best neural network architecture for a problem with 3 inputs and 12 outputs? | https://ai.stackexchange.com/questions/17571/how-do-i-determine-the-best-neural-network-architecture-for-a-problem-with-3-inp | <p>This post continues the topic in the following post:
<a href="https://ai.stackexchange.com/q/17553/2444">Is it possible to train a neural network with 3 inputs and 12 outputs?</a>.</p>
<p>I conducted several experiments in MATLAB and selected those neural networks that best approximate the data.</p>
<p>Here is a... | 26 | |
neural network architectures | Is there a neural network architecture that enforces context-specific constraints on the output? | https://ai.stackexchange.com/questions/46756/is-there-a-neural-network-architecture-that-enforces-context-specific-constraint | <p>I am working on a prediction problem where each outcome vector in my training data <span class="math-container">$y_i$</span> was generated to satisfy a set of linear constraints <span class="math-container">$A_i y_i = b_i$</span>. I know each <span class="math-container">$A_i$</span> and <span class="math-container"... | 27 | |
neural network architectures | Is there a theoretically optimal input range for neural networks? | https://ai.stackexchange.com/questions/46150/is-there-a-theoretically-optimal-input-range-for-neural-networks | <p>I've been experimenting with different neural network architectures and am curious about the impact of input ranges on their performance. While normalizing inputs to ranges such as [0,1] or [-1,1] is a common practice, I wonder if there's a theoretically preferable input range that neural networks tend to perform be... | <p>Unfortunately, there is no <em>theoretically</em> optimal parameter for a neural network. However, they can be roughly defined when talking about a specific topic or application domain. <em>Normalization</em> is a very important procedure in the operation of neural networks. Normalization makes it easier for the net... | 28 |
neural network architectures | How to choose the suitable Neural Network Architecture for Regression Tasks | https://ai.stackexchange.com/questions/15816/how-to-choose-the-suitable-neural-network-architecture-for-regression-tasks | <p>so I'm working on a Project where I want to predict the Vehicle Position from the Vehicle Data like speed, acceleration etc.. now the data that I have comes also with a timestamp for each sample ( I mean that I have also a timestamp feature).</p>
<p>at first I thought that I should get rid of that timestamp feature... | 29 | |
neural network architectures | How can we derive a Convolution Neural Network from a more generic Graph Neural Network? | https://ai.stackexchange.com/questions/24891/how-can-we-derive-a-convolution-neural-network-from-a-more-generic-graph-neural | <p>Convolution Neural Network (CNNs) operate over strict grid-like structures (<span class="math-container">$M \times N \times C$</span> images), whereas Graph Neural Networks (GNNs) can operate over all-flexible graphs, with an undefined number of neighbors and edges.</p>
<p>On the face of it, GNNs appear to be neural... | <p>Yes, a CNN can be formalized as a specific kind of GNN where nodes are connected together in a 2D lattice structure and the outer edge is padded with zeros. Down-sampling techniques or pooling layers are an additional operation which remove edge nodes or low activation nodes. Convolutional layers act in the same man... | 30 |
neural network architectures | Is it possible that a deep neural network, with some variations, can be used for multiple tasks? | https://ai.stackexchange.com/questions/34019/is-it-possible-that-a-deep-neural-network-with-some-variations-can-be-used-for | <p>I am asking this question on deep neural network architectures only. If you want to restrict the domain of tasks then you can choose computer vision for this question.</p>
<p>Suppose there is an architecture that performs well on a task. Is it possible can edit or append the first or last few layers and then it perf... | 31 | |
neural network architectures | Is a basic neural network architecture better with small datasets? | https://ai.stackexchange.com/questions/18439/is-a-basic-neural-network-architecture-better-with-small-datasets | <p>I'm currently trying to predict 1 output value with 52 input values. The problem is that I only have around 100 rows of data that I can use. </p>
<p>Will I get more accurate results when I use a small architecture than when I use multiple layers with a higher amount of neurons? </p>
<p>Right now, I use 1 hidden la... | <p>I'm not aware of a direct way for finding the best NN architecture for a given task, but the recommended way, as far as I know, is to devise a network that can overfit the training data, and then apply regularization on top of it.</p>
<p>That way, you can be almost sure you're not underfitting/underperforming due to... | 32 |
neural network architectures | Is traditional machine learning obsolete given that neural networks typically outperform them? | https://ai.stackexchange.com/questions/18085/is-traditional-machine-learning-obsolete-given-that-neural-networks-typically-ou | <p>I have been coming across visualizations showing that the neural nets tend to perform better as compared to the traditional machine learning algorithms (Linear regression, Log regression, etc.)</p>
<p>Assuming that we have sufficient data to train deep/neural nets, can we ignore the traditional machine learning top... | <p>"Assuming that we have sufficient data..." — that's quite a big assumption. Also, traditional methods are well understood, while neural networks (and especially deep learning) is still something of a black box: you train it, and then you get a mapping from input to output. But you don't really know how tha... | 33 |
neural network architectures | Trying to understand VGG convolution neural networks architecture | https://ai.stackexchange.com/questions/4711/trying-to-understand-vgg-convolution-neural-networks-architecture | <p>Trying to understand the VGG architecture and I have these following questions.</p>
<ol>
<li>I understand the general understanding of increasing filter size is because we are using max pooling and so its image size gets reduced. So in order to keep information gain, we increase filter size. But the last few layers... | <p>Good questions. Let me reply one by one.</p>
<p>1- Filter size can be increased. There is no limit for it. However, think two cases:</p>
<ul>
<li>DNN part. Shape will be 1024 x 7 x 7 and it will map to 4096 features, it will cause 204M parameters at dense_1 layer. This change will cause two possible problem. Overf... | 34 |
neural network architectures | How to identify too small network in reinforcement learning? | https://ai.stackexchange.com/questions/10210/how-to-identify-too-small-network-in-reinforcement-learning | <p>I am using <a href="https://github.com/pytorch/examples/blob/master/reinforcement_learning/actor_critic.py" rel="nofollow noreferrer">Open AI's</a> code to do a RL task on an environment that I built myself.</p>
<p>I tried some network architectures, and they all converge, faster or slower on CartPole.</p>
<p>On m... | <h1>Check the function loss.</h1>
<p>It might be that your environment is impossible to learn. However, most likely the network simply can't handle it. By measuring the loss during the learning stage, if you find it is always very high and does not decrease, it's a strong indication this might be the issue.</p>
<p>Beca... | 35 |
neural network architectures | How to justify the chosen neural architecture? | https://ai.stackexchange.com/questions/35873/how-to-justify-the-chosen-neural-architecture | <p>I had a task to implement a neural network that would carry out multiclass classification of traffic by several parameters. On the advice of colleagues, I chose the "Multilayer Perceptron" architecture. One of these days I will have a defense of my work, but I absolutely do not understand how to answer the... | <p>This is a very general question, so I'll just point to a reference that should be a good starting point. <a href="https://arxiv.org/abs/1810.07906" rel="nofollow noreferrer">Deep Learning for Encrypted Traffic Classification: An Overview</a> seems to contain exactly what you're looking for:</p>
<blockquote>
<p>Sever... | 36 |
neural network architectures | Distributions over outputs for randomly initialized neural networks | https://ai.stackexchange.com/questions/37128/distributions-over-outputs-for-randomly-initialized-neural-networks | <p>Does anyone have any pointers to resources about the properties of randomly initialized neural networks (with no training)? I'm guessing this might depend on the network architecture and initialization scheme, but I'm most interested in properties that seem to be mostly true across architectures and initializations.... | 37 | |
neural network architectures | Alternatives to brute forcing neural network plateau | https://ai.stackexchange.com/questions/37716/alternatives-to-brute-forcing-neural-network-plateau | <p>Below is the loss of the same training run at different scales illustrating the plateau phenomenon.
<img src="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb7759d9f-88f2-4a96-a38a-82e281b74... | <p>I think the primary solution to plateauing is improving the dataset.</p>
<p>The iteration process should be</p>
<ol>
<li>Train the neural network</li>
<li>Identify what properties are causing the neural network to plateau.</li>
<li>Gather more data, improve the targets, argument the existing dataset, to target these... | 38 |
neural network architectures | Are there transformer-based architectures that can produce fixed-length vector encodings given arbitrary-length text documents? | https://ai.stackexchange.com/questions/23611/are-there-transformer-based-architectures-that-can-produce-fixed-length-vector-e | <p><a href="https://arxiv.org/abs/1810.04805" rel="nofollow noreferrer">BERT</a> encodes a piece of text such that each token (usually words) in the input text map to a vector in the encoding of the text. However, this makes the length of the encoding vary as a function of the input length of the text, which makes it m... | <p>One way you could do it is by using <strong>SentenceTransformers</strong>.</p>
<blockquote>
<p>SentenceTransformers is a Python framework for state-of-the-art
sentence, text and image embeddings. The initial work is described in
our paper <a href="https://arxiv.org/abs/1908.10084" rel="nofollow noreferrer">Sentence-... | 39 |
neural network architectures | How to Handle Masked Values in Neural Networks for Geospatial Data? | https://ai.stackexchange.com/questions/47006/how-to-handle-masked-values-in-neural-networks-for-geospatial-data | <p>I am working on neural networks for oceanographic data and face challenges in dealing with masked values, which I set to NaN.. I can train a neural network model with 1D vertical profiles (e.g. temperature and salinity at different depths in the ocean) and 2D ocean surface data (e.g. sea surface temperature), where<... | 40 | |
neural network architectures | What activation functions are better for what problems? | https://ai.stackexchange.com/questions/17526/what-activation-functions-are-better-for-what-problems | <p>I’ve been reading about neural network architectures. In certain cases, people say that the sigmoid "more accurately reflects real-life" and, in other cases, functions like hard limits reflect "the brain neural networks more accurately". </p>
<p>What activation functions are better for what problems?</p>
| 41 | |
neural network architectures | Which neural network should I use to approximate a specific but unknown function? | https://ai.stackexchange.com/questions/9319/which-neural-network-should-i-use-to-approximate-a-specific-but-unknown-function | <p>We have convolutional neural networks and recurrent neural networks for analyzing, respectively, images and sequential data.</p>
<p>Now, suppose I want to approximate the unknown function <span class="math-container">$f(x,y) = \sin(2\pi x)\sin(2\pi y)$</span>, with domain <span class="math-container">$\Omega = [0,1]... | <p>If the concept class specified is</p>
<p><span class="math-container">$$f(x, y) = k \, \sin(2 \pi f_x x) \, sin(2 \pi f_y y) \\ \land 0 < x < 1 \\ \land 0 < y < 1 \; \text{,}$$</span></p>
<p>and the optimum fit to example data is expected occur when <span class="math-container">$k \approx 1 \land f_x \... | 42 |
neural network architectures | Which neural network can count the number of objects in an image? | https://ai.stackexchange.com/questions/11139/which-neural-network-can-count-the-number-of-objects-in-an-image | <p>I'm looking for a neural network architecture that excels in counting objects. For example, CNN that can output the number of balls (or any other object) in a given image.</p>
<p>I already found articles about crowd counting. I'm looking for articles about different types of objects.</p>
| <p>If you want to count the number of objects using a neural network, you can use pretrained YOLO with the bottom prediction layer removed, and feed the features to a classification feed forward layer of let's say 1000 class representing 0-999 objects in the image. You can then train it and propagate the gradients thro... | 43 |
neural network architectures | What are the aspects that most impact on the inference time for neural networks in embedded systems? | https://ai.stackexchange.com/questions/10418/what-are-the-aspects-that-most-impact-on-the-inference-time-for-neural-networks | <p>I work with neural networks for real-time image processing on embedded softwares and I tested different architectures (Googlenet, Mobilenet, Resnet, custom networks...) and different hardware solutions (boards, processors, AI accelerators...). I noticed that the performance of the system, in terms of inference time,... | <p>You can expect that the inference time will strongly depend on particular hardware and software present on your platform. First, GPU equipped devices (eg NVidia TX) will outperform non-GPU equipped devices (eg. Intel Movidius). Second, software support (eg. cudnn, TensorRT) will make dramatic further impact. </p>
<... | 44 |
neural network architectures | Applications of one-to-one recurrent networks | https://ai.stackexchange.com/questions/35155/applications-of-one-to-one-recurrent-networks | <p>I'm studying recurrent neural networks. Reading <a href="https://stanford.edu/%7Eshervine/teaching/cs-230/cheatsheet-recurrent-neural-networks" rel="nofollow noreferrer">this page</a> where it lists different types of recurrent network architectures, I think think of applications involving one-to-many (speech/senten... | 45 | |
neural network architectures | Principles of designing a neural network | https://ai.stackexchange.com/questions/36326/principles-of-designing-a-neural-network | <p>I have become more familiar with libraries such as tensorflow for a while now, and have become interested in utilizing neural networks for solving specific problems. The big question I have is, what are some principles that you have to take into account for designing your neural networks architecture?</p>
<p>Some ot... | <p>Designing neural network architectures from scratch for harder tasks is work usually performed by entire research groups (whether academic or business). There are, however, some things to keep in mind:</p>
<ul>
<li><p>Deeper networks have more abstraction, but also higher complexity. This means they can learn more c... | 46 |
neural network architectures | How can a Regression based Neural Network learn class thresholds? | https://ai.stackexchange.com/questions/41461/how-can-a-regression-based-neural-network-learn-class-thresholds | <p>I understand that to solve multilabel classification problems, we can use the softmax activation function in the output layer of the neural network. The softmax function outputs probabilities of each label, and the label with highest probability is then predicted as the target label.
However, I just saw in a researc... | <p>First thing to notice, is that the assumptions on the target don't match the ones of multi-classifications: in particular, in multi-class classification, it's generally assumed that any other class outside the target one, is equally bad.</p>
<p>Instead here, it's clear that this is not true:<br />
<a href="https://i... | 47 |
neural network architectures | What is the potential issue of nested neural networks | https://ai.stackexchange.com/questions/42777/what-is-the-potential-issue-of-nested-neural-networks | <p>everyone. I am working on a nested neural network architecture. For the sake of better understanding my question, simply assume the loss is</p>
<p><span class="math-container">$L = G(k’) - H(k'')$</span></p>
<p>where <span class="math-container">$G$</span> and <span class="math-container">$H$</span> are two function... | <p>Isn't this just a very short recurrent neural network? Same issues apply, although they are less severe since you aren't applying as many recurrent iterations. Once you start "nesting" them more, most typical issues are vanishing and exploding gradients.</p>
| 48 |
neural network architectures | Is the size of a neural network directly linked with an increase in its inteligence? | https://ai.stackexchange.com/questions/22469/is-the-size-of-a-neural-network-directly-linked-with-an-increase-in-its-intelige | <p>Just came across <a href="https://www.gwern.net/newsletter/2020/05#gpt-3" rel="nofollow noreferrer">this article on GPT-3</a>, and that lead me to the question:</p>
<p>In order to make a certain kind of neural network architecture smarter all one needs to do is to make it bigger?</p>
<p>Also, if that is true, how do... | <p>First of all, there is no real 'intelligence' innate to artificial Neural Networks (NNs).
All they do is trying to approximate a mathematical function with a certain degree of generalization (hopefully without learning a given dataset by heart, i.e. hopefully without <em>overfitting</em>).</p>
<p>The more nodes (or ... | 49 |
attention mechanism | What is the intuition behind the attention mechanism? | https://ai.stackexchange.com/questions/21389/what-is-the-intuition-behind-the-attention-mechanism | <blockquote>
<p><a href="https://medium.com/saarthi-ai/transformers-attention-based-seq2seq-machine-translation-a28940aaa4fe" rel="noreferrer">Attention</a> idea is one of the most influential ideas in deep learning. The main idea behind attention technique is that it allows the decoder to "look back” at the complete... | <p>Simply put, the attention mechanism is loosely inspired on well, attention. Consider we are attempting machine translation on the following sentence: "The dog is a Labrador." If you were to ask someone to pick out the key words of the sentence, i.e. which ones encode the most meaning, they would likely say "dog" and... | 50 |
attention mechanism | A mathematical explanation of Attention Mechanism | https://ai.stackexchange.com/questions/12313/a-mathematical-explanation-of-attention-mechanism | <p>I am trying to understand why attention models are different than just using neural networks. Essentially the optimization of weights or using gates for protecting and controlling cell state (in recurrent networks), should eventually lead to the network focusing on certain parts of the input/source. So what is atten... | <p>There's plenty, but keep in mind that these articles do not describe the same approach. They simply have attention shifting automation as part of their approaches and therefore must detect a need for shift and execute it in a way that improves speed, accuracy, reliability or some combination of them.</p>
<p>There i... | 51 |
attention mechanism | How to use RNN With Attention Mechanism on Non Textual Data? | https://ai.stackexchange.com/questions/10010/how-to-use-rnn-with-attention-mechanism-on-non-textual-data | <p>Recurrent Neural Networks (RNN) With Attention Mechanism is generally used for Machine Translation and Natural Language Processing. In Python, implementation of RNN With Attention Mechanism is abundant in Machine Translation (For Eg. <a href="https://talbaumel.github.io/blog/attention/" rel="nofollow noreferrer">htt... | <p><strong>Project Definition</strong></p>
<ul>
<li>Labelled data set contains 21 K rows; 1,936 features; and 1 textual label</li>
<li>Label can be 1 of 14 possible categories</li>
<li>The first feature is a time stamp reflecting exact or approximate 10 minute sampling period</li>
<li>Data content not primarily natural... | 52 |
attention mechanism | How do autoregressive attention mechanism work in multi-headed attention? | https://ai.stackexchange.com/questions/28113/how-do-autoregressive-attention-mechanism-work-in-multi-headed-attention | <p>[LONG POST!!] I am working on a DNN model that works as an improviser to generate music sequences. The idea of generating music is based on taking a sequence of music nodes (their index representation) and generating sequences that are distinctive with more context and coherent structure as well as capturing syntact... | 53 | |
attention mechanism | Probability interpretation of attention mechanism in Seq2Seq | https://ai.stackexchange.com/questions/45853/probability-interpretation-of-attention-mechanism-in-seq2seq | <p>I have ready many explanations of the seq2seq model. In my opinion, however, it is really like a robot that might say something correctly, but doesn't really understand it, just as is true with an LLM generally.</p>
<p>In my opinion, the correct way to describe Seq2Seq and similar NLP models should start from a prob... | <p>Pretty much anything can be interpreted as a distribution or some kind of energy model, that doesn't mean that everything is the same</p>
<p>First of all, the softmax output of a Seq2Seq is just a formalization of the categorical distribution with which we model our problem</p>
<p>Attention in other hand is more com... | 54 |
attention mechanism | Can the attention mechanism improve the performance in the case of short sequences? | https://ai.stackexchange.com/questions/25253/can-the-attention-mechanism-improve-the-performance-in-the-case-of-short-sequenc | <p>I am aware that the attention mechanism can be used to deal with long sequences, where problems related to gradient vanishing and, more generally, representing effectively the whole sequence arise.</p>
<p>However, I was wondering if attention, applied either to seq2seq RNN/GRU/LSTM or via Transformers, can contribut... | <p>They shouldn't have any issues with short sequences, as short dependencies are easier to learn. The only difficult cases are long dependencies which is where most of the research is geared at. However, this is assuming that by "short sequence" you mean a sequence of text that is fully contained within itse... | 55 |
attention mechanism | How is visual attention mechanism different from a two branch convolutional neural network? | https://ai.stackexchange.com/questions/21211/how-is-visual-attention-mechanism-different-from-a-two-branch-convolutional-neur | <p>I am doing some research on the visual attention mechanism in remote sensing domain (where the features learnt from one layer are highlighted using the attention mask derived from another layer). From what I have observed, the attention mask is learnt in a similar fashion as any other branch in CNN. So, what is so s... | 56 | |
attention mechanism | Does transformers' self-attention mechanism process tokens independently, or entire sequence at a time? | https://ai.stackexchange.com/questions/43820/does-transformers-self-attention-mechanism-process-tokens-independently-or-ent | <p>About attention: the Query, Key and Value vectors (before the linear transformations) are just the entire sequence, that is being inputted, or just each token? Chat-GPT nor Youtube didn't give me a clear answer. But, I thought. If we feed in each sequence straight into the Attention mechanism, then the linear layers... | <p>TL;DR YES.</p>
<hr />
<p>If the sequence length of <span class="math-container">$Q, K, V$</span> is <span class="math-container">$L$</span>, the embedding size is <span class="math-container">$E$</span>, and the number of heads is <span class="math-container">$H$</span>, then weight matrices are of the order <span c... | 57 |
attention mechanism | Is there any evidence that the bias terms help in the attention mechanism of the transformers? | https://ai.stackexchange.com/questions/38983/is-there-any-evidence-that-the-bias-terms-help-in-the-attention-mechanism-of-the | <p>In the <a href="https://arxiv.org/pdf/1706.03762.pdf" rel="nofollow noreferrer">original transformer paper</a>, the attention mechanism uses parameter matrices, but no bias terms. However, in more recent implementations I see people often using a bias term when computing "key", "query", and "... | <p>I guess that bias terms have the ability to increase the expression power of the model.According to the paper:"BitFit: Simple Parameter-efficient Fine-tuning for Transformer-based Masked Language-models".</p>
| 58 |
attention mechanism | Couldn't the self-attention mechanism be replaced with a global depth-wise convolution? | https://ai.stackexchange.com/questions/30169/couldnt-the-self-attention-mechanism-be-replaced-with-a-global-depth-wise-convo | <p>The main advantages of the self-attention mechanism are:</p>
<ul>
<li>Ability to capture long-range dependencies</li>
<li>Ease to parallelize on GPU or TPU</li>
</ul>
<p>However, I wonder why the same goals cannot be achieved by <em>global depthwise convolution</em> (with the kernel size equal to the length of the i... | 59 | |
attention mechanism | Attention mechanism: Why apply multiple different transformations to obtain query, key, value | https://ai.stackexchange.com/questions/29989/attention-mechanism-why-apply-multiple-different-transformations-to-obtain-quer | <p>I have two questions about the structure of attention modules:</p>
<p>Since I work with imagery I will be talking about using convolutions on feature maps in order to obtain attention maps.</p>
<ol>
<li><p>If we have a set of feature maps with dimensions [B, C, H, W] (batch, channel, height, width), why do we transf... | <p>I assume you're talking about this design: (<a href="https://lilianweng.github.io/lil-log/2018/06/24/attention-attention.html" rel="nofollow noreferrer">image source</a>)
<a href="https://i.sstatic.net/U1ATS.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/U1ATS.png" alt="SAGAN attention network" /></a... | 60 |
attention mechanism | Why do the values in the cross attentional mechanism within a transformer come from the encoder and not from the decoder? | https://ai.stackexchange.com/questions/38340/why-do-the-values-in-the-cross-attentional-mechanism-within-a-transformer-come-f | <p>The transformer architecture contains a cross attention mechanism which is enriching the encoder with information from the decoder. The place where this takes place is visualized in the image below:</p>
<p><a href="https://i.sstatic.net/L3ifH.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/L3ifH.jpg" ... | <blockquote>
<p>The transformer architecture contains a cross attention mechanism which is
enriching the encoder with information from the decoder. The place where this
takes place is visualized in the image below:</p>
</blockquote>
<p>I think that you got it the other way round. The encoder passes an enriched input se... | 61 |
attention mechanism | Using similarity score within lstm embedding for attention based mechanism | https://ai.stackexchange.com/questions/36922/using-similarity-score-within-lstm-embedding-for-attention-based-mechanism | <p>Yesterday, I found <a href="https://pubmed.ncbi.nlm.nih.gov/34150797/" rel="nofollow noreferrer">this</a> fascinating paper about predicting various clinical conditions using an attention based LSTM. I don't have any practical experience with attention mechanism or transformers, which might be the reason why I strug... | 62 | |
attention mechanism | How are the intuitions and mathematics of attention mechanisms related to those of PageRank? | https://ai.stackexchange.com/questions/40425/how-are-the-intuitions-and-mathematics-of-attention-mechanisms-related-to-those | <p>Excuse me if you find this question too vague and not fitting to this forum and feel free to close it. The overall goal of my question is to get a better intuition of the attention concept and mechanism.</p>
<p>There is a high-level analogy between attention mechanisms (to be specific: in the transformer) and Google... | <p>Peter,</p>
<p>A very interesting observation indeed.</p>
<p>Let's narrow down from top to bottom into the cone of understanding (the depth of your understanding represents the narrower cross-section).</p>
<p>When you are at the highest (biggest cross-section) it's easy to confuse (or understand) the concept of the t... | 63 |
attention mechanism | Is Softmax Necessary as the Activation Function for Self-Attention Mechanisms? | https://ai.stackexchange.com/questions/43048/is-softmax-necessary-as-the-activation-function-for-self-attention-mechanisms | <p>I’m curious about the mathematical reasoning behind the use of the softmax function as the activation function in self-attention mechanisms within neural networks. Specifically, I’m interested in understanding if there is a theoretical basis that necessitates the use of softmax over other activation functions.</p>
<... | <p>Softmax was first used for its properties, as it is differentiable, has not domain problem even though it has a division, and it's gradient is well behaved (and in conjunction with Categorical Cross Entropy it gets simplified a lot becoming linear)</p>
<p>In the case of attention, many of such properties do not hold... | 64 |
attention mechanism | Why are biases (typically) not used in attention mechanism? | https://ai.stackexchange.com/questions/40252/why-are-biases-typically-not-used-in-attention-mechanism | <p>Watching <a href="https://youtu.be/kCc8FmEb1nY?t=4767" rel="noreferrer">this video</a> implementing attention in a transformer. He set query, key, and value biases to <code>False</code> and said "Typically, people don't use biases for these".</p>
<p>Even in <a href="https://pytorch.org/docs/stable/_modules... | <p>For certain types of layers, such as transformers and convolutional layers, including a bias term is unnecessary and adds unnecessary overhead to the model.</p>
<p>The reason for this is that these layers are typically followed by a normalization layer, such as Batch Normalization or Layer Normalization. These norma... | 65 |
attention mechanism | In the multi-head attention mechanism of the transformer, why do we need both $W_i^Q$ and ${W_i^K}^T$? | https://ai.stackexchange.com/questions/25217/in-the-multi-head-attention-mechanism-of-the-transformer-why-do-we-need-both-w | <p>In the <a href="https://arxiv.org/pdf/1706.03762.pdf" rel="nofollow noreferrer">Attention is all you need</a> paper, on the 4th page, we have equation 1, which describes the self-attention mechanism of the transformer architecture</p>
<p><span class="math-container">$$
\text { Attention }(Q, K, V)=\operatorname{soft... | <p>I'll use notation from the paper you cited, and any other readers should refer to the paper (widely available) for definitions of notation. The utility of using <span class="math-container">$W^Q$</span> and <span class="math-container">$W^K$</span>, rather than <span class="math-container">$W$</span>, lies in the f... | 66 |
attention mechanism | In the attention mechanism, why don't we normalize after multiplying values? | https://ai.stackexchange.com/questions/40244/in-the-attention-mechanism-why-dont-we-normalize-after-multiplying-values | <p>As this <a href="https://ai.stackexchange.com/q/21237/23811">question</a> says:</p>
<blockquote>
<p>In scaled dot product attention, we scale our outputs by dividing the
dot product by the square root of the dimensionality of the matrix:</p>
<p><a href="https://i.sstatic.net/wLI4m.png" rel="nofollow noreferrer"><img... | <p>Because what attention does is to control how much of the information in <span class="math-container">$V$</span> to use based on weights computed through the similarity between <span class="math-container">$Q$</span> and <span class="math-container">$K$</span>.</p>
<p>When we multiply the attention weights by <span ... | 67 |
attention mechanism | What is different in each head of a multi-head attention mechanism? | https://ai.stackexchange.com/questions/25148/what-is-different-in-each-head-of-a-multi-head-attention-mechanism | <p>I have a difficult time understanding the "multi-head" notion in the original <a href="https://papers.nips.cc/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf" rel="noreferrer">transformer paper</a>. What makes the learning in each head unique? Why doesn't the neural network learn the same set of... | <p>The reason each head is different is because they each learn a different set of weight matrices <span class="math-container">$\{ W_i^Q, W_i^K, W_i^V \}$</span> where <span class="math-container">$i$</span> is the index of the head. To clarify, the input to each attention head is the same. For attention head <span cl... | 68 |
attention mechanism | How to Interpret Cross Attention | https://ai.stackexchange.com/questions/45543/how-to-interpret-cross-attention | <p>I am a bit confused on what cross attention mechanisms are doing. I understand that the currently decoded output is usually the query and the conditioning/input (from an encoder) is the key and value. The query is multiplied by the key to make an attention matrix that details how much each element of the currently d... | 69 | |
attention mechanism | Difference between dot product attention and "matrix attention" | https://ai.stackexchange.com/questions/40082/difference-between-dot-product-attention-and-matrix-attention | <p>As far as I know, attention was first introduced in <a href="https://arxiv.org/abs/1409.0473" rel="nofollow noreferrer">Learning To Align And Translate</a>.</p>
<p>There, the core mechanism which is able to disregard the sequence length, is a dynamically-built matrix, of shape output_size X input_size, in which ever... | <p>The key difference between the attention mechanisms used in "Learning To Align And Translate" and "Attention Is All You Need" lies in the way that the similarity between the query and key vectors is calculated.</p>
<h3>"Learning To Align And Translate"</h3>
<p>The attention score is cal... | 70 |
attention mechanism | What is the purpose of "alignment" in the self-attention mechanism of transformers? | https://ai.stackexchange.com/questions/26184/what-is-the-purpose-of-alignment-in-the-self-attention-mechanism-of-transforme | <p>I've been reading about transformers & have been having some difficulty understanding the concept of <em>alignment</em>.</p>
<p>Based on this <a href="https://towardsdatascience.com/attn-illustrated-attention-5ec4ad276ee3#16cb" rel="nofollow noreferrer">article</a></p>
<blockquote>
<p>Alignment means matching se... | <h3>Alignment:</h3>
<p>We all know that a good translation cannot be done just by splitting words, converting them, and concatenating them back. Otherwise, a dictionary would be just enough. One translation problem is on the <strong>alignment</strong> of the words.
For example:</p>
<pre><code>Uma maçã grande e vermelha... | 71 |
attention mechanism | Autoregressive Models(LLM) inference Prediction | https://ai.stackexchange.com/questions/47124/autoregressive-modelsllm-inference-prediction | <p>So while predicting the next word in autoregressive models(LLM) will the attention mechanism use queries from starting word or only previous word. Like for predicting after sentence "I love" attention mechanism takes query value for I and love and after predicting lets say as pizza, the next word attention... | <p>During inference, autoregressive models predicts text one token at a time sequentially. At each prediction step, attention mechanism takes query from only the current token and scores with all previous tokens' keys to compute a (softmax) weighted sum of the values associated with each of these previous tokens as out... | 72 |
attention mechanism | Can Self Attention capture rate of change of token? | https://ai.stackexchange.com/questions/48398/can-self-attention-capture-rate-of-change-of-token | <p>From what I understand, the self-attention mechanism captures the dependency of a given token on various other tokens in a sequence. Inspired by nature, where natural laws are often expressed in terms of differential equations, I wonder: Does self-attention also capture relationships analogous to the rate of change ... | <p>The self-attention mechanism in transformers does not explicitly compute derivatives or model rates of change in the strict mathematical sense of differential equations. However, it captures relationships between tokens analogous to a rate of change. Multiple attention layers can be interpreted as discrete steps in ... | 73 |
attention mechanism | Understanding CNN+LSTM concept with attention and need help | https://ai.stackexchange.com/questions/13507/understanding-cnnlstm-concept-with-attention-and-need-help | <p>I have a question about the context of CNN and LSTM. I have trained a CNN network for image classification. However, I would like to combine it with LSTM for visualizing the attention weights. So, I extracted the features from the CNN to put it into LSTM. However, I am stuck at the concept of combinating the CNN wit... | 74 | |
attention mechanism | Any comparison between transformer and RNN+Attention on the same dataset? | https://ai.stackexchange.com/questions/23898/any-comparison-between-transformer-and-rnnattention-on-the-same-dataset | <p>I am wondering what is believed to be the reason for superiority of transformer?</p>
<p>I see that some people believe because of the attention mechanism used, it’s able to capture much longer dependencies. However, as far as I know, you can use attention also with RNN architectures as in the famous paper attention... | <p>If you go through the <a href="https://arxiv.org/pdf/1706.03762.pdf" rel="nofollow noreferrer">main introductory paper of the transformer</a> ("Attention is all you need"), you can find the comparison of the model with other state-of-the-art machine translation method:</p>
<p><a href="https://i.sstatic.net... | 75 |
attention mechanism | Is the multi-head attention in the transformer a weighted adjacency matrix? | https://ai.stackexchange.com/questions/32036/is-the-multi-head-attention-in-the-transformer-a-weighted-adjacency-matrix | <p>Are multi-head attention matrices weighted adjacency matrices?</p>
<p>The job of the multi-head-attention mechanism in transformer models is to determine how likely a word is to appear after another word. In a sense this makes the resulting matrix a big graph with nodes and edges, where a node represents a word and ... | <p>Short answer, yes I believe we can! One way feels more meaningful that the other. First, let's look at some nuance in the definition of attention. If <span class="math-container">$\text{score}(x_i, x_j) = \text{score}(x_j, x_i)$</span>, then the attention matrix is symmetric and naturally has the form of a weighted ... | 76 |
attention mechanism | Recent deep learning textbook (i.e. covering at least GANs, LSTM and transformers and attention) | https://ai.stackexchange.com/questions/25329/recent-deep-learning-textbook-i-e-covering-at-least-gans-lstm-and-transformer | <p>I am searching for an academic (i.e. with maths formulae) textbook which covers (at least) the following:</p>
<ul>
<li>GAN</li>
<li>LSTM and transformers (e.g. seq2seq)</li>
<li>Attention mechanism</li>
</ul>
<p>The closest match I got is <em>Deep Learning</em> (2016, MIT Press) but it only deals with part of the ab... | <p>There are a few more books that were published after 2016 that cover some of the topics you are interested in. I've not read any of them, so I don't really know whether they are good or not, but I try to summarise if they cover some of the topics you may be interested in.</p>
<ul>
<li><p><a href="http://faculty.neu.... | 77 |
attention mechanism | Why does the BERT encoder have an intermediate layer between the attention and neural network layers with a bigger output? | https://ai.stackexchange.com/questions/11235/why-does-the-bert-encoder-have-an-intermediate-layer-between-the-attention-and-n | <p>I am reading the BERT paper <a href="https://arxiv.org/pdf/1810.04805.pdf" rel="nofollow noreferrer">BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding</a>.</p>
<p>As I look at the attention mechanism, I don't understand why in the BERT encoder we have an intermediate layer between the... | <p>The paper <a href="https://arxiv.org/abs/2012.11881" rel="nofollow noreferrer">Undivided Attention: Are Intermediate Layers Necessary for BERT?</a> should answer it.</p>
<p>In the abstract, they write</p>
<blockquote>
<p>All BERT-based architectures have a self-attention block followed by a block of intermediate lay... | 78 |
attention mechanism | Why do we need cosine positional encoding in multi-head attention based transformer? | https://ai.stackexchange.com/questions/47763/why-do-we-need-cosine-positional-encoding-in-multi-head-attention-based-transfor | <p>My understanding is that all tokens are passed to a transformer at once, and positional encodings help it understand their order in the sequence. And cosine type of positional encoding helps capture the short-term and long-term dependencies between the tokens (this is due to different frequencies for the cosine func... | <p>Your intuition is right when you use causal language models like GPTs which can learn sequence implicitly, positional encodings (PE) could further reduce the learning burden by injecting sequence order explicitly. However, attention mechanism itself is <a href="https://en.wikipedia.org/wiki/Attention_(machine_learni... | 79 |
attention mechanism | Are there any advantages of the local attention against convolutions? | https://ai.stackexchange.com/questions/28599/are-there-any-advantages-of-the-local-attention-against-convolutions | <p>Transformer architectures, based on the self-attention mechanism, have achieved outstanding performance in a variety of applications.</p>
<p>The main advantage of this approach is that the given token can interact with any token in the input sequence and extract global information since the first layer, whereas CNN ... | <p>It is true that when using local attention with a window of size 5, the "receptive field" is the same as a CNN with kernel size 5 (or two CNN layers with kernel size 3). However, there is a key difference in how the learned weights are applied to the inputs.</p>
<p><strong>In a CNN</strong>, the values of ... | 80 |
attention mechanism | Can transformer attention make predictions based on analogy? | https://ai.stackexchange.com/questions/45866/can-transformer-attention-make-predictions-based-on-analogy | <p>Suppose I have included 3 examples of an idiosyncratic sentence for training by a transformer:</p>
<ul>
<li>Example 1: <strong>Asdfogiug likes Zsdfoiusdhf and Zsdfoiusdhf likes Asdfogiug too.</strong></li>
<li>Example 2: <strong>Bsodifhas likes Zsdfoiusdhf and Zsdfoiusdhf likes Bsodifhas too.</strong></li>
<li>Examp... | <p>To complete the pattern based on the given examples, the last statement should follow the same structure. Each example follows a clear pattern where the second person in the first part of the sentence is mirrored as the first person in the second part:</p>
<ol>
<li>Asdfogiug likes Zsdfoiusdhf and Zsdfoiusdhf likes A... | 81 |
attention mechanism | How to understand the matrices used in the Attention layer? | https://ai.stackexchange.com/questions/21588/how-to-understand-the-matrices-used-in-the-attention-layer | <p>Attention-scoring mechanism seems to be a commonly-used component in various seq2seq models, and I was reading about the original "Location-based Attention" in Bahadanau well-known paper at <a href="https://arxiv.org/pdf/1506.07503.pdf" rel="nofollow noreferrer">https://arxiv.org/pdf/1506.07503.pdf</a>. (it seems th... | 82 | |
attention mechanism | Why is there a shared matrix W in graph attention networks instead of the query-key-value trio like in regular transformers? | https://ai.stackexchange.com/questions/42292/why-is-there-a-shared-matrix-w-in-graph-attention-networks-instead-of-the-query | <p>In section 2.1 of the <a href="https://arxiv.org/pdf/1710.10903.pdf" rel="nofollow noreferrer">Graph attention network paper</a></p>
<p>The graph attention layer is described as</p>
<blockquote>
<p>as an initial step, a shared
linear transformation, parametrized by a weight matrix, W ∈ RF ′×F , is applied to every n... | <p>To my understanding, there isn't any theoretical reason why the query, key and values weights are absent.</p>
<blockquote>
<p>I feel that the difference may lie in the way the additive attention is calculated vs the dot-product one.</p>
</blockquote>
<p>In the equations for the Graph Attention Network (GAT), there i... | 83 |
attention mechanism | When do we apply a mask onto our padded values during attention mechanisms | https://ai.stackexchange.com/questions/41062/when-do-we-apply-a-mask-onto-our-padded-values-during-attention-mechanisms | <p>When we are applying a mask onto the padded values in an input sequence, it is typically done through setting the padded values as negative infinity. For example, a tensor of values <code>[1,2,3,0,0]</code> should result in a padding mask of <code>pad_mask = [True, True, True, False, False]</code> (or the opposite d... | <p>You are masking at the wrong place. Masking happens before the sequence goes into the encoder/decoder layer depending on what kind of architecture you are using. It happens right after you calculate the embeddings using positional encoding + token encodings.</p>
<p>This is because the masked positions are also consi... | 84 |
attention mechanism | What is a neuron in large language models? | https://ai.stackexchange.com/questions/40385/what-is-a-neuron-in-large-language-models | <p>I'm reading OpenAI's new paper "<a href="https://openaipublic.blob.core.windows.net/neuron-explainer/paper/index.html" rel="nofollow noreferrer">Language models can explain neurons in language models</a>" And I can't fully understand the concept of neurons here.</p>
<p>Can you please explain it? Is it rela... | <p>It seems that in this paper neuron means the perceptrons in the MLP layers of the transformer.</p>
| 85 |
attention mechanism | Attention with Recurrent Neural Networks | https://ai.stackexchange.com/questions/43660/attention-with-recurrent-neural-networks | <p>In RNNs, to avoid "forgetting" information encoded by earlier encoders, we can use attention. It's basically a second neural network that tells us how much we should attend at time <em>t</em> on each of the earlier hidden states (from <em>1</em> to <em>t - 1</em>).
This is described here:
<a href="https://... | <p>You don't need padding for attention with variable-length inputs. Looking at the formulation in the article:
<a href="https://i.sstatic.net/u6VTP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/u6VTP.png" alt="Attention description from article: https://medium.com/swlh/a-simple-overview-of-rnn-lstm-an... | 86 |
attention mechanism | Is it possible to express attention as a Fourier convolution? | https://ai.stackexchange.com/questions/23699/is-it-possible-to-express-attention-as-a-fourier-convolution | <p>Convolutions can be expressed as a matrix-multiplication (see e.g. <a href="https://ai.stackexchange.com/q/11172/2444">this post</a>) and as an element-wise multiplication using the Fourier domain (<a href="https://en.wikipedia.org/wiki/Convolution_theorem" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Con... | 87 | |
attention mechanism | Reasoning behind performance improvement with hopfield networks | https://ai.stackexchange.com/questions/26038/reasoning-behind-performance-improvement-with-hopfield-networks | <p>In the paper <a href="https://arxiv.org/pdf/2008.02217.pdf" rel="nofollow noreferrer">Hopfield networks is all you need</a>, the authors mention that their modern Hopfield network layers are a good replacement for pooling, GRU, LSTM, and attention layers, and tend to outperform them in various tasks.</p>
<p>I unders... | <p>Will try to formulate my understanding of the ideas in this paper, mention my own concerns that I see are relevant to your question, and see if we can identify any confusions along the way that might clarify the issue</p>
<p>On eq(6) of <a href="https://ml-jku.github.io/hopfield-layers/" rel="nofollow noreferrer">th... | 88 |
attention mechanism | How ChatGPT pass from a prompt to a predicted word? | https://ai.stackexchange.com/questions/45890/how-chatgpt-pass-from-a-prompt-to-a-predicted-word | <p>There is something that i can't get it, given a prompt input to ChatGPT, this is One Hot Encoded, Embedded, Positional Encoded and so on. Anyway we have a matrix, still after attention mechanism we have a matrix, how we end with a probability vector and not with a probability matrix?</p>
| <p>Once the last level of the <a href="https://paperswithcode.com/method/multi-head-attention" rel="nofollow noreferrer"><em>multi-head attention</em></a> mechanism returns its output, the matrix is flattened in an array and sent as input to a <em><a href="https://pytorch.org/docs/stable/generated/torch.nn.Linear.html#... | 89 |
attention mechanism | Are single-head and multi-head attention equivalent in terms of input and output? | https://ai.stackexchange.com/questions/47156/are-single-head-and-multi-head-attention-equivalent-in-terms-of-input-and-output | <p>So I'm trying to write PyTorch code that performs the single-head computation, so you get some input vectors, attention mechanism/linear transformations, some output vectors.</p>
<p>Then I tried to re-use the same matrices by splitting them up into submatrices and get the same output vectors by using a 2-head attent... | <p>Your approach of splitting the same matrices into submatrices for different heads and then concatenating together as output doesn't work as intended because each head in multi-head attention should have distinct learnable weight matrices which enable each head to focus on different aspects of the input sequence. Sim... | 90 |
attention mechanism | How are the parameters $\alpha_i$ of hard attention trained? | https://ai.stackexchange.com/questions/25828/how-are-the-parameters-alpha-i-of-hard-attention-trained | <p>I have a question about <a href="http://proceedings.mlr.press/v37/xuc15.pdf" rel="nofollow noreferrer">Show, Attend and Tell: Neural Image CaptionGeneration with Visual Attention</a> paper by Xu. The basic mechanism of stochastic hard attention is that each pixel of the input image has a corresponding parameter <spa... | 91 | |
attention mechanism | Do RNNs/LSTMs really need to be sequential? | https://ai.stackexchange.com/questions/27171/do-rnns-lstms-really-need-to-be-sequential | <p>There are many articles comparing RNNs/LSTMs and the Attention mechanism. One of the disadvantages of RNNs that is often mentioned is that while Attention can be computed in parallel, RNNs are highly sequential. That is, the computation of the next tokens depends on the result of previous tokens, thus, RNNs are losi... | <p>You are talking about model parallelism. But, that's not the reason RNNs/LSTMs are not in vogue.</p>
<p>Imagine your ability to read the first line of a page and going on reading and still making connections to the first line until the end of the page.</p>
<p>Can RNNs/LSTMs do that? No.
Can Attention (i.e. Transform... | 92 |
attention mechanism | What is the internal state of a Simple Neural Attentive Meta-Learner(SNAIL)? | https://ai.stackexchange.com/questions/11557/what-is-the-internal-state-of-a-simple-neural-attentive-meta-learnersnail | <p>In the paper <a href="https://openreview.net/pdf?id=B1DmUzWAW" rel="nofollow noreferrer">A Simple Neural Attentive Meta-Learner</a>, the authors mentioned right before Section 3.1:</p>
<blockquote>
<p>we preserve the internal state of a SNAIL across episode boundaries, which allows it to have memory that spans mu... | <p>Here's what I understand, welcome to point out any mistakes.</p>
<p>When starting a new episode(but still in the same task), SNAIL does not clear its batches. Instead, it makes decisions based on the current observation and observation-action pairs from the previous episode. In this way, it keeps knowledge of the p... | 93 |
attention mechanism | Why does a transformer not use an activation function following the multi-head attention layer? | https://ai.stackexchange.com/questions/30341/why-does-a-transformer-not-use-an-activation-function-following-the-multi-head-a | <p>I was hoping someone could explain to me why in the transformer model from the "Attention is all you need" paper there is no activation applied after both the multihead attention layer and to the residual connections. It seems to me that there are multiple linear layers in a row, and I have always been un... | <p>This goes back to the purpose of self-attention. While the Vaswani et als Attention is All You Need paper does not explicitly define self-attention, I am using it here as being synonymous to what it refers to as scaled dot-product attention when all three inputs are identical.</p>
<p>Measure between word-vectors is ... | 94 |
attention mechanism | How the Q,K,V be calculated in multi-head attention | https://ai.stackexchange.com/questions/45329/how-the-q-k-v-be-calculated-in-multi-head-attention | <p>I want to understand the transformer architecture, so I start with self attention and I understand their mechanism, but when I pass to the multi-head attention I find some difficulties like how calculate Q , K and V for each head.
I find many way to calculate Q , K and V but I don't know which way is correct.<br>
<... | <p>As far as I understand your question, you have problems with multiple heads. Let's take the input <span class="math-container">$\mathbf{Q}$</span> (with dimension: <span class="math-container">$\textit{seq_length}$</span> x <span class="math-container">$d_{model}$</span>), which is the same for <span class="math-con... | 95 |
attention mechanism | Understanding self attention - How come there is no connection between different states? | https://ai.stackexchange.com/questions/39891/understanding-self-attention-how-come-there-is-no-connection-between-different | <p>During trying to understand transformers by reading <a href="https://arxiv.org/abs/1706.03762" rel="nofollow noreferrer">Attention is all you need</a>, I noticed the authors constantly refer to "self attention" without explaining it.</p>
<p>The original attention mechanism is introduced in <a href="https:/... | <blockquote>
<ol>
<li>Is this really the self attention mentioned throughout "attention is all you need"?</li>
</ol>
</blockquote>
<p>I think that the crucial point that you are missing is the difference between the Transformer architecture and recurrent neural network (RNN) architecture.</p>
<p>In the RNNs t... | 96 |
attention mechanism | Does Number of Fully connected neural networks changes in transformer architechture based on max length input size? | https://ai.stackexchange.com/questions/40173/does-number-of-fully-connected-neural-networks-changes-in-transformer-architecht | <p>Considering the architecture of encoder and decoder in transformer as shown below:
<a href="https://i.sstatic.net/4pAzL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/4pAzL.png" alt="enter image description here" /></a></p>
<ul>
<li><strong>Does each input token after self attention mechanism (z1,z2,... | <ul>
<li>the z’s are stacked and then passed to a single feed forward layer</li>
<li>the difference in shapes of inputs is resolved by padding to the dimension of the model</li>
</ul>
| 97 |
attention mechanism | What is the difference between Squeeze-and-excite and bottleneck modules from Mobilenet v2? | https://ai.stackexchange.com/questions/14009/what-is-the-difference-between-squeeze-and-excite-and-bottleneck-modules-from-mo | <p><a href="https://arxiv.org/pdf/1709.01507.pdf" rel="nofollow noreferrer">Squezee-and-excite networks</a> introduced SE blocks, while <a href="https://arxiv.org/pdf/1801.04381.pdf" rel="nofollow noreferrer">MobileNet v2</a> introduced linear bottlenecks.</p>
<p>What is the effective difference between these two conc... | 98 | |
attention mechanism | What is the Essence of Memory of ANNs and Brain? | https://ai.stackexchange.com/questions/42478/what-is-the-essence-of-memory-of-anns-and-brain | <p>I am learning Computational Neuroscience. If I do reasoning in my mind, especially Classifying an object and Deducing to figure out its qualities, I have to memorize the category and the category's definition, qualities in the past.</p>
<p>So what are the Essence and foundations of Memory in ANNs and the Brain? Memo... | <p>I may not be able to fully address your question but I want to provide some comparisons between ANNs and the Brain.</p>
<ol>
<li><strong>Plasticity.</strong> The brain can adapt/grow/remove its connections among neurons as required. For example, learning a new skill (like playing a new instrument) causes the grow of... | 99 |
transformer models | How do transformer models handle negation in sentiment analysis | https://ai.stackexchange.com/questions/46067/how-do-transformer-models-handle-negation-in-sentiment-analysis | <p>I'm trying to understand how transformer models, such as BERT or GPT, handle negation in sentiment analysis. Specifically, I'm curious about how these models manage to correctly interpret sentences where negation changes the sentiment, such as "The movie is not good."</p>
<p>A simple model using word embed... | <p>To answer this question, it makes sense to go over how multi-headed self attention works. Say we have 2 heads defined as follows (I am leaving small details out for simplicity):</p>
<p><span class="math-container">$$W_q^1, W_k^1, \text{ and } W_v^1$$</span></p>
<p><span class="math-container">$$W_q^2, W_k^2, \text{ ... | 100 |
transformer models | How do Transformer models ensure unique token representations when combining embeddings and positional encodings? | https://ai.stackexchange.com/questions/46205/how-do-transformer-models-ensure-unique-token-representations-when-combining-emb | <p>In Transformer models, token embeddings are combined with positional encodings through element-wise addition to incorporate positional information. However, this raises a concern about the potential for different tokens in different positions to end up with identical embeddings.</p>
<p>For example, consider the foll... | <p>Positional Encoding (PE) is a broad term encompassing various techniques meant to embed positional information within a matrix <span class="math-container">$x \in \mathbb{R}^{S \times d_{\text{model}}}$</span>, where <span class="math-container">$S$</span> is the number of tokens, and <span class="math-container">$d... | 101 |
transformer models | Why (not) using pre-processing before using Transformer models? | https://ai.stackexchange.com/questions/27009/why-not-using-pre-processing-before-using-transformer-models | <p>Regarding the use of pre-processing techniques before using Transformers models, I read <a href="https://stackoverflow.com/a/63986348/13745968">this post</a> that apparently says that these measures are not so necessary nor interfere so much in the final result.</p>
<p>The arguments raised seemed to me quite convinc... | 102 | |
transformer models | Are transformer models better than comparable-complexity MLP-based models? | https://ai.stackexchange.com/questions/40686/are-transformer-models-better-than-comparable-complexity-mlp-based-models | <p>I've watched the outstanding Andrej Karpathy's <a href="https://www.youtube.com/watch?v=VMj-3S1tku0&list=PLAqhIrjkxbuWI23v9cThsA9GvCAUhRvKZ&index=1&t=0s" rel="nofollow noreferrer">From Zero to Hero course</a>. In the last lecture, he introduces Transformer decoder architecture, which is able to produce S... | <p>I can't provide you with numbers and results, but I'd expect (for not triavial problems) the MLP-based model to be worse than a Transformer.</p>
<p>The reason is that transformers are designed to handle sequences, whereas MLP are not (even if you flatten the entire sequence into a vector). Trasformers can leverage a... | 103 |
transformer models | Where should we place layer normalization in a transformer model? | https://ai.stackexchange.com/questions/16835/where-should-we-place-layer-normalization-in-a-transformer-model | <p>In <a href="https://proceedings.neurips.cc/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf" rel="nofollow noreferrer">Attention Is All You Need</a> paper:</p>
<blockquote>
<p>That is, the output of each sub-layer is <span class="math-container">$LayerNorm(x+Sublayer(x))$</span>, where <span class="math-co... | 104 | |
transformer models | How does positional encoding work in the transformer model? | https://ai.stackexchange.com/questions/18437/how-does-positional-encoding-work-in-the-transformer-model | <p>In the transformer model, to incorporate positional information of texts, the researchers have added a positional encoding to the model. <em>How does positional encoding work? How does the positional encoding system learn the positions when varying lengths and types of text are passed at different time intervals?</e... | 105 | |
transformer models | Is Positional Encoding always needed for using Transformer models correctly? | https://ai.stackexchange.com/questions/32396/is-positional-encoding-always-needed-for-using-transformer-models-correctly | <p>I am trying to make a model that uses a <em>Transformer</em> to see the relationship between several data vectors, but the order of the data is not relevant in this case, so I am not using the <em>Positional Encoding</em>.</p>
<p>Since the performance of models using Transformers is quite improved with the use of th... | <p>Positional Encodings in Transformers exist to give the model some information about the position of the embedding. This makes sense in fields like NLP or Time Series Data, since the position(order) matters in this case.</p>
<p>However, since you say that order of the data is not relevant in your use case, positional... | 106 |
transformer models | How can BERT/Transformer models accept input batches of different sizes? | https://ai.stackexchange.com/questions/41858/how-can-bert-transformer-models-accept-input-batches-of-different-sizes | <p>I understand that all inputs in a batch need to be of the same size. However, it seems BERT/Transformers models can accept batches with different sizes as input.</p>
<p>How is that possible? I thought we needed to pad all examples in a batch to <code>model.max_input_size</code>, however, it seems HuggingFace does <c... | <p>The reason why you want to pad at all is because you want to stuff everything into giant matrix multiplies. GPUs are great at parallelizing these operations. Instead of running e.g., <span class="math-container">$Wx_i + b$</span> 32 times, you can run <span class="math-container">$W X + b$</span> a single time, wher... | 107 |
transformer models | Dimensions of a Transformer model and purpose of masking | https://ai.stackexchange.com/questions/34760/dimensions-of-a-transformer-model-and-purpose-of-masking | <p>I'm currently studying the Transformer model (<strong>Attention is all you need</strong>) and after reading it I still have some questions for which I get conflicting answers if I google them:</p>
<ul>
<li>What exactly are the dimensions of the input to the encoder of a transformer, from what I've seen you can input... | <p>Transformer networks are great, because they can handle variable length inputs, but they also have limitations, concerning the input size. For example BERT (a transformer based language model) only accepts <span class="math-container">$N = 512$</span> input tokens at most. They way transformer models can accept sequ... | 108 |
transformer models | "Following instructions" as an emergent behaviour in transformer models - isn't this fundamentally different from the models' basic purpose? | https://ai.stackexchange.com/questions/38973/following-instructions-as-an-emergent-behaviour-in-transformer-models-isnt | <p>I am not technically familiar with AI or neural networks beyond a tech news reading level of knowledge, so I apologise if this is a dumb question.</p>
<p>I was recently reading <a href="https://arstechnica.com/gadgets/2023/01/the-generative-ai-revolution-has-begun-how-did-we-get-here/3/" rel="nofollow noreferrer">th... | 109 | |
transformer models | How transformer models can imitate characters? | https://ai.stackexchange.com/questions/47813/how-transformer-models-can-imitate-characters | <p>So I was experimenting with the Llama and Mistral models, and using "talk like a viking" in the system prompt caused the model to resemble a viking or similar. How they know that? This was on a instruct version of these models. Here is a example output from Hugging Face spaces, when I asked about the plane... | <p>The ability of models like Llama and Mistral to "talk like a Viking" when prompted with phrases like "talk like a viking" stems from the transformer's self-attention training process, where they <em>implicitly</em> learn patterns in the data including various styles and tones using their pretrain... | 110 |
transformer models | Which situation will helpful using encoder or decoder or both in transformer model? | https://ai.stackexchange.com/questions/41505/which-situation-will-helpful-using-encoder-or-decoder-or-both-in-transformer-mod | <p>I have some questions about using (encoder / decoder / encoder-decoder) transformer models, included (language) transformer or Vision transformer.</p>
<p>The overall form of a transformer consists of an encoder and a decoder. Depending on the model, you may use only the encoder, only the decoder, or both. However, f... | <p>The <a href="https://arxiv.org/abs/1706.03762" rel="noreferrer">original transformer paper</a> presents the transformer as a model consisting of both encoder and decoder. However, many times you will see (or hear) people describing their model as a "transformer model", but it actually consists only of an e... | 111 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.