diff --git "a/data.json" "b/data.json" new file mode 100644--- /dev/null +++ "b/data.json" @@ -0,0 +1,16002 @@ +[ + [ + { + "context": "Could a paradox kill an AI? In Portal 2 we see that AI's can be \"killed\" by thinking about a paradox.\n\nI assume this works by forcing the AI into an infinite loop which would essentially \"freeze\" the computer's consciousness.\nQuestions: \n\nWould this confuse the AI technology we have today to the point of destroying it? \nIf so, why? \nAnd if not, could it be possible in the future?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This classic problem exhibits a basic misunderstanding of what an artificial general intelligence would likely entail. First, consider this programmer's joke:\n\nThe programmer's wife couldn't take it anymore. Every discussion with her husband turned into an argument over semantics, picking over every piece of trivial detail. One day she sent him to the grocery store to pick up some eggs. On his way out the door, she said, \"While you are there, pick up milk.\"\nAnd he never returned.\n\nIt's a cute play on words, but it isn't terribly realistic.\nYou are assuming because AI is being executed by a computer, it must exhibit this same level of linear, unwavering pedantry outlined in this joke. But AI isn't simply some long-winded computer program hard-coded with enough if-statements and while-loops to account for every possible input and follow the prescribed results.\nwhile (command not completed)\n find solution()\n\nThis would not be strong AI.\nIn any classic definition of artificial general intelligence, you are creating a system that mimics some form of cognition that exhibits problem solving and adaptive learning (\u2190note this phrase here). I would suggest that any AI that could get stuck in such an \"infinite loop\" isn't a learning AI at all. It's just a buggy inference engine.\nEssentially, you are endowing a program of currently-unreachable sophistication with an inability to postulate if there is a solution to a simple problem at all. I can just as easily say \"walk through that closed door\" or \"pick yourself up off the ground\" or even \"turn on that pencil\" \u2014 and present a similar conundrum.\n\n\"Everything I say is false.\" \u2014 The Liar's Paradox\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How could self-driving cars make ethical decisions about who to kill? Obviously, self-driving cars aren't perfect, so imagine that the Google car (as an example) got into a difficult situation.\nHere are a few examples of unfortunate situations caused by a set of events:\n\nThe car is heading toward a crowd of 10 people crossing the road, so it cannot stop in time, but it can avoid killing 10 people by hitting the wall (killing the passengers),\nAvoiding killing the rider of the motorcycle considering that the probability of survival is greater for the passenger of the car,\nKilling an animal on the street in favour of a human being,\nPurposely changing lanes to crash into another car to avoid killing a dog,\n\nAnd here are a few dilemmas:\n\nDoes the algorithm recognize the difference between a human being and an animal?\nDoes the size of the human being or animal matter?\nDoes it count how many passengers it has vs. people in the front?\nDoes it \"know\" when babies/children are on board?\nDoes it take into the account the age (e.g. killing the older first)?\n\nHow would an algorithm decide what it should do from the technical perspective? Is it being aware of above (counting the probability of kills), or not (killing people just to avoid its own destruction)? \nRelated articles:\n\nWhy Self-Driving Cars Must Be Programmed to Kill\nHow to Help Self-Driving Cars Make Ethical Decisions\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nHow could self-driving cars make ethical decisions about who to kill?\n\nIt shouldn't. Self-driving cars are not moral agents. Cars fail in predictable ways. Horses fail in predictable ways. \n\nthe car is heading toward a crowd of 10 people crossing the road, so\n it cannot stop in time, but it can avoid killing 10 people by hitting\n the wall (killing the passengers),\n\nIn this case, the car should slam on the brakes. If the 10 people die, that's just unfortunate. We simply cannot trust all of our beliefs about what is taking place outside the car. What if those 10 people are really robots made to look like people? What if they're trying to kill you?\n\navoiding killing the rider of the motorcycle considering that the\n probability of survival is greater for the passenger of the car,\n\nAgain, hard-coding these kinds of sentiments into a vehicle opens the rider of the vehicle up to all kinds of attacks, including \"fake\" motorcyclists. Humans are barely equipped to make these decisions on their own, if at all. When it doubt, just slam on the brakes.\n\nkilling animal on the street in favour of human being,\n\nAgain, just hit the brakes. What if it was a baby? What if it was a bomb?\n\nchanging lanes to crash into another car to avoid killing a dog,\n\nNope. The dog was in the wrong place at the wrong time. The other car wasn't. Just slam on the brakes, as safely as possible.\n\nDoes the algorithm recognize the difference between a human being and an animal?\n\nDoes a human? Not always. What if the human has a gun? What if the animal has large teeth? Is there no context?\n\n\nDoes the size of the human being or animal matter?\nDoes it count how many passengers it has vs. people in the front?\nDoes it \"know\" when babies/children are on board?\nDoes it take into the account the age (e.g. killing the older first)?\n\n\nHumans can't agree on these things. If you ask a cop what to do in any of these situations, the answer won't be, \"You should have swerved left, weighed all the relevant parties in your head, assessed the relevant ages between all parties, then veered slightly right, and you would have saved 8% more lives.\" No, the cop will just say, \"You should have brought the vehicle to a stop, as quickly and safely as possible.\" Why? Because cops know people normally aren't equipped to deal with high-speed crash scenarios.\nOur target for \"self-driving car\" should not be 'a moral agent on par with a human.' It should be an agent with the reactive complexity of cockroach, which fails predictably.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can neural networks deal with varying input sizes? As far as I can tell, neural networks have a fixed number of neurons in the input layer.\nIf neural networks are used in a context like NLP, sentences or blocks of text of varying sizes are fed to a network. \nHow is the varying input size reconciled with the fixed size of the input layer of the network? In other words, how is such a network made flexible enough to deal with an input that might be anywhere from one word to multiple pages of text?\nIf my assumption of a fixed number of input neurons is wrong and new input neurons are added to/removed from the network to match the input size I don't see how these can ever be trained.\nI give the example of NLP, but lots of problems have an inherently unpredictable input size. I'm interested in the general approach for dealing with this.\nFor images, it's clear you can up/downsample to a fixed size, but, for text, this seems to be an impossible approach since adding/removing text changes the meaning of the original input.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Three possibilities come to mind.\nThe easiest is the zero-padding. Basically, you take a rather big input size and just add zeroes if your concrete input is too small. Of course, this is pretty limited and certainly not useful if your input ranges from a few words to full texts.\nRecurrent NNs (RNN) are a very natural NN to choose if you have texts of varying size as input. You input words as word vectors (or embeddings) just one after another and the internal state of the RNN is supposed to encode the meaning of the full string of words. This is one of the earlier papers.\nAnother possibility is using recursive NNs. This is basically a form of preprocessing in which a text is recursively reduced to a smaller number of word vectors until only one is left - your input, which is supposed to encode the whole text. This makes a lot of sense from a linguistic point of view if your input consists of sentences (which can vary a lot in size), because sentences are structured recursively. For example, the word vector for \"the man\", should be similar to the word vector for \"the man who mistook his wife for a hat\", because noun phrases act like nouns, etc. Often, you can use linguistic information to guide your recursion on the sentence. If you want to go way beyond the Wikipedia article, this is probably a good start.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Do scientists know what is happening inside artificial neural networks? Do scientists or research experts know from the kitchen what is happening inside complex \"deep\" neural network with at least millions of connections firing at an instant? Do they understand the process behind this (e.g. what is happening inside and how it works exactly), or it is a subject of debate?\nFor example this study says:\n\nHowever there is no clear understanding of why they perform so well, or how they might be improved.\n\nSo does this mean that scientists actually don't know how complex convolutional network models work?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are many approaches that aim to make a trained neural network more interpretable and less like a \"black box\", specifically convolutional neural networks that you've mentioned.\nVisualizing the activations and layer weights\nActivations visualization is the first obvious and straight-forward one. For ReLU networks, the activations usually start out looking relatively blobby and dense, but as the training progresses the activations usually become more sparse (most values are zero) and localized. This sometimes shows what exactly a particular layer is focused on when it sees an image.\nAnother great work on activations that I'd like to mention is deepvis that shows reaction of every neuron at each layer, including pooling and normalization layers. Here's how they describe it:\n\nIn short, we\u2019ve gathered a few different methods that allow you to\n \u201ctriangulate\u201d what feature a neuron has learned, which can help you\n better understand how DNNs work.\n\nThe second common strategy is to visualize the weights (filters). These are usually most interpretable on the first CONV layer which is looking directly at the raw pixel data, but it is possible to also show the filter weights deeper in the network. For example, the first layer usually learns gabor-like filters that basically detect edges and blobs.\n\nOcclusion experiments\nHere's the idea. Suppose that a ConvNet classifies an image as a dog. How can we be certain that it\u2019s actually picking up on the dog in the image as opposed to some contextual cues from the background or some other miscellaneous object? \nOne way of investigating which part of the image some classification prediction is coming from is by plotting the probability of the class of interest (e.g. dog class) as a function of the position of an occluder object. \nIf we iterate over regions of the image, replace it with all zeros and check the classification result, we can build a 2-dimensional heat map of what's most important for the network on a particular image. This approach has been used in Matthew Zeiler\u2019s Visualizing and Understanding Convolutional Networks (that you refer to in your question):\n\nDeconvolution\nAnother approach is to synthesize an image that causes a particular neuron to fire, basically what the neuron is looking for. The idea is to compute the gradient with respect to the image, instead of the usual gradient with respect to the weights. So you pick a layer, set the gradient there to be all zero except for one for one neuron and backprop to the image. \nDeconv actually does something called guided backpropagation to make a nicer looking image, but it's just a detail.\nSimilar approaches to other neural networks\nHighly recommend this post by Andrej Karpathy, in which he plays a lot with Recurrent Neural Networks (RNN). In the end, he applies a similar technique to see what the neurons actually learn:\n\nThe neuron highlighted in this image seems to get very excited about\n URLs and turns off outside of the URLs. The LSTM is likely using this\n neuron to remember if it is inside a URL or not.\n\nConclusion\nI've mentioned only a small fraction of results in this area of research. It's pretty active and new methods that shed light to the neural network inner workings appear each year.\nTo answer your question, there's always something that scientists don't know yet, but in many cases they have a good picture (literary) of what's going on inside and can answer many particular questions. \nTo me the quote from your question simply highlights the importance of research of not only accuracy improvement, but the inner structure of the network as well. As Matt Zieler tells in this talk, sometimes a good visualization can lead, in turn, to better accuracy.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is self-supervised learning in machine learning? What is self-supervised learning in machine learning? How is it different from supervised learning?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Introduction\nThe term self-supervised learning (SSL) has been used (sometimes differently) in different contexts and fields, such as representation learning [1], neural networks, robotics [2], natural language processing, and reinforcement learning. In all cases, the basic idea is to automatically generate some kind of supervisory signal to solve some task (typically, to learn representations of the data or to automatically label a dataset).\nI will describe what SSL means more specifically in three contexts: representation learning, neural networks and robotics.\nRepresentation learning\nThe term self-supervised learning has been widely used to refer to techniques that do not use human-annotated datasets to learn (visual) representations of the data (i.e. representation learning).\nExample\nIn [1], two patches are randomly selected and cropped from an unlabelled image and the goal is to predict the relative position of the two patches. Of course, we have the relative position of the two patches once you have chosen them (i.e. we can keep track of their centers), so, in this case, this is the automatically generated supervisory signal. The idea is that, to solve this task (known as a pretext or auxiliary task in the literature [3, 4, 5, 6]), the neural network needs to learn features in the images. These learned representations can then be used to solve the so-called downstream tasks, i.e. the tasks you are interested in (e.g. object detection or semantic segmentation).\nSo, you first learn representations of the data (by SSL pre-training), then you can transfer these learned representations to solve a task that you actually want to solve, and you can do this by fine-tuning the neural network that contains the learned representations on a labeled (but smaller dataset), i.e. you can use SSL for transfer learning.\nThis example is similar to the example given in this other answer.\nNeural networks\nSome neural networks, for example, autoencoders (AE) [7] are sometimes called self-supervised learning tools. In fact, you can train AEs without images that have been manually labeled by a human. More concretely, consider a de-noising AE, whose goal is to reconstruct the original image when given a noisy version of it. During training, you actually have the original image, given that you have a dataset of uncorrupted images and you just corrupt these images with some noise, so you can calculate some kind of distance between the original image and the noisy one, where the original image is the supervisory signal. In this sense, AEs are self-supervised learning tools, but it's more common to say that AEs are unsupervised learning tools, so SSL has also been used to refer to unsupervised learning techniques.\nRobotics\nIn [2], the training data is automatically but approximately labeled by finding and exploiting the relations or correlations between inputs coming from different sensor modalities (and this technique is called SSL by the authors). So, as opposed to representation learning or auto-encoders, in this case, an actual labeled dataset is produced automatically.\nExample\nConsider a robot that is equipped with a proximity sensor (which is a short-range sensor capable of detecting objects in front of the robot at short distances) and a camera (which is long-range sensor, but which does not provide a direct way of detecting objects). You can also assume that this robot is capable of performing odometry. An example of such a robot is Mighty Thymio.\nConsider now the task of detecting objects in front of the robot at longer ranges than the range the proximity sensor allows. In general, we could train a CNN to achieve that. However, to train such CNN, in supervised learning, we would first need a labelled dataset, which contains labelled images (or videos), where the labels could e.g. be \"object in the image\" or \"no object in the image\". In supervised learning, this dataset would need to be manually labelled by a human, which clearly would require a lot of work.\nTo overcome this issue, we can use a self-supervised learning approach. In this example, the basic idea is to associate the output of the proximity sensors at a time step $t' > t$ with the output of the camera at time step $t$ (a smaller time step than $t'$).\nMore specifically, suppose that the robot is initially at coordinates $(x, y)$ (on the plane), at time step $t$. At this point, we still do not have enough info to label the output of the camera (at the same time step $t$). Suppose now that, at time $t'$, the robot is at position $(x', y')$. At time step $t'$, the output of the proximity sensor will e.g. be \"object in front of the robot\" or \"no object in front of the robot\". Without loss of generality, suppose that the output of the proximity sensor at $t' > t$ is \"no object in front of the robot\", then the label associated with the output of the camera (an image frame) at time $t$ will be \"no object in front of the robot\".\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is it possible that deep neural networks are so easily fooled? The following page/study demonstrates that the deep neural networks are easily fooled by giving high confidence predictions for unrecognisable images, e.g.\n\n\nHow this is possible? Can you please explain ideally in plain English?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First up, those images (even the first few) aren't complete trash despite being junk to humans; they're actually finely tuned with various advanced techniques, including another neural network.\n\nThe deep neural network is the pre-trained network modeled on AlexNet provided by Caffe. To evolve images, both the directly encoded and indirectly encoded images, we use the Sferes evolutionary framework. The entire code base to conduct the evolutionary experiments can be download [sic] here. The code for the images produced by gradient ascent is available here.\n\nImages that are actually random junk were correctly recognized as nothing meaningful:\n\nIn response to an unrecognizable image, the networks could have output a low confidence for each of the 1000 classes, instead of an extremely high confidence value for one of the classes. In fact, they do just that for randomly generated images (e.g. those in generation 0 of the evolutionary run)\n\nThe original goal of the researchers was to use the neural networks to automatically generate images that look like the real things (by getting the recognizer's feedback and trying to change the image to get a more confident result), but they ended up creating the above art. Notice how even in the static-like images there are little splotches - usually near the center - which, it's fair to say, are triggering the recognition.\n\nWe were not trying to produce adversarial, unrecognizable images. Instead, we were trying to produce recognizable images, but these unrecognizable images emerged.\n\nEvidently, these images had just the right distinguishing features to match what the AI looked for in pictures. The \"paddle\" image does have a paddle-like shape, the \"bagel\" is round and the right color, the \"projector\" image is a camera-lens-like thing, the \"computer keyboard\" is a bunch of rectangles (like the individual keys), and the \"chainlink fence\" legitimately looks like a chain-link fence to me.\n\nFigure 8. Evolving images to match DNN classes produces a tremendous diversity of images. Shown are images selected to showcase diversity from 5 evolutionary runs. The diversity suggests that the images are non-random, but that instead evolutions producing [sic] discriminative features of each target class.\n\nFurther reading: the original paper (large PDF)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does the transformer do better than RNN and LSTM in long-range context dependencies? I am reading the article How Transformers Work where the author writes\n\nAnother problem with RNNs, and LSTMs, is that it\u2019s hard to parallelize the work for processing sentences, since you have to process word by word. Not only that but there is no model of long and short-range dependencies. \n\nWhy exactly does the transformer do better than RNN and LSTM in long-range context dependencies?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I'll list some bullet points of the main innovations introduced by transformers , followed by bullet points of the main characteristics of the other architectures you mentioned, so we can then compared them.\nTransformers\nTransformers (Attention is all you need) were introduced in the context of machine translation with the purpose to avoid recursion in order to allow parallel computation (to reduce training time) and also to reduce drops in performance due to long dependencies. The main characteristics are:\n\nNon sequential: sentences are processed as a whole rather than word by word.\nSelf Attention: this is the newly introduced 'unit' used to compute similarity scores between words in a sentence.\nPositional embeddings: another innovation introduced to replace recurrence. The idea is to use fixed or learned weights which encode information related to a specific position of a token in a sentence.\n\nThe first point is the main reason why transformer do not suffer from long dependency issues. The original transformers do not rely on past hidden states to capture dependencies with previous words. They instead process a sentence as a whole. That is why there is no risk to lose (or \"forget\") past information. Moreover, multi-head attention and positional embeddings both provide information about the relationship between different words.\nRNN / LSTM\nRecurrent neural networks and Long-short term memory models, for what concerns this question, are almost identical in their core properties:\n\nSequential processing: sentences must be processed word by word.\nPast information retained through past hidden states: sequence to sequence models follow the Markov property: each state is assumed to be dependent only on the previously seen state.\n\nThe first property is the reason why RNN and LSTM can't be trained in parallel. In order to encode the second word in a sentence I need the previously computed hidden states of the first word, therefore I need to compute that first. The second property is a bit more subtle, but not hard to grasp conceptually. Information in RNN and LSTM are retained thanks to previously computed hidden states. The point is that the encoding of a specific word is retained only for the next time step, which means that the encoding of a word strongly affects only the representation of the next word, so its influence is quickly lost after a few time steps. LSTM (and also GruRNN) can boost a bit the dependency range they can learn thanks to a deeper processing of the hidden states through specific units (which comes with an increased number of parameters to train) but nevertheless the problem is inherently related to recursion. Another way in which people mitigated this problem is to use bi-directional models. These encode the same sentence from the start to end, and from the end to the start, allowing words at the end of a sentence to have stronger influence in the creation of the hidden representation. However, this is just a workaround rather than a real solution for very long dependencies.\nCNN\nAlso convolutional neural networks are widely used in nlp since they are quite fast to train and effective with short texts. The way they tackle dependencies is by applying different kernels to the same sentence, and indeed since their first application to text (Convolutional Neural Networks for Sentence Classification) they were implement as multichannel CNN. Why do different kernels allow to learn dependencies? Because a kernel of size 2 for example would learn relationships between pairs of words, a kernel of size 3 would capture relationships between triplets of words and so on. The evident problem here is that the number of different kernels required to capture dependencies among all possible combinations of words in a sentence would be enormous and unpractical because of the exponential growing number of combinations when increasing the maximum length size of input sentences.\nTo summarize, Transformers are better than all the other architectures because they totally avoid recursion, by processing sentences as a whole and by learning relationships between words thanks to multi-head attention mechanisms and positional embeddings. Nevertheless, it must be pointed out that also transformers can capture only dependencies within the fixed input size used to train them, i.e. if I use as a maximum sentence size 50, the model will not be able to capture dependencies between the first word of a sentence and words that occur more than 50 words later, like in another paragraph. New transformers like Transformer-XL tries to overcome exactly this issue, by kinda re-introducing recursion by storing hidden states of already encoded sentences to leverage them in the subsequent encoding of the next sentences.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do we need explainable AI? If the original purpose for developing AI was to help humans in some tasks and that purpose still holds, why should we care about its explainability? For example, in deep learning, as long as the intelligence helps us to the best of their abilities and carefully arrives at its decisions, why would we need to know how its intelligence works?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As argued by Selvaraju et al., there are three stages of AI evolution, in which interpretability is helpful.\n\nIn the early stages of AI development, when AI is weaker than human performance, transparency can help us build better models. It can give a better understanding of how a model works and helps us answer several key questions. For example, why a model works in some cases and doesn't in others, why some examples confuse the model more than others, why these types of models work and the others don't, etc.\n\nWhen AI is on par with human performance and ML models are starting to be deployed in several industries, it can help build trust for these models. I'll elaborate a bit on this later, because I think that it is the most important reason.\n\nWhen AI significantly outperforms humans (e.g. AI playing chess or Go), it can help with machine teaching (i.e. learning from the machine on how to improve human performance on that specific task).\n\n\nWhy is trust so important?\nFirst, let me give you a couple of examples of industries where trust is paramount:\n\nIn healthcare, imagine a Deep Neural Net performing diagnosis for a specific disease. A classic black box NN would just output a binary \"yes\" or \"no\". Even if it could outperform humans in sheer predictability, it would be utterly useless in practice. What if the doctor disagreed with the model's assessment, shouldn't he know why the model made that prediction; maybe it saw something the doctor missed. Furthermore, if it made a misdiagnosis (e.g. a sick person was classified as healthy and didn't get the proper treatment), who would take responsibility: the model's user? the hospital? the company that designed the model? The legal framework surrounding this is a bit blurry.\n\nAnother example is self-driving cars. The same questions arise: if a car crashes, whose fault is it: the driver's? the car manufacturer's? the company that designed the AI? Legal accountability, is key for the development of this industry.\n\n\nIn fact, according to many, this lack of trust has hindered the adoption of AI in many fields (sources: [1], [2], [3]). While there is a running hypothesis that with more transparent, interpretable or explainable systems users will be better equipped to understand and therefore trust the intelligent agents (sources: [4], [5], [6]).\nIn several real-world applications, you can't just say \"it works 94% of the time\". You might also need to provide a justification...\nGovernment regulations\nSeveral governments are slowly proceeding to regulate AI and transparency seems to be at the center of all of this.\nThe first to move in this direction is the EU, which has set several guidelines where they state that AI should be transparent (sources: [7], [8], [9]). For instance, the GDPR states that if a person's data has been subject to \"automated decision-making\" or \"profiling\" systems, then he has a right to access\n\n\"meaningful information about the logic involved\"\n\n(Article 15, EU GDPR)\nNow, this is a bit blurry, but there is clearly the intent of requiring some form of explainability from these systems. The general idea the EU is trying to pass is that \"if you have an automated decision-making system affecting people's lives then they have a right to know why a certain decision has been made.\" For example, a bank has an AI accepting and declining loan applications, then the applicants have a right to know why their application was rejected.\nTo sum up...\nExplainable AIs are necessary because:\n\nIt gives us a better understanding, which helps us improve them.\nIn some cases, we can learn from AI how to make better decisions in some tasks.\nIt helps users trust AI, which leads to a wider adoption of AI.\nDeployed AIs in the (not too distant) future might be required to be more \"transparent\".\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is Python such a popular language in the AI field? First of all, I'm a beginner studying AI and this is not an opinion-oriented question or one to compare programming languages. I'm not implying that Python is the best language. But the fact is that most of the famous AI frameworks have primary support for Python. They can even be multilanguage supported, for example, TensorFlow that supports Python, C++, or CNTK from Microsoft that supports C# and C++, but the most used is Python (I mean more documentation, examples, bigger community, support, etc). Even if you choose C# (developed by Microsoft and my primary programming language), you must have the Python environment set up.\nI read in other forums that Python is preferred for AI because the code is simplified and cleaner, good for fast prototyping.\nI was watching a movie with AI thematics (Ex Machina). In some scenes, the main character hacks the interface of the house automation. Guess which language was on the scene? Python.\nSo, what is the big deal with Python? Why is there a growing association between Python and AI?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Python comes with a huge amount of inbuilt libraries. Many of the libraries are for Artificial Intelligence and Machine Learning. Some of the libraries are TensorFlow (which is a high-level neural network library), scikit-learn (for data mining, data analysis and machine learning), pylearn2 (more flexible than scikit-learn), etc. The list keeps going and never ends. You can find some libraries here.\nPython has an easy implementation for OpenCV. What makes Python favorite for everyone is its powerful and easy implementation.\nFor other languages, students and researchers need to get to know the language before getting into ML or AI with that language. This is not the case with Python. Even a programmer with very basic knowledge can easily handle Python. Apart from that, the time someone spends on writing and debugging code in Python is way less when compared to C, C++ or Java. This is exactly what the students of AI and ML want. They don't want to spend time on debugging the code for syntax errors, they want to spend more time on their algorithms and heuristics related to AI and ML\nNot just the libraries but their tutorials, handling of interfaces are easily available online. People build their own libraries and upload them on GitHub or elsewhere to be used by others.\nAll these features make Python suitable for them.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are neural networks prone to catastrophic forgetting? Imagine you show a neural network a picture of a lion 100 times and label it with \"dangerous\", so it learns that lions are dangerous.\nNow imagine that previously you have shown it millions of images of lions and alternatively labeled it as \"dangerous\" and \"not dangerous\", such that the probability of a lion being dangerous is 50%.\nBut those last 100 times have pushed the neural network into being very positive about regarding the lion as \"dangerous\", thus ignoring the last million lessons.\nTherefore, it seems there is a flaw in neural networks, in that they can change their mind too quickly based on recent evidence. Especially if that previous evidence was in the middle.\nIs there a neural network model that keeps track of how much evidence it has seen? (Or would this be equivalent to letting the learning rate decrease by $1/T$ where $T$ is the number of trials?)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, indeed, neural networks are very prone to catastrophic forgetting (or interference). Currently, this problem is often ignored because neural networks are mainly trained offline (sometimes called batch training), where this problem does not often arise, and not online or incrementally, which is fundamental to the development of artificial general intelligence.\nThere are some people that work on continual lifelong learning in neural networks, which attempts to adapt neural networks to continual lifelong learning, which is the ability of a model to learn from a stream of data continually, so that they do not completely forget previously acquired knowledge while learning new information. See, for example, the paper Continual lifelong learning with neural networks: A review (2019), by German I. Parisi et al., which summarises the problems and existing solutions related to catastrophic forgetting of neural networks.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are some well-known problems where neural networks don't do very well? Background: It's well-known that neural networks offer great performance across a large number of tasks, and this is largely a consequence of their universal approximation capabilities. However, in this post I'm curious about the opposite:\nQuestion: Namely, what are some well-known cases, problems or real-world applications where neural networks don't do very well?\n\nSpecification:\nI'm looking for specific regression tasks (with accessible data-sets) where neural networks are not the state-of-the-art. The regression task should be \"naturally suitable\", so no sequential or time-dependent data (in which case an RNN or reservoir computer would be more natural).\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Here's a snippet from an article by Gary Marcus \n\nIn particular, they showed that standard deep learning nets often fall\n apart when confronted with common stimuli rotated in three dimensional\n space into unusual positions, like the top right corner of this\n figure, in which a schoolbus is mistaken for a snowplow:\n\n.\n .\n .\nMistaking an overturned schoolbus is\n not just a mistake, it\u2019s a revealing mistake: it that shows not only\n that deep learning systems can get confused, but they are challenged\n in making a fundamental distinction known to all philosophers: the\n distinction between features that are merely contingent associations\n (snow is often present when there are snowplows, but not necessary)\n and features that are inherent properties of the category itself\n (snowplows ought other things being equal have plows, unless eg they\n have been dismantled). We\u2019d already seen similar examples with\n contrived stimuli, like Anish Athalye\u2019s carefully designed, 3-d\n printed foam covered dimensional baseball that was mistaken for an\n espresso\n\nAlcorn\u2019s results\u200a\u2014\u200asome from real photos from the natural\n world\u200a\u2014\u200ashould have pushed worry about this sort of anomaly to the top\n of the stack.\n\nPlease note that the opinions of the author are his alone and I do not necessarily share all of them with him.\nEdit: Some more fun stuff\n1) DeepMind's neural network that could play Breakout and Starcraft\nsaw a dramatic dip in performance when the paddle was moved up by a few pixels.\nSee: General Game Playing With Schema Networks\nWhile in the latter, it performed well with one race of the character but not on a different map and with different characters.\nSource\n2) \n\nAlphaZero searches just 80,000 positions per second in chess and\n 40,000 in shogi, compared to 70 million for Stockfish and 35 million\n for elmo.\n\nWhat the team at Deepmind did was to build a very good search algorithm. A search algorithm that includes the capability to remember facets of previous searches to apply better results to new searches. This is very clever; it undoubtedly has immense value in many areas, but it cannot be considered general intelligence.\nSee: AlphaZero: How Intuition Demolished Logic (Medium)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does ChatGPT retain the context of previous questions? One of the innovations with OpenAI's ChatGPT is how natural it is for users to interact with it.\nWhat is the technical enabler for ChatGPT to maintain the context of previous questions in its answers? For example, ChatGPT understands a prompt of \"tell me more\" and expands on it's previous answer.\nDoes it use activations from previous questions? Is there a separate input for the context? How does it work?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Based on an answer by OpenAI, it appears that the illusion of understanding context is created by the model's capacity to accept very long input sequences. The OpenAI FAQ states that approximately 3000 words can be given as input. This together with the fact that GPT-3 was trained to produce text that continues a given prompt could explain the context feature.\nIn practice, each prompt is probably extended with the previous outputs and prompt, as much as the input sequence length allows. So, all of the context is actually in the prompt.\nEdit 18.2.2023\nAfter spending some time with large language models and reading up the theory, I think my old answer is an understatement of ChatGPT's capabilities.\nIt is likely that there are several engineering approaches to improve the context after the maximum content length is exceeded. These include (but are probably not limited to)\n\nUsing language models to summarize the conversation thus far, and using that as context\nUsing language models to search for the relevant context from the previous discussion (can be done by embedding questions and answers and doing a distance-based lookup in vector space), and feeding those as context with clever prompting like \"If this information improves your answer, update your answer accordingly\".\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How could artificial intelligence harm us? We often hear that artificial intelligence may harm or even kill humans, so it might prove dangerous.\nHow could artificial intelligence harm us?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "tl;dr\nThere are many valid reasons why people might fear (or better be concerned about) AI, not all involve robots and apocalyptic scenarios. \nTo better illustrate these concerns, I'll try to split them into three categories.\nConscious AI\nThis is the type of AI that your question is referring to. A super-intelligent conscious AI that will destroy/enslave humanity. This is mostly brought to us by science-fiction. Some notable Hollywood examples are \"The terminator\", \"The Matrix\", \"Age of Ultron\". The most influential novels were written by Isaac Asimov and are referred to as the \"Robot series\" (which includes \"I, robot\", which was also adapted as a movie).\nThe basic premise under most of these works are that AI will evolve to a point where it becomes conscious and will surpass humans in intelligence. While Hollywood movies mainly focus on the robots and the battle between them and humans, not enough emphasis is given to the actual AI (i.e. the \"brain\" controlling them). As a side note, because of the narrative, this AI is usually portrayed as supercomputer controlling everything (so that the protagonists have a specific target). Not enough exploration has been made on \"ambiguous intelligence\" (which I think is more realistic).\nIn the real world, AI is focused on solving specific tasks! An AI agent that is capable of solving problems from different domains (e.g. understanding speech and processing images and driving and ... - like humans are) is referred to as General Artificial Intelligence and is required for AI being able to \"think\" and become conscious. \nRealistically, we are a loooooooong way from General Artificial Intelligence! That being said there is no evidence on why this can't be achieved in the future. So currently, even if we are still in the infancy of AI, we have no reason to believe that AI won't evolve to a point where it is more intelligent than humans.\nUsing AI with malicious intent\nEven though an AI conquering the world is a long way from happening there are several reasons to be concerned with AI today, that don't involve robots!\nThe second category I want to focus a bit more on is several malicious uses of today's AI. \nI'll focus only on AI applications that are available today. Some examples of AI that can be used for malicious intent:\n\nDeepFake: a technique for imposing someones face on an image a video of another person. This has gained popularity recently with celebrity porn and can be used to generate fake news and hoaxes. Sources: 1, 2, 3\nWith the use of mass surveillance systems and facial recognition software capable of recognizing millions of faces per second, AI can be used for mass surveillance. Even though when we think of mass surveillance we think of China, many western cities like London, Atlanta and Berlin are among the most-surveilled cities in the world. China has taken things a step further by adopting the social credit system, an evaluation system for civilians which seems to be taken straight out of the pages of George Orwell's 1984.\nInfluencing people through social media. Aside from recognizing user's tastes with the goal of targeted marketing and add placements (a common practice by many internet companies), AI can be used malisciously to influence people's voting (among other things). Sources: 1, 2, 3. \nHacking.\nMilitary applications, e.g. drone attacks, missile targeting systems.\n\nAdverse effects of AI\nThis category is pretty subjective, but the development of AI might carry some adverse side-effects. The distinction between this category and the previous is that these effects, while harmful, aren't done intentionally; rather they occur with the development of AI. Some examples are:\n\nJobs becoming redundant. As AI becomes better, many jobs will be replaced by AI. Unfortunately there are not many things that can be done about this, as most technological developments have this side-effect (e.g. agricultural machinery caused many farmers to lose their jobs, automation replaced many factory workers, computers did the same). \nReinforcing the bias in our data. This is a very interesting category, as AI (and especially Neural Networks) are only as good as the data they are trained on and have a tendency of perpetuating and even enhancing different forms of social biases, already existing in the data. There are many examples of networks exhibiting racist and sexist behavior. Sources: 1, 2, 3, 4.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is fuzzy logic? I'm new to A.I. and I'd like to know in simple words, what is the fuzzy logic concept? How does it help, and when is it used?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As complexity rises, precise statements lose meaning and meaningful statements lose precision. ( Lofti Zadeh ).\nFuzzy logic deals with reasoning that is approximate rather than fixed and exact. This may make the reasoning more meaningful for a human:\n\n\nFuzzy logic is an extension of Boolean logic by Lotfi Zadeh in 1965 based on the\nmathematical theory of fuzzy sets, which is a generalization of the classical set theory.\nBy introducing the notion of degree in the verification of a condition, thus enabling a\ncondition to be in a state other than true or false, fuzzy logic provides a very valuable\nflexibility for reasoning, which makes it possible to take into account inaccuracies and\nuncertainties.\nOne advantage of fuzzy logic in order to formalize human reasoning is that the rules\nare set in natural language. For example, here are some rules of conduct that a driver\nfollows, assuming that he does not want to lose his driver\u2019s licence:\n\nIntuitively, it thus seems that the input variables like in this example are approximately\nappreciated by the brain, such as the degree of verification of a condition in fuzzy\nlogic.\n\nI've written a short introduction to fuzzy logic that goes into a bit more details but should be very accessible.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between strong-AI and weak-AI? I've heard the terms strong-AI and weak-AI used. Are these well defined terms or subjective ones? How are they generally defined?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The terms strong and weak don't actually refer to processing, or optimization power, or any interpretation leading to \"strong AI\" being stronger than \"weak AI\". It holds conveniently in practice, but the terms come from elsewhere. In 1980, John Searle coined the following statements:\n\nAI hypothesis, strong form: an AI system can think and have a mind (in the philosophical definition of the term);\nAI hypothesis, weak form: an AI system can only act like it thinks and has a mind.\n\nSo strong AI is a shortcut for an AI systems that verifies the strong AI hypothesis. Similarly, for the weak form. The terms have then evolved: strong AI refers to AI that performs as well as humans (who have minds), weak AI refers to AI that doesn't.\nThe problem with these definitions is that they're fuzzy. For example, AlphaGo is an example of weak AI, but is \"strong\" by Go-playing standards. A hypothetical AI replicating a human baby would be a strong AI, while being \"weak\" at most tasks.\nOther terms exist: Artificial General Intelligence (AGI), which has cross-domain capability (like humans), can learn from a wide range of experiences (like humans), among other features. Artificial Narrow Intelligence refers to systems bound to a certain range of tasks (where they may nevertheless have superhuman ability), lacking capacity to significantly improve themselves.\nBeyond AGI, we find Artificial Superintelligence (ASI), based on the idea that a system with the capabilities of an AGI, without the physical limitations of humans would learn and improve far beyond human level.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "To what extent can quantum computers help to develop Artificial Intelligence? What aspects of quantum computers, if any, can help to further develop Artificial Intelligence?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Quantum computers are super awesome at matrix multiplication, with some limitations. Quantum superposition allows each bit to be in a lot more states than just zero or one, and quantum gates can fiddle those bits in many different ways. Because of that, a quantum computer can process a lot of information at once for certain applications.\nOne of those applications is the Fourier transform, which is useful in a lot of problems, like signal analysis and array processing. There's also Grover's quantum search algorithm, which finds the single value for which a given function returns something different. If an AI problem can be expressed in a mathematical form amenable to quantum computing, it can receive great speedups. Sufficient speedups could transform an AI idea from \"theoretically interesting but insanely slow\" to \"quite practical once we get a good handle on quantum computing.\"\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can digital computers understand infinity? As a human being, we can think infinity. In principle, if we have enough resources (time etc.), we can count infinitely many things (including abstract, like numbers, or real).\nFor example, at least, we can take into account integers. We can think, principally, and \"understand\" infinitely many numbers that are displayed on the screen. Nowadays, we are trying to design artificial intelligence which is capable at least human being. However, I am stuck with infinity. I try to find a way how can teach a model (deep or not) to understand infinity. I define \"understanding' in a functional approach. For example, If a computer can differentiate 10 different numbers or things, it means that it really understand these different things somehow. This is the basic straight forward approach to \"understanding\".\nAs I mentioned before, humans understand infinity because they are capable, at least, counting infinite integers, in principle. From this point of view, if I want to create a model, the model is actually a function in an abstract sense, this model must differentiate infinitely many numbers. Since computers are digital machines which have limited capacity to model such an infinite function, how can I create a model that differentiates infinitely many integers?\nFor example, we can take a deep learning vision model that recognizes numbers on the card. This model must assign a number to each different card to differentiate each integer. Since there exist infinite numbers of integer, how can the model assign different number to each integer, like a human being, on the digital computers? If it cannot differentiate infinite things, how does it understand infinity?\nIf I take into account real numbers, the problem becomes much harder.\nWhat is the point that I am missing? Are there any resources that focus on the subject?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I think this is a fairly common misconception about AI and computers, especially among laypeople. There are several things to unpack here.\nLet's suppose that there's something special about infinity (or about continuous concepts) that makes them especially difficult for AI. For this to be true, it must both be the case that humans can understand these concepts while they remain alien to machines, and that there exist other concepts that are not like infinity that both humans and machines can understand. What I'm going to show in this answer is that wanting both of these things leads to a contradiction.\nThe root of this misunderstanding is the problem of what it means to understand. Understanding is a vague term in everyday life, and that vague nature contributes to this misconception.\nIf by understanding, we mean that a computer has the conscious experience of a concept, then we quickly become trapped in metaphysics. There is a long running, and essentially open debate about whether computers can \"understand\" anything in this sense, and even at times, about whether humans can! You might as well ask whether a computer can \"understand\" that 2+2=4. Therefore, if there's something special about understanding infinity, it cannot be related to \"understanding\" in the sense of subjective experience.\nSo, let's suppose that by \"understand\", we have some more specific definition in mind. Something that would make a concept like infinity more complicated for a computer to \"understand\" than a concept like arithmetic. Our more concrete definition for \"understanding\" must relate to some objectively measurable capacity or ability related to the concept (otherwise, we're back in the land of subjective experience). Let's consider what capacity or ability might we pick that would make infinity a special concept, understood by humans and not machines, unlike say, arithmetic.\nWe might say that a computer (or a person) understands a concept if it can provide a correct definition of that concept. However, if even one human understands infinity by this definition, then it should be easy for them to write down the definition. Once the definition is written down, a computer program can output it. Now the computer \"understands\" infinity too. This definition doesn't work for our purposes.\nWe might say that an entity understands a concept if it can apply the concept correctly. Again, if even the one person understands how to apply the concept of infinity correctly, then we only need to record the rules they are using to reason about the concept, and we can write a program that reproduces the behavior of this system of rules. Infinity is actually very well characterized as a concept, captured in ideas like Aleph Numbers. It is not impractical to encode these systems of rules in a computer, at least up to the level that any human understands them. Therefore, computers can \"understand\" infinity up to the same level of understanding as humans by this definition as well. So this definition doesn't work for our purposes.\nWe might say that an entity \"understands\" a concept if it can logically relate that concept to arbitrary new ideas. This is probably the strongest definition, but we would need to be pretty careful here: very few humans (proportionately) have a deep understanding of a concept like infinity. Even fewer can readily relate it to arbitrary new concepts. Further, algorithms like the General Problem Solver can, in principal, derive any logical consequences from a given body of facts, given enough time. Perhaps under this definition computers understand infinity better than most humans, and there is certainly no reason to suppose that our existing algorithms will not further improve this capability over time. This definition does not seem to meet our requirements either.\nFinally, we might say that an entity \"understands\" a concept if it can generate examples of it. For example, I can generate examples of problems in arithmetic, and their solutions. Under this definition, I probably do not \"understand\" infinity, because I cannot actually point to or create any concrete thing in the real world that is definitely infinite. I cannot, for instance, actually write down an infinitely long list of numbers, merely formulas that express ways to create ever longer lists by investing ever more effort in writing them out. A computer ought to be at least as good as me at this. This definition also does not work.\nThis is not an exhaustive list of possible definitions of \"understands\", but we have covered \"understands\" as I understand it pretty well. Under every definition of understanding, there isn't anything special about infinity that separates it from other mathematical concepts.\nSo the upshot is that, either you decide a computer doesn't \"understand\" anything at all, or there's no particularly good reason to suppose that infinity is harder to understand than other logical concepts. If you disagree, you need to provide a concrete definition of \"understanding\" that does separate understanding of infinity from other concepts, and that doesn't depend on subjective experiences (unless you want to claim your particular metaphysical views are universally correct, but that's a hard argument to make).\nInfinity has a sort of semi-mystical status among the lay public, but it's really just like any other mathematical system of rules: if we can write down the rules by which infinity operates, a computer can do them as well as a human can (or better).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the relation between Q-learning and policy gradients methods? As far as I understand, Q-learning and policy gradients (PG) are the two major approaches used to solve RL problems. While Q-learning aims to predict the reward of a certain action taken in a certain state, policy gradients directly predict the action itself.\nHowever, both approaches appear identical to me, i.e. predicting the maximum reward for an action (Q-learning) is equivalent to predicting the probability of taking the action directly (PG). Is the difference in the way the loss is back-propagated?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nHowever, both approaches appear identical to me i.e. predicting the maximum reward for an action (Q-learning) is equivalent to predicting the probability of taking the action directly (PG).\n\nBoth methods are theoretically driven by the Markov Decision Process construct, and as a result use similar notation and concepts. In addition, in simple solvable environments you should expect both methods to result in the same - or at least equivalent - optimal policies.\nHowever, they are actually different internally. The most fundamental differences between the approaches is in how they approach action selection, both whilst learning, and as the output (the learned policy). In Q-learning, the goal is to learn a single deterministic action from a discrete set of actions by finding the maximum value. With policy gradients, and other direct policy searches, the goal is to learn a map from state to action, which can be stochastic, and works in continuous action spaces.\nAs a result, policy gradient methods can solve problems that value-based methods cannot:\n\nLarge and continuous action space. However, with value-based methods, this can still be approximated with discretisation - and this is not a bad choice, since the mapping function in policy gradient has to be some kind of approximator in practice.\nStochastic policies. A value-based method cannot solve an environment where the optimal policy is stochastic requiring specific probabilities, such as Scissor/Paper/Stone. That is because there are no trainable parameters in Q-learning that control probabilities of action, the problem formulation in TD learning assumes that a deterministic agent can be optimal.\n\nHowever, value-based methods like Q-learning have some advantages too:\n\nSimplicity. You can implement Q functions as simple discrete tables, and this gives some guarantees of convergence. There are no tabular versions of policy gradient, because you need a mapping function $p(a \\mid s, \\theta)$ which also must have a smooth gradient with respect to $\\theta$.\nSpeed. TD learning methods that bootstrap are often much faster to learn a policy than methods which must purely sample from the environment in order to evaluate progress.\n\nThere are other reasons why you might care to use one or other approach:\n\nYou may want to know the predicted return whilst the process is running, to help other planning processes associated with the agent.\nThe state representation of the problem lends itself more easily to either a value function or a policy function. A value function may turn out to have very simple relationship to the state and the policy function very complex and hard to learn, or vice-versa.\n\nSome state-of-the-art RL solvers actually use both approaches together, such as Actor-Critic. This combines strengths of value and policy gradient methods.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the time complexity for training a neural network using back-propagation? Suppose that a NN contains $n$ hidden layers, $m$ training examples, $x$ features, and $n_i$ nodes in each layer. What is the time complexity to train this NN using back-propagation? \nI have a basic idea about how they find the time complexity of algorithms, but here there are 4 different factors to consider here i.e. iterations, layers, nodes in each layer, training examples, and maybe more factors. I found an answer here but it was not clear enough.\nAre there other factors, apart from those I mentioned above, that influence the time complexity of the training algorithm of a NN?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I haven't seen an answer from a trusted source, but I'll try to answer this myself, with a simple example (with my current knowledge).\nIn general, note that training an MLP using back-propagation is usually implemented with matrices.\nTime complexity of matrix multiplication\nThe time complexity of matrix multiplication for $M_{ij} * M_{jk}$ is simply $\\mathcal{O}(i*j*k)$.\nNotice that we are assuming the simplest multiplication algorithm here: there exist some other algorithms with somewhat better time complexity.\nFeedforward pass algorithm\nThe feedforward propagation algorithm is as follows.\nFirst, to go from layer $i$ to $j$, you do\n$$S_j = W_{ji}*Z_i$$\nThen you apply the activation function\n$$Z_j = f(S_j)$$\nIf we have $N$ layers (including input and output layer), this will run $N-1$ times.\nExample\nAs an example, let's compute the time complexity for the forward pass algorithm for an MLP with $4$ layers, where $i$ denotes the number of nodes of the input layer, $j$ the number of nodes in the second layer, $k$ the number of nodes in the third layer and $l$ the number of nodes in the output layer.\nSince there are $4$ layers, you need $3$ matrices to represent weights between these layers. Let's denote them by $W_{ji}$, $W_{kj}$ and $W_{lk}$, where $W_{ji}$ is a matrix with $j$ rows and $i$ columns ($W_{ji}$ thus contains the weights going from layer $i$ to layer $j$).\nAssume you have $t$ training examples. For propagating from layer $i$ to $j$, we have first\n$$S_{jt} = W_{ji} * Z_{it}$$\nand this operation (i.e. matrix multiplication) has $\\mathcal{O}(j*i*t)$ time complexity. Then we apply the activation function\n$$\nZ_{jt} = f(S_{jt})\n$$\nand this has $\\mathcal{O}(j*t)$ time complexity, because it is an element-wise operation.\nSo, in total, we have\n$$\\mathcal{O}(j*i*t + j*t) = \\mathcal{O}(j*t*(i + 1)) = \\mathcal{O}(j*i*t)$$\nUsing same logic, for going $j \\to k$, we have $\\mathcal{O}(k*j*t)$, and, for $k \\to l$, we have $\\mathcal{O}(l*k*t)$.\nIn total, the time complexity for feedforward propagation will be\n$$\\mathcal{O}(j*i*t + k*j*t + l*k*t) = \\mathcal{O}(t*(ij + jk + kl))$$\nI'm not sure if this can be simplified further or not. Maybe it's just $\\mathcal{O}(t*i*j*k*l)$, but I'm not sure.\nBack-propagation algorithm\nThe back-propagation algorithm proceeds as follows. Starting from the output layer $l \\to k$, we compute the error signal, $E_{lt}$, a matrix containing the error signals for nodes at layer $l$\n$$\nE_{lt} = f'(S_{lt}) \\odot {(Z_{lt} - O_{lt})}\n$$\nwhere $\\odot$ means element-wise multiplication. Note that $E_{lt}$ has $l$ rows and $t$ columns: it simply means each column is the error signal for training example $t$.\nWe then compute the \"delta weights\", $D_{lk} \\in \\mathbb{R}^{l \\times k}$ (between layer $l$ and layer $k$)\n$$\nD_{lk} = E_{lt} * Z_{tk}\n$$\nwhere $Z_{tk}$ is the transpose of $Z_{kt}$.\nWe then adjust the weights\n$$\nW_{lk} = W_{lk} - D_{lk}\n$$\nFor $l \\to k$, we thus have the time complexity $\\mathcal{O}(lt + lt + ltk + lk) = \\mathcal{O}(l*t*k)$.\nNow, going back from $k \\to j$. We first have\n$$\nE_{kt} = f'(S_{kt}) \\odot (W_{kl} * E_{lt})\n$$\nThen\n$$\nD_{kj} = E_{kt} * Z_{tj}\n$$\nAnd then\n$$W_{kj} = W_{kj} - D_{kj}$$\nwhere $W_{kl}$ is the transpose of $W_{lk}$. For $k \\to j$, we have the time complexity $\\mathcal{O}(kt + klt + ktj + kj) = \\mathcal{O}(k*t(l+j))$.\nAnd finally, for $j \\to i$, we have $\\mathcal{O}(j*t(k+i))$. In total, we have\n$$\\mathcal{O}(ltk + tk(l + j) + tj (k + i)) = \\mathcal{O}(t*(lk + kj + ji))$$\nwhich is the same as the feedforward pass algorithm. Since they are the same, the total time complexity for one epoch will be $$O(t*(ij + jk + kl)).$$\nThis time complexity is then multiplied by the number of iterations (epochs). So, we have $$O(n*t*(ij + jk + kl)),$$ where $n$ is number of iterations.\nNotes\nNote that these matrix operations can greatly be parallelized by GPUs.\nConclusion\nWe tried to find the time complexity for training a neural network that has 4 layers with respectively $i$, $j$, $k$ and $l$ nodes, with $t$ training examples and $n$ epochs. The result was $\\mathcal{O}(nt*(ij + jk + kl))$.\nWe assumed the simplest form of matrix multiplication that has cubic time complexity. We used the batch gradient descent algorithm. The results for stochastic and mini-batch gradient descent should be the same. (Let me know if you think the otherwise: note that batch gradient descent is the general form, with little modification, it becomes stochastic or mini-batch)\nAlso, if you use momentum optimization, you will have the same time complexity, because the extra matrix operations required are all element-wise operations, hence they will not affect the time complexity of the algorithm.\nI'm not sure what the results would be using other optimizers such as RMSprop.\nSources\nThe following article http://briandolhansky.com/blog/2014/10/30/artificial-neural-networks-matrix-form-part-5 describes an implementation using matrices. Although this implementation is using \"row major\", the time complexity is not affected by this.\nIf you're not familiar with back-propagation, check this article:\nhttp://briandolhansky.com/blog/2013/9/27/artificial-neural-networks-backpropagation-part-4\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do capsule neural networks work? Geoffrey Hinton has been researching something he calls \"capsules theory\" in neural networks. What is it? How do capsule neural networks work?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It appears to not be published yet; the best available online are these slides for this talk. (Several people reference an earlier talk with this link, but sadly it's broken at time of writing this answer.)\nMy impression is that it's an attempt to formalize and abstract the creation of subnetworks inside a neural network. That is, if you look at a standard neural network, layers are fully connected (that is, every neuron in layer 1 has access to every neuron in layer 0, and is itself accessed by every neuron in layer 2). But this isn't obviously useful; one might instead have, say, n parallel stacks of layers (the 'capsules') that each specializes on some separate task (which may itself require more than one layer to complete successfully).\nIf I'm imagining its results correctly, this more sophisticated graph topology seems like something that could easily increase both the effectiveness and the interpretability of the resulting network.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How should I handle invalid actions (when using REINFORCE)? I want to create an AI which can play five-in-a-row/Gomoku. I want to use reinforcement learning for this.\nI use the policy gradient method, namely REINFORCE, with baseline. For the value and policy function approximation, I use a neural network. It has convolutional and fully connected layers. All of the layers, except for the output, are shared. The policy's output layer has $8 \\times 8=64$ (the size of the board) output unit and softmax on them. So it is stochastic.\nBut what if the network produces a very high probability for an invalid action? An invalid action is when the agent wants to check a square that has one X or O in it. I think it can be stuck in that game state.\nHow should I handle this situation?\nMy guess is to use the actor-critic method. For an invalid action, we should give a negative reward and pass the turn to the opponent.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Just ignore the invalid moves.\nFor exploration, it is likely that you won't just execute the move with the highest probability, but instead choose moves randomly based on the outputted probability. If you only punish illegal moves they will still retain some probability (however small) and therefore will be executed from time to time (however seldom). So you will always retain an agent which occasionally makes illegal moves.\nTo me, it makes more sense to just set the probabilities of all illegal moves to zero and renormalise the output vector before you choose your move.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Could a neural network detect primes? I am not looking for an efficient way to find primes (which of course is a solved problem). This is more of a \"what if\" question.\nSo, in theory, could you train a neural network to predict whether or not a given number $n$ is composite or prime? How would such a network be laid out?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Early success on prime number testing via artificial networks is presented in A Compositional Neural-network Solution to Prime-number Testing, L\u00e1szl\u00f3 Egri, Thomas R. Shultz, 2006.\nThe knowledge-based cascade-correlation (KBCC) network approach showed the most promise, although the practicality of this approach is eclipsed by other prime detection algorithms that usually begin by checking the least significant bit, immediately reducing the search by half, and then searching based other theorems and heuristics up to $floor(\\sqrt{x})$. However the work was continued with Knowledge Based Learning with KBCC, Shultz et. al. 2006\nThere are actually multiple sub-questions in this question. First, let's write a more formal version of the question: \"Can an artificial network of some type converge during training to a behavior that will accurately test whether the input ranging from $0$ to $2^n-1$, where $n$ is the number of bits in the integer representation, represents a prime number?\"\n\nCan it by simply memorizing the primes over the range of integers?\nCan it by learning to factor and apply the definition of a prime?\nCan it by learning a known algorithm?\nCan it by developing a novel algorithm of its own during training?\n\nThe direct answer is yes, and it has already been done according to 1. above, but it was done by over-fitting, not learning a prime number detection method. We know the human brain contains a neural network that can accomplish 2., 3., and 4., so if artificial networks are developed to the degree most think they can be, then the answer is yes for those. There exists no counter-proof to exclude any of them from the range of possibilities as of this answer's writing.\nIt is not surprising that work has been done to train artificial networks on prime number testing because of the importance of primes in discrete mathematics, its application to cryptography, and, more specifically, to cryptanalysis. We can identify the importance of digital network detection of prime numbers in the research and development of intelligent digital security in works like A First Study of the Neural Network Approach in the RSA Cryptosystem, G.c. Meletius et. al., 2002. The tie of cryptography to the security of our respective nations is also the reason why not all of the current research in this area will be public. Those of us that may have the clearance and exposure can only speak of what is not classified.\nOn the civilian end, ongoing work in what is called novelty detection is an important direction of research. Those like Markos Markou and Sameer Singh are approaching novelty detection from the signal processing side, and it is obvious to those that understand that artificial networks are essentially digital signal processors that have multi-point self tuning capabilities can see how their work applies directly to this question. Markou and Singh write, \"There are a multitude of applications where novelty detection is extremely important including signal processing, computer vision, pattern recognition, data mining, and robotics.\"\nOn the cognitive mathematics side, the development of a mathematics of surprise, such as Learning with Surprise: Theory and Applications (thesis), Mohammadjavad Faraji, 2016 may further what Ergi and Shultz began.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between latent and embedding spaces? In general, the word \"latent\" means \"hidden\" and \"to embed\" means \"to incorporate\". In machine learning, the expressions \"hidden (or latent) space\" and \"embedding space\" occur in several contexts. More specifically, an embedding can refer to a vector representation of a word. An embedding space can refer to a subspace of a bigger space, so we say that the subspace is embedded in the bigger space. The word \"latent\" comes up in contexts like hidden Markov models (HMMs) or auto-encoders.\nWhat is the difference between these spaces? In some contexts, do these two expressions refer to the same concept?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Embedding vs Latent Space\nDue to Machine Learning's recent and rapid renaissance, and the fact that it draws from many distinct areas of mathematics, statistics, and computer science, it often has a number of different terms for the same or similar concepts.\n\"Latent space\" and \"embedding\" both refer to an (often lower-dimensional) representation of high-dimensional data:\n\nLatent space refers specifically to the space from which the low-dimensional representation is drawn.\nEmbedding refers to the way the low-dimensional data is mapped to (\"embedded in\") the original higher dimensional space.\n\nFor example, in this \"Swiss roll\" data, the 3d data on the left is sensibly modelled as a 2d manifold 'embedded' in 3d space. The function mapping the 'latent' 2d data to its 3d representation is the embedding, and the underlying 2d space itself is the latent space (or embedded space):\n\nSynonyms\nDepending on the specific impression you wish to give, \"embedding\" often goes by different terms:\n\n\n\n\nTerm\nContext\n\n\n\n\ndimensionality reduction\ncombating the \"curse of dimensionality\"\n\n\nfeature extraction feature projection feature embedding feature learning representation learning\nextracting 'meaningful' features from raw data\n\n\nembedding manifold learning latent feature representation\nunderstanding the underlying topology of the data\n\n\n\n\nHowever this is not a hard-and-fast rule, and they are often completely interchangeable.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the purpose of an activation function in neural networks? It is said that activation functions in neural networks help introduce non-linearity.\n\nWhat does this mean?\nWhat does non-linearity mean in this context?\nHow does the introduction of this non-linearity help?\nAre there any other purposes of activation functions?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Almost all of the functionalities provided by the non-linear activation functions are given by other answers. Let me sum them up:\n\nFirst, what does non-linearity mean? It means something (a function in this case) which is not linear with respect to a given variable/variables i.e. $f(c1.x1 + c2.x2...cn.xn + b) != c1.f(x1) + c2.f(x2) ... cn.f(xn) + f(b).$\nNOTE: There is some ambiguity about how one might define linearity. In polynomial equations we define linearity in somewhat a different way as compared to in vectors or some systems which take an input $x$ and give an output $f(x)$. See the second answer.\nWhat does non-linearity mean in this context? It means that the Neural Network can successfully approximate functions (up-to a certain error $e$ decided by the user) which does not follow linearity or it can successfully predict the class of a function that is divided by a decision boundary that is not linear.\nWhy does it help? I hardly think you can find any physical world phenomenon which follows linearity straightforwardly. So you need a non-linear function that can approximate the non-linear phenomenon. Also, a good intuition would be any decision boundary or a function is a linear combination of polynomial combinations of the input features (so ultimately non-linear).\nPurposes of activation function? In addition to introducing non-linearity, every activation function has its own features.\n\nSigmoid $\\frac{1} {(1 + e ^ {-(w1*x1...wn*xn + b)})}$\nThis is one of the most common activation function and is monotonically increasing everywhere. This is generally used at the final output node as it squashes values between 0 and 1 (if the output is required to be 0 or 1). Thus above 0.5 is considered 1 while below 0.5 as 0, although a different threshold (not 0.5) maybe set. Its main advantage is that its differentiation is easy and uses already calculated values and supposedly horseshoe crab neurons have this activation function in their neurons.\nTanh $\\frac{e ^ {(w1*x1...wn*xn + b)} - e ^ {-(w1*x1...wn*xn + b)})}{(e ^ { (w1*x1...wn*xn + b)} + e ^ {-(w1*x1...wn*xn + b)}}$\nThis has an advantage over the sigmoid activation function as it tends to centre the output to 0 which has an effect of better learning on the subsequent layers (acts as a feature normaliser). A nice explanation here. Negative and positive output values maybe considered as 0 and 1 respectively. Used mostly in RNN's.\nRe-Lu activation function - This is another very common simple non-linear (linear in positive range and negative range exclusive of each other) activation function that has the advantage of removing the problem of vanishing gradient faced by the above two i.e. gradient tends to 0 as x tends to +infinity or -infinity. Here is an answer about Re-Lu's approximation power in-spite of its apparent linearity. ReLu's have a disadvantage of having dead neurons which result in larger NN's.\nAlso, you can design your own activation functions depending on your specialized problem. You may have a quadratic activation function which will approximate quadratic functions much better. But then, you have to design a cost function that should be somewhat convex in nature, so that you can optimise it using first-order differentials and the NN actually converges to a decent result. This is the main reason why standard activation functions are used. But I believe with proper mathematical tools, there is a huge potential for new and eccentric activation functions.\nFor example, say you are trying to approximate a single-variable quadratic function say $a.x^2 + c$. This will be best approximated by a quadratic activation $w1.x^2 + b$ where$w1$ and $b$ will be the trainable parameters. But designing a loss function that follows the conventional first-order derivative method (gradient descent) can be quite tough for non-monotonically increasing function.\nFor Mathematicians: In the sigmoid activation function $(1 / (1 + e ^ {-(w1*x1...wn*xn + b)})$ we see that $e ^ {-(w1*x1...wn*xn + b)}$ is always < 1. By binomial expansion, or by reverse calculation of the infinite GP series we get $sigmoid(y)$ = $1 + y + y^2.....$. Now in a NN $y = e ^ {-(w1*x1...wn*xn + b)}$. Thus we get all the powers of $y$ which is equal to $e ^ {-(w1*x1...wn*xn + b)}$ thus each power of $y$ can be thought of as a multiplication of several decaying exponentials based on a feature $x$, for eaxmple $y^2 = e^ {-2(w1x1)} * e^ {-2(w2x2)} * e^ {-2(w3x3)} *...... e^ {-2(b)}$. Thus each feature has a say in the scaling of the graph of $y^2$.\nAnother way of thinking would be to expand the exponentials according to Taylor Series:\n$$e^{x}=1+\\frac{x}{1 !}+\\frac{x^{2}}{2 !}+\\frac{x^{3}}{3 !}+\\cdots$$\nSo we get a very complex combination, with all the possible polynomial combinations of input variables present. I believe if a Neural Network is structured correctly the NN can fine-tune these polynomial combinations by just modifying the connection weights and selecting polynomial terms maximum useful, and rejecting terms by subtracting the output of 2 nodes weighted properly.\nThe $tanh$ activation can work in the same way since output of $|tanh| < 1$. I am not sure how Re-Lu's work though, but due to its rigid structure and problem of dead neurons we require larger networks with ReLu's for a good approximation.\nBut for a formal mathematical proof, one has to look at the Universal Approximation Theorem.\n\nA visual proof that neural nets can compute any function\nThe Universal Approximation Theorem For Neural Networks- An Elegant Proof\n\nFor non-mathematicians some better insights visit these links:\nActivation Functions by Andrew Ng - for more formal and scientific answer\nHow does neural network classifier classify from just drawing a decision plane?\nDifferentiable activation function\nA visual proof that neural nets can compute any function\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is ChatGPT aware of today's date? I asked ChatGPT (3.5 and 4) about current date and (s)he answered correctly. In subsequent conversation (s)he was not able to explain how (s)he has this knowledge.\nI always thought that the model only sees the conversation above and a pretrained NN is used. How is the information about current date injected into his/her knowledge?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "For ChatGPT 3, the current date is inserted into a long pre-prompt, along with instructions like \"this is a conversation between an AI chatbot and a human\" plus \"be nice\" and \"be truthful\", which are part of the attempts to frame the next-word-predicting engine at the core of ChatGPT as a chatbot. OpenAI have confirmed this in the past, but sadly recent releases have removed that documentation.\nInherently, the core of ChatGPT - the GPT large language model - is not a chatbot. It has some resemblance conceptually to an image inpainting system \u2014 it predicts text that is likely, given preceding text.\nI expect the same is true of ChatGPT 4, but have not seen any confirmation of this. It is feasible in principle to alter architecture of the bots to have them reference external data sources, but I believe that for the current date, a pre-prompt will still be in use.\nOld link to OpenAI's confirmation - sadly no longer available - https://platform.openai.com/docs/guides/chat/instructing-chat-models - if anyone has link to archived copy please let me know in the comments.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the \"temperature\" in the GPT models? What does the temperature parameter mean when talking about the GPT models?\nI know that a higher temperature value means more randomness, but I want to know how randomness is introduced.\nDoes temperature mean we add noise to the weights/activations or do we add randomness when choosing a token in the softmax layer?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In sequence generating models, for vocabulary of size $N$ (number of words, parts of words, any other kind of token), one predicts the next token from distribution of the form:\n$$\n\\mathrm{softmax} (x_i/T) \\quad i = 1, \\ldots N,\n$$\nHere $T$ is the temperature. The output of the softmax is the probability that the next token will be the $i$-th word in the vocabulary.\nThe temperature determines how greedy the generative model is.\nIf the temperature is low, the probabilities to sample other but the class with the highest log probability will be small, and the model will probably output the most correct text, but rather boring, with small variation.\nIf the temperature is high, the model can output, with rather high probability, other words than those with the highest probability. The generated text will be more diverse, but there is a higher possibility of grammar mistakes and generation of nonsense.\n\nThe difference between the low-temperature case (left) and the high-temperature case for the categorical distribution is illustrated in the picture above, where the heights of the bars correspond to probabilities.\nExample\nA good sample is provided in the Deep Learning with Python by Fran\u00e7ois Chollet in chapter 12. An extract from the tutorial, refer to this notebook.\nimport numpy as np\n\ntokens_index = dict(enumerate(text_vectorization.get_vocabulary()))\n\ndef sample_next(predictions, temperature=1.0):\n predictions = np.asarray(predictions).astype(\"float64\")\n predictions = np.log(predictions) / temperature\n exp_preds = np.exp(predictions)\n predictions = exp_preds / np.sum(exp_preds)\n probas = np.random.multinomial(1, predictions, 1)\n return np.argmax(probas)\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the concept of the technological singularity? I've heard the idea of the technological singularity, what is it and how does it relate to Artificial Intelligence? Is this the theoretical point where Artificial Intelligence machines have progressed to the point where they grow and learn on their own beyond what humans can do and their growth takes off? How would we know when we reach this point?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The technological singularity is a theoretical point in time at which a self-improving artificial general intelligence becomes able to understand and manipulate concepts outside of the human brain's range, that is, the moment when it can understand things humans, by biological design, can't.\nThe fuzziness about the singularity comes from the fact that, from the singularity onwards, history is effectively unpredictable. Humankind would be unable to predict any future events, or explain any present events, as science itself becomes incapable of describing machine-triggered events. Essentially, machines would think of us the same way we think of ants. Thus, we can make no predictions past the singularity. Furthermore, as a logical consequence, we'd be unable to define the point at which the singularity may occur at all, or even recognize it when it happens.\nHowever, in order for the singularity to take place, AGI needs to be developed, and whether that is possible is quite a hot debate right now. Moreover, an algorithm that creates superhuman intelligence (or superintelligence) out of bits and bytes would have to be designed. By definition, a human programmer wouldn't be able to do such a thing, as his/her brain would need to be able to comprehend concepts beyond its range. There is also the argument that an intelligence explosion (the mechanism by which a technological singularity would theoretically be formed) would be impossible due to the difficulty of the design challenge of making itself more intelligent, getting larger proportionally to its intelligence, and that the difficulty of the design itself may overtake the intelligence required to solve the said challenge.\nAlso, there are related theories involving machines taking over humankind and all of that sci-fi narrative. However, that's unlikely to happen, if Asimov's laws are followed appropriately. Even if Asimov's laws were not enough, a series of constraints would still be necessary in order to avoid the misuse of AGI by misintentioned individuals, and Asimov's laws are the nearest we have to that.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is the \"Chinese room\" an explanation of how ChatGPT works? Sorry if this question makes no sense. I'm a software developer but know very little about AI.\nQuite a while ago, I read about the Chinese room, and the person inside who has had a lot of training/instructions how to combine symbols, and, as a result, is very good at combining symbols in a \"correct\" way, for whatever definition of correct. I said \"training/instructions\" because, for the purpose of this question, it doesn't really make a difference if the \"knowledge\" was acquired by parsing many many examples and getting a \"feeling\" for what's right and what's wrong (AI/learning), or by a very detailed set of instructions (algorithmic).\nSo, the person responds with perfectly reasonable sentences, without ever understanding Chinese, or the content of its input.\nNow, as far as I understand ChatGPT (and I might be completely wrong here), that's exactly what ChatGPT does. It has been trained on a huge corpus of text, and thus has a very good feeling which words go together well and which don't, and, given a sentence, what's the most likely continuation of this sentence. But that doesn't really mean it understands the content of the sentence, it only knows how to chose words based on what it has seen. And because it doesn't really understand any content, it mostly gives answers that are correct, but sometimes it's completely off because it \"doesn't really understand Chinese\" and doesn't know what it's talking about.\nSo, my question: is this \"juggling of Chinese symbols without understanding their meaning\" an adequate explanation of how ChatGPT works, and if not, where's the difference? And if yes, how far is AI from models that can actually understand (for some definition of \"understand\") textual content?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, the Chinese Room argument by John Searle essentially demonstrates that at the very least it is hard to locate intelligence in a system based on its inputs and outputs. And the ChatGPT system is built very much as a machine for manipulating symbols according to opaque rules, without any grounding provided for what those symbols mean.\nThe large language models are trained without ever getting to see, touch, or get any experience reference for any of their language components, other than yet more written language. It is much like trying to learn the meaning of a word by looking up its dictionary definition and finding that composed of other words that you don't know the meaning of, recursively without any way of resolving it. If you possessed such a dictionary and no knowledge of the words defined, you would still be able to repeat those definitions, and if they were received by someone who did understand some of the words, the result would look like reasoning and \"understanding\". But this understanding is not yours, you are simply able to retrieve it on demand from where someone else stored it.\nThis is also related to the symbol grounding problem in cognitive science.\nIt is possible to argue that pragmatically the \"intelligence\" shown by the overall system is still real and resides somehow in the rules of how to manipulate the symbols. This argument and other similar ones try to side-step or dismiss some proposed hard problems in AI - for instance, by focusing on behaviour of the whole system and not trying to address the currently impossible task of asking whether any system has subjective experience. This is beyond the scope of this answer (and not really what the question is about), but it is worth noting that The Chinese Room argument has some criticism, and is not the only way to think about issues with AI systems based on language and symbols.\nI would agree with you that the latest language models, and ChatGPT are good example models of the The Chinese Room made real. The room part that is, there is no pretend human in the middle, but actually that's not hugely important - the role of the human in the Chinese room is to demonstrate that from the perspective of an entity inside the room processing a database of rules, nothing need to possess any understanding or subjective experience that is relevant to the text. Now that next-symbol predictors (which all Large Language Models are to date) are demonstrating quite sophisticated, even surprising behaviour, it may lead to some better insights into the role that symbol-to-symbol references can take in more generally intelligent systems.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is Lisp such a good language for AI? I've heard before from computer scientists and from researchers in the area of AI that that Lisp is a good language for research and development in artificial intelligence.\n\nDoes this still apply, with the proliferation of neural networks and deep learning?\nWhat was their reasoning for this?\nWhat languages are current deep-learning systems currently built in?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First, I guess that you mean Common Lisp (which is a standard language specification, see its HyperSpec) with efficient implementations (\u00e0 la SBCL). But some recent implementations of Scheme could also be relevant (with good implementations such as Bigloo or Chicken/Scheme). Both Common Lisp and Scheme (and even Clojure) are from the same Lisp family. And as a scripting language driving big data or machine learning applications, Guile might be a useful replacement to Python and is also a Lisp dialect. BTW, I do recommend reading SICP, an excellent introduction to programming using Scheme.\nThen, Common Lisp (and other dialects of Lisp) is great for symbolic AI. However, many recent machine learning libraries are coded in more mainstream languages, for example TensorFlow is coded in C++ & Python. Deep learning libraries are mostly coded in C++ or Python or C (and sometimes using OpenCL or Cuda for GPU computing parts).\nCommon Lisp is great for symbolic artificial intelligence because:\n\nit has very good implementations (e.g. SBCL, which compiles to machine code every expression given to the REPL)\nit is homoiconic, so it is easy to deal with programs as data, in particular it is easy to generate [sub-]programs, that is use meta-programming techniques.\nit has a Read-Eval-Print Loop to ease interactive programming\nit provides a very powerful macro machinery (essentially, you define your own domain specific sublanguage for your problem), much more powerful than in other languages like C.\nit mandates a garbage collector (even code can be garbage collected)\nit provides many container abstract data types, and can easily handle symbols.\nyou can code both high-level (dynamically typed) and low-level (more or less startically typed) code, thru appropriate annotations.\n\nHowever most machine learning & neural network libraries are not coded in CL. Notice that neither neural network nor deep learning is in the symbolic artificial intelligence field. See also this question.\nSeveral symbolic AI systems like Eurisko or CyC have been developed in CL (actually, in some DSL built above CL).\nNotice that the programming language might not be very important. In the Artificial General Intelligence research topic, some people work on the idea of a AI system which would generate all its own code (so are designing it with a bootstrapping approach). Then, the code which is generated by such a system can even be generated in low level programming languages like C. See J.Pitrat's blog, which has inspired the RefPerSys project.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can Transformers handle arbitrary length input? The transformer, introduced in the paper Attention Is All You Need, is a popular new neural network architecture that is commonly viewed as an alternative to recurrent neural networks, like LSTMs and GRUs.\nHowever, having gone through the paper, as well as several online explanations, I still have trouble wrapping my head around how they work. How can a non-recurrent structure be able to deal with inputs of arbitrary length?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Actually, there is usually an upper bound for inputs of transformers, due to the inability of handling long-sequence. Usually, the value is set as 512 or 1024 at current stage.\nHowever, if you are asking handling the various input size, adding padding token such as [PAD] in BERT model is a common solution. The position of [PAD] token could be masked in self-attention, therefore, causes no influence. Let's say we use a transformer model with 512 limit of sequence length, then we pass a input sequence of 103 tokens. We padded it to 512 tokens. In the attention layer, positions from 104 to 512 are all masked, that is, they are not attending or being attended.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do CNN's sometimes make highly confident mistakes, and how can one combat this problem? I trained a simple CNN on the MNIST database of handwritten digits to 99% accuracy. I'm feeding in a bunch of handwritten digits, and non-digits from a document.\nI want the CNN to report errors, so I set a threshold of 90% certainty below which my algorithm assumes that what it's looking at is not a digit. \nMy problem is that the CNN is 100% certain of many incorrect guesses. In the example below, the CNN reports 100% certainty that it's a 0. How do I make it report failure?\n\nMy thoughts on this:\nMaybe the CNN is not really 100% certain that this is a zero. Maybe it just thinks that it can't be anything else, and it's being forced to choose (because of normalisation on the output vector). Is there any way I can get insight into what the CNN \"thought\" before I forced it to choose?\nPS: I'm using Keras on Tensorflow with Python.\nEdit\nBecause someone asked. Here is the context of my problem:\nThis came from me applying a heuristic algorithm for segmentation of sequences of connected digits. In the image above, the left part is actually a 4, and the right is the curve bit of a 2 without the base. The algorithm is supposed to step through segment cuts, and when it finds a confident match, remove that cut and continue moving along the sequence. It works really well for some cases, but of course it's totally reliant on being able to tell if what it's looking at is not a good match for a digit. Here's an example of where it kind of did okay.\n\nMy next best option is to do inference on all permutations and maximise combined score. That's more expensive.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The concept you are looking for is called epistemic uncertainty, also known as model uncertainty. You want the model to produce meaningful calibrated probabilities that quantify the real confidence of the model.\nThis is generally not possible with simple neural networks as they simply do not have this property, for this you need a Bayesian Neural Network (BNN). This kind of network learns a distribution of weights instead of scalar or point-wise weights, which then allow to encode model uncertainty, as then the distribution of the output is calibrated and has the properties you want.\nThis problem is also called out of distribution (OOD) detection, and again it can be done with BNNs, but unfortunately training a full BNN is untractable, so we use approximations.\nAs a reference, one of these approximations is Deep Ensembles, which train several instances of a model in the same dataset and then average the softmax probabilities, and has good out of distribution detection properties. Check the paper here, in particular section 3.5 which shows results for OOD based on entropy of the ensemble probabilities.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does the (decoder-only) transformer architecture work? How does the (decoder-only) transformer architecture work which is used in impressive models such as GPT-4?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Introduction\nLarge-language models (LLMs) have gained tons of popularity lately with the releases of ChatGPT, GPT-4, Bard, and more. All these LLMs are based on the transformer neural network architecture. The transformer architecture was first introduced in the paper \"Attention is All You Need\" by Google Brain in 2017. LLMs/GPT models use a variant of this architecture called de' decoder-only transformer'.\nThe most popular variety of transformers are currently these GPT models. The only purpose of these models is to receive a prompt (an input) and predict the next token/word that comes after this input. Nothing more, nothing less.\nNote: Not all large-language models use a transformer architecture. However, models such as GPT-3, ChatGPT, GPT-4 & LaMDa use the (decoder-only) transformer architecture.\nOverview of the (decoder-only) Transformer model\nIt is key first to understand the input and output of a transformer:\n\nThe input is a prompt (often referred to as context) fed into the transformer as a whole. There is no recurrence.\nThe output depends on the goal of the model. For GPT models, the output is a probability distribution of the next token/word that comes after the prompt. It outputs one prediction for the complete input.\n\nNext, it is essential to understand the key components that make up the decoder-only transformer architecture:\n\nThe embedding: the input of the transformer model is a prompt. This prompt needs to be embedded into something that the model can use.\nThe block(s): This is the main source of complexity. Each block contains a masked multi-head attention submodule, a feedforward network, and several layer normalization operations. Blocks are put in sequence to make the model deeper.\nThe output: the output of the last block is fed through one more linear layer to obtain the final output of the model (a classification, a next word/token etc.)\n\nThe following visualization gives an overview of the transformer architecture.\n\nSelf-Attention Mechanism\nSelf-attention makes the transformer powerful. The intuition of self-attention is that the mechanism allows the model to focus on (attend to) the most relevant parts of the input. A single self-attention mechanism is called a head.\nThe head works as follows. First, the input is fed into three separate linear layers. Two of those (the queries Q and the keys K) are multiplied, scaled, and turned into a probability distribution using a softmax activation function. Think of this probability distribution as describing which indices matter most for the output (i.e. which words in the prompt matter for the next word to be predicted). Finally, the output is multiplied with values V. This thus gives V * the importance of each of the tokens in V. A key observation is that the learnable parameters in the head are the three linear layers.\nThe following figure gives an overview of the operations done in a head and an overview of how multi-head attention works.\n\nMulti-Head Attention\nMulti-head attention is nothing more than several individual heads stacked on top of one another. The input to all heads is equivalent. However, each head has its own weights. After forwarding the input through all the heads, the output of the heads is concatenated and passed through a linear layer which brings the dimensionality back to the dimension of the initial input.\nMasked Self-Attention\nIn the decoder-only transformer, masked self-attention is nothing more than sequence padding. The 'masking' term is a left-over of the original encoder-decoder transformer module in which the encoder could see the whole (original language) sentence, and the decoder could only see the first part of the sentence which was already translated. As such, they called it 'masking'.\nBlock\nEach block contains a multi-head attention submodule, a feedforward network, 2 layer-normalization operations, and 2 skip connections.\nThe feedforward network is simply a multi-layer perceptron. In the original paper, the proposed feedforward module consisted of (1) a fully connected layer; (2) a ReLU activation; (3) another fully connected layer; and (4) a dropout layer.\nThe 'add & norm' blocks get the output from the multi-head attention/feedforward submodule and add it to the input into those modules. After that, a layer normalization operation is performed. Adding the input and output of a submodule together is known as a skip-connection. As blocks can be put in sequence, the skip connections help tremendously reduce the problem of vanishing or exploding gradients. In other words, skip connections are necessary to ensure proper backpropagation of the gradients.\nPositional Embedding\nTransformers take in a complete prompt at once (in contrast to RNNs) and embed this as one big Tensor. As such, transformers do not know which word is at what position in the sentence. This is problematic as the following two sentences mean entirely different things, only dependent on the order of the words:\n\nThe boy chased the bird with a butterfly net.\n\n\nThe bird chased the boy with a butterfly net.\n\nTo that end, a positional embedding is added to allow the model to deduce which word is where. Positional embeddings can be learned using any embedding layer from your favourite AI library. However, the original authors proposed a much more complicated method, which does not require learning any parameters. Please find an elaborate explanation (not mine) on the original positional embedding here.\nOutput\nAfter the prompt is forwarded through all the blocks sequentially, the output is forwarded through one final linear layer. This final linear layer maps the output of the model back to the size of the 'vocabulary'. I.e. if you want to predict the next letter in a message, it would map to 26 (letters) + additional stuff (such as .,-!? etc.).\nThe output of the model is a probability distribution. For GPT models, the output is the probability of each token being the next token in the sequence.\nTraining\nBasic training\nThe basic training process consists of self-supervised learning. Simply put, you gather lots of text, strip the last word from that text, feed it as input into the transformer, check if the prediction matches the word you cut off and backpropagate the error.\nEvery text/sentence/book/webpage can be separated into several samples.\nsample = [\n [\"This\"],\n [\"This\", \"is\"],\n [\"This\", \"is\", \"a\"]] # padding is added until the max-sequence length is reached.\ntargets = [\"is\", \"a\", \"sample\"]\n\nFine-tuning / transfer-learning\nAfter the first stage of training is completed, the model is now a large-language model. As in, it can predict the next word based on a context. However, through fine-tuning/transfer-learning the model can be adapted to better suit the needs of the final application.\nOne of the key reasons why ChatGPT & GPT-4 seem so ridiculously impressive is because of this second stage of training. In this stage, the following process is executed many times:\n\nThe model is given a prompt and generates different answers\nThe different answers are ranked by a human from best to worst.\nThe scores of the different answers are backpropagated.\n\nHowever, transformer models can also be used for different tasks than language generation. They can, for example, be used for sentiment analysis. After doing the basic training, a transformer can be fine-tuned for sentiment analysis by removing the outgoing linear layer and replacing it with a different layer suitable for the task to be executed. Consequently, it can be trained in a supervised fashion on a custom (sentiment analysis) dataset.\nInference (answer generation)\nDoing inference with a transformer is just like training. You insert a prompt and out comes the next word/classification/other.\nFor GPT models, this means that the prompt is extended one word at a time. You insert the prompt, and out comes the first word of the answer. The first word of the answer is now added to the prompt, creating a new, slightly different prompt. This prompt is again forwarded through the model, giving the prediction of a new word.\nAs the output is the probability for each token to be the next one, you can do several things during inference. For one, you can sample from the probability distribution. This induces some randomness into the algorithm. You can also take the token that has the highest probability; then, the model becomes deterministic.\nHow can a transformer do X?\nThe transformer can do X because it has seen enough examples of similar sentences in its training to give a satisfactory output to your prompt. However, for the question 'Why can a transformer not do X?' the answers are vastly more diverse.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can BERT be used for sentence generating tasks? I am a new learner in NLP. I am interested in the sentence generating task. As far as I am concerned, one state-of-the-art method is the CharRNN, which uses RNN to generate a sequence of words.\nHowever, BERT has come out several weeks ago and is very powerful. Therefore, I am wondering whether this task can also be done with the help of BERT? I am a new learner in this field, and thank you for any advice!\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "For newbies, NO.\nSentence generation requires sampling from a language model, which gives the probability distribution of the next word given previous contexts. But BERT can't do this due to its bidirectional nature.\n\nFor advanced researchers, YES.\nYou can start with a sentence of all [MASK] tokens, and generate words one by one in arbitrary order (instead of the common left-to-right chain decomposition). Though the text generation quality is hard to control.\nHere's the technical report BERT has a Mouth, and It Must Speak: BERT as a Markov Random Field Language Model, its errata and the source code.\n\nIn summary:\n\nIf you would like to do some research in the area of decoding with\nBERT, there is a huge space to explore\nIf you would like to generate\nhigh quality texts, personally I recommend you to check GPT-2.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is a switch from R to Python worth it? I just finished a 1-year Data Science master's program where we were taught R. I found that Python is more popular and has a larger community in AI.\nWhat are the advantages that Python may have over R in terms of features applicable to the field of Data Science and AI (other than popularity and larger community)? What positions in Data Science and AI would be more Python-heavy than R-heavy (especially comparing industry, academic, and government job positions)? In short, is Python worthwhile in all job situations or can I get by with only R in some positions?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I want to reframe your question.\nDon't think about switching, think about adding.\nIn data science you'll be able to go very far with either python or r but you'll go farthest with both.\nPython and r integrate very well, thanks to the reticulate package. I often tidy data in r because it is easier for me, train a model in python to benefit from superior speed and visualize the outcomes in r in beautiful ggplot all in one notebook!\nIf you already know r there is no sense in abandoning it, use it where sensible and easy to you. But it is 100% a good idea to add python for many uses.\nOnce you feel comfortable in both you'll have a workflow that fits you best dominated by your favorite language.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it possible to train the neural network to solve math equations? I'm aware that neural networks are probably not designed to do that, however asking hypothetically, is it possible to train the deep neural network (or similar) to solve math equations?\nSo given the 3 inputs: 1st number, operator sign represented by the number (1 - +, 2 - -, 3 - /, 4 - *, and so on), and the 2nd number, then after training the network should give me the valid results.\nExample 1 (2+2):\n\nInput 1: 2; Input 2: 1 (+); Input 3: 2; Expected output: 4\nInput 1: 10; Input 2: 2 (-); Input 3: 10; Expected output: 0\nInput 1: 5; Input 2: 4 (*); Input 3: 5; Expected output: 25\nand so\n\nThe above can be extended to more sophisticated examples.\nIs that possible? If so, what kind of network can learn/achieve that?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, it has been done!\nHowever, the applications aren't to replace calculators or anything like that. The lab I'm associated with develops neural network models of equational reasoning to better understand how humans might solve these problems. This is a part of the field known as Mathematical Cognition. Unfortunately, our website isn't terribly informative, but here's a link to an example of such work.\nApart from that, recent work on extending neural networks to include external memory stores (e.g. Neural Turing Machines) was used to solve math problems as a good proof of concept. This is because many arithmetic problems involve long procedures with stored intermediate results. See the sections of this paper on long binary addition and multiplication.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to find the optimal number of neurons per layer? When you're writing your algorithm, how do you know how many neurons you need per single layer? Are there any methods for finding the optimal number of them, or is it a rule of thumb?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is no direct way to find the optimal number of them: people empirically try and see (e.g., using cross-validation). The most common search techniques are random, manual, and grid searches. \nThere exist more advanced techniques such as Gaussian processes, e.g. Optimizing Neural Network Hyperparameters with Gaussian Processes for Dialog Act Classification, IEEE SLT 2016.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does an AI like ChatGPT answer a question in a subject which it may not know? After seeing StackOverflow's banning of ChatGPT, I explored it out of curiosity. It's marvellous as it can write code by itself!\nLater to check if it knows chess as well like Google-Deepmind's AlphaZero AI, I asked below questions:\n\nMe: Does openai know how to play chess?\nOpenAI: It is not clear whether OpenAI knows how to play chess. As an artificial intelligence research organization, OpenAI has developed a number of advanced machine learning algorithms and techniques that allow AI systems to learn and adapt to new tasks and situations. ...\n\n\nMe: In a chess if white has a king & bishop and if black has only a king, then who can win with a perfect play?\nOpenAI: In a chess game where white has a king and a bishop and black has only a king, it is possible for either player to win with perfect play. This type of endgame is known as a king and bishop versus king endgame, and it is considered one of the most challenging in chess. ...\n\nNow this answer is entirely wrong. Because as soon as only a bishop (or a knight) remains apart from the kings, it's instantly declared as a draw!\nQuestion: Shouldn't the AI reject my question on a subject which is not in its known criteria?\nIt does so for many other subjects.\n\nNote: Should we replace bishop = rook then ChatGPT answers exactly the same answer with replacing those pieces. However that happens to be true.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "ChatGPT is a large language model. That means it's very good at stringing together words in ways that humans tend to use them. It's able to construct sentences that are grammatically correct and sound natural, for the most part, because it's been trained on language.\nBecause it's good at stringing together words, it's able to take your prompt and generate words in a grammatically correct way that's similar to what it's seen before.\nBut that's all that it's doing: generating words and making sure it sounds natural. It doesn't have any built-in fact checking capabilities, and the manual limitations that OpenAI placed can be fairly easily worked around. Someone in the OpenAI Discord server a few days ago shared a screenshot of the question \"What mammal lays the largest eggs?\" ChatGPT confidently declared that the elephant lays the largest eggs of any mammal.\nWhile much of the information that ChatGPT was trained on is accurate, always keep in mind that it's just stringing together words with no way to check if what it's saying is accurate. Its sources may have been accurate, but just writing in the style of your sources doesn't mean that the results will themselves be true.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is sample efficiency, and how can importance sampling be used to achieve it? For instance, the title of this paper reads: \"Sample Efficient Actor-Critic with Experience Replay\".\nWhat is sample efficiency, and how can importance sampling be used to achieve it?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "An algorithm is sample efficient if it can get the most out of every sample. Imagine yourself playing PONG for the first time. As a human, it would take you within seconds to learn how to play the game based on very few samples. This makes you very \"sample efficient\". Modern RL algorithms would have to see $100$ thousand times more data than you so they are, relatively, sample inefficient.\nIn the case of off-policy learning, not all samples are useful in that they are not part of the distribution that we are interested in. Importance sampling is a technique to filter these samples. Its original use was to understand one distribution while only being able to take samples from a different but related distribution. In RL, this often comes up when trying to learn off-policy. Namely, that your samples are produced by some behaviour policy but you want to learn a target policy. Thus one needs to measure how important/similar the samples generated are to samples that the target policy may have made. Thus, one is sampling from a weighted distribution which favours these \"important\" samples. There are many methods, however, for characterizing what is important, and their effectiveness may differ depending on the application.\nThe most common approach to this off-policy style of importance sampling is finding a ratio of how likely a sample is to be generated by the target policy. The paper On a Connection between Importance Sampling and\nthe Likelihood Ratio Policy Gradient (2010) by Tang and Abbeel covers this topic.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can I deal with images of variable dimensions when doing image segmentation? I'm facing the problem of having images of different dimensions as inputs in a segmentation task. Note that the images do not even have the same aspect ratio.\nOne common approach that I found in general in deep learning is to crop the images, as it is also suggested here. However, in my case, I cannot crop the image and keep its center or something similar, since, in segmentation, I want the output to be of the same dimensions as the input.\nThis paper suggests that in a segmentation task one can feed the same image multiple times to the network but with a different scale and then aggregate the results. If I understand this approach correctly, it would only work if all the input images have the same aspect ratio. Please correct me if I am wrong.\nAnother alternative would be to just resize each image to fixed dimensions. I think this was also proposed by the answer to this question. However, it is not specified in what way images are resized.\nI considered taking the maximum width and height in the dataset and resizing all the images to that fixed size in an attempt to avoid information loss. However, I believe that our network might have difficulties with distorted images as the edges in an image might not be clear. \n\nWhat is possibly the best way to resize your images before feeding them to the network?\nIs there any other option that I am not aware of for solving the problem of having images of different dimensions?\nAlso, which of these approaches you think is the best taking into account the computational complexity but also the possible loss of performance by the network? \n\nI would appreciate if the answers to my questions include some link to a source if there is one.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are 2 problems you might face.\n\nYour neural net (in this case convolutional neural net) cannot physically accept images of different resolutions. This is usually the case if one has fully-connected layers, however, if the network is fully-convolutional, then it should be able to accept images of any dimension. Fully-convolutional implies that it doesn't contain fully-connected layers, but only convolutional, max-pooling, and batch normalization layers all of which are invariant to the size of the image. \nExactly this approach was proposed in this ground-breaking paper Fully Convolutional Networks for Semantic Segmentation. Keep in mind that their architecture and training methods might be slightly outdated by now. A similar approach was used in widely used U-Net: Convolutional Networks for Biomedical Image Segmentation, and many other architectures for object detection, pose estimation, and segmentation.\nConvolutional neural nets are not scale-invariant. For example, if one trains on the cats of the same size in pixels on images of a fixed resolution, the net would fail on images of smaller or larger sizes of cats. In order to overcome this problem, I know of two methods (might be more in the literature): \n\nmulti-scale training of images of different sizes in fully-convolutional nets in order to make the model more robust to changes in scale; and \nhaving multi-scale architecture. \n\nA place to start is to look at these two notable papers: Feature Pyramid Networks for Object Detection and High-Resolution Representations for Labeling Pixels and Regions.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Where can I find the proof of the universal approximation theorem? The Wikipedia article for the universal approximation theorem cites a version of the universal approximation theorem for Lebesgue-measurable functions from this conference paper. However, the paper does not include the proofs of the theorem. Does anybody know where the proof can be found?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are multiple papers on the topic because there have been multiple attempts to prove that neural networks are universal (i.e. they can approximate any continuous function) from slightly different perspectives and using slightly different assumptions (e.g. assuming that certain activation functions are used). Note that these proofs tell you that neural networks can approximate any continuous function, but they do not tell you exactly how you need to train your neural network so that it approximates your desired function. Moreover, most papers on the topic are quite technical and mathematical, so, if you do not have a solid knowledge of approximation theory and related fields, they may be difficult to read and understand. Nonetheless, below there are some links to some possibly useful articles and papers.\nThe article A visual proof that neural nets can compute any function (by Michael Nielsen) should give you some intuition behind the universality of neural networks, so this is probably the first article you should read.\nThen you should probably read the paper Approximation by Superpositions of a Sigmoidal Function (1989), by G. Cybenko, who proves that multi-layer perceptrons (i.e. feed-forward neural networks with at least one hidden layer) can approximate any continuous function. However, he assumes that the neural network uses sigmoid activations functions, which, nowadays, have been replaced in many scenarios by ReLU activation functions. Other works (e.g. [1], [2]) showed that you don't necessarily need sigmoid activation functions, but only certain classes of activation functions do not make neural networks universal.\nThe universality property (i.e. the ability to approximate any continuous function) has also been proved in the case of convolutional neural networks. For example, see Universality of Deep Convolutional Neural Networks (2020), by Ding-Xuan Zhou, which shows that convolutional neural networks can approximate any continuous function to an arbitrary accuracy when the depth of the neural network is large enough. See also Refinement and Universal Approximation via Sparsely Connected ReLU Convolution Nets (by A. Heinecke et al., 2020)\nSee also page 632 of Recurrent Neural Networks Are Universal Approximators (2006), by Sch\u00e4fer et al., which shows that recurrent neural networks are universal function approximators. See also On the computational power of neural nets (1992, COLT) by Siegelmann and Sontag. This answer could also be useful.\nFor graph neural networks, see Universal Function Approximation on Graphs (by Rickard Br\u00fcel Gabrielsson, 2020, NeurIPS)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the Bellman operator in reinforcement learning? In mathematics, the word operator can refer to several distinct but related concepts. An operator can be defined as a function between two vector spaces, it can be defined as a function where the domain and the codomain are the same, or it can be defined as a function from functions (which are vectors) to other functions (for example, the differential operator), that is, a high-order function (if you are familiar with functional programming).\n\nWhat is the Bellman operator in reinforcement learning (RL)?\nWhy do we even need it?\nHow is the Bellman operator related to the Bellman equations in RL?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The notation I'll be using is from two different lectures by David Silver and is also informed by these slides.\nThe expected Bellman equation is\n$$v_\\pi(s) = \\sum_{a\\in \\cal{A}} \\pi(a|s) \\left(\\cal{R}_s^a + \\gamma\\sum_{s' \\in \\cal{S}} \\cal{P}_{ss'}^a v_\\pi(s')\\right) \\tag 1$$\nIf we let\n$$\\cal{P}_{ss'}^\\pi = \\sum\\limits_{a \\in \\cal{A}} \\pi(a|s)\\cal{P}_{ss'}^a \\tag 2$$\nand\n$$\\cal{R}_{s}^\\pi = \\sum\\limits_{a \\in \\cal{A}} \\pi(a|s)\\cal{R}_{s}^a \\tag 3$$\nthen we can rewrite $(1)$ as\n$$v_\\pi(s) = \\cal{R}_s^\\pi + \\gamma\\sum_{s' \\in \\cal{S}} \\cal{P}_{ss'}^\\pi v_\\pi(s') \\tag 4$$\nThis can be written in matrix form\n$$\\left.\n\\begin{bmatrix}\nv_\\pi(1) \\\\\n\\vdots \\\\\nv_\\pi(n)\n\\end{bmatrix}=\n\\begin{bmatrix}\n\\cal{R}_1^\\pi \\\\\n\\vdots \\\\\n\\cal{R}_n^\\pi\n\\end{bmatrix}\n+\\gamma\n\\begin{bmatrix}\n\\cal{P}_{11}^\\pi & \\dots & \\cal{P}_{1n}^\\pi\\\\\n\\vdots & \\ddots & \\vdots\\\\\n\\cal{P}_{n1}^\\pi & \\dots & \\cal{P}_{nn}^\\pi\n\\end{bmatrix}\n\\begin{bmatrix}\nv_\\pi(1) \\\\\n\\vdots \\\\\nv_\\pi(n)\n\\end{bmatrix}\n\\right. \\tag 5$$\nOr, more compactly,\n$$v_\\pi = \\cal{R}^\\pi + \\gamma \\cal{P}^\\pi v_\\pi \\tag 6$$\nNotice that both sides of $(6)$ are $n$-dimensional vectors. Here $n=|\\cal{S}|$ is the size of the state space. We can then define an operator $\\cal{T}^\\pi:\\mathbb{R}^n\\to\\mathbb{R}^n$ as\n$$\\cal{T^\\pi}(v) = \\cal{R}^\\pi + \\gamma \\cal{P}^\\pi v \\tag 7$$\nfor any $v\\in \\mathbb{R}^n$. This is the expected Bellman operator.\nSimilarly, you can rewrite the Bellman optimality equation\n$$v_*(s) = \\max_{a\\in\\cal{A}} \\left(\\cal{R}_s^a + \\gamma\\sum_{s' \\in \\cal{S}} \\cal{P}_{ss'}^a v_*(s')\\right) \\tag 8$$\nas the Bellman optimality operator\n$$\\cal{T^*}(v) = \\max_{a\\in\\cal{A}} \\left(\\cal{R}^a + \\gamma \\cal{P}^a v\\right) \\tag 9$$\nThe Bellman operators are \"operators\" in that they are mappings from one point to another within the vector space of state values, $\\mathbb{R}^n$.\nRewriting the Bellman equations as operators is useful for proving that certain dynamic programming algorithms (e.g. policy iteration, value iteration) converge to a unique fixed point. This usefulness comes in the form of a body of existing work in operator theory, which allows us to make use of special properties of the Bellman operators.\nSpecifically, the fact that the Bellman operators are contractions gives the useful results that, for any policy $\\pi$ and any initial vector $v$,\n$$\\lim_{k\\to\\infty}(\\cal{T}^\\pi)^k v = v_\\pi \\tag{10}$$\n$$\\lim_{k\\to\\infty}(\\cal{T}^*)^k v = v_* \\tag{11}$$\nwhere $v_\\pi$ is the value of policy $\\pi$ and $v_*$ is the value of an optimal policy $\\pi^*$. The proof is due to the contraction mapping theorem.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the credit assignment problem? In reinforcement learning (RL), the credit assignment problem (CAP) seems to be an important problem. What is the CAP? Why is it relevant to RL?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In reinforcement learning (RL), an agent interacts with an environment in time steps. On each time step, the agent takes an action in a certain state and the environment emits a percept or perception, which is composed of a reward and an observation, which, in the case of fully-observable MDPs, is the next state (of the environment and the agent). The goal of the agent is to maximise the reward in the long run.\nThe (temporal) credit assignment problem (CAP) (discussed in Steps Toward Artificial Intelligence by Marvin Minsky in 1961) is the problem of determining the actions that lead to a certain outcome. \nFor example, in football, at each second, each football player takes an action. In this context, an action can e.g. be \"pass the ball\", \"dribbe\", \"run\" or \"shoot the ball\". At the end of the football match, the outcome can either be a victory, a loss or a tie. After the match, the coach talks to the players and analyses the match and the performance of each player. He discusses the contribution of each player to the result of the match. The problem of determinig the contribution of each player to the result of the match is the (temporal) credit assignment problem.\nHow is this related to RL? In order to maximise the reward in the long run, the agent needs to determine which actions will lead to such outcome, which is essentially the temporal CAP.\nWhy is it called credit assignment problem? In this context, the word credit is a synonym for value. In RL, an action that leads to a higher final cumulative reward should have more value (so more \"credit\" should be assigned to it) than an action that leads to a lower final reward.\nWhy is the CAP relevant to RL? Most RL agents attempt to solve the CAP. For example, a $Q$-learning agent attempts to learn an (optimal) value function. To do so, it needs to determine the actions that will lead to the highest value in each state.\nThere are a few variations of the (temporal) CAP problem. For example, the structural CAP, that is, the problem of assigning credit to each structural component (which might contribute to the final outcome) of the system.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is a deep neural network different from other neural networks? How is a neural network having the \"deep\" adjective actually distinguished from other similar networks?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The difference is mostly in the number of layers. \nFor a long time, it was believed that \"1-2 hidden layers are enough for most tasks\" and it was impractical to use more than that, because training neural networks can be very computationally demanding.\nNowadays, computers are capable of much more, so people have started to use networks with more layers and found that they work very well for some tasks.\nThe word \"deep\" is there simply to distinguish these networks from the traditional, \"more shallow\" ones.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it possible to train a neural network as new classes are given? I would like to train a neural network (NN) where the output classes are not (all) defined from the start. More and more classes will be introduced later based on incoming data. This means that, every time I introduce a new class, I would need to retrain the NN.\nHow can I train an NN incrementally, that is, without forgetting the previously acquired information during the previous training phases?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I'd like to add to what's been said already that your question touches upon an important notion in machine learning called transfer learning. In practice, very few people train an entire convolutional network from scratch (with random initialization), because it is time consuming and relatively rare to have a dataset of sufficient size. \nModern ConvNets take 2-3 weeks to train across multiple GPUs on ImageNet. So it is common to see people release their final ConvNet checkpoints for the benefit of others who can use the networks for fine-tuning. For example, the Caffe library has a Model Zoo where people share their network weights.\nWhen you need a ConvNet for image recognition, no matter what your application domain is, you should consider taking an existing network, for example VGGNet is a common choice.\nThere are a few things to keep in mind when performing transfer learning:\n\nConstraints from pretrained models. Note that if you wish to use a pretrained network, you may be slightly constrained in terms of the architecture you can use for your new dataset. For example, you can\u2019t arbitrarily take out Conv layers from the pretrained network. However, some changes are straight-forward: due to parameter sharing, you can easily run a pretrained network on images of different spatial size. This is clearly evident in the case of Conv/Pool layers because their forward function is independent of the input volume spatial size (as long as the strides \u201cfit\u201d).\nLearning rates. It\u2019s common to use a smaller learning rate for ConvNet weights that are being fine-tuned, in comparison to the (randomly-initialized) weights for the new linear classifier that computes the class scores of your new dataset. This is because we expect that the ConvNet weights are relatively good, so we don\u2019t wish to distort them too quickly and too much (especially while the new Linear Classifier above them is being trained from random initialization).\n\nAdditional reference if you are interested in this topic: How transferable are features in deep neural networks?\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is BERT different from the original transformer architecture? As far as I can tell, BERT is a type of Transformer architecture. What I do not understand is:\n\nHow is Bert different from the original transformer architecture?\n\nWhat tasks are better suited for BERT, and what tasks are better suited for the original architecture?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "What is a transformer?\nThe original transformer, proposed in the paper Attention is all you need (2017), is an encoder-decoder-based neural network that is mainly characterized by the use of the so-called attention (i.e. a mechanism that determines the importance of words to other words in a sentence or which words are more likely to come together) and the non-use of recurrent connections (or recurrent neural networks) to solve tasks that involve sequences (or sentences), even though RNN-based systems were becoming the standard practice to solve natural language processing (NLP) or understanding (NLU) tasks. Hence the name of the paper \"Attention is all you need\", i.e. you only need attention and you don't need recurrent connections to solve NLP tasks.\nBoth the encoder-decoder architecture and the attention mechanism are not novel proposals. In fact, previous neural network architectures to solve many NLP tasks, such as machine translation, had already used these mechanisms (for example, take a look at this paper). The novelty of the transformer and this cited paper is that it shows that we can simply use attention to solve tasks that involve sequences (such as machine translation) and we do not need recurrent connections, which is an advantage, given that recurrent connections can hinder the parallelization of the training process.\nThe original transformer architecture is depicted in figure 1 of the cited paper. Both the encoder and decoder are composed of\n\nattention modules\nfeed-forward (or fully connected) layers\nresidual (or skip) connections\nnormalization layers\ndropout\nlabel smoothing\nembedding layers\npositional encoding\n\nThe decoder part is also composed of a linear layer followed by a softmax to solve the specific NLP task (for example, predict the next word in a sentence).\nWhat is BERT?\nBERT stands for Bidirectional Encoder Representations from\nTransformers, so, as the name suggests, it is a way of learning representations of a language that uses a transformer, specifically, the encoder part of the transformer.\nWhat is the difference between the transformer and BERT?\n\nBERT is a language model, i.e. it represents the statistical relationships of the words in a language, i.e. which words are more likely to come after another word and stuff like that. Hence the part Representations in its name, Bidirectional Encoder Representations from\nTransformers.\nBERT can be trained in an unsupervised way for representation learning, and then we can fine-tune BERT on the so-called downstream tasks in a supervised fashion (i.e. transfer learning). There are pre-trained versions of BERT that can be already fine-tuned (e.g. this one) and used to solve your specific supervised learning task. You can play with this TensorFlow tutorial to use a pre-trained BERT model.\nOn the other hand, the original transformer was not originally conceived to be a language model, but to solve sequence transduction tasks (i.e. converting one sequence to another, such as machine translation) without recurrent connections (or convolutions) but only attention.\n\nBERT is only an encoder, while the original transformer is composed of an encoder and decoder. Given that BERT uses an encoder that is very similar to the original encoder of the transformer, we can say that BERT is a transformer-based model. So, BERT does not use recurrent connections, but only attention and feed-forward layers. There are other transformer-based neural networks that use only the decoder part of the transformer, for example, the GPT model.\n\nBERT uses different hyper-parameters than the ones used in Attention is all you need to achieve the best performance. For example, it uses 12 and 16 \"attention heads\" (please, read the transformer paper to know more about these \"attention heads\") rather than 8 (although in the original transformer paper the authors experimented with a different number of heads).\n\nBERT also uses segment embeddings, while the original transformer only uses word embeddings and positional encodings.\n\n\nThere are probably other small differences that I missed, but, after having read the paper Attention is all you need and quickly read some parts of the BERT paper, these seem to be the main differences.\nWhen to use BERT and the transformer?\nAlthough I never used them, I would say that you want to use BERT whenever you want to solve an NLP task in a supervised fashion, but your labeled training dataset is not big enough to achieve good performance. In that case, you start with a pre-trained BERT model, then fine-tune it with your small labeled dataset. You probably need to add specific layers to BERT to solve your task.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are \"bottlenecks\" in neural networks? What are \"bottlenecks\" in the context of neural networks?\nThis term is mentioned, for example, in this TensorFlow article, which also uses the term \"bottleneck values\". How does one calculate bottleneck values? How do these values help image classification?\nPlease explain in simple words.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The bottleneck in a neural network is just a layer with fewer neurons than the layer below or above it. Having such a layer encourages the network to compress feature representations (of salient features for the target variable) to best fit in the available space. Improvements to compression occur due to the goal of reducing the cost function, as for all weight updates.\nIn a CNN (such as Google's Inception network), bottleneck layers are added to reduce the number of feature maps (aka channels) in the network, which, otherwise, tend to increase in each layer. This is achieved by using 1x1 convolutions with fewer output channels than input channels.\nYou don't usually calculate weights for bottleneck layers directly, the training process handles that, as for all other weights. Selecting a good size for a bottleneck layer is something you have to guess, and then experiment, in order to find network architectures that work well. The goal here is usually finding a network that generalises well to new images, and bottleneck layers help by reducing the number of parameters in the network whilst still allowing it to be deep and represent many feature maps.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is Lisp still being used to tackle AI problems? I know that language of Lisp was used early on when working on artificial intelligence problems. Is it still being used today for significant work? If not, is there a new language that has taken its place as the most common one being used for work in AI today?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Overall, the answer is no, but the current paradigms owe a lot to LISP. The language most commonly used today is python.\nRelevant answers:\n\nStack Overflow thread explaining why LISP was thought of as the AI language: Why is Lisp used for AI\nQuora answer by Peter Norvig, who wrote a popular textbook on the subject and is currently Director of Research at Google: Is it true that Lisp is highly used programming language in AI?\n\nLISP pioneered many important concepts in what we now call functional programming, with a key attraction being how close the programs were to math. Many of these features have since been incorporated into modern languages (see the Wikipedia page). LISP is very expressive: it has very little syntax (just lists and some elementary operations on them) but you can write short succinct programs that represent complex ideas. This amazes newcomers and has sold it as the language for AI. However, this is a property of programs in general. Short programs can represent complex concepts. And while you can write powerful code in LISP, any beginner will tell you that it is also very hard to read anyone else's LISP code or to debug your own LISP code. Initially, there were also performance considerations with functional programming and it fell out of favor to be replaced by low level imperative languages like C. (For example, functional programming requires that no object ever be changed (\"mutated\"), so every operation requires a new object to be created. Without good garbage collection, this can get unwieldy). Today, we've learned that a mix of functional and imperative programming is needed to write good code and modern languages like python, ruby and scala support both. At this point, and this is just my opinion, there is no reason to prefer LISP over python.\nThe paradigm for AI that currently receives the most attention is Machine Learning, where we learn from data, as opposed to previous approaches like Expert Systems (in the 80s) where experts wrote rules for the AI to follow. Python is currently the most widely used language for machine learning and has many libraries, e.g. Tensorflow and Pytorch, and an active community. To process the massive amounts of data, we need systems like Hadoop, Hive or Spark. Code for these is written in python, java or scala. Often, the core time-intensive subroutines are written in C.\nThe AI Winter of the 80s was not because we did not have the right language, but because we did not have the right algorithms, enough computational power and enough data. If you're trying to learn AI, spend your time studying algorithms and not languages.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are Siri and Cortana AI programs? Siri and Cortana communicate pretty much like humans. Unlike Google Now, which mainly gives us search results when asked some questions (not setting alarms or reminders), Siri and Cortana provide us with an answer, in the same way that a person would do.\nSo, are they actual AI programs or not?\n(By \"question\" I don't mean any academic-related question or asking routes/ temperature, but rather opinion based question).\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Siri and Cortana are AI to some extent. The usual label is \"weak AI\" (also called \"narrow\" or \"soft\" AI). It turns out the Wikipedia article on Weak AI explicitly refers to Siri:\n\nSiri is a good example of narrow intelligence. Siri operates within a limited pre-defined range, there is no genuine intelligence, no self-awareness, no life despite being a sophisticated example of weak AI. In Forbes (2011), Ted Greenwald wrote: \"The iPhone/Siri marriage represents the arrival of hybrid AI, combining several narrow AI techniques plus access to massive data in the cloud.\" AI researcher Ben Goertzel, on his blog in 2010, stated Siri was \"VERY narrow and brittle\" evidenced by annoying results if you ask questions outside the limits of the application.\n\nImportant to note that \"mixing\" weak AIs does not make a \"stronger\" AI, by some arguments (see Searle's Chinese Room argument), but there is no consensus on this topic yet.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How could we build a neural network that is invariant to permutations of the inputs? \nGiven a neural network $f$ that takes as input $n$ data points: $x_1, \\dots, x_n$. We say $f$ is permutation invariant if\n$$f(x_1 ... x_n) = f(\\sigma(x_1 ... x_n))$$\nfor any permutation $\\sigma$.\n\nHow could we build such a neural network? The output can be anything (e.g. a number or vector), as long as it does not depend on the order of inputs. Is there any research work on these types of neural networks?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Traditionally, due to the way the network is structured, each input has a set of weights, that are connected to more inputs. If the inputs switch, the output will too.\nApproach 1\nHowever, you can build a network that approaches this behaviour. In your training set, use batch learning and for each training sample, give all possible permutations to the network such that it learns to be permutation invariant. This will never be exactly invariant, it just might be close.\nApproach 2\nAnother way to do this is to have the weights replicated for all inputs. For example, let's assume you have 3 inputs ($i_0, i_1, i_2$), and the next/first hidden layer has 2 nodes ($h_{10}, h_{11}$) and activation function $\\phi$. Assuming a fully connected layer, you have 2 weights $w_0$ and $w_1$. The hidden layer's nodes $h_{10}$ and $h_{11}$ are given, respectively, by\n\n$h_{10} = \\phi(i_0 w_0 + i_1 w_0 + i_2 w_0)$\n\n$h_{11} = \\phi(i_0 w_1 + i_1 w_1 + i_2 w_1)$\n\n\nThus giving you a hidden layer whose values are permutation invariant from the input. From now on, you can learn and build the rest of the network as you see fit. This is an approach derived from convolutional layers.\nApproach 3\nFinally, you can use a dimension reduction to achieve this. I've published this in Exploring Communication Protocols and Centralized Critics in Multi-Agent Deep Learning, on Integrated Computer-Aided Engineering. This approach uses convolutional architectures to efficiently achieve permutation invariance.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does C++ seem less widely used than Python in AI? I just want to know why do machine learning engineers and AI programmers use languages like Python to perform AI tasks and not C++, even though C++ is technically a more powerful language than Python.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You don't need a powerful language for programming AI. Most of the developers are using libraries like Keras, Torch, Caffe, Watson, TensorFlow, etc. Those low level libraries are highly optimized and handle all the tough work. They are built with high-performance languages, like C, C++. Python is just there for high level task like describing the neural network layers, load data, launch the processing, and display results. \nUsing C++ for high level task instead of Python would give barely any performance improvement, but it would be harder for non-developers as it requires to care for memory management. Also, several AI people may not have a very solid programming or computer science background.\nAnother similar example would be game development, where the engine is coded in C/C++, and, often, all the game logic scripted in a higher-level language.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there any research on the development of attacks against artificial intelligence systems? Is there any research on the development of attacks against artificial intelligence systems?\nFor example, is there a way to generate a letter \"A\", which every human being in this world can recognize but, if it is shown to the state-of-the-art character recognition system, this system will fail to recognize it? Or spoken audio which can be easily recognized by everyone but will fail on the state-of-the-art speech recognition system. \nIf there exists such a thing, is this technology a theory-based science (mathematics proved) or an experimental science (randomly add different types of noise and feed into the AI system and see how it works)? Where can I find such material? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, there is some research on this topic, which can be called adversarial machine learning, which is more an experimental field.\nAn adversarial example is an input similar to the ones used to train the model, but that leads the model to produce an unexpected outcome. For example, consider an artificial neural network (ANN) trained to distinguish between oranges and apples. You are then given an image of an apple similar to another image used to train the ANN, but that is slightly blurred. Then you pass it to the ANN, which unexpectedly predicts the object to be an orange.\nSeveral machine learning and optimization methods have been used to detect the boundary behaviour of machine learning models, that is, the unexpected behaviour of the model that produces different outcomes given two slightly different inputs (but that correspond to the same object). For example, evolutionary algorithms have been used to develop tests for self-driving cars. See, for example, Automatically testing self-driving cars with search-based procedural content generation (2019) by Alessio Gambi et al.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the minimum requirements to call something AI? I believe artificial intelligence (AI) term is overused nowadays. For example, people see that something is self-moving and they call it AI, even if it's on autopilot (like cars or planes) or there is some simple algorithm behind it.\nWhat are the minimum general requirements so that we can say something is AI?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It's true that the term has become a buzzword, and is now widely used to a point of confusion - however if you look at the definition provided by Stuart Russell and Peter Norvig, they write it as follows:\n\nWe define AI as the study of agents that receive percepts from the environment and perform actions. Each such agent implements a function that maps percept sequences to actions, and we cover different ways to represent these functions, such as reactive agents, real-time planners, and decision-theoretic systems. We explain the role of learning as extending the reach of the designer into unknown environments, and we show how that role constrains agent design, favoring explicit knowledge representation and reasoning.\n\nArtificial Intelligence: A Modern Approach - Stuart Russell and Peter Norvig\nSo the example you cite, \"autopilot for cars/planes\", is actually a (famous) form of AI as it has to use a form of knowledge representation to deal with unknown environments and circumstances. Ultimately, these systems also collect data so that the knowledge representation can be updated to deal with the new inputs that they have found. They do this with autopilot for cars all the time\nSo, directly to your question, for something to be considered as \"having AI\", it needs to be able to deal with unknown environments/circumstances in order to achieve its objective/goal, and render knowledge in a manner that provides for new learning/information to be added easily. There are many different types of well defined knowledge representation methods, ranging from the popular neural net, through to probabilistic models like bayesian networks (belief networks) - but fundamentally actions by the system must be derived from whichever representation of knowledge you choose for it to be considered as AI.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What exactly are the \"parameters\" in GPT-3's 175 billion parameters and how are they chosen/generated? When I studied neural networks, parameters were learning rate, batch size etc. But even GPT3's ArXiv paper does not mention anything about what exactly the parameters are, but gives a small hint that they might just be sentences.\n\nEven tutorial sites like this one start talking about the usual parameters, but also say \"model_name: This indicates which model we are using. In our case, we are using the GPT-2 model with 345 million parameters or weights\". So are the 175 billion \"parameters\" just neural weights? Why then are they called parameters? GPT3's paper shows that there are only 96 layers, so I'm assuming it's not a very deep network, but extremely fat. Or does it mean that each \"parameter\" is just a representation of the encoders or decoders?\n\nAn excerpt from this website shows tokens:\n\nIn this case, there are two additional parameters that can be passed\nto gpt2.generate(): truncate and include_prefix. For example, if each\nshort text begins with a <|startoftext|> token and ends with a\n<|endoftext|>, then setting prefix='<|startoftext|>',\ntruncate=<|endoftext|>', and include_prefix=False, and length is\nsufficient, then gpt-2-simple will automatically extract the shortform\ntexts, even when generating in batches.\n\nSo are the parameters various kinds of tokens that are manually created by humans who try to fine-tune the models? Still, 175 billion such fine-tuning parameters is too high for humans to create, so I assume the \"parameters\" are auto-generated somehow.\nThe attention-based paper mentions the query-key-value weight matrices as the \"parameters\". Even if it is these weights, I'd just like to know what kind of a process generates these parameters, who chooses the parameters and specifies the relevance of words? If it's created automatically, how is it done?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Parameters is a synonym for weights, which is the term most people use for a neural networks parameters (and indeed in my experience it is a term that machine learners will use in general whereas parameters is more often found in statistics literature). Batch size, learning rate etc. are hyper-parameters which basically means they are user specified, whereas weights are what the learning algorithm will learn through training.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is Prolog still used in AI? According to Wikipedia,\n\nProlog is a general-purpose logic programming language associated with artificial intelligence and computational linguistics.\n\nIs it still used for AI?\n\nThis is based off of a question on the 2014 closed beta. The author had the UID of 330.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Remembering that artificial intelligence has been an academic endeavour for the longest time, Prolog was amongst one of the early languages used as part of the study and implementation of it. It has rarely made its way into large commercial applications, having said that, a famous commercial implementation is in Watson, where prolog is used for NLP.\nThe University of Edinburgh contributed to the language and it was sometimes referred to as \"Edinburgh Prolog\". It is still used in academic teachings there as part of the artificial intelligence course.\nThe reason why Prolog is considered powerful in AI is because the language allows for easy management of recursive methods, and pattern matching.\nTo quote Adam Lally from the IBM Thomas J. Watson Research Center, and Paul Fodor from Stony Brook University:\n\nthe Prolog language is very expressive allowing recursive rules to represent reachability in parse trees and the operation of negation-as-failure to check the absence of conditions.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do ChatGPT \u201cjailbreaks\u201d work? Do developers not genuinely want to prevent them? It seems like if they are able to develop such impressive AI models then it wouldn\u2019t be that difficult to create catch-all/wildcard mitigations to the various jailbreak methods that are devised over time.\nWhat gives? (i.e., what is so difficult about plugging these holes, or why might the developers not really want to do so?)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\"Jailbreaks\" work for a variety of reasons:\n\nA lot of the setup that turns an LLM instance into a polite, well-behaved chatbot is actually just a hidden piece of starting text (a \"pre-prompt\" or a \"system prompt\") that the LLM processes in the same way as user input - the system text will always be inserted first, so sets context for how other text is processed, but is not otherwise privileged. There are other components and factors involved, but the LLM at the centre of it all remains a text-prediction engine that works with the text it has seen so far. When it processes multiple conflicting wording and rules, the core system does not always have an easy way to prioritise, and can decide to base predictions on new instructions instead of old ones.\n\nMany \"Jailbreaks\" are creative in that they obey the letter of the law from the pre-prompt and training rules, but re-frame a conversation into a place where issues that would be blocked by rules are no longer valid. A very common jailbreak theme is to get the chatbot to respond as if it is writing fiction from some imagined perspective that is not its assigned identity.\n\nIt is very hard to detect and block jailbreaks without also blocking uses that are intended or supported. The task is not dissimilar to trying to control a conversation between two people by writing down a list of rules for one of them to follow, that they can consult when they answer. The rules have to be simple and objective so they can be followed, but a conversation can progress in many ways which make it tricky to process whether a rule applies. For example conversation topic can become subjective, and/or allegorical, it can consist of asides and multiple layers etc.\n\nLLMs are very complex internally, and driven by an amount of data that is next to impossible for a human to navigate. The developers cannot exert detailed control on the models - we're still in the phase of not fully understanding how an LLM can perform some of the types of processing that it does. These things are being unpicked in published papers, but the work is not complete.\n\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can the decoder in a transformer model be parallelized like the encoder? Can the decoder in a transformer model be parallelized like the encoder?\nAs far as I understand, the encoder has all the tokens in the sequence to compute the self-attention scores. But for a decoder, this is not possible (in both training and testing), as self-attention is calculated based on previous timestep outputs. Even if we consider some techniques, like teacher forcing, where we are concatenating expected output with obtained, this still has a sequential input from the previous timestep. \nIn this case, apart from the improvement in capturing long-term dependencies, is using a transformer-decoder better than say an LSTM, when comparing purely on the basis of parallelization?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nCan the decoder in a transformer model be parallelized like the\nencoder?\n\nGenerally NO:\nYour understanding is completely right. In the decoder, the output of each step is fed to the bottom decoder in the next time step, just like an LSTM.\nAlso, like in LSTMs, the self-attention layer needs to attend to earlier positions in the output sequence in order to compute the output. Which makes straight parallelisation impossible.\nHowever, when decoding during training, there is a frequently used procedure which doesn't take the previous output of the model at step t as input at step t+1, but rather takes the ground truth output at step t. This procudure is called 'Teacher Forcing' and makes the decoder parallelised during training. You can read more about it here.\nAnd For detailed explanation of how Transformer works I suggest reading this article: The Illustrated Transformer.\n\nIs using a transformer-decoder better than say an lstm when comparing\npurely on the basis of parallelization?\n\nYES:\nParallelization is the main drawback of RNNs in general. In a simple way, RNNs have the ability to memorize but not parallelize while CNNs have the opposite. Transformers are so powerful because they combine both parallelization (at least partially) and memorizing.\nIn Natural Language Processing for example, where RNNs are used to be so effective, if you take a look at GLUE leaderboard you will find that most of the world leading algorithms today are Transformer-based (e.g BERT by GOOGLE, GPT by OpenAI..)\nFor better understanding of why Transformers are better than CNNs I suggest reading this Medium article: How Transformers Work.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do I handle large images when training a CNN? Suppose that I have 10K images of sizes $2400 \\times 2400$ to train a CNN. \nHow do I handle such large image sizes without downsampling?\nHere are a few more specific questions.\n\nAre there any techniques to handle such large images which are to be trained?\nWhat batch size is reasonable to use?\nAre there any precautions to take, or any increase and decrease in hardware resources that I can do?\n\nHere are the system requirements\nUbuntu 16.04 64-bit \nRAM 16 GB\nGPU 8 GB\nHDD 500 GB\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nHow do I handle such large image sizes without downsampling?\n\nI assume that by downsampling you mean scaling down the input before passing it into CNN. Convolutional layer allows to downsample the image within a network, by picking a large stride, which is going to save resources for the next layers. In fact, that's what it has to do, otherwise your model won't fit in GPU.\n\n\nAre there any techniques to handle such large images which are to be trained?\n\n\nCommonly researches scale the images to a resonable size. But if that's not an option for you, you'll need to restrict your CNN. In addition to downsampling in early layers, I would recommend you to get rid of FC layer (which normally takes most of parameters) in favor of convolutional layer. Also you will have to stream your data in each epoch, because it won't fit into your GPU.\nNote that none of this will prevent heavy computational load in the early layers, exactly because the input is so large: convolution is an expensive operation and the first layers will perform a lot of them in each forward and backward pass. In short, training will be slow.\n\n\nWhat batch size is reasonable to use?\n\n\nHere's another problem. A single image takes 2400x2400x3x4 (3 channels and 4 bytes per pixel) which is ~70Mb, so you can hardly afford even a batch size 10. More realistically would be 5. Note that most of the memory will be taken by CNN parameters. I think in this case it makes sense reduce the size by using 16-bit values rather than 32-bit - this way you'll be able to double the batches.\n\n\nAre there any precautions to take, or any increase and decrease in hardware resources that I can do?\n\n\nYour bottleneck is GPU memory. If you can afford another GPU, get it and split the network across them. Everything else is insignificant compared to GPU memory.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a Dynamic Computational Graph? Frameworks like PyTorch and TensorFlow through TensorFlow Fold support Dynamic Computational Graphs and are receiving attention from data scientists.\nHowever, there seems to be a lack of resource to aid in understanding Dynamic Computational Graphs.\nThe advantage of Dynamic Computational Graphs appears to include the ability to adapt to a varying quantities in input data. It seems like there may be automatic selection of the number of layers, the number of neurons in each layer, the activation function, and other NN parameters, depending on each input set instance during the training. Is this an accurate characterization?\nWhat are the advantages of dynamic models over static models? Is that why DCGs are receiving much attention? In summary, what are DCGs and what are the pros and cons their use?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Two Short Answers\nThe short answer from a theoretical perspective is that ...\n\nA Dynamic Computational Graph is a mutable system represented as a directed graph of data flow between operations. It can be visualized as shapes containing text connected by arrows, whereby the vertices (shapes) represent operations on the data flowing along the edges (arrows).\n\nNote that such a graph defines dependencies in the data flow but not necessarily the temporal order of the application of operations, which can become ambiguous in the retention of state in vertices or cycles in the graph without an additional mechanism to specify temporal precedence.\nThe short answer from an applications development perspective is that ...\n\nA Dynamic Computational Graph framework is a system of libraries, interfaces, and components that provide a flexible, programmatic, run time interface that facilitates the construction and modification of systems by connecting a finite but perhaps extensible set of operations.\n\nThe PyTorch Framework\nPyTorch is the integration of the Torch framework with the Python language and data structuring. Torch competes with Theano, TensorFlow, and other dynamic computational system construction frameworks.\n\n\n\u2014\u2014\u2014 \u00a0 Additional Approaches to Understanding \u00a0 \u2014\u2014\u2014\n\nArbitrary Computational Structures of Arbitrary Discrete Tensors\nOne of the components that can be used to construct a computational system is an element designed to be interconnected to create neural networks. The availability of these supports the construction of deep learning and back-propagating neural networks. A wide variety of other systems involving the assembly of components that work with potentially multidimensional data in arbitrarily defined computational structures can also be constructed.\nThe data can be scalar values, such as floating-point numbers, integers, or strings, or orthogonal aggregations of these, such as vectors, matrices, cubes, or hyper-cubes. The operations on the generalization of these data forms are discrete tensors and the structures created from the assembly of tensor operations into working systems are data flows.\nPoints of Reference for Understanding the Dynamic Computation Concept\nDynamic Computational Graphs are not a particularly new concept, even though the term is relatively new. The interest in DCGs among computer scientists is not as new as the term Data Scientist. Nonetheless, the question correctly states that there are few well-written resources available (other than code examples) from which one can learn the overall concept surrounding their emergence and use.\nOne possible point of reference for beginning to understand DCGs is the Command design pattern which is one of the many design patterns popularized by the proponents of object-oriented design. The Command design pattern considers operations as computation units the details of which are hidden from the command objects that trigger them. The Command design pattern is often used in conjunction with the Interpreter design pattern.\nIn the case of DCGs, the Composite and Facade design patterns are also involved to facilitate the definition of plug-and-play discrete tensor operations that can be assembled together in patterns to form systems.\nThis particular combination of design patterns to form systems is actually a software abstraction that largely resembles the radical idea that led to the emergence of the Von Neumann architecture, central to most computers today. Von Neumann's contribution to the emergence of the computer is the idea of permitting arbitrary algorithms containing Boolean logic, arithmetic, and branching to be represented and stored as data -- a program.\nAnother forerunner of DCGs is expression engines. Expression engines can be as simple as arithmetic engines and as complex as applications such as Mathematica. A rules engine is a little like DCGs except that rules engines are declarative and meta-rules for rules engines operate on those declarations.\nPrograms Manipulating Programs\nWhat these have in common with DCGs is that the flow of data and operations to be applied can be defined at run time. As with DCGs, some of these software libraries and applications have APIs or other mechanisms to permit operations to be applied to functional details. It is essentially the idea of a program permitting the manipulation of another program.\nAnother reference point for understanding this principle at a primitive level is the switch-case statement available in some computer languages. It is a source code structure whereby the programmer essentially expresses, \"We're not sure what must be done, but the value of this variable will tell the real-time execution model what to do from a set of possibilities.\"\nThe switch-case statement is an abstraction that extends the idea of deferring the decision as to the direction of computation until run time. It is the software version of what is done inside the control unit of a contemporary CPU and an extension of the concept of deferring some algorithm details. A table of functors (function pointers) in C or polymorphism in C++, Java, or Python are other primitive examples.\nDynamic Computation takes the abstraction further. They defer most if not all of the specification of computations and the relationships between them to run time. This comprehensive generalization broadens the possibilities of functional modification at run time.\nDirected Graph Representation of Computation\nThat's what the Dynamic Computational model is. Now for the Graph part.\nOnce one decides to defer the choice of operations to be performed until run time, a structure is required to hold the operations, their dependency relationships, and perhaps mapping parameters. Such a representation is more than a syntactic tree (such as a tree representing the hierarchy of source code). Unlike an assembly language program or machine code, it must be easily and arbitrarily mutable. It must contain more information than a data flow graph and much more than a memory map. What must that data structure that specifies the computational structure look like?\nFortunately, any arbitrary, finite, bounded algorithm can be represented as a directed graph of dependencies between specified operations. In such a graph, the vertices (often represented as nodes of various shapes when displayed) represent operations performed on the data and the edges (often represented as arrows when displayed) are digital representations of information originating resulting from some operation (or system input) and upon which other operations (or system output) depend.\nKeep in mind that the directed graph is neither an algorithm (in that a precise sequence of operations is specified) nor a declaration (in that data can be explicitly stored and loops, branches, functions, and modules may be definable and nested).\nMost of these Dynamic Computational Graph frameworks and libraries permit the components to do computations on the component input that support machine learning. Vertices in the directed graph can be simulations of neurons for the construction of a neural net or components that support differential calculus. These frameworks present possibilities of constructs that can be used for deep learning in a more generalized sense.\nIn the Context of Computer History\nAgain, nothing mentioned thus far is new to computer science. LISP permits computational schematics to be modified by other algorithms. And generalized input dimensionality and numerocity is built into a number of longstanding plug-and-play interfaces and protocols. The idea of a framework for learning dates back to the same mid-Twentieth Century period too.\nWhat is new and gaining in popularity is a particular combination of integrated features and the associated set of terminology, an aggregation of existing terminology for each of the features, leading to a wider base for comprehension by those already studying for and working in the software industry.\n\nContemporary (trendy) flavor of API interfaces\nObject orientation\nDiscrete tensor support\nThe directed graph abstraction\nInteroperability with popular languages and packages that support big data, data mining, machine learning, and statistical analysis\nSupport for arbitrary and systematic neural network construction\nThe possibility of dynamic neural network structural adaptation (which facilitates experimentation on neural plasticity)\n\nMany of these frameworks support adaptability to changing input dimensionality (number of dimensions and the range of each).\nSimilarity to Abstract Symbol Trees in Compilers\nA dependency graph of inputs and outputs of operations also appears within abstract symbol trees (AST), which some of the more progressive compilers construct during the interpretation of the source code structure. The AST is then used to generate assembler instructions or machine instructions in the process of linking with libraries and forming an executable. The AST is a directed graph that represents the structure of data, operations performed, and the control flow specified by the source code.\nThe data flow is simply the set of dependencies between operations, which must be inherent in the AST for the AST to be used to create execution instructions in assembler or machine code that precisely follows the algorithm specified in the source code.\nDynamic Computational Graph frameworks, unlike switch-case statements or AST models in compilers, can be manipulated in real-time, optimized, tuned (as in the case of plastic artificial nets), inverted, transformed by tensors, decimated, modified to add or remove entropy, mutated according to a set of rules, or otherwise translated into derivative forms. They can be stored as files or streams and then retrieved from them.\nThis is a trivial concept for LISP programmers or those that understand the nature of John von Neumann's recommendation to store operational specifications as data. In this later sense, a program is a data stream to instruct, through a compiler and operating system, a dynamic computational system implemented in VLSI digital circuitry.\nAchieving Adaptable Dimensionality and Numerocity\nIn the question is the comment that one doesn't, \"Need to have data set -- that all the instances within it have the same, a fixed number of inputs.\" That statement does not promote accurate comprehension. There are clearer ways to say what is true about input adaptability.\nThe interface between a DCG and other components of an overall system must be defined, but these interfaces may have dynamic dimensionality or numerocity built into them. It is a matter of abstraction.\nFor instance, a discrete tensor object type presents a specific software interface, yet a tensor is a dynamic mathematical concept around which a common interface can be used. A discrete tensor may be a scalar, a vector, a matrix, a cube, or a hypercube, and the range of dependent variables for each dimension may be variable.\nIt can be the case that the number of nodes in a layer of the system defined in a Dynamic Computational Graph can be a function of the number of inputs of a particular type, and that too can be a computation deferred to run time.\nThe framework may be programmed to select layer structure (an extension of the switch-case paradigm again) or calculate parameters defining the structure sizes and depth or activation. However, these sophisticated features are not what qualifies the framework as a Dynamic Computational Graph framework.\nWhat Qualifies a Framework to Support Dynamic Computational Graphs?\nTo qualify as a Dynamic Computational Graph framework, the framework must merely support the deferring of the determination of algorithm to run time, therefore opening the door to a plethora of operations on the computational dependencies and data flow at run time. The basics of the operations deferred must include the specification, manipulation, execution, and storage of the directed graphs that represent systems of operations.\nIf the specification of the algorithm is NOT deferred until run time but is compiled into the executable designed for a specific operating system with only the traditional flexibility provided by low-level languages such as if-then-else, switch-case, polymorphism, arrays of functors, and variable-length strings, it is considered a static algorithm.\nIf the operations, the dependencies between them, the data flow, the dimensionality of the data within the flow, and the adaptability of the system to the input numerocity and dimensionality are all variable at run time in a way to create a highly adaptive system, then the algorithm is dynamic in these ways.\nAgain, LISP programs that operate on LISP programs, rules engines with meta-rule capabilities, expression engines, discrete tensor object libraries, and even relatively simple Command design patterns are all dynamic in some sense, deferring some characteristics to run time. DCGs are flexible and comprehensive in their capabilities to support arbitrary computational constructs in such a way to create a rich environment for deep learning experimentation and systems implementation.\nWhen to Use Dynamic Computational Graphs\nThe pros and cons of DCGs are entirely problem-specific. If you investigate the various dynamic programming concepts above and others that may be closely tied to them in the associated literature, it will become obvious whether you need a Dynamic Computational Graph or not.\nIn general, if you need to represent an arbitrary and changing model of computation to facilitate the implementation of the deep learning system, mathematical manipulation system, adaptive system, or another flexible and complex software construct that maps to the DCG paradigm well, then a proof of concept using a Dynamic Computational Graph framework is a good first step in defining your software architecture for the problem's solution.\nNot all learning software uses DCG's, but they are often a good choice when the systematic and possibly continuous manipulation of an arbitrary computational structure is a run time requirement.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between First-Visit Monte-Carlo and Every-Visit Monte-Carlo Policy Evaluation? I came across these 2 algorithms, but I cannot understand the difference between these 2, both in terms of implementation as well as intuitionally.\nSo, what difference does the second point in both the slides refer to?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The first-visit and the every-visit Monte-Carlo (MC) algorithms are both used to solve the prediction problem (or, also called, \"evaluation problem\"), that is, the problem of estimating the value function associated with a given (as input to the algorithms) fixed (that is, it does not change during the execution of the algorithm) policy, denoted by $\\pi$. In general, even if we are given the policy $\\pi$, we are not necessarily able to find the exact corresponding value function, so these two algorithms are used to estimate the value function associated with $\\pi$.\nIntuitively, we care about the value function associated with $\\pi$ because we might want or need to know \"how good it is to be in a certain state\", if the agent behaves in the environment according to the policy $\\pi$.\nFor simplicity, assume that the value function is the state value function (but it could also be e.g. the state-action value function), denoted by $v_\\pi(s)$, where $v_\\pi(s)$ is the expected return (or, in other words, expected cumulative future discounted reward), starting from state $s$ (at some time step $t$) and then following (after time step $t$) the given policy $\\pi$. Formally, $v_\\pi(s) = \\mathbb{E}_\\pi [ G_t \\mid S_t = s ]$, where $G_t = \\sum_{k=0}^\\infty \\gamma^k R_{t+k+1}$ is the return (after time step $t$). \nIn the case of MC algorithms, $G_t$ is often defined as $\\sum_{k=0}^T R_{t+k+1}$, where $T \\in \\mathbb{N}^+$ is the last time step of the episode, that is, the sum goes up to the final time step of the episode, $T$. This is because MC algorithms, in this context, often assume that the problem can be naturally split into episodes and each episode proceeds in a discrete number of time steps (from $t=0$ to $t=T$). \nAs I defined it here, the return, in the case of MC algorithms, is only associated with a single episode (that is, it is the return of one episode). However, in general, the expected return can be different from one episode to the other, but, for simplicity, we will assume that the expected return (of all states) is the same for all episodes.\nTo recapitulate, the first-visit and every-visit MC (prediction) algorithms are used to estimate $v_\\pi(s)$, for all states $s \\in \\mathcal{S}$. To do that, at every episode, these two algorithms use $\\pi$ to behave in the environment, so that to obtain some knowledge of the environment in the form of sequences of states, actions and rewards. This knowledge is then used to estimate $v_\\pi(s)$. How is this knowledge used in order to estimate $v_\\pi$? Let us have a look at the pseudocode of these two algorithms.\n\n$N(s)$ is a \"counter\" variable that counts the number of times we visit state $s$ throughout the entire algorithm (i.e. from episode one to $num\\_episodes$). $\\text{Returns(s)}$ is a list of (undiscounted) returns for state $s$. \nI think it is more useful for you to read the pseudocode (which should be easily translatable to actual code) and understand what it does rather than explaining it with words. Anyway, the basic idea (of both algorithms) is to generate trajectories (of states, actions and rewards) at each episode, keep track of the returns (for each state) and number of visits (of each state), and then, at the end of all episodes, average these returns (for all states). This average of returns should be an approximation of the expected return (which is what we wanted to estimate).\nThe differences of the two algorithms are highlighted in $\\color{red}{\\text{red}}$. The part \"If state $S_t$ is not in the sequence $S_0, S_1, \\dots, S_{t-1}$\" means that the associated block of code will be executed only if $S_t$ is not part of the sequence of states that were visited (in the episode sequence generated with $\\pi$) before the time step $t$. In other words, that block of code will be executed only if it is the first time we encounter $S_t$ in the sequence of states, action and rewards: $S_0, A_0, R_1, S_1, A_1, R_2 \\ldots, S_{T-1}, A_{T-1}, R_T$ (which can be collectively be called \"episode sequence\"), with respect to the time step and not the way the episode sequence is processed. Note that a certain state $s$ might appear more than once in $S_0, A_0, R_1, S_1, A_1, R_2 \\ldots, S_{T-1}, A_{T-1}, R_T$: for example, $S_3 = s$ and $S_5 = s$. \nDo not get confused by the fact that, within each episode, we proceed from the time step $T-1$ to time step $t = 0$, that is, we process the \"episode sequence\" backwards. We are doing that only to more conveniently compute the returns (given that the returns are iteratively computed as follows $G \\leftarrow G + R_{t+1}$).\nSo, intuitively, in the first-visit MC, we only update the $\\text{Returns}(S_t)$ (that is, the list of returns for state $S_t$, that is, the state of the episode at time step $t$) the first time we encounter $S_t$ in that same episode (or trajectory). In the every-visit MC, we update the list of returns for the state $S_t$ every time we encounter $S_t$ in that same episode. \nFor more info regarding these two algorithms (for example, the convergence properties), have a look at section 5.1 (on page 92) of the book \"Reinforcement Learning: An Introduction\" (2nd edition), by Andrew Barto and Richard S. Sutton.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is non-Euclidean data? What is non-Euclidean data?\nHere are some sub-questions\n\nWhere does this type of data arise? I have come across this term in the context of geometric deep learning and graph neural networks.\n\nApparently, graphs and manifolds are non-Euclidean data. Why exactly is that the case?\n\nWhat is the difference between non-Euclidean and Euclidean data?\n\nHow would a dataset of non-Euclidean data look like?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I presume this question was prompted by the paper Geometric deep learning:\ngoing beyond Euclidean data (2017). If we look at its abstract:\n\nMany scientific fields study data with an underlying structure that is a non-Euclidean space. Some examples include social networks in computational social sciences, sensor networks in communications, functional networks in brain imaging, regulatory networks in genetics, and meshed surfaces in computer graphics. In many applications, such geometric\n data are large and complex (in the case of social networks, on the scale of billions), and are natural targets for machine learning techniques. In particular, we would like to use deep neural networks, which have recently proven to be powerful tools for a broad range of problems from computer vision, natural language processing, and audio analysis. However,\n these tools have been most successful on data with an underlying Euclidean or grid-like structure, and in cases where the invariances of these structures are built into networks used to model them.\n\nWe see that the authors use the term \"non-Euclidean data\" to refer to data whose underlying structure is non-Euclidean.\nSince Euclidean spaces are prototypically defined by $\\mathbb{R}^n$ (for some dimension $n$), 'Euclidean data' is data which is sensibly modelled as being plotted in $n$-dimensional linear space, for example image files (where the $x$ and $y$ coordinates refer to the location of each pixel, and the $z$ coordinate refers to its colour/intensity).\nHowever some data does not map neatly into $\\mathbb{R}^n$, for example, a social network modelled by a graph. You can of course embed the physical shape of a graph in 3-d space, but you will lose information such as the quality of edges, or the values associated with nodes, or the directionality of edges, and there isn't an obvious sensible way of mapping these attributes to higher dimensional Euclidean space. And depending on the specific embedding, you may introduce spurious correlations (e.g. two unconnected nodes appearing closer to each other in the embedding than to nodes they are connected to).\nMethods such as Graph Neural Networks seek to adapt existing Machine Learning technologies to directly process non-Euclidean structured data as input, so that this (possibly useful) information is not lost in transforming the data into a Euclidean input as required by existing techniques.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to choose an activation function for the hidden layers? I choose the activation function for the output layer depending on the output that I need and the properties of the activation function that I know. For example, I choose the sigmoid function when I'm dealing with probabilities, a ReLU when I'm dealing with positive values, and a linear function when I'm dealing with general values.\nIn hidden layers, I use a leaky ReLU to avoid dead neurons instead of the ReLU, and the tanh instead of the sigmoid. Of course, I don't use a linear function in hidden units.\nHowever, the choice for them in the hidden layer is mostly due to trial and error.\nIs there any rule of thumb of which activation function is likely to work well in some situations?\nTake the term situations as general as possible: it could be referring to the depth of the layer, to the depth of the NN, to the number of neurons for that layer, to the optimizer that we chose, to the number of input features of that layer, to the application of this NN, etc.\nThe more activation functions I discover the more I'm confused in the choice of the function to use in hidden layers. I don't think that flipping a coin is a good way of choosing an activation function.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It seems to me that you already understand the shortcomings of ReLUs and sigmoids (like dead neurons in the case of plain ReLU).\nYou may want to look at ELU (exponential linear units) and SELU (self-normalising version of ELU). Under some mild assumptions, the latter has the nice property of self-normalisation, which mitigates the problem of vanishing and exploding gradients. In addition, they propagate normalisation - i.e., they guarantee that the input to the next layer will have zero mean and unit variance.\nHowever, it would be incredibly difficult to recommend an activation function (AF) that works for all use cases, although I believe that SELU was designed so that it would do the right thing with pretty much any input.\nThere are many considerations - how difficult it is to compute the derivative (if it is differentiable at all!), how quickly a NN with your chosen AF converges, how smooth it is, whether it satisfies the conditions of the universal approximation theorem, whether it preserves normalisation, and so on. You may or may not care about some or any of those.\nThe bottom line is that there is no universal rule for choosing an activation function for hidden layers. Personally, I like to use sigmoids (especially tanh) because they are nicely bounded and very fast to compute, but most importantly because they work for my use cases. Others recommend leaky ReLU for the input and hidden layers as a go-to function if your NN fails to learn. You can even mix and match activation functions to evolve NNs for fancy applications.\nAt the end of the day, you are probably going to get as many opinions as there are people about the right choice of activation function, so the short answer should probably be: start with the AF of the day (leaky ReLU / SELU?) and work your way through other AFs in order of decreasing popularity if your NN struggles to learn anything.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How could emotional intelligence be implemented? I've seen emotional intelligence defined as the capacity to be aware of, control, and express one's emotions, and to handle interpersonal relationships judiciously and empathetically. \n\nWhat are some strategies for artificial intelligence to begin to tackle this problem and develop emotional intelligence for computers? \nAre there examples where this is already happening to a degree today? \nWouldn't a computer that passes a Turing test necessarily express emotional intelligence or it would be seen as an obvious computer? \nPerhaps that is why early programs that pass the test represented young people, who presumably have lower emotional intelligence.\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Architectures for recognizing and generating emotion are typically somewhat complex and don't generally have short descriptions, so it's probably better to reference the literature rather than give a misleading soundbite:\nSome of the early work in affective computing was done by Rosalind W. Picard. There is a research group at MIT specializing in this area.\nSome of the more developed architectural ideas are due to Marvin Minsky.\nA pre-publication draft of his book, The Emotion Machine, is available via Wikipedia.\nEmotional intelligence would certainly seem to be a necessary component of passing the Turing test - indeed, in the original Turing test essay in Computing Machinery and Intelligence implied some degree of \"Theory of Mind\" about Mr. Pickwick's preferences:\n\nYet Christmas is a Winter\u2019s day, and I do not think Mr. Pickwick would mind the comparison.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When should I use Reinforcement Learning vs PID Control? When designing solutions to problems such as the Lunar Lander on OpenAIGym, Reinforcement Learning is a tempting means of giving the agent adequate action control so as to successfully land. \nBut what are the instances in which control system algorithms, such as PID controllers, would do just an adequate job as, if not better than, Reinforcement Learning?\nQuestions such as this one do a great job at addressing the theory of this question, but do little to address the practical component.\nAs an Artificial Intelligence engineer, what elements of a problem domain should suggest to me that a PID controller is insufficient to solve a problem, and a Reinforcement Learning algorithm should instead be used (or vice versa)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I think the comments are basically on the right track.\nPID controllers are useful for finding optimal policies in continuous dynamical systems, and often these domains are also used as benchmarks for RL, precisely because there is an easily derived optimal policy. However, in practice, you'd obviously prefer a PID controller for any domain in which you can easily design one: the controller's behaviors are well understood, while RL solutions are often difficult to interpret. \nWhere RL shines is in tasks where we know what good behaviour looks like (i.e., we know the reward function), and we know what sensor inputs look like (i.e. we can completely and accurately describe a given state numerically), but we have little or no idea what we actually want the agent to do to achieve those rewards.\nHere's a good example:\n\nIf I wanted to make an agent to maneuver a plane from in front of an enemy plane with known movement patterns to behind it, using the least amount of fuel, I'd much prefer to use a PID controller.\nIf I wanted to make an agent to control a plane and shoot down an enemy plane with enough fuel left to land, but without a formal description of how the enemy plane might attack (perhaps a human expert will pilot it in simulations against our agent), I'd much prefer RL. \n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between reinforcement learning and optimal control? Coming from a process (optimal) control background, I have begun studying the field of deep reinforcement learning.\nSutton & Barto (2015) state that\n\nparticularly important (to the writing of the text) have been the contributions establishing and developing the relationships to the theory of optimal control and dynamic programming\n\nWith an emphasis on the elements of reinforcement learning - that is, policy, agent, environment, etc., what are the key differences between (deep) RL and optimal control theory?\nIn optimal control we have, controllers, sensors, actuators, plants, etc, as elements. Are these different names for similar elements in deep RL? For example, would an optimal control plant be called an environment in deep RL?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The same book Reinforcement learning: an introduction (2nd edition, 2018) by Sutton and Barto has a section, 1.7 Early History of Reinforcement Learning, that describes what optimal control is and how it is related to reinforcement learning. I will quote the most relevant part to answer your question, but you should read all that section to have a full understanding of the relationship between optimal control and reinforcement learning.\n\nThe term \"optimal control\" came into use in the late 1950s to describe the problem of designing a controller to minimize or maximize a measure of a dynamical system's behavior over time. One of the approaches to this problem was developed in the mid-1950s by Richard Bellman and others through extending a nineteenth-century theory of Hamilton and Jacobi. This approach uses the concepts of a dynamical system's state and of a value function, or \"optimal return function\", to define a functional equation, now often called the Bellman equation. The class of methods for solving optimal control problems by solving this equation came to be known as dynamic programming (Bellman, 1957a). Bellman (1957b) also introduced the discrete stochastic version of the optimal control problem known as Markov decision processes (MDPs). Ronald Howard (1960) devised the policy iteration method for MDPs. All of these are essential elements underlying the theory and algorithms of modern reinforcement learning.\n\nTo answer your specific questions.\n\nIn optimal control we have, controllers, sensors, actuators, plants, etc, as elements. Are these different names for similar elements in deep RL? For example, would an optimal control plant be called an environment in deep RL?\n\nYes. In reinforcement learning (see the first footnote of the cited book on page 48), the term control is often used as a synonym for action. Similarly, the term controller (or decision maker) is used as a synonym for agent (and sometimes also a synonym for policy, given that the policy usually defines and controls the agent, although the concept of the agent is more abstract and we could associate more than one policy with the same agent). The term environment is also used as a synonym for controlled system (or plant).\nSee also section 38.8 Notes (page 530) of the book Bandit Algorithms by Csaba Szepesvari and Tor Lattimore.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why can't OCR be perceived as a good example of AI? On the Wikipedia page about AI, we can read:\n\nOptical character recognition is no longer perceived as an exemplar of \"artificial intelligence\" having become a routine technology.\n\nOn the other hand, the MNIST database of handwritten digits is specially designed for training and testing neural networks and their error rates (see: Classifiers).\nSo, why does the above quote state that OCR is no longer exemple of AI?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Whenever a problem becomes solvable by a computer, people start arguing that it does not require intelligence. John McCarthy is often quoted: \"As soon as it works, no one calls it AI anymore\" (Referenced in CACM).\nOne of my teachers in college said that in the 1950's, a professor was asked what he thought was intelligent for a machine. The professor reputedly answered that if a vending machine gave him the right change, that would be intelligent.\nLater, playing chess was considered intelligent. However, computers can now defeat grandmasters at chess, and people are no longer saying that it is a form of intelligence. \nNow we have OCR. It's already stated in another answer that our methods do not have the recognition facilities of a 5 year old. As soon as this is achieved, people will say \"meh, that's not intelligence, a 5 year old can do that!\"\nA psychological bias, a need to state that we are somehow superior to machines, is at the basis of this.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to define states in reinforcement learning? I am studying reinforcement learning and the variants of it. I am starting to get an understanding of how the algorithms work and how they apply to an MDP.\nWhat I don't understand is the process of defining the states of the MDP. In most examples and tutorials, they represent something simple like a square in a grid or similar.\nFor more complex problems, like a robot learning to walk, etc.,\n\nHow do you go about defining those states?\nCan you use learning or classification algorithms to \"learn\" those states?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The problem of state representation in Reinforcement Learning (RL) is similar to problems of feature representation, feature selection and feature engineering in supervised or unsupervised learning.\nLiterature that teaches the basics of RL tends to use very simple environments so that all states can be enumerated. This simplifies value estimates into basic rolling averages in a table, which are easier to understand and implement. Tabular learning algorithms also have reasonable theoretical guarantees of convergence, which means if you can simplify your problem so that it has, say, less than a few million states, then this is worth trying.\nMost interesting control problems will not fit into that number of states, even if you discretise them. This is due to the \"curse of dimensionality\". For those problems, you will typically represent your state as a vector of different features - e.g. for a robot, various positions, angles, velocities of mechanical parts. As with supervised learning, you may want to treat these for use with a specific learning process. For instance, typically you will want them all to be numeric, and if you want to use a neural network you should also normalise them to a standard range (e.g. -1 to 1).\nIn addition to the above concerns which apply for other machine learning, for RL, you also need to be concerned with the Markov Property - that the state provides enough information, so that you can accurately predict expected next rewards and next states given an action, without the need for any additional information. This does not need to be perfect, small differences due to e.g. variations in air density or temperature for a wheeled robot will not usually have a large impact on its navigation, and can be ignored. Any factor which is essentially random can also be ignored whilst sticking to RL theory - it may make the agent less optimal overall, but the theory will still work. \nIf there are consistent unknown factors that influence result, and could logically be deduced - maybe from history of state or actions - but you have excluded them from the state representation, then you may have a more serious problem, and the agent may fail to learn.\nIt is worth noting the difference here between observation and state. An observation is some data that you can collect. E.g. you may have sensors on your robot that feed back the positions of its joints. Because the state should possess the Markov Property, a single raw observation might not be enough data to make a suitable state. If that is the case, you can either apply your domain knowledge in order to construct a better state from available data, or you can try to use techniques designed for partially observable MDPs (POMDPs) - these effectively try to build missing parts of state data statistically. You could use a RNN or hidden markov model (also called a \"belief state\") for this, and in some way this is using a \"learning or classification algorithms to \"learn\" those states\" as you asked.\nFinally, you need to consider the type of approximation model you want to use. A similar approach applies here as for supervised learning: \n\nA simple linear regression with features engineered based on domain knowledge can do very well. You may need to work hard on trying different state representations so that the linear approximation works. The advantage is that this simpler approach is more robust against stability issues than non-linear approximation\nA more complex non-linear function approximator, such as a multi-layer neural network. You can feed in a more \"raw\" state vector and hope that the hidden layers will find some structure or representation that leads to good estimates. In some ways, this too is \"learning or classification algorithms to \"learn\" those states\" , but in a different way to a RNN or HMM. This might be a sensible approach if your state was expressed naturally as a screen image - figuring out the feature engineering for image data by hand is very hard.\n\nThe Atari DQN work by DeepMind team used a combination of feature engineering and relying on deep neural network to achieve its results. The feature engineering included downsampling the image, reducing it to grey-scale and - importantly for the Markov Property - using four consecutive frames to represent a single state, so that information about velocity of objects was present in the state representation. The DNN then processed the images into higher-level features that could be used to make predictions about state values.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do we need floats for using neural networks? Is it possible to make a neural network that uses only integers by scaling input and output of each function to [-INT_MAX, INT_MAX]? Is there any drawbacks?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "TL;DR\nNot only it's possible, it even gets done and is commercially available. It's just impractical on a commodity HW which is pretty good at FP arithmetic.\nDetails\nIt is definitely possible, and you might get some speed for a lot of troubles.\nThe nice thing about floating point is that it works without you knowing the exact range. You can scale your inputs to the range (-1, +1) (such a scaling is pretty commonplace as it speeds up the convergence) and multiply them by 2**31, so they used the range of signed 32-bit integers. That's fine.\nYou can't do the same to your weights as there's no limit on them. You can assume them to lie in the interval (-128, +128) and scale them accordingly.\nIf your assumption was wrong, you get an overflow and a huge negative weight where a huge positive weight should be or the other way round. In any case, a disaster.\nYou could check for overflow, but this is too expensive. Your arithmetic gets slower than FP.\nYou could check for possible overflow from time to time and take a corrective action. The details may get complicated.\nYou could use saturation arithmetic, but it's implemented only in some specialized CPUs, not in your PC.\nNow, there's a multiplication. With use of 64-bit integers, it goes well, but you need to compute a sum (with a possible overflow) and scale the output back to same sane range (another problem).\nAll in all, with fast FP arithmetic available, it's not worth the hassle.\nIt might be a good idea for a custom chip, which could do saturation integer arithmetic with much less hardware and much faster then FP.\n\nDepending on what integer types you use, there may be a precision loss when compared to the floating point, which may or may not matter. Note that TPU (used in AlphaZero) has 8-bit precision only.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between machine learning and deep learning? Can someone explain to me the difference between machine learning and deep learning? Is it possible to learn deep learning without knowing machine learning?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Deep learning is a specific variety of a specific type of machine learning. So it's possible to learn about deep learning without learning all of machine learning, but it requires learning some machine learning (because it is some machine learning).\nMachine learning refers to any technique that focuses on teaching the machine how it can learn statistical parameters from a large amount of training data. One particular type of machine learning is artificial neural networks, which learn a network of nonlinear transformations that can approximate very complicated functions of wide arrays of input variables. Recent advances in artificial neural networks have to do with how to train deep neural networks, which have more layers than normal and also special structure to deal with the challenges of learning more layers.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Has the Lovelace Test 2.0 been successfully used in an academic setting? In October 2014, Dr. Mark Riedl published an approach to testing AI intelligence, called the \"Lovelace Test 2.0\", after being inspired by the original Lovelace Test (published in 2001). Mark believed that the original Lovelace Test would be impossible to pass, and therefore, suggested a weaker, and more practical version.\nThe Lovelace Test 2.0 makes the assumption that for an AI to be intelligent, it must exhibit creativity. From the paper itself:\n\nThe Lovelace 2.0 Test is as follows: artificial agent $a $ is challenged as follows:\n\n$a$ must create an artifact $o$ of type $t$;\n$o$ must conform to a set of constraints $C$ where $c_i \u2208 C$ is\n any criterion expressible in natural language;\na human evaluator $h$, having chosen $t$ and $C$, is satisfied\n that $o$ is a valid instance of $t$ and meets $C$; and\na human referee $r$ determines the combination of $t$ and $C$\n to not be unrealistic for an average human.\n\n\nSince it is possible for a human evaluator to come up with some pretty easy constraints for an AI to beat, the human evaluator is then expected to keep coming up with more and more complex constraints for the AI until the AI fails. The point of the Lovelace Test 2.0 is to compare the creativity of different AIs, not to provide a definite dividing line between 'intelligence' and 'nonintelligence' like the Turing Test would.\nHowever, I am curious about whether this test has actually been used in an academic setting, or it is only seen as a thought experiment at the moment. The Lovelace Test seems easy to apply in academic settings (you only need to develop some measurable constraints that you can use to test the artificial agent), but it also may be too subjective (humans can disagree on the merits of certain constraints, and whether a creative artifact produced by an AI actually meets the final result).\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "No.\nTL;DR: The Lovelace Test 2.0 is very vague, making it ill-suited for evaluation of intelligence. It is also generally ignored by researchers of Computational Creativity, who already have their own tests to evaluate creativity.\nLonger Answer:\nAccording to Google Scholar, there are 10 references to the \"Lovelace Test 2.0\" paper. All of those references exist merely to point out that the Lovelace Test 2.0 exists. In fact, at least two of articles I consulted (A novel approach for identifying a human-like self-conscious behavior and FraMoTEC: A Framework for Modular Task-Environment Construction for Evaluating Adaptive Control Systems) proposed their own tests instead.\nOne of the authors who wrote the FraMoTEC paper also wrote his thesis on FraMoTEC, and indirectly critiqued the Lovelace Test 2.0 and other similar such tests:\n\nThe Piaget-MacGyver Room problem [Bringsjord and Licato, 2012], Lovelace Test 2.0 [Riedl, 2014] and Toy Box problem [Johnston, 2010] all come with the caveat of being defined very vaguely \u2014 these evaluation methods may be likely to come up with a reasonable evaluation for intelligence, but it is very difficult to compare two different agents (or controllers) that partake in the their own domain-specific evaluations, which is what frequently happens when agents are tailored to pass specific evaluations.\n\nAnother major issue with the Lovelace Test 2.0 is that there is a proliferation of other tests to \"measure\" the creativity of AI. Evaluating Evaluation: Assessing Progress in Computational Creativity Research, published by \nAnna Jordanous in 2011 (3 years before the invention of the Lovelace Test 2.0) analyzed research papers about AI creativity and wrote:\n\nOf the 18 papers that applied creativity evaluation methodologies to evaluate their system\u2019s creativity, no one methodology emerged as standard across the community. Colton\u2019s creative tripod framework (Colton 2008) was used most often (6 uses), with 4 papers using Ritchie\u2019s empirical criteria (Ritchie 2007). \n\nThat leaves 10 papers with miscellaneous creativity evaluation methods.\nThe goal of \"Evaluating Evaluation\" was to standardize the process of evaluating creativity, to avoid the possibility of the field stagnating due to the proliferation of so many creativity tests. Anna Jordanous still remained interested in evaluating creativity tests, publishing articles such as \"Stepping Back to Progress Forwards: Setting Standards for Meta-Evaluation of Computational Creativity\" and Four PPPPerspectives on Computational Creativity.\n\"Evaluating Evaluation\" does provide some commentary to explain the proliferation of systems to evaluate creativity:\n\nEvaluation standards are not easy to define. It is difficult to evaluate creativity and even more difficult to describe how we evaluate creativity, in human creativity as well as in computational creativity. In fact, even the very definition of creativity is problematic (Plucker, Beghetto, and Dow 2004). It is hard to identify what \u2019being creative\u2019 entails, so there are no benchmarks or ground truths to measure against.\n\nThe fact that so many tests of creativity already exist (to the extent that Jordanous can make an academic career in studying them) means that it's very difficult for any new test (such as the Lovelace Test 2.0) to even be noticed (much less cited). Why would you want to use something like the Lovelace Test 2.0 when there's so many other tests you could use instead?\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What activation function does the human brain use? Does the human brain use a specific activation function?\nI've tried doing some research, and as it's a threshold for whether the signal is sent through a neuron or not, it sounds a lot like ReLU. However, I can't find a single article confirming this. Or is it more like a step function (it sends 1 if it's above the threshold, instead of the input value)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The thing you were reading about is known as the action potential. It is a mechanism that governs how information flows within a neuron.\nIt works like this: Neurons have an electrical potential, which is a voltage difference inside and outside the cell. They also have a default resting potential, and an activation potential. The neuron tends to move towards the resting potential if it is left alone, but incoming electric activations from dendrites can shift its electric potential. \nIf the neuron reaches a certain threshold in electric potential (the activation potential), the entire neuron and its connecting axons goes through a chain reaction of ionic exchange inside/outside the cell that results in a \"wave of propagation\" through the axon.\nTL;DR: Once a neuron reaches a certain activation potential, it electrically discharges. But if the electric potential of the neuron doesn't reach that value then the neuron does not activate.\n\nDoes the human brain use a specific activation function? \n\nIIRC neurons in different parts of the brain behave a bit differently, and the way this question is phrased sounds as if you are asking if there is a specific implementation of neuronal activation (as opposed to us modelling it). \nBut in general behave relatively similar to each other (Neurons communicate with each other via neurochemicals, information propagates inside a neuron via a mechanism known as the action potential...) But the details and the differences they cause could be significant.\nThere are various biological neuron models, but the Hodgkin-Huxley Model is the most notable. \nAlso note that a general description of neurons don't give you a general description of neuronal dynamics a la cognition (understanding a tree doesn't give you complete understanding of a forest)\nBut, the method of which information propagates inside a neuron is in general quite well understood as sodium / potassium ionic exchange.\n\nIt (activation potential) sounds a lot like ReLU...\n\nIt's only like ReLU in the sense that they require a threshold before anything happens. But ReLU can have variable output while neurons are all-or-nothing. \nAlso ReLU (and other activation functions in general) are differentiable with respect to input space. This is very important for backprop.\nThis is a ReLU function, with the X-axis being input value and Y-axis being output value.\n\nAnd this is the action potential with the X-axis being time, and Y being output value.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the flaws in Jeff Hawkins's AI framework? In 2004 Jeff Hawkins, inventor of the palm pilot, published a very interesting book called On Intelligence, in which he details a theory how the human neocortex works.\nThis theory is called Memory-Prediction framework and it has some striking features, for example not only bottom-up (feedforward), but also top-down information processing and the ability to make simultaneous, but discrete predictions of different future scenarios (as described in this paper).\nThe promise of the Memory-Prediction framework is unsupervised generation of stable high level representations of future possibilities. Something which would revolutionise probably a whole bunch of AI research areas.\nHawkins founded a company and proceeded to implement his ideas. Unfortunately more than ten years later the promise of his ideas is still unfulfilled. So far the implementation is only used for anomaly detection, which is kind of the opposite of what you really want to do. Instead of extracting the understanding, you'll extract the instances which your artificial cortex doesn't understand.\nMy question is in what way Hawkins's framework falls short. What are the concrete or conceptual problems that so far prevent his theory from working in practice?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The short answer is that Hawkins' vision has yet to be implemented in a widely accessible way, particularly the indispensable parts related to prediction. \nThe long answer is that I read Hawkins' book a few years ago and was excited by the possibilities of Hierarchical Temporal Memory (HTM). I still am, despite the fact that I have a few reservations about some of his philosophical musings on the meanings of consciousness, free will and other such topics. I won't elaborate on those misgivings here because they're not germane to the main, overwhelming reason why HTM nets haven't succeeded as much as expected to date: to my knowledge, Numenta has only implemented a truncated version of his vision. They left out most of the prediction architecture, which plays such a critical role in Hawkins' theories. As Gerod M. Bonhoff put it in an excellent thesis1 on HTMs, \n\n\"In March of 2007, Numenta released what they claimed was a \u201cresearch\n implementation\u201d of HTM theory called Numenta Platform for Intelligent\n Computing (NuPIC). The algorithm used by NuPIC at this time is called\n \u201cZeta1.\u201d NuPIC was released as an open source software platform and\n binary files of the Zeta1 algorithm. Because of licensing, this paper\n is not allowed to discuss the proprietary implementation aspects of\n Numenta\u2019s Zeta1 algorithm. There are, however, generalized\n concepts of implementation that can be discussed freely. The two most\n important of these are how the Zeta 1 algorithm (encapsulated in each\n memory node of the network hierarchy) implements HTM theory. To\n implement any theory in software, an algorithmic design for each\n aspect of the theory must be addressed. The most important design\n decision Numenta adopted was to eliminate feedback within the\n hierarchy and instead choose to simulate this theoretical concept\n using only data pooling algorithms for weighting. This decision is\n immediately suspect and violates key concepts of HTM. Feedback,\n Hawkins\u2019 insists, is vital to cortical function and central to his\n theories. Still, Numenta claims that most HTM applicable problems can\n be solved using their implementation and proprietary pooling\n algorithms.\"\n\nI am still learning the ropes in this field and cannot say whether or not Numenta has since scrapped this approach in favor of a full implementation of Hawkins' ideas, especially the all-important prediction architecture. Even if they have, this design decision has probably delayed adoption by many years. That's not a criticism per se; perhaps the computational costs of tracking prediction values and updating them on the fly were too much to bear at the time, on top of the ordinary costs of processing neural nets, leaving them with no other path except to try half-measures like their proprietary pooling mechanisms. Nevertheless, all of the best research papers I've read on the topic since then have chosen to reimplement the algorithms rather than relying on Numenta's platform, typically because of the missing prediction features. Cases in point include Bonhoff's thesis and Maltoni's technical report for the University of Bologna Biometric System Laboratory2. In all of those cases, however, there is no readily accessible software for putting their variant HTMs to immediate use (as far as I know). The gist of all this is that like G.K. Chesterton's famous maxim about Christianity, \"HTMs have not been tried and found wanting; they have been found difficult, and left untried.\" Since Numenta left out the prediction steps, I assume that they would be the main stumbling blocks awaiting anyone who wants to code Hawkins' full vision of what an HTM should be.\n1Bonhoff, Gerod M., 2008, Using Hierarchical Temporal Memory for Detecting Anomalous Network Activity. Presented in March, 2008 at the Air Force Institute of Technology, Wright-Patterson Air Force Base, Ohio. \n2Maltoni, Davide, 2011, Pattern Recognition by Hierarchical Temporal Memory. DEIS Technical Report published April 13, 2011. University of Bologna Biometric System Laboratory: Bologna, Italy. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why has the cross-entropy become the classification standard loss function and not Kullback-Leibler divergence? The cross-entropy is identical to the KL divergence plus the entropy of the target distribution. The KL divergence equals zero when the two distributions are the same, which seems more intuitive to me than the entropy of the target distribution, which is what the cross-entropy is on a match.\nI'm not saying there's more information in one of the other except that a human view may find a zero more intuitive than a positive.\nOf course, one usually uses an evaluative method to really see how well classification occurs. But is the choice of the cross-entropy over the KL divergence historic?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "When it comes to a classification problem in machine learning, the cross-entropy and the KL divergence are equal.\nAs already stated in the question, the general formula is this:\n$$H(p, q) = H(p) + D_{KL}(p \\parallel q),$$\nwhere $p$ is the \"true\"/target distribution and $q$ is an estimated distribution, $H(p, q)$ is the cross-entropy, $H(p)$ is the entropy and $D$ is the Kullback-Leibler divergence.\nNote that in machine learning, $p$ is a one-hot representation of the ground-truth class, i.e.,\n$$p = [0,..., 1, ..., 0]$$\nwhich is basically a delta-function distribution. But the entropy of the delta function is zero, hence KL divergence simply equals the cross-entropy.\nIn fact, even if $H(p)$ wasn't $0$ (e.g., soft labels), it is fixed and has no contribution to the gradient. In terms of optimization, it's safe to simply remove it and optimize the Kullback-Leibler divergence.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are softmax outputs of classifiers true probabilities? BACKGROUND: The softmax function is the most common choice for an activation function for the last dense layer of a multiclass neural network classifier. The outputs of the softmax function have mathematical properties of probabilities and are--in practice--presumed to be (conditional) probabilities of the classes given the features:\n\nFirst, the softmax output for each class is between $0$ and $1$.\nSecond, the outputs of all the classes sum to $1$.\n\nPROBLEM: However, just because they have mathematical properties of probabilities does not automatically mean that the softmax outputs are in fact probabilities. In fact, there are other functions that also have these mathematical properties, which are also occasionally used as activation functions.\nQUESTION: \"Do softmax outputs represent probabilities in the usual sense?\" In other words, do they really reflect chances or likelihoods? (I use likelihood in the colloquial sense here.)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The answer is both yes, and no. Or, to put it another way, the answer depends on what exactly you mean by \"represent probabilities\", and there is a valid sense in which the answer is yes, and another valid sense in which the answer is no.\nNo, they don't represent the probability\nNo, they do not represent the true probability.\nYou can think of a neural network as a function $f$. Let $f(y;x)$ denote the softmax output of the neural network corresponding to class $y$, on input $x$. Then $f(y;x)$ will typically not be equal to $p(y|x)$, the probability that sample $x$ is from class $y$. $f(y;x)$ can be viewed as an estimate of $p(y|x)$ -- as a best-effort guess at $p(y|x)$ -- but it can be an arbitrarily bad estimate/guess. Neural networks routinely make errors on tasks that even humans find clear. Also, neural networks have systematic biases. For instance, as the other answer explains, neural networks tend to be biased towards \"overconfidence\".\nSo you should not assume that the output from the neural network represents the true probability $p(y|x)$. There is some underlying probability. We might not know how to compute it, but it exists. Neural networks are an attempt to estimate it, but it is a highly imperfect estimate.\nYes, they do represent probabilities\nWhile the softmax outputs are not the true probability $p(y|x)$, they do represent a probability distribution. You can think of them as an estimate of $p(y|x)$. For a number of reasons, it is an imperfect and flawed estimate, but it is an estimate nonetheless. (Even bad or noisy estimates are still estimates.)\nMoreover, the way we train neural networks is designed to try to make them a good estimate -- or as good as possible. We train a neural network to minimize the expected loss. The expected loss is defined as\n$$L = \\mathbb{E}_x[H(p(y|x),f(y;x))],$$\nwhere the expectation is with respect to $x$ chosen according to the data distribution embodied in the training set, and $H$ is the cross-entropy of the distribution $f(y;x)$ relative to the distribution $p(y|x)$. Intuitively, the smaller the training loss is, the closer that $f(y;x)$ is to $p(y|x)$.\nSo, neural networks are trained in a way that tries to make its output be as good an approximation to $p(y|x)$ as is possible, given the limitations of neural networks and given the training data that is available. As highlighted above, this is highly imperfect. But $f(y;x)$ does still represent a probability distribution, that is our attempt to estimate the true probability distribution $p(y|x)$.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What limits, if any, does the halting problem put on Artificial Intelligence? Given the proven halting problem for Turing machines, can we infer limits on the ability of strong Artificial Intelligence?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Does the halting problem imply any limits on human cognition?\nYes, absolutely--that there are pieces of code a human could look at and not be sure whether or not it will halt in finite time. (Certainly there are pieces of code that a human can look at and say \"yes\" or \"no\" definitely, but we're talking about the ones that are actually quite difficult to analyze.)\nThe halting problem means that there are types of code analysis that no computer could do, because it's mathematically impossible. But the realm of possibility is still large enough to allow strong artificial intelligence (in the sense of code that can understand itself well enough to improve itself).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a fully convolution network? I was surveying some literature related to Fully Convolutional Networks and came across the following phrase, \n\nA fully convolutional network is achieved by replacing the parameter-rich fully connected layers in standard CNN architectures by convolutional layers with $1 \\times 1$ kernels.\n\nI have two questions.\n\nWhat is meant by parameter-rich? Is it called parameter rich because the fully connected layers pass on parameters without any kind of \"spatial\" reduction? \nAlso, how do $1 \\times 1$ kernels work? Doesn't $1 \\times 1$ kernel simply mean that one is sliding a single pixel over the image? I am confused about this.\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Fully convolution networks\nA fully convolution network (FCN) is a neural network that only performs convolution (and subsampling or upsampling) operations. Equivalently, an FCN is a CNN without fully connected layers.\nConvolution neural networks\nThe typical convolution neural network (CNN) is not fully convolutional because it often contains fully connected layers too (which do not perform the convolution operation), which are parameter-rich, in the sense that they have many parameters (compared to their equivalent convolution layers), although the fully connected layers can also be viewed as convolutions with kernels that cover the entire input regions, which is the main idea behind converting a CNN to an FCN. See this video by Andrew Ng that explains how to convert a fully connected layer to a convolutional layer.\nAn example of an FCN\nAn example of a fully convolutional network is the U-net (called in this way because of its U shape, which you can see from the illustration below), which is a famous network that is used for semantic segmentation, i.e. classify pixels of an image so that pixels that belong to the same class (e.g. a person) are associated with the same label (i.e. person), aka pixel-wise (or dense) classification.\n\nSemantic segmentation\nSo, in semantic segmentation, you want to associate a label with each pixel (or small patch of pixels) of the input image. Here's a more suggestive illustration of a neural network that performs semantic segmentation.\n\nInstance segmentation\nThere's also instance segmentation, where you also want to differentiate different instances of the same class (e.g. you want to distinguish two people in the same image by labeling them differently). An example of a neural network that is used for instance segmentation is mask R-CNN. The blog post Segmentation: U-Net, Mask R-CNN, and Medical Applications (2020) by Rachel Draelos describes these two problems and networks very well.\nHere's an example of an image where instances of the same class (i.e. person) have been labeled differently (orange and blue).\n\nBoth semantic and instance segmentations are dense classification tasks (specifically, they fall into the category of image segmentation), that is, you want to classify each pixel or many small patches of pixels of an image.\n$1 \\times 1$ convolutions\nIn the U-net diagram above, you can see that there are only convolutions, copy and crop, max-pooling, and upsampling operations. There are no fully connected layers.\nSo, how do we associate a label to each pixel (or a small patch of pixels) of the input? How do we perform the classification of each pixel (or patch) without a final fully connected layer?\nThat's where the $1 \\times 1$ convolution and upsampling operations are useful!\nIn the case of the U-net diagram above (specifically, the top-right part of the diagram, which is illustrated below for clarity), two $1 \\times 1 \\times 64$ kernels are applied to the input volume (not the images!) to produce two feature maps of size $388 \\times 388$. They used two $1 \\times 1$ kernels because there were two classes in their experiments (cell and not-cell). The mentioned blog post also gives you the intuition behind this, so you should read it.\n\nIf you have tried to analyze the U-net diagram carefully, you will notice that the output maps have different spatial (height and weight) dimensions than the input images, which have dimensions $572 \\times 572 \\times 1$.\nThat's fine because our general goal is to perform dense classification (i.e. classify patches of the image, where the patches can contain only one pixel), although I said that we would have performed pixel-wise classification, so maybe you were expecting the outputs to have the same exact spatial dimensions of the inputs. However, note that, in practice, you could also have the output maps to have the same spatial dimension as the inputs: you would just need to perform a different upsampling (deconvolution) operation.\nHow $1\\times 1$ convolutions work?\nA $1 \\times 1$ convolution is just the typical 2d convolution but with a $1\\times1$ kernel.\nAs you probably already know (and if you didn't know this, now you know it), if you have a $g \\times g$ kernel that is applied to an input of size $h \\times w \\times d$, where $d$ is the depth of the input volume (which, for example, in the case of grayscale images, it is $1$), the kernel actually has the shape $g \\times g \\times d$, i.e. the third dimension of the kernel is equal to the third dimension of the input that it is applied to. This is always the case, except for 3d convolutions, but we are now talking about the typical 2d convolutions! See this answer for more info.\nSo, in the case we want to apply a $1\\times 1$ convolution to an input of shape $388 \\times 388 \\times 64$, where $64$ is the depth of the input, then the actual $1\\times 1$ kernels that we will need to use have shape $1\\times 1 \\times 64$ (as I said above for the U-net). The way you reduce the depth of the input with $1\\times 1$ is determined by the number of $1\\times 1$ kernels that you want to use. This is exactly the same thing as for any 2d convolution operation with different kernels (e.g. $3 \\times 3$).\nIn the case of the U-net, the spatial dimensions of the input are reduced in the same way that the spatial dimensions of any input to a CNN are reduced (i.e. 2d convolution followed by downsampling operations). The main difference (apart from not using fully connected layers) between the U-net and other CNNs is that the U-net performs upsampling operations, so it can be viewed as an encoder (left part) followed by a decoder (right part).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do you not see dropout layers on reinforcement learning examples? I've been looking at reinforcement learning, and specifically playing around with creating my own environments to use with the OpenAI Gym AI. I am using agents from the stable_baselines project to test with it.\nOne thing I've noticed in virtually all RL examples is that there never seems to be any dropout layers in any of the networks. Why is this?\nI have created an environment that simulates currency prices and a simple agent, using DQN, that attempts to learn when to buy and sell. Training it over almost a million timesteps taken from a specific set of data consisting of one month's worth of 5-minute price data it seems to overfit a lot. If I then evaluate the agents and model against a different month's worth of data is performs abysmally. So sounds like classic overfitting.\nBut is there a reason why you don't see dropout layers in RL networks? Is there other mechanisms to try and deal with overfitting? Or in many RL examples does it not matter? e.g. there may only be one true way to the ultimate high score in the 'breakout' game, so you might as well learn that exactly, and no need to generalise?\nOr is it deemed that the chaotic nature of the environment itself should provide enough different combinations of outcomes that you don't need to have dropout layers?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Dropout essentially introduces a bit more variance. In supervised learning settings, this indeed often helps to reduce overfitting (although I believe there dropout is also already becoming less.. fashionable in recent years than in the few years before that; I'm not 100% sure though, it's not my primary area of expertise).\nIn Reinforcement Learning, additional variance is not really what we're looking for. There already tends to be a large amount of variance in the learning signals that we get, and this variance already tends to be a major issue for learning stability and/or learning speed. For example:\n\nRandomness in action selection leads to variance in returns that we observe\nThere may be randomness inherent to the environment itself, leading to extra variance in our observations (some environments are nondeterministic)\nUnlike Supervised Learning settings, in Reinforcement Learning we often actually use our own predictions as a part of our loss function / training signal. For example, in temporal-difference learning (like Q-learning / DQN), the target that we update towards looks like $r + \\max_{a'} Q(s', a')$. In that term, only the $r$ is a ground-truth observation (like we would use in supervised learning), and the other term is our own prediction. During a learning process, those latter parts (our own predictions) are changing over time. This is a \"moving target'' problem, which can be viewed as additional variance in our learning signals.\n\nMany important parts of Deep RL algorithms (without which our training processes empirically turn out to destabilize and break down) are very much tailored towards reducing that variance. For example, Target Networks in DQN were introduced specifically to reduce the moving target problem. From this point of view, it's not surprising that if we were to add more artificial variance through other means again (such as dropout), that this would hurt performance / destabilize learning.\n\n\nIs there other mechanisms to try and deal with overfitting? Or in many RL examples does it not matter? e.g. there may only be one true way to the ultimate high score in the 'breakout' game, so you might as well learn that exactly, and no need to generalise?\n\nIn the majority of current (Deep) Reinforcement Learning research, overfitting is indeed not viewed as a problem. The vast majority of RL research consists of training in one environment (for example Cartpole, or Breakout, or one particular level in Pacman, or navigating in one specific maze, etc.), and either constantly evaluating performance during that learning process, or evaluating performance after such a learning process in the same environment.\nIf we were to compare that evaluation methodology to what happens in supervised learning... we are basically evaluating performance on the training set*. In supervised learning, this would be absolutely unacceptable, but in RL it is very much treated as acceptable and more rule than exception. Some say this is simply a problem in current RL research, something that needs to change. It could also be argued that it's not necessarily a problem; if we really are able to train the agent in precisely the same environment that we wish to deploy it in later... well, then what's the problem with it overfitting to that environment? \nSo, when we're using the evaluation methodology described above, indeed we are overfitting to one specific environment, but overfitting is good rather than bad according to our evaluation criteria. It is clear that this methodology does not lead to agents that can generalize well though; if you consistently train an agent to navigate in one particular maze, it will likely be unable to navigate a different maze after training.\n*Note: the truth, in my opinion, is slightly more nuanced than that we are really \"evaluating on the training set\" in RL. See, for example, this nice thread of tweets: https://twitter.com/nanjiang_cs/status/1049682399980908544\n\n\nI have created an environment that simulates currency prices and a simple agent, using DQN, that attempts to learn when to buy and sell. Training it over almost a million timesteps taken from a specific set of data consisting of one month's worth of 5-minute price data it seems to overfit a lot. If I then evaluate the agents and model against a different month's worth of data is performs abysmally. So sounds like classic overfitting.\n\nNote that your evaluation methodology described here indeed no longer fits the more \"common\" evaluation methodology. You have a problem with concept drift, with nonstationarity in the environment. This means overfitting may be a problem for you. \nStill, I'm not sure if dropout would help (it's still additional variance which may hurt). First and foremost, you'd want to make sure that there's some way to keep track of the time / month in your inputs, such that you'll at least have a chance of learning a policy that adapts itself over time. If you have a clear, solid boundary between \"training phase\" and \"evaluation phase\", and you know that concept drift occurs across that boundary (you know that your environment behaves differently in the training phase from the evaluation phase)... you really don't have much hope of learning a policy only from experience in the training phase that still performs well in the evaluation phase. I suspect you'll have to get rid of that clear, solid boundary. You'll want to keep learning throughout the evaluation phase as well. This enables your learning algorithm to actually collect experience in the changed environment, and adapt to it.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can we process the data from both the true distribution and the generator? I'm struggling to understand the GAN loss function as provided in Understanding Generative Adversarial Networks (a blog post written by Daniel Seita).\nIn the standard cross-entropy loss, we have an output that has been run through a sigmoid function and a resulting binary classification.\nSieta states\n\nThus, For [each] data point $x_1$ and its label, we get the following loss function ...\n$$\nH((x_1, y_1), D) = -y_1 \\log D(x_1) - (1 - y_1) \\log (1 - D(x_1))\n$$\n\nThis is just the log of the expectation, which makes sense. However, according to this formulation of the GAN loss, how can we process the data from both the true distribution and the generator in the same iteration?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The Focus of This Question\n\"How can ... we process the data from the true distribution and the data from the generative model in the same iteration?\nAnalyzing the Foundational Publication\nIn the referenced page, Understanding Generative Adversarial Networks (2017), doctoral candidate Daniel Sieta correctly references Generative Adversarial Networks, Goodfellow, Pouget-Abadie, Mirza, Xu, Warde-Farley, Ozair, Courville, and Bengio, June 2014. It's abstract states, \"We propose a new framework for estimating generative models via an adversarial process, in which we simultaneously train two models ...\" This original paper defines two models defined as MLPs (multilayer perceptrons).\n\nGenerative model, G\nDiscriminative model, D\n\nThese two models are controlled in a way where one provides a form of negative feedback toward the other, therefore the term adversarial.\n\nG is trained to capture the data distribution of a set of examples well enough to fool D.\nD is trained to discover whether its input are G's mocks or the set of examples for the GAN system.\n\n(The set of examples for the GAN system are sometimes referred to as the real samples, but they may be no more real than the generated ones. Both are numerical arrays in a computer, one set with an internal origin and the other with an external origin. Whether the external ones are from a camera pointed at some physical scene is not relevant to GAN operation.)\nProbabilistically, fooling D is synonymous to maximizing the probability that D will generate as many false positives and false negatives as it does correct categorizations, 50% each. In information science, this is to say that the limit of information D has of G approaches 0 as t approaches infinity. It is a process of maximizing the entropy of G from D's perspective, thus the term cross-entropy.\nHow Convergence is Accomplished\nBecause the loss function reproduced from Sieta's 2017 writing in the question is that of D, designed to minimize the cross entropy (or correlation) between the two distributions when applied to the full set of points for a given training state.\n\n$H((x_1, y_1), D) = 1 \\, D(x_1)$\n\nThere is a separate loss function for G, designed to maximize the cross entropy. Notice that there are TWO levels of training granularity in the system.\n\nThat of game moves in a two-player game\nThat of the training samples\n\nThese produce nested iteration with the outer iteration as follows.\n\nTraining of G proceeds using the loss function of G.\nMock input patterns are generated from G at its current state of training.\nTraining of D proceeds using the loss function of D.\nRepeat if the cross entropy is not yet sufficiently maximized, D can still discriminate.\n\nWhen D finally loses the game, we have achieved our goal.\n\nG recovered the training data distribution\nD has been reduced to ineffectiveness (\"1/2 probability everywhere\")\n\nWhy Concurrent Training is Necessary\nIf the two models were not trained in a back and forth manner to simulate concurrency, convergence in the adversarial plane (the outer iteration) would not occur on the unique solution claimed in the 2014 paper.\nMore Information\nBeyond the question, the next item of interest in Sieta's paper is that, \"Poor design of the generator's loss function,\" can lead to insufficient gradient values to guide descent and produce what is sometimes called saturation. Saturation is simply the reduction of the feedback signal that guides descent in back-propagation to chaotic noise arising from floating point rounding. The term comes from signal theory.\nI suggest studying the 2014 paper by Goodfellow et alia (the seasoned researchers) to learn about GAN technology rather than the 2017 page.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do I choose the best algorithm for a board game like checkers? How do I choose the best algorithm for a board game like checkers?\nSo far, I have considered only three algorithms, namely, minimax, alpha-beta pruning, and Monte Carlo tree search (MCTS). Apparently, both the alpha-beta pruning and MCTS are extensions of the basic minimax algorithm.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "tl;dr:\n\nNone of these algorithms are practical for modern work, but they are good places to start pedagogically. \nYou should always prefer to use Alpha-Beta pruning over bare minimax search.\nYou should prefer to use some form of heuristic guided search if you can come up with a useful heuristic. Coming up with a useful heuristic usually requires a lot of domain knowledge.\nYou should prefer to use Monte Carlo Tree search when you lack a good heuristic, when computational resources are limited, and when mistakes will not have outsize real-world consequences.\n\nMore Details:\nIn minimax search, we do not attempt to be very clever. We just use a standard dynamic programming approach. It is easy to figure out the value of difference moves if we're close to the end of the game (since the game will end in the next move, we don't have to look very far ahead). Similarly, if we know what our opponent will do in the last move of the game, it's easy to figure out what we should do in the second last move. Effectively we can treat the second last move as the last move of a shorter game. We can then repeat this process. Using this approach is certain to uncover the best strategies in a standard extensive-form game, but will require us to consider every possible move, which is infeasible for all but the simplest games.\nAlpha-Beta pruning is a strict improvement on Minimax search. It makes use of the fact that some moves are obviously worse than others. For example, in chess, I need not consider any move that would give you the opportunity to put me in checkmate, even if you could do other things from that position. Once I see that a move might lead to a lose, I'm not going to bother thinking about what else might happen from that point. I'll go look at other things. This algorithm is also certain to yield the correct result, and is faster, but still must consider most of the moves in practice.\nThere are two common ways you can get around the extreme computational cost of solving these kinds of games exactly:\n\nUse a Heuristic (A* search is the usual algorithm for pedagogical purposes, but Quiescence search is a similar idea in 2 player games). This is just a function that gives an estimate of the value of a state of the game. Instead of considering all the moves in a game, you can just consider moves out to some finite distance ahead, and then use the value of the heuristic to judge the value of the states you reached. If your heuristic is consistent (essentially: if it always overestimates the quality of states), then this will still yield the correct answer, but with enormous speedups in practice.\nUse Rollouts (like Monte Carlo Tree Search). Basically, instead of considering every move, run a few thousand simulated games between players acting randomly (this is faster than considering all possible moves). Assign a value to states equal to the average win rate of games starting from it. This may not yield the correct answer, but in some kinds of games, it performs reliably. It is often used as an extension of more exact techniques, rather than being used on its own.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What kind of word embedding is used in the original transformer? I am currently trying to understand transformers.\nTo start, I read Attention Is All You Need and also this tutorial.\nWhat makes me wonder is the word embedding used in the model. Is word2vec or GloVe being used? Are the word embeddings trained from scratch?\nIn the tutorial linked above, the transformer is implemented from scratch and nn.Embedding from pytorch is used for the embeddings. I looked up this function and didn't understand it well, but I tend to think that the embeddings are trained from scratch, right?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I have found a good answer in this blog post The Transformer: Attention Is All You Need:\n\nwe learn a \u201cword embedding\u201d which is a smaller real-valued vector representation of the word that carries some information about the word. We can do this using nn.Embedding in Pytorch, or, more generally speaking, by multiplying our one-hot vector with a learned weight matrix W.\n\n\nThere are two options for dealing with the Pytorch nn.Embedding weight matrix. One option is to initialize it with pre-trained embeddings and keep it fixed, in which case it\u2019s really just a lookup table. Another option is to initialize it randomly, or with pre-trained embeddings, but keep it trainable. In that case the word representations will get refined and modified throughout training because the weight matrix will get refined and modified throughout training.\nThe Transformer uses a random initialization of the weight matrix and refines these weights during training \u2013 i.e. it learns its own word embeddings.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are Asimov's Laws flawed by design, or are they feasible in practice? Isaac Asimov's famous Three Laws of Robotics originated in the context of Asimov's science fiction stories. In those stories, the three laws serve as a safety measure, in order to avoid untimely or manipulated situations from exploding in havoc.\nMore often than not, Asimov's narratives would find a way to break them, leading the writer to make several modifications to the laws themselves. For instance, in some of his stories, he modified the First Law, added a Fourth (or Zeroth) Law, or even removed all Laws altogether.\nHowever, it is easy to argue that, in popular culture, and even in the field of AI research itself, the Laws of Robotics are taken quite seriously. Ignoring the side problem of the different, subjective, and mutually-exclusive interpretations of the laws, are there any arguments proving the laws themselves intrinsically flawed by their design, or, alternatively, strong enough for use in reality? Likewise, has a better, stricter security heuristics set being designed for the purpose?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Asimov's laws are not strong enough to be used in practice. Strength isn't even a consideration, when considering that since they're written in English words would first have to be interpreted subjectively to have any meaning at all. You can find a good discussion of this here.\nTo transcribe an excerpt:\n\nHow do you define these things? How do you define \"human\", without first having to take a stand on almost every issue. And if \"human\" wasn't hard enough, you then have to define \"harm\", and you've got the same problem again. Almost any really solid unambiguous definitions you give for those words\u2014that don't rely on human intuition\u2014result in weird quirks of philosophy, leading to your AI doing something you really don't want it to do.\n\nOne can easily imagine that Asimov was smart enough to know this and was more interested in story-writing than designing real-world AI control protocols.\nIn the novel Neuromancer, it was suggested that AIs could possibly serve as checks against each other. Ray Kurzweil's impending Singularity, or the possibility of hyperintelligent AGIs otherwise, might not leave much of a possibility for humans to control AIs at all, leaving peer-regulation as the only feasible possibility.\nIt's worth noting that Eliezer Yudkowsky and others ran an experiment wherein Yudkowsky played the role of a superintelligent AI with the ability to speak, but no other connection outside of a locked box. The challengers were tasked simply with keeping the AI in the box at all costs. Yudkowsky escaped both times.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Problems that only humans will ever be able to solve With the increasing complexity of reCAPTCHA, I wondered about the existence of some problem, that only a human will ever be able to solve (or that AI won't be able to solve as long as it doesn't reproduce exactly the human brain).\nFor instance, the distorted text used to be only possible to solve by humans. Although...\n\nThe computer now got the [distorted text] test right 99.8%, even in the most challenging situations.\n\nIt seems also obvious that the distorted text can't be used for real human detection anymore. \nI'd also like to know whether an algorithm can be employed for the creation of such a problem (as for the distorted text), or if the originality of a human brain is necessarily needed. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Informally, AI-complete problems are the most difficult problems for an AI. The concept is not mathematically defined yet, as e.g. NP-complete problems. However, intuitively, these are the problems that require a human-level or general intelligence to be solved.\nReal natural language understanding is believed to be an AI-complete problem (this is also discussed in the paper Making AI Meaningful Again by Jobst Landgrebe and Barry Smith, 2019). There are a lot more AI-complete problems. For example, problems that involve emotions.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What exactly are genetic algorithms and what sort of problems are they good for? I've noticed that a few questions on this site mention genetic algorithms and it made me realize that I don't really know much about those.\nI have heard the term before, but it's not something I've ever used, so I don't have much idea about how they work and what they are good for. All I know is that they involve some sort of evolution and randomly changing values.\nCan you give me a short explanation, preferably including some sort of practical example that illustrates the basic principles?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Evolutionary algorithms are a family of optimization algorithms based on the principle of Darwinian natural selection. As part of natural selection, a given environment has a population of individuals that compete for survival and reproduction. The ability of each individual to achieve these goals determines their chance to have children, in other words, to pass on their genes to the next generation of individuals, who, for genetic reasons, will have an increased chance of doing well, even better, in realizing these two objectives.\nThis principle of continuous improvement over the generations is taken by evolutionary algorithms to optimize solutions to a problem. In the initial generation, a population composed of different individuals is generated randomly or by other methods. An individual is a solution to the problem, more or less good: the quality of the individual in regards to the problem is called fitness, which reflects the adequacy of the solution to the problem to be solved. The higher the fitness of an individual, the higher it is likely to pass some or all of its genotype to the individuals of the next generation.\nAn individual is coded as a genotype, which can have any shape, such as a bit vector (genetic algorithms) or a vector of real (evolution strategies). Each genotype is transformed into a phenotype when assessing the individual, i.e. when its fitness is calculated. In some cases, the phenotype is identical to the genotype: it is called direct coding. Otherwise, the coding is called indirect. For example, suppose you want to optimize the size of a rectangular parallelepiped defined by its length, height and width. To simplify the example, assume that these three quantities are integers between 0 and 15. We can then describe each of them using a 4-bit binary number. An example of a potential solution may be to genotype 0001 0111 1010. The corresponding phenotype is a parallelepiped of length 1, height 7 and width 10.\nDuring the transition from the old to the new generation, the variation operators, whose purpose is to manipulate individuals, are applied. There are two distinct types of variation operators:\n\nthe mutation operators, which are used to introduce variations within the same individual, as genetic mutations;\nthe crossover operators, which are used to cross at least two different genotypes, as genetic crosses from breeding.\n\nEvolutionary algorithms have proven themselves in various fields such as operations research, robotics, biology, nuance, or cryptography. In addition, they can optimize multiple objectives simultaneously and can be used as black boxes because they do not assume any properties in the mathematical model to optimize. Their only real limitation is the computational complexity.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How are Artificial Neural Networks and the Biological Neural Networks similar and different? I've heard multiple times that \"Neural Networks are the best approximation we have to model the human brain\", and I think it is commonly known that Neural Networks are modelled after our brain.\nI strongly suspect that this model has been simplified, but how much? \nHow much does, say, the vanilla NN differ from what we know about the human brain? Do we even know?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "We all know that artificial neural networks (ANNs) are inspired by but most of them are only loosely based on the biological neural networks (BNNs).\nWe can analyze the differences and similarities between ANNs and BNNs in terms of the following components.\nNeurons\nThe following diagram illustrates a biological neuron (screenshot of an image from this book).\n\nThe following one illustrates a typical artificial neuron of an ANN (screenshot of figure 1.14 of this book).\n\nInitialization\nIn the case of an ANN, the initial state and weights are assigned randomly. While for BNNs, the strengths of connections between neurons and the structure of connections don't start as random. The initial state is genetically derived and is the byproduct of evolution.\nLearning\nIn BNN, learning comes from the interconnections between myriad neurons in the brain. These interconnections change configuration when the brain experiences new stimuli. The changes result in new connections, strengthening of existing connections, and removal of old and unused ones.\nANNs are trained from scratch usually using a fixed topology (remember topology changes in case of BNNs), although the topology of ANN can also change (for example, take a look at NEAT or some continual learning techniques), which depends on the problem being solved. The weights of an ANN are randomly initialized and adjusted via an optimization algorithm.\nNumber of neurons\nAnother difference (although this difference is always smaller) is in the number of neurons in the network. A typical ANN consists of hundreds, thousands, millions, and, in some exceptional (e.g. GPT-3), billions of neurons. The BNN of the human brain consists of billions. This number varies from animal to animal.\nFurther reading\nYou can find more information here or here.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does LSTM in deep reinforcement learning differ from experience replay? In the paper Deep Recurrent Q-Learning for Partially Observable MDPs, the author processed the Atari game frames with an LSTM layer at the end. My questions are: \n\nHow does this method differ from the experience replay, as they both use past information in the training? \nWhat's the typical application of both techniques? \nCan they work together?\nIf they can work together, does it mean that the state is no longer a single state but a set of contiguous states?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nHow does this method differ from the experience replay, as they both use past information in the training? What's the typical application of both techniques?\n\nUsing a recurrent neural network is one way for an agent to build a model of hidden or unobserved state in order to improve its predictions when direct observations do not give enough information, but a history of observations might give better information. Another way is to learn a Hidden Markov model. Both of these approaches build an internal representation that is effectively considered part of the state when making a decision by the agent. They are a way to approach solving POMDPs. \nYou can consider using individual frame images from Atari games as state as a POMDP, because each individual frame does not contain information about velocity. Velocity of objects in play is an important concept in many video games. By formulating the problem as a POMDP with individual image inputs, this challenges the agent to find some representation of velocity (or something similar conceptually) from a sequence of images. Technically a NN may also do this using fixed inputs of 4 frames at a time (as per the original DQN Atari paper), but in that case the designers have deliberately \"solved\" the partially observable part of the problem for the agent in advance, by selecting a better state representation from the start.\nExperience replay solves some different problems:\n\nEfficient use of experience, by learning repeatedly from observed transitions. This is important when the agent needs to use a low learning rate, as it does when the environment has stochastic elements or when the agent includes a complex non-linear function approximator like a neural network.\nDe-correlating samples to avoid problems with function approximators that work best with i.i.d. data. If you didn't effectively shuffle the dataset, the correlations between each time step could cause significant issues with a feed-forward neural network.\n\nThese two issues are important to learning stability for neural networks in DQN. Without experience replay, often Q-learning with neural networks will fail to converge at all. \n\nCan they work together?\n\nSort of, but not quite directly, because LSTM requires input of multiple related time steps at once, as opposed to randomly sampled individual time steps. However, you could keep a history of longer trajectories, and sample sections from it for the history in order to train a LSTM. This would still achieve the goal of using experience efficiently. Depending on the LSTM architecture, you may need to sample quite long trajectories or even complete episodes in order to do this.\nFrom comments by Muppet, it seems that is even possible to sample more randomly with individual steps by saving LSTM state. For instance, there is a paper \"Deep reinforcement learning for time series: playing idealized trading games\" where the authors get a working system doing this. I have no experience of this approach myself, and there are theoretical reasons why this may not work in all cases, but it is an option.\n\nIf they can work together, does it mean that the state is no longer a single state but a set of contiguous states?\n\nNot really, the state at any time step is still a single state representation, is separate conceptually from an observation, and is separate conceptually from a trajectory or sequence of states used to train a RNN (other RL approaches such as TD($\\lambda$) also require longer trajectories). Using an LSTM implies you have hidden state on each time step (compared to what you are able to observe), and that you hope the LSTM will discover a way to represent it. \nOne way to think of this is that the state is the current observation, plus a summary of observation history. The original Atari DQN paper simply used the previous three observations hard-coded as this \"summary\", which appeared to capture enough information to make predicting value functions reliable. \nThe LSTM approach is partly of interest, because it does not rely on human input to decide how to construct state from the observations, but discovers this by itself. One key goal of deep learning is designs and architectures that are much less dependent on human interpretations of the problem (typically these use feature engineering to assist in learning process). An agent that can work directly from raw observations has solved more of the problem by itself without injection of knowledge by the engineers that built it.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Would Google's self-driving-car stop when it sees somebody with a T-shirt with a stop sign printed on it? In Hidden Obstacles for Google\u2019s Self-Driving Cars article we can read that:\n\nGoogle\u2019s cars can detect and respond to stop signs that aren\u2019t on its map, a feature that was introduced to deal with temporary signs used at construction sites.\nGoogle says that its cars can identify almost all unmapped stop signs, and would remain safe if they miss a sign because the vehicles are always looking out for traffic, pedestrians and other obstacles.\n\nWhat would happen if a car spotted somebody in front of it (but not on the collision path) wearing a T-shirt that has a stop sign printed on it. Would it react and stop the car?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Google\u2019s self-driving car most likely uses mapping of traffic signs using google street view images for roadway inventory management. If traffic signs are not in its database, it can still \u201csee\u201d and detect moving objects which can be distinguished from the presence of certain stationary objects, like traffic lights. So its software can classify objects based on the size, shape and movement patterns. Therefore it is highly unlikely that a person would be mistaken for a traffic sign. See: How does Google's self-driving car identify pedestrians?\n\nImage: Technology Review\nTo support such a claim, Illah Nourbakhsh, a professor of robotics at Carnegie Mellon University, gave an interview to the New York Times magazine cover story on autonomous driving cars, and includes this hypothetical scenario, saying:\n\nIf they\u2019re outside walking, and the sun is at just the right glare level, and there\u2019s a mirrored truck stopped next to you, and the sun bounces off that truck and hits the guy so that you can\u2019t see his face anymore \u2014 well, now your car just sees a stop sign. The chances of all that happening are diminishingly small \u2014 it\u2019s very, very unlikely \u2014 but the problem is we will have millions of these cars. The very unlikely will happen all the time.\n\nEven so, the risk would be minimal, since the car is always looking out for traffic, pedestrians and other obstacles.\nSources:\n\nHow Google's self-driving cars see the world\nThe Dream Life of Driverless Cars at The New York Times\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between actor-critic and advantage actor-critic? I'm struggling to understand the difference between actor-critic and advantage actor-critic.\nAt least, I know they are different from asynchronous advantage actor-critic (A3C), as A3C adds an asynchronous mechanism that uses multiple worker agents interacting with their own copy of the environment and reports the gradient to the global agent. \nBut what is the difference between the actor-critic and advantage actor-critic (A2C)? Is it simply with or without advantage function? But, then, does the actor-critic have any other implementation except for the use of advantage function?\nOr maybe are they synonyms and actor-critic is just a shorthand for A2C?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Actor-Critic is not just a single algorithm, it should be viewed as a \"family\" of related techniques. They're all techniques based on the policy gradient theorem, which train some form of critic that computes some form of value estimate to plug into the update rule as a lower-variance replacement for the returns at the end of an episode. They all perform \"bootstrapping\" by using some sort of prediction of value.\nAdvantage Actor-Critic specifically uses estimates of the advantage function $A(s, a) = Q(s, a) - V(s)$ for its bootstrapping, whereas \"actor-critic\" without the \"advantage\" qualifier is not specific; it could be a trained $V(s)$ function, it could be some sort of estimate of $Q(s, a)$, it could be a variety of things.\nIn practice, the critic of Advantage Actor-Critic methods actually can just be trained to predict $V(s)$. Combined with an empirically observed reward $r$, they can then compute the advantage estimate $A(s, a) = r + \\gamma V(s') - V(s)$.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "1 hidden layer with 1000 neurons vs. 10 hidden layers with 100 neurons These types of questions may be problem-dependent, but I have tried to find research that addresses the question whether the number of hidden layers and their size (number of neurons in each layer) really matter or not.\nSo my question is, does it really matter if we for example have 1 large hidden layer of 1000 neurons vs. 10 hidden layers with 100 neurons each?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Basically, having multiple layers (aka a deep network) makes your network more eager to recognize certain aspects of input data. For example, if you have the details of a house (size, lawn size, location etc.) as input and want to predict the price. The first layer may predict:\n\nBig area, higher price\nSmall amount of bedrooms, lower price\n\nThe second layer might conclude:\n\nBig area + small amount of bedrooms = large bedrooms = +- effect\n\nYes, one layer can also 'detect' the stats, however it will require more neurons as it cannot rely on other neurons to do 'parts' of the total calculation required to detect that stat.\nCheck out this answer\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the mathematical prerequisites for an AI researcher? What are the mathematical prerequisites for understanding the core part of various algorithms involved in artificial intelligence and developing one's own algorithms?\nPlease, refer to some specific books.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Good Mathematics Foundation\nBegin by ensuring full competency with intermediate algebra and some other foundations of calculus and discrete math, including the terminology and basic concepts within these topics.\n\nInfinite series\nLogical proofs\nLinear algebra and matrices\nAnalytic geometry, especially the distinction between local and global extremes (minima and maxima), saddle points, and points of inflection\nSet theory\nProbability\nStatistics\n\nFoundations of Cybernetics\nNorbert Wiener, Cybernetics, 1948, MIT Press, contains time series and feedback concepts with clarity and command not seen in subsequent works; it also contains an introduction to information theory beginning with Shannon's log2 formula for a defining the amount of information in a bit. This is important to understand the expansion of the information entropy concept.\nCalculus\nFind a good calculus book and make sure you have clarity around key theory and application in these categories.\n\nTime series\nInfinite series\nConvergence \u2014 Artificial networks ideally converge to an optimum during learning.\nPartial differentials\nJacobian and Hessian matrices\nMultivariate math\nBoundary regions\nDiscrete math\n\nMuch of that is in Calculus, Strang, MIT, Wellesley-Cambridge Press. Although the PDF is available on the web, it is basic and not particularly deep. The one in our laboratory's library is Intermediate Calculus, Hurley, Holt Rinehart & Winston, 1980. It is comprehensive and in some ways better laid out than the one I have in my home library, which Princeton uses for sophomores.\nEnsure you are comfortable working in spaces beyond \u211d2 (beyond 2D). For instance, RNNs are often in spaces such as \u211d4 thorugh \u211d7 because of the horizontal, vertical, pixel depth, and movie frame dimensions.\nFinite Math\nIt is unfortunate that no combination of any three books I can think of has all of these.\n\nDirected graphs \u2014 Learn this BEFORE trees or circuits (artificial nets) because it is the superset topography of all those configurations\nAbstract symbol trees (ASTs)\nAdvanced set theory\nDecision trees\nMarkov chains\nChaos theory (especially the difference between random and pseudo-random)\nGame Theory starting with Von Neumann and Morgenstern's Game Theory, the seminal work in that field\nConvergence in discrete systems especially the application of theory to signal saturation in integer, fixed point, or floating-point arithmetic\nStatistical means, deviations, correlation, and the more progressive concepts of entropy, relative entropy, and cross-entropy\nCurve fitting\nConvolution\nProbability especially Bayes' Theorem\nAlgorithmic theory (G\u00f6del's uncertainty theorems and Turing completeness)\n\nChemistry and Neurology\nIt is good to recall chemical equilibria from high school chemistry. Balance plays a key role in more sophisticated AI designs. Understanding the symbiotic relationship between generative and discriminative models in GANs will help a student further this understanding.\nThe control functions within biological systems remain a primary source of proofs of concept in artificial intelligence research. As researchers become more creative in imagining forms of adaptation that do not directly mimic some aspect of biology (still a distance off as of this writing) creativity may play a larger role in AI research objective formulation.\nEven so, AI will probably remain a largely interdisciplinary field.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What language is the GPT-3 engine written in? I know that the API is python based, but what's the gpt-3 engine written in mostly? C? C++? I'm having some trouble finding this info.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The GPT-3 source code hasn\u2019t been released but the creators say it uses the \u201csame model and architecture as GPT-2\u201d (source) with some exceptions.\nThe GPT-2 source code is written in 100% Python. The model is based on Tensorflow and NumPy which are written using C and C++. My best guess is that GPT-3 is also written in Python using libraries based on C.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is geometric deep learning? What is geometric deep learning (GDL)?\nHere are a few sub-questions\n\nHow is it different from deep learning?\nWhy do we need GDL?\nWhat are some applications of GDL?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The article Geometric deep learning: going beyond Euclidean data (by Michael M. Bronstein, Joan Bruna, Yann LeCun, Arthur Szlam, Pierre Vandergheynst) provides an overview of this relatively new sub-field of deep learning. It answers all the questions asked above (and more). If you are familiar with deep learning, graphs, linear algebra and calculus, you should be able to follow this article.\nWhat is geometric deep learning (GDL)?\nThis article describes GDL as follows\n\nGeometric deep learning is an umbrella term for emerging techniques attempting to generalize (structured) deep neural models to non-Euclidean domains such as graphs and manifolds.\n\nSo, the inputs to these GDL models are graphs (or representations of graphs), or, in general, any non-Euclidean data. To be more concrete, the input to these models (e.g. graph neural networks) are e.g. feature vectors associated with the nodes of the graphs and matrices which describe the graph structure (e.g. the adjacency matrix of the graphs).\nWhy are e.g. graphs non-Euclidean data?\nA graph is a non-Euclidean structure because e.g. distances between nodes are not well defined. Yes, you can have graphs with weights associated with the edges, but not all graphs have this property.\nWhat classes of problems does GDL address?\nIn GDL, there are two classes of problems that are often tackled:\n\ncharacterise the structure of the data (e.g. of a graph)\nanalyse functions defined on a given non-Euclidean domain\n\nThese classes of problems are related, given that the structure of the graph imposes certain properties on the functions that can be defined on it. Furthermore, these properties of these functions can also convey information about the structure of the graph.\nWhat are applications of GDL?\nAn example of an application where this type of data (graphs) arises is in the context of social networks, where each user can be associated with a vertex of the social graph and the characteristics (or features) of each user (e.g. number of friends) can be represented as a feature vector (which can then be associated with the corresponding vertex of a graph). In this context, the goal might e.g. be to determine different groups of users in the social network (i.e. clustering).\nWhy can't we simply use deep learning methods (like CNNs) when the data is non-Euclidean?\nThere are several problems that arise when dealing with non-Euclidean data. For example, operations like convolution are not (usually) defined on non-Euclidean data. More concretely, the relative position of nodes is not defined on graphs (but this would be required to perform the usual convolution operation): in other words, it is meaningless to talk about a vertex that is e.g. on the left of another vertex. In practice, it means that we can't simply use the usual CNN when we are given non-Euclidean data. There have been attempts to generalise the convolution operation to graphs (or to approximate it). The field is still quite new, so there will certainly be new developments and breakthroughs.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to classify data which is spiral in shape? I have been messing around in tensorflow playground. One of the input data sets is a spiral. No matter what input parameters I choose, no matter how wide and deep the neural network I make, I cannot fit the spiral. How do data scientists fit data of this shape?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are many approaches to this kind of problem. The most obvious one is to create new features. The best features I can come up with is to transform the coordinates to spherical coordinates. \nI have not found a way to do it in playground, so I just created a few features that should help with this (sin features). After 500 iterations it will saturate and will fluctuate at 0.1 score. This suggest that no further improvement will be done and most probably I should make the hidden layer wider or add another layer.\nNot a surprise that after adding just one neuron to the hidden layer you easily get 0.013 after 300 iterations. Similar thing happens by adding a new layer (0.017, but after significantly longer 500 iterations. Also no surprise as it is harder to propagate the errors). Most probably you can play with a learning rate or do an adaptive learning to make it faster, but this is not the point here.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What research has been done in the domain of \"identifying sarcasm in text\"? Identifying sarcasm is considered one of the most difficult open-ended problems in the domain of ML and NLP/NLU.\nSo, was there any considerable research done on that front? If yes, then what is the accuracy like? Please, also, explain the NLP model briefly.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The following survey article by researchers from IIT Bombay summarizes recent advances in sarcasm detection: Arxiv link.\nIn reference to your question, I do not think it is considered either extraordinarily difficult or open-ended. While it does introduce ambiguity that computers cannot yet handle, Humans are easily able to understand sarcasm, and are thus able to label datasets for sarcasm detection.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What exactly is a hidden state in an LSTM and RNN? I'm working on a project, where we use an encoder-decoder architecture. We decided to use an LSTM for both the encoder and decoder due to its hidden states. In my specific case, the hidden state of the encoder is passed to the decoder, and this would allow the model to learn better latent representations.\nDoes this make sense?\nI am a bit confused about this because I really don't know what the hidden state is. Moreover, we're using separate LSTMs for the encoder and decoder, so I can't see how the hidden state from the encoder LSTM can be useful to the decoder LSTM because only the encoder LSTM really understands it.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is my own understanding of the hidden state in a recurrent network. If it's wrong, please, feel free to let me know.\nLet's consider the following two input and output sequences\n\\begin{align}\nX &= [a, b, c, d, \\dots,y , z]\\\\\nY &= [b, c, d, e, \\dots,z , a]\n\\end{align}\nWe will first try to train a multi-layer perceptron (MLP) with one input and one output from $X$ and $Y$. Here, the details of the hidden layers don't matter.\nWe can write this relationship in maths as\n$$f(x)\\rightarrow y$$\nwhere $x$ is an element of $X$ and $y$ is an element of $Y$ and $f(\\cdot)$ is our MLP.\nAfter training, if given the input $a = x$, our neural network will give an output $b = y$ because $f(\\cdot)$ learned the mapping between the sequence $X$ and $Y$.\nNow, instead of the above sequences, try to teach the following sequences to the same MLP.\n\\begin{align}\nX &= [a,a,b,b,c,c,\\cdots, y,z,z]\\\\\nY &= [a,b,c,\\cdots, z,a,b,c, \\cdots, y,z]\n\\end{align}\nMore than likely, this MLP will not be able to learn the relationship between $X$ and $Y$. This is because a simple MLP can't learn and understand the relationship between the previous and current characters.\nNow, we use the same sequences to train an RNN. In an RNN, we take two inputs, one for our input and the previous hidden values, and two outputs, one for the output and the next hidden values.\n$$f(x, h_t)\\rightarrow (y, h_{t+1})$$\nImportant: here $h_{t+1}$ represents the next hidden value.\nWe will execute some sequences of this RNN model. We initialize the hidden value to zero.\nx = a and h = 0\n(a,next_hidden) <- f(x,h)\nprev_hidden = next_hidden\n\nx = a and h = prev_hidden\n(b,next_hidden) <- f(x,h)\nprev_hidden = next_hidden\n\nx = b and h = prev_hidden\n(c,next_hidden) <- f(x,h)\nprev_hidden = next_hidden\n\nand so on \n\nIf we look at the above process we can see that we are taking the previous hidden state values to compute the next hidden state. What happens is while we iterate through this process prev_hidden = next_hidden it also encodes some information about our sequence which will help in predicting our next character.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does DQN require two different networks? I was going through this implementation of DQN and I see that on line 124 and 125 two different Q networks have been initialized. From my understanding, I think one network predicts the appropriate action and the second network predicts the target Q values for finding the Bellman error.\nWhy can we not just make one single network that simply predicts the Q value and use it for both the cases? My best guess that it's been done to reduce the computation time, otherwise we would have to find out the q value for each action and then select the best one. Is this the only reason? Am I missing something?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nMy best guess that it's been done to reduce the computation time, otherwise we would have to find out the q value for each action and then select the best one. \n\nIt has no real impact on computation time, other than a slight increase (due to extra memory used by two networks). You could cache results of the target network I suppose, but it probably would not be worth it for most environments, and I have not seen an implementation which does that.\n\nAm I missing something?\n\nIt is to do with stability of the Q-learning algorithm when using function approximation (i.e. the neural network). Using a separate target network, updated every so many steps with a copy of the latest learned parameters, helps keep runaway bias from bootstrapping from dominating the system numerically, causing the estimated Q values to diverge.\nImagine one of the data points (at $s, a, r, s'$) causes a currently poor over-estimate for $q(s', a')$ to get worse. Maybe $s', a'$ has not even been visited yet, or the values of $r$ seen so far is higher than average, just by chance. If a sample of $(s, a)$ cropped up multiple times in experience replay, it would get worse again each time, because the update to $q(s,a)$ is based on the TD target $r + \\text{max}_{a'} q(s',a')$. Fixing the target network limits the damage that such over-estimates can do, giving the learning network time to converge and lose more of its initial bias.\nIn this respect, using a separate target network has a very similar purpose to experience replay. It stabilises an algorithm that otherwise has problems converging.\nIt is also possible to have DQN with \"double learning\" to address a separate issue: Maximisation bias. In that case you may see DQN implementations with 4 neural networks.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Issues with and alternatives to Deep Learning approaches? Over the last 50 years, the rise/fall/rise in popularity of neural nets has acted as something of a 'barometer' for AI research.\nIt's clear from the questions on this site that people are interested in applying Deep Learning (DL) to a wide variety of difficult problems.\nI therefore have two questions:\n\nPractitioners - What do you find to be the main obstacles to\napplying DL 'out of the box' to your problem? \nResearchers - What\ntechniques do you use (or have developed) that might help address\npractical issues? Are they within DL or do they offer an\nalternative approach?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "To summarize, There are two major issues in applied Deep Learning.\n\nThe first being that computationally , it's exhaustive. Normal CPU's require a lot of time to perform even the basic computation/training with Deep Learning. GPU's are thus recommended however, even they may not be enough in a lot of situations. Typical deep learning models don't support the theoretical time to be in Polynomials. However, if we look at the relatively simpler models in ML for the same tasks, too often we have mathematical guarantees that training time required for such simpler Algorithms is in Polynomials. This, for me, at least is probably the biggest difference. \nThere're solutions to counter this issue, though. One main approach being is to optimize DL Algorithms to a number of iterations only (instead of looking at the global solutions in practice, just optimize the algorithm to a good local solution, whereas the criterion for \"Good\" is defined by the user).\nAnother Issue which may be a little bit controversial to young deep learning enthusiasts is that Deep Learning algorithms lack theoretical understanding and reasoning. Deep Neural Networks have been successfully used in a lot of situations including Hand writing recognition, Image processing, Self Driving Cars, Signal Processing, NLP and Biomedical Analysis. In some of these cases, they have even surpassed humans. However, that being said, they're not under any circumstance, theoretically as sound as most of Statistical Methods.\nI will not go into detail , rather I leave that up to you. There're pros and cons for every Algorithm/methodology and DL is not an exception. It's very useful as has been proven in a lot of situations and every young Data Scientist must learn at least the basics of DL. However, in the case of relatively simple problems, it's better to use famous Statistical methods as they have a lot of theoretical results/guarantees to support them. Furthermore, from learning point of view, it's always better to start with simple approaches and master them first. \n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do I decide the optimal number of layers for a neural network? How do I decide the optimal number of layers for a neural network (feedforward or recurrent)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is a technique called Pruning in neural networks, which is used just for this same purpose.\nThe pruning is done on the number of hidden layers. The process is very similar to the pruning process of decision trees. The pruning process is done as follows:\n\nTrain a large, densely connected, network with a standard training\nalgorithm\nExamine the trained network to assess the relative importance of the\nweights\nRemove the least important weight(s)\nretrain the pruned network\nRepeat steps 2-4 until satisfied\n\nHowever, there are several optimized methods for pruning neural nets, and it is also a very active area of research.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the most general definition of \"intelligence\"? When we talk about artificial intelligence, human intelligence, or any other form of intelligence, what do we mean by the term intelligence in a general sense? What would you call intelligent and what not? In other words, how do we define the term intelligence in the most general possible way?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I'm going to preface this answer by noting that persons much smarter than myself have treated this subject in some detail. That said, as far as I can discern:\n\nWhen we talk about intelligence we're referring to problem solving strength in relation to a problem, relative to the strength of other intelligences.\n\nThis is a somewhat game-theoretic conception, related to rationality and the concept of the rational agent. Regarding intelligence in this manner may be unavoidable. Specifically, we could define intelligence as the ability to understand a problem or solution or abstract concepts, but we can't validate that understanding without testing it. (For instance, I might believe I grasp a mathematical technique, but the only way to determine if that belief is real or illusory is to utilize that technique and evaluate the results.)\nThe reason games like Chess and Go have been used as milestones, aside from longstanding human interest in the games, is that they provide models with simple, fully definable parameters, and, in the case of Go at least, have complexity akin to nature, by which I mean unsolvable/intractable. (Compare to strength at Tic-Tac-Toe, which is trivially solved.)\nHowever, we should consider a point made in this concise answer to a question involving the Turing Test:\n\n\"...is [intelligence] defined purely by behaviour in an environment, or by the mechanisms that arrive at that behaviour?\"\n\nThis is important because Google just gave control over data center cooling to an AI. Here it is clearly the mechanism itself that demonstrates utility, but if we call that mechanism intelligent, for intelligence to have meaning, we still have to contend with \"intelligent how?\" (In what way is it intelligent?) If we want to know \"how intelligent?\" (its degree of utility) we still have to evaluate its performance in relation to the performance of other mechanisms.\n(In the case of the automata controlling the air conditioning at Google, we can say that it is more intelligent than the prior control system, and by how much.)\nBecause we're starting to talk about more \"generalized intelligence\", defined here as mechanisms that can be applied to a set of problems, (I include minimax as a form of \"axiomatic intelligence\" and machine learning as a form \"adaptive intelligence\"), it may be worthwhile to expand and clarify the definition:\n\nIntelligence is the problem solving strength of a mechanism in relation to a problem or a set of problems, relative to the strength of other mechanisms.\n\nor, if we wanted to be pithy:\n\nIntelligence is as intelligence does (and how well.)\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is reinforcement learning not the answer to AGI? I previously asked a question about How can an AI freely make decisions?. I got a great answer about how current algorithms lack agency.\nThe first thing I thought of was reinforcement learning, since the entire concept is oriented around an agent getting rewarded for performing a correct action in an environment. It seems to me that reinforcement learning is the path to AGI.\nI'm also thinking: what if an agent was proactive instead of reactive? That would seem like a logical first step towards AGI. What if an agent could figure out what questions to ask based on their environment? For example, it experiences an apple falling from a tree and asks \"What made the Apple fall?\". But it's similar to us not knowing what questions to ask about say the universe.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Some AI researchers do think RL is a path to AGI, and your intuition about how an agent would need to be proactive in selecting actions to learn about is exactly the area these researchers are now focused on.\nMuch of the work in this area is focused on the idea of curiosity, and since 2014 this idea has gained a lot of traction in the research community.\nSo, maybe RL can lead to AGI. We don't know for sure yet.\nHowever, many of the classic arguments against AGI aren't addressed by the RL approach. For instance, if like Searle, you think computers just don't have the right kind of hardware to do thinking, then running an RL algorithm on that hardware isn't going to yield AGI, just ever increasingly robust narrow AI. Ultimately Searle's arguments get into issues of metaphysics, so it isn't clear that there exists any argument that would convince someone like Searle that a particular computer-based technique is AGI-capable.\nThere are also other arguments. For example, the cognitivist school of thought thinks that statistical learning approaches to AI, and, in particular, the black-box approaches of statistically-driven RL, are unlikely to lead to general intelligence because they do not engage in the kind of systematic reasoning process that proponents of cognitivism assume is necessary for general intelligence. Some more extreme proponents of this school might say that a logical planning algorithm like STRIPS is innately more intelligent than any approach based on deep learning, because it involves sound logical deduction rather than mere statistical calculation. In particular, STRIPS can correctly generalize to any new domain, as long as it is fed the correct sense data, while an RL approach will need to learn how to act there.\nSo, while there are definitely reasons to be optimistic about RL as a direction for achieving AGI, it's definitely not yet settled.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does the discount rate in the REINFORCE algorithm appear twice? I was reading the book Reinforcement Learning: An Introduction by Richard S. Sutton and Andrew G. Barto (complete draft, November 5, 2017). \nOn page 271, the pseudo-code for the episodic Monte-Carlo Policy-Gradient Method is presented. Looking at this pseudo-code I can't understand why it seems that the discount rate appears 2 times, once in the update state and a second time inside the return. [See the figure below] \n\nIt seems that the return for the steps after step 1 are just a truncation of the return of the first step. Also, if you look just one page above in the book you find an equation with just 1 discount rate (the one inside the return.) \nWhy then does the pseudo-code seem to be different? My guess is that I am misunderstanding something: \n$$\n{\\mathbf{\\theta}}_{t+1} ~\\dot{=}~\\mathbf{\\theta}_t + \\alpha G_t \\frac{{\\nabla}_{\\mathbf{\\theta}} \\pi \\left(A_t \\middle| S_t, \\mathbf{\\theta}_{t} \\right)}{\\pi \\left(A_t \\middle| S_t, \\mathbf{\\theta}_{t} \\right)}.\n\\tag{13.6}\n$$\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The discount factor does appear twice, and this is correct.\nThis is because the function you are trying to maximise in REINFORCE for an episodic problem (by taking the gradient) is the expected return from a given (distribution of) start state:\n$$J(\\theta) = \\mathbb{E}_{\\pi(\\theta)}[G_t|S_t = s_0, t=0]$$\nTherefore, during the episode, when you sample the returns $G_1$, $G_2$ etc, these will be less relevant to the problem you are solving, reduced by the discount factor a second time as you noted. At the extreme with an episodic problem and $\\gamma = 0$ then REINFORCE will only find an optimal policy for the first action.\nIn continuing problems, you would use different formulations for $J(\\theta)$, and these do not lead to the extra factor of $\\gamma^t$.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When is deep learning overkill? For example, for classifying emails as spam, is it worthwhile - from a time/accuracy perspective - to apply deep learning (if possible) instead of another machine learning algorithm? Will deep learning make other machine learning algorithms like naive Bayes unnecessary?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It's all about Return On Investment. If DL is \"worth doing\", it's not overkill.\nIf the cost of using DL (computer cycles, storage, training time) is acceptable, and the data available to train it is plentiful, and if the marginal advantage over alternative algorithms is valuable, then DL is a win. \nBut, as you suggest, if your problem is amenable to alternate methods, especially if it offers a signal that matches up well with classic methods like regression or naive Bayes, or your problem requires explanation of why the decision boundary is where it is (e.g. decision trees), or if your data lacks the continuous gradients needed by DL (especially, CNNs), or your data varies over time which would require periodic retraining (especially, at unpredictable intervals), then DL probably is a mismatch for you.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are search engines considered AI? Are search engines considered AI because of the way they analyze what you search for and remember it? Or how they send you ads of what you've searched for recently? \nIs this considered AI or just smart?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I believe it would be more accurate to say that (some) search engines use AI. Broadly saying \"search engines are AI\" is not really correct. At the core, most search engines are nothing more than an inverted text index using something like tf\u2013idf scoring. That's a very mechanical/simple thing that nobody would really call AI. \nBut more sophisticated search engines may use AI or AI techniques to do things like semantic analysis - so they can actually \"answer questions\" instead of just looking up words in an index. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can policy gradients be applied in the case of multiple continuous actions? Trusted Region Policy Optimization (TRPO) and Proximal Policy Optimization (PPO) are two cutting edge policy gradients algorithms.\nWhen using a single continuous action, normally, you would use some probability distribution (for example, Gaussian) for the loss function. The rough version is:\n$$L(\\theta) = \\log(P(a_1)) A,$$\nwhere $A$ is the advantage of rewards, $P(a_1)$ is characterized by $\\mu$ and $\\sigma^2$ that comes out of neural network like in the Pendulum environment here: https://github.com/leomzhong/DeepReinforcementLearningCourse/blob/69e573cd88faec7e9cf900da8eeef08c57dec0f0/hw4/main.py.\nThe problem is that I cannot find any paper on 2+ continuous actions using policy gradients (not actor-critic methods that use a different approach by transferring gradient from Q-function).\nDo you know how to do this using TRPO for 2 continuous actions in LunarLander environment?\nIs following approach correct for policy gradient loss function?\n$$L(\\theta) = (\\log P(a_1) + \\log P(a_2) )*A$$\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As you has said, actions chosen by Actor-Critic typically come from a normal distribution and it is the agent's job to find the appropriate mean and standard deviation based on the the current state. In many cases this one distribution is enough because only 1 continuous action is required. However, as domains such as robotics become more integrated with AI, situations where 2 or more continuous actions are required are a growing problem.\nThere are 2 solutions to this problem:\nThe first and most common is that for every continuous action, there is a separate agent learning its own 1-dimensional mean and standard deviation. Part of its state includes the actions of the other agents as well to give context of what the entire system is doing. We commonly do this in my lab and here is a paper which describes this approach with 3 actor-critic agents working together to move a robotic arm. \nThe second approach is to have one agent find a multivariate (usually normal) distribution of a policy. Although in theory, this approach could have a more concise policy distribution by \"rotating\" the distribution based on the co-variance matrix, it means that all of the values of the co-variance matrix must be learned as well. This increases the number of values that must be learned to have $n$ continuous outputs from $2n$ (mean and stddev), to $n+n^2$ ($n$ means and an $n \\times n$ co-variance matrix). This drawback has made this approach not as popular in the literature.\nThis is a more general answer but should help you and others on their related problems.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between Q-learning, Deep Q-learning and Deep Q-network? Q-learning uses a table to store all state-action pairs. Q-learning is a model-free RL algorithm, so how could there be the one called Deep Q-learning, as deep means using DNN; or maybe the state-action table (Q-table) is still there but the DNN is only for input reception (e.g. turning images into vectors)?\nDeep Q-network seems to be only the DNN part of the Deep Q-learning program, and Q-network seems the short for Deep Q-network.\nQ-learning, Deep Q-learning, and Deep Q-network, what are the differences? May be there a comparison table between these 3 terms?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In Q-learning (and in general value based reinforcement learning) we are typically interested in learning a Q-function, $Q(s, a)$. This is defined as\n$$Q(s, a) = \\mathbb{E}_\\pi\\left[ G_t | S_t = s, A_t = a \\right]\\;.$$\nFor tabular Q-learning, where you have a finite state and action space you can maintain a table lookup that maintains your current estimate of the Q-value. Note that in practice even the spaces being finite might not be enough to not use function approximation, if e.g. your state space contains a large number, say $10^{10000}$, of states, then it might not be manageable to maintain a separate Q-function for each state-action pair\nWhen you have an infinite state space (and/or action space) then it becomes impossible to use a table, and so you need to use function approximation to generalise across states. This is typically done using a deep neural network due to their expressive power -- aka, a deep Q-network (DQN). As a technical aside, the Q-networks don't usually take state and action as input, but take in a representation of the state (e.g. a $d$-dimensional vector, or an image) and output a real valued vector of size $|\\mathcal{A}|$, where $\\mathcal{A}$ is the action space.\nNow, it seems in your question that you're confused as to why you use a model (the neural network) when Q-learning is, as you rightly say, model-free. The answer here is that when we talk about RL algorithms being model-free we are not talking about how the value-functions or policy are parameterised, we are actually talking about whether the algorithms use a model of the transition dynamics to help with their learning. That is, a model free algorithm doesn't use any knowledge about $p(s' | s, a)$ (other than implicitly through repeated interactions with the environment), whereas model-based methods look to use this transition function explicitly - it can be known exactly such as in Atari environments, or it can approximated/learnt - to perform planning with the dynamics, or generate artificial data to learn from, etc.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the fringe in the context of search algorithms? What is the fringe in the context of search algorithms?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In English, the fringe is (also) defined as the outer, marginal, or extreme part of an area, group, or sphere of activity.\nIn the context of AI search algorithms, the state (or search) space is usually represented as a graph, where nodes are states and the edges are the connections (or actions) between the corresponding states. If you're performing a tree (or graph) search, then the set of all nodes at the end of all visited paths is called the fringe, frontier or border.\nIn the picture below, the grey nodes (the lastly visited nodes of each path) form the fringe.\n\nThe video Example Route Finding by Peter Norvig also gives some intuition behind this concept.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the state-of-the-art results on the generalization ability of deep learning methods? I've read a few classic papers on different architectures of deep CNNs used to solve varied image-related problems. I'm aware there's some paradox in how deep networks generalize well despite seemingly overfitting training data. A lot of people in the data science field that I've interacted with agree that there's no explanation on why deep neural networks work as well as they do.\nThat's gotten me interested in the theoretical basis for why deep nets work so well. Googling tells me it's kind of an open problem, but I'm not sure of the current state of research in answering this question. Notably, there are these two preprints that seem to tackle this question:\n\nGeneralization in Deep Learning (2019)\nQuantifying the generalization error in deep learning in terms of data distribution and neural network smoothness (2019)\n\nIf anyone else is interested in and following this research area, could you please explain the current state of research on this open problem? What are the latest works, preprints or publications that attempt to tackle it?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Introduction\nThe paper Generalization in Deep Learning provides a good overview (in section 2) of several results regarding the concept of generalisation in deep learning. I will try to describe one of the results (which is based on concepts from computational or statistical learning theory, so you should expect a technical answer), but I will first introduce and describe the general machine learning problem and I will give a definition of the generalisation gap problem. To keep this answer relatively short, I will assume the reader is familiar with certain basic machine learning and mathematical concepts, such as expected risk minimization, but, nonetheless, I will refer the reader to more detailed explanations of the concepts (at least the first time they are mentioned). If you are familiar with the basic concepts of computational learning theory (e.g. hypotheses), you will be advantaged.\nMachine Learning Problem\nIn the following description, unless stated otherwise, I do not make any assumption about the nature of the variables. However, I will occasionally provide examples of concrete values for these variables.\nLet $x \\in \\mathcal{X}$ be an input and let $y \\in \\mathcal{Y}$ be a target. Let $\\mathcal{L}$ be a loss function (e.g. MSE).\nThen the expected risk of a function (or hypothesis) $f$ is defined as\n\\begin{align}\nR[f] \n&= \\mathbb{E}_{x, y \\sim \\mathbb{P}(X, Y)} \\left[ \\mathcal{L}(f(x), y) \\right] \\\\\n&= \\int \\mathcal{L}(f(x), y) d\\mathbb{P}(X=x, Y=y),\n\\end{align}\nwhere $\\mathbb{P}(X, Y)$ is the true joint probability distribution of the inputs and targets. In other words, each $(x, y)$ is drawn from the joint distribution $\\mathbb{P}(X, Y)$, which contains or represents all the information required to understand the relationship between the inputs and the targets.\nLet $A$ be a learning algorithm or learner (e.g. gradient descent), which is the algorithm responsible for choosing a hypothesis $f$ (which can e.g. be represented by a neural network with parameters $\\theta$). Let\n$$S_m = \\{(x_i, y_i) \\}_{i=1}^m$$\nbe the training dataset. Let\n$$f_{A(S_m)} : \\mathcal{X} \\rightarrow \\mathcal{Y}$$\nbe the hypothesis (or model) chosen by the learning algorithm $A$ using the training dataset $S_m$.\nThe empirical risk can then be defined as\n$$\nR_{S_m}[f] = \\frac{1}{m} \\sum_{i=1}^m \\mathcal{L} (f(x_i), y_i) \n$$\nwhere $m$ is the total number of training examples.\nLet $F$ be the hypothesis space (for example, the space of all neural networks).\nLet\n$$\n\\mathcal{L_F} = \\{ g : f \\in F , g(x, y) = \\mathcal{L}(f(x), y)\\}\n$$ be a family of loss functions associated with the hypothesis space $F$.\nExpected Risk Minimization\nIn machine learning, the goal can be framed as the minimization of the expected risk\n\\begin{align}\nf^*_{A(S_m)} \n&= \\operatorname{argmin}_{f_{A(S_m)}} R[f_{A(S_m)}] \\\\\n&= \\operatorname{argmin}_{f_{A(S_m)}} \\mathbb{E}_{x, y \\sim \\mathbb{P}(X, Y)} \\left[ \\mathcal{L}(f_{A(S_m)}(x), y) \\right] \\tag{1}\\label{1}\n\\end{align}\nHowever, the expected risk $R[f_{A(S_m)}]$ is incomputable, because it is defined as an expectation over $x, y \\sim \\mathbb{P}(X, Y)$ (which is defined as an integral), but the true joint probability distribution $\\mathbb{P}(X, Y)$ is unknown.\nEmpirical Risk Minimization\nTherefore, we solve the approximate problem, which is called the empirical risk minimization problem\n\\begin{align}\nf^*_{A(S_m)} &= \\operatorname{argmin}_{f_{A(S_m)} \\in F} R_S[f_{A(S_m)}] \\\\\n&= \n\\operatorname{argmin}_{f_{A(S_m)} \\in F} \\frac{1}{m} \\sum_{i=1}^m \\mathcal{L} (f_{A(S_m)}(x_i), y_i) \n\\end{align}\nGeneralization\nIn order to understand the generalization ability of $f_{A(S_m)}$, the hypothesis chosen by the learner $A$ with training dataset $S_m$, we need to understand when the empirical risk minimization problem is a good proxy for the expected risk minimization problem. In other words, we want to study the following problem\n\\begin{align}\nR[f_{A(S_m)}] - R_S[f_{A(S_m)}] \\tag{2}\\label{2}\n\\end{align}\nwhich can be called the generalization gap problem. So, in generalization theory, one goal is to study the gap between the expected and empirical risks.\nClearly, we would like the expected risk to be equal to the empirical risk $$R_S[f_{A(S_m)}] = R[f_{A(S_m)}]$$ because this would allow us to measure the performance of the hypothesis (or model) $f_{A(S_m)}$ with the empirical risk, which can be computed. So, if $R_S[f_{A(S_m)}] = R[f_{A(S_m)}]$, the generalization ability of $f_{A(S_m)}$ roughly corresponds to $R_S[f_{A(S_m)}]$.\nTherefore, in generalization theory, one goal is to provide bounds for the generalisation gap $R[f_{A(S_m)}] - R_S[f_{A(S_m)}]$.\nDependency on $S$\nThe hypothesis $f_{A(S_m)}$ is explicitly dependent on the training dataset $S$. How does this dependency affect $f_{A(S_m)}$? Can we avoid this dependency? Several approaches have been proposed to deal with this dependency.\nIn the following sub-section, I will describe one approach to deal with the generalization gap problem, but you can find a description of the stability, robustness and flat minima approaches in Generalization in Deep Learning.\nHypothesis-space Complexity\nIn this approach, we try to avoid the dependency of the hypothesis $f_{A(S_m)}$ by considering the worst-case generalization problem in the hypothesis space $F$\n$$\nR[f_{A(S_m)}] - R_S[f_{A(S_m)}] \\leq \\sup_{f \\in F} \\left( R[f] - R_S[f] \\right)\n$$\nwhere $\\sup_{f \\in F} \\left( R[f] - R_S[f] \\right)$ is the supremum of a more general generalization gap problem, which is greater or equal to \\ref{2}. In other words, we solve a more general problem to decouple the hypothesis (or model) from the training dataset $S$.\nBound 1\nIf you assume the loss function $\\mathcal{L}$ to take values in the range $[0, 1]$, then, for any $\\delta > 0$, with probability $1 - \\delta$ (or more), the following bound holds\n\\begin{align}\n\\sup_{f \\in F} \\left( R[f] - R_S[f] \\right) \\leq 2 \\mathcal{R}_m \\left( \\mathcal{L}_F \\right) + \\sqrt{\\frac{\\log{\\frac{1}{\\delta}} }{2m}} \\tag{3} \\label{3}\n\\end{align}\nwhere $m$ is the size of the training dataset, $\\mathcal{R}_m$ is the Rademacher complexity of $\\mathcal{L}_F$, which is the family of loss functions for the hypothesis space $F$ (defined above).\nThis theorem is proved in Foundations of machine learning (2nd edition, 2018) by Mehryar Mohri et al.\nThere are other bounds, but I will not list or describe them here. If you want to know more, have a look at this paper.\nI will also not attempt to give you an intuitive explanation of this bound. However, you can ask questions like - What happens to the bound if $m$ increases (or decreases)?\nConclusion\nThere are several approaches to find bounds for the generalisation gap problem \\ref{2}\n\nHypothesis-space complexity\nStability\nRobustness\nFlat minima\n\nIn section 2 of the paper Generalization in Deep Learning, bounds for problem \\ref{2} are given based on the stability and robustness approaches.\nTo conclude, the study of the generalization ability of deep learning models is based on computational or statistical learning theory. There are many more results related to this topic. You can find some of them in Generalization in Deep Learning. The studies and results are highly technical, so, if you want to understand something, good knowledge of mathematics, proofs, and computational learning theory is required.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does \"Monte-Carlo search\" work? I have heard about this concept in a Reddit post about AlphaGo. I have tried to go through the paper and the article, but could not really make sense of the algorithm.\nSo, can someone give an easy-to-understand explanation of how the Monte-Carlo search algorithm work and how is it being used in building game-playing AI bots?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Monte Carlo method is an approach where you generate a large number of random values or simulations and form some sort of conlusions based on the general patterns, such as the means and variances.\nAs an example, you could use it for weather forecasts. Predicting long-term weather is quite difficult, because it is a chaotic system where small changes can lead to very different results. Using Monte Carlo methods, you could run a large number of simulations, each with slightly different atmospheric changes. Then you can analyze the results and for example calculate the probability of rain on a given day based on how many simulations ended up with rain. \nAs for the use of Monte Carlo in Alpha Go, they seem to be using the so-called Monte Carlo Tree Search. In this approach, you make a tree of possible moves, a few turns into the future, and try to find the best sequence. However, since the number of possible moves in the game of go is very large, you won't be able to explore very far ahead. This means that some of the moves which look good now might turn out to be bad later. \nSo, in the Monte Carlo Tree Search, you pick a promising sequence of moves and run one or more simulations of how the game might proceed from that point. Then you can use the results of that simulation to get a better idea of how good that specific sequence of moves really is and you update the tree accordingly. Repeat as needed until you find a good move.\nIf you want more information or to look at some illustrations, I found an interesting paper on the topic: C. Browne et al., A Survey of Monte Carlo Tree Search Methods (open repository / permanent link (paywalled))\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to implement a variable action space in Proximal Policy Optimization? I'm coding a Proximal Policy Optimization (PPO) agent with the Tensorforce library (which is built on top of TensorFlow).\nThe first environment was very simple. Now, I'm diving into a more complex environment, where all the actions are not available at each step.\nLet's say there are 5 actions and their availability depends on an internal state (which is defined by the previous action and/or the new state/observation space):\n\n2 actions (0 and 1) are always available\n2 actions (2 and 3) are only available when the internal state is 0\n1 action (4) is only available when the internal state is 1\n\nHence, there are 4 actions available when the internal state is 0 and 3 actions available when the internal state is 1.\nI'm thinking of a few possibilities to implement that:\n\nChange the action space at each step, depending on the internal state. I assume this is nonsense.\n\nDo nothing: let the model understand that choosing an unavailable action has no impact.\n\nDo almost nothing: impact slightly negatively the reward when the model chooses an unavailable action.\n\nHelp the model: by incorporating an integer into the state/observation space that informs the model what's the internal state value + bullet point 2 or 3\n\n\nAre there other ways to implement this? From your experience, which one would be the best?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The most straightforward solution is to simply make every action \"legal\", but implementing a consistent, deterministic mapping from potentially illegal actions to different legal actions. Whenever the PPO implementation you are using selects an illegal action, you simply replace it with the legal action that it maps to. Your PPO algorithm can then still update itself as if the illegal action were selected (the illegal action simply becomes like... a \"nickname\" for the legal action instead).\nFor example, in the situation you describe:\n\n\n2 actions (0 and 1) are always available\n2 actions (2 and 3) are only available when the internal_state == 0\n1 action (4) is only available when the internal_state == 1\n\n\nIn cases where internal_state == 0, if action 4 was selected (an illegal action), you can always swap it out for one of the other actions and play that one instead. It doesn't really matter (theoretically) which one you pick, as long as you're consistent about it. The algorithm doesn't have to know that it picked an illegal action, whenever it picks that same illegal action in the future again in similar states it will consistently get mapped to the same legal action instead, so you just reinforce according to that behaviour.\n\nThe solution described above is very straightforward, probably the most simple to implement, but of course it... \"smells\" a bit \"hacky\". A cleaner solution would involve a step in the Network that sets the probability outputs of illegal actions to $0$, and re-normalizes the rest to sum up to $1$ again. This requires much more care to make sure that your learning updates are still performed correctly though, and is likely a lot more complex to implement on top of an existing framework like Tensorforce (if not already somehow supported in there out of the box).\n\nFor the first \"solution\", I wrote above that it does not matter \"theoretically\" how you choose you mapping. I absolutely do expect your choices here will have an impact on learning speed in practice though. This is because, in the initial stages of your learning process, you'll likely have close-to-random action selection. If some actions \"appear multiple times\" in the outputs, they will have a greater probability of being selected with the initial close-tor-andom action selection. So, there will be an impact on your initial behaviour, which has an impact on the experience that you collect, which in turn also has an impact on what you learn.\nI certainly expect it will be beneficial for performance if you can include input feature(s) for the internal_state variable. \nIf some legal actions can be identified that are somehow \"semantically close\" to certain illegal actions, it could also be beneficial for performance to specifically connect those \"similar\" actions in the \"mapping\" from illegal to legal actions if you choose to go with that solution. For example, if you have a \"jump forwards\" action that becomes illegal in states where the ceiling is very low (because you'd bump your head), it may be better to map that action to a \"move forwards\" action (which is still kind of similar, they're both going forwards), than it would be to map it to a \"move backwards\" action. This idea of \"similar\" actions will only be applicable to certain domains though, in some domains there may be no such similarities between actions.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How would an AI learn language? I was think about AIs and how they would work, when I realised that I couldn't think of a way that an AI could be taught language. A child tends to learn language through associations of language and pictures to an object (e.g., people saying the word \"dog\" while around a dog, and later realising that people say \"a dog\" and \"a car\" and learn what \"a\" means, etc.). However, a text based AI couldn't use this method to learn, as they wouldn't have access to any sort of input device.\nThe only way I could come up with is programming in every word, and rule, in the English language (or whatever language it is meant to 'speak' in), however that would, potentially, take years to do.\nDoes anyone have any ideas on how this could be done? Or if it has been done already, if so how?\nBy the way, in this context, I am using AI to mean an Artificial Intelligence system with near-human intelligence, and no prior knowledge of language.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The general research area is known as grammar induction.\nIt is generally framed as a supervised learning problem, with the input presented as raw text, and the desired output the corresponding parse tree.\nThe training set often consists of both positive and negative examples.\nThere is no single best method for achieving this, but some of the techniques that have been used to date include:\n\nBayesian approaches\nGenetic Algorithms\nGenetic Programming\nBlackboard Architectures\nThe UpWrite Predictor\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between active learning and online learning? The definitions for these two appear to be very similar, and frankly, I've been only using the term \"active learning\" the past couple of years. What is the actual difference between the two? Is one a subset of the other?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Active learning (AL) is a weakly supervised learning (WSL) technique where you can have both labelled and unlabelled data [1]. The main idea behind AL is that the learner (or learning algorithm) can query an \"oracle\" (e.g. a human) to label some unlabelled instances. AL is similar to semi-supervised learning (SSL), which is also a WSL technique, given that both deal with unlabelled and labeled data, but do that differently (i.e. SSL does not use an oracle).\nOnline learning are machine learning techniques that update the models as new data is collected or arrives sequentially, as opposed to batch learning (or offline learning), where you first collect a dataset of multiple instances and then you train a model once (although you can later update it when you update your dataset). Batch learning is currently the common way of training machine learning models, given that it avoids problems like the known catastrophic interference (aka catastrophic forgetting) problem, which can occur if you learn online. For example, neural networks are known to face this problem when learning online. There are incremental learning (aka lifelong learning) algorithms that attempt to address this catastrophic interference problem.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is it called Latent Vector? I just learned about GAN and I'm a little bit confused about the naming of Latent Vector.\n\nFirst, In my understanding, a definition of a latent variable is a random variable that can't be measured directly (we needs some calculation from other variables to get its value). For example, knowledge is a latent variable. Is it correct?\nAnd then, in GAN, a latent vector $z$ is a random variable which is an input of the generator network. I read in some tutorials, it's generated using only a simple random function:\nz = np.random.uniform(-1, 1, size=(batch_size, z_size))\n\n\nthen how are the two things related? why don't we use the term \"a vector with random values between -1 and 1\" when referring $z$ (generator's input) in GAN?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It is called a Latent variable because you cannot access it during train time (which means manipulate it), In a normal Feed Forward NN you cannot manipulate the values output by hidden layers. Similarly the case here. \nThe term originally came from RBM's (they used term hidden variables). The interpretation of hidden variables in the context of RBM was that these hidden nodes helped to model the interaction between 2 input features (if both activate together, then the hidden unit will also activate). This principle can be traced to Hebb's rule which states \"Neurons that fire together, wire together.\" Thus RBM's were used to find representation of models, in a space (generally lower dimensional than than the original). This is the principal used in Auto Encoder's also. Thus as you can see we are explicitly, not modelling the interaction between 2 features, how the process is occurring is \"hidden\" from us.\nSo, the term latent basically can be attributed to the following ideas:\n\nWe map higher dimensional data to a lower dimensional data with no prior convictions of how the mapping will be done. The NN trains itself for the best configuration.\nWe cannot manipulate this lower dimensional data. Thus it is \"hidden from us.\nAs we do not know what each dimension means, it is \"hidden\" from us.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can the IQ of an AI program be measured? Can an AI program have an IQ? In other words, can the IQ of an AI program be measured? Like how humans can do an IQ test.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Short answer: No.\nLonger answer: It depends on what IQ exactly is, and when the question is asked compared to ongoing development. The topic you're referring to is actually more commonly described as AGI, or Artificial General Intelligence, as opposed to AI, which could be any narrow problem solving capability represented in software/hardware.\nIntelligence quotient is a rough estimate of how well humans are able to generally answer questions they have not previously encountered, but as a predictor it is somewhat flawed, and has many criticisms and detractors.\nCurrently (2016), no known programs have the ability to generalize, or apply learning from one domain to solving problems in an arbitrarily different domain through an abstract understanding. (However there are programs which can effectively analyze, or break down some information domains into simpler representations.) This seems likely to change as time goes on and both hardware and software techniques are developed toward this goal. Experts widely disagree as to the likely timing and approach of these developments, as well as to the most probable outcomes.\nIt's also worth noting that there seems to be a large deficit of understanding as to what exactly consciousness is, and disagreement over whether there is ever likely to be anything in the field of artificial intelligence that compares to it.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why are the initial weights of neural networks randomly initialised? This might sound silly to someone who has plenty of experience with neural networks but it bothers me...\nRandom initial weights might give you better results that would be somewhat closer to what a trained neural network should look like, but it might as well be the exact opposite of what it should be, while 0.5, or some other average for the range of reasonable weights' values, would sound like a good default setting.\nWhy are the initial weights of neural networks randomly initialized rather than being all set to, for example, 0.5?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You shouldn't assign all to 0.5 because you'd have the \"break symmetry\" issue.\n\nhttp://www.deeplearningbook.org/contents/optimization.html\nPerhaps the only property known with complete certainty is that the initial\nparameters need to \u201cbreak symmetry\u201d\u00a0between different units. If two hidden\nunits with the same activation function are connected to the same inputs, then\nthese units must have different initial parameters.\u00a0If they have the same initial\nparameters, then a deterministic learning algorithm applied to a deterministic cost\nand model will constantly update both of these units in the same way. Even if the\nmodel or training algorithm is capable of using stochasticity to compute different\nupdates for different units (for example, if one trains with dropout), it is usually\nbest to initialize each unit to compute a different function from all of the other\nunits. This may help to make sure that no input patterns are lost in the null\nspace of forward propagation and no gradient patterns are lost in the null space\nof back-propagation.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can the convolution operation be implemented as a matrix multiplication? How can the convolution operation used by CNNs be implemented as a matrix-vector multiplication? We often think of the convolution operation in CNNs as a kernel that slides across the input. However, rather than sliding this kernel (e.g. using loops), we can perform the convolution operation \"in one step\" using a matrix-vector multiplication, where the matrix is a circulant matrix containing shifted versions of the kernel (as rows or columns) and the vector is the input. \nHow exactly can this operation be performed? I am looking for a detailed step-by-step answer that shows how the convolution operation (as usually presented) can be performed using a matrix-vector multiplication.\nIs this the usual way the convolution operations are implemented in CNNs?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "To show how the convolution (in the context of CNNs) can be viewed as matrix-vector multiplication, let's suppose that we want to apply a $3 \\times 3$ kernel to a $4 \\times 4$ input, with no padding and with unit stride.\nHere's an illustration of this convolutional layer (where, in blue, we have the input, in dark blue, the kernel, and, in green, the feature map or output of the convolution).\n\nNow, let the kernel be defined as follows\n$$\n\\mathbf{W} = \n\\begin{bmatrix}\nw_{0, 0} & w_{0, 1} & w_{0, 2} \\\\\nw_{1, 0} & w_{1, 1} & w_{1, 2} \\\\\nw_{2, 0} & w_{2, 1} & w_{2, 2}\n\\end{bmatrix} \n\\in\n\\mathbb{R}^{3 \\times 3}\n$$\nSimilarly, let the input be defined as\n$$\n\\mathbf{I} = \n\\begin{bmatrix}\ni_{0, 0} & i_{0, 1} & i_{0, 2} & i_{0, 3} \\\\\ni_{1, 0} & i_{1, 1} & i_{1, 2} & i_{1, 3} \\\\\ni_{2, 0} & i_{2, 1} & i_{2, 2} & i_{2, 3} \\\\\ni_{3, 0} & i_{3, 1} & i_{3, 2} & i_{3, 3} \\\\ \n\\end{bmatrix} \n\\in\n\\mathbb{R}^{4 \\times 4}\n$$\nThen the convolution above (without padding and with stride 1) can be computed as a matrix-vector multiplication as follows. First, we redefine the kernel $\\mathbf{W}$ as a sparse matrix $\\mathbf{W}' \\in \\mathbb{R}^{4 \\times 16}$ (which is a circulant matrix because of its circular nature) as follows.\n$$\n{\\scriptscriptstyle\n\\mathbf{W}' = \n\\begin{bmatrix}\nw_{0, 0} & w_{0, 1} & w_{0, 2} & 0 & w_{1, 0} & w_{1, 1} & w_{1, 2} & 0 & w_{2, 0} & w_{2, 1} & w_{2, 2} & 0 & 0 & 0 & 0 & 0 \\\\\n0 & w_{0, 0} & w_{0, 1} & w_{0, 2} & 0 & w_{1, 0} & w_{1, 1} & w_{1, 2} & 0 & w_{2, 0} & w_{2, 1} & w_{2, 2} & 0 & 0 & 0 & 0 \\\\\n0 & 0 & 0 & 0 & w_{0, 0} & w_{0, 1} & w_{0, 2} & 0 & w_{1, 0} & w_{1, 1} & w_{1, 2} & 0 & w_{2, 0} & w_{2, 1} & w_{2, 2} & 0 \\\\\n0 & 0 & 0 & 0 & 0 & w_{0, 0} & w_{0, 1} & w_{0, 2} & 0 & w_{1, 0} & w_{1, 1} & w_{1, 2} & 0 & w_{2, 0} & w_{2, 1} & w_{2, 2}\n\\end{bmatrix} \n}\n$$\nSimilarly, we reshape the input $\\mathbf{I}$ as a 16-dimensional vector $\\mathbf{I}' \\in \\mathbb{R}^{16}$.\n$$\n{\\scriptstyle\n\\mathbf{I}' = \n\\begin{bmatrix}\ni_{0, 0} & i_{0, 1} & i_{0, 2} & i_{0, 3} & i_{1, 0} & i_{1, 1} & i_{1, 2} & i_{1, 3} & i_{2, 0} & i_{2, 1} & i_{2, 2} & i_{2, 3} & i_{3, 0} & i_{3, 1} & i_{3, 2} & i_{3, 3} \n\\end{bmatrix}^T\n}\n$$\nThen the convolution of $\\mathbf{W}$ and $\\mathbf{I}$, that is\n$$\\mathbf{W} \\circledast \\mathbf{I} = \\mathbf{O} \\in \\mathbb{R}^{2 \\times 2},$$\nwhere $\\circledast$ is the convolution operator, is equivalently defined as $$\\mathbf{W}' \\cdot \\mathbf{I}' = \\mathbf{O}' \\in \\mathbb{R}^{4},$$ where $\\cdot$ is the matrix-vector multiplication operator. The produced vector $\\mathbf{O}'$ can then be reshaped as a $2 \\times 2$ feature map.\nYou can easily verify that this representation is correct by multiplying e.g. the 16-dimensional input vector $\\mathbf{I}'$ with the first row of $\\mathbf{W}'$ to obtain the top-left entry of the feature map.\n$$w_{0, 0} i_{0, 0} + w_{0, 1} i_{0, 1} + w_{0, 2} i_{0, 2} + 0 i_{0, 3} + w_{1, 0} i_{1, 0} + w_{1, 1} i_{1, 1} + w_{1, 2}i_{1, 2} + 0 i_{1, 3} + w_{2, 0} i_{2, 0} + w_{2, 1}i_{2, 1} + w_{2, 2} i_{2, 2} + 0 i_{2, 3} + 0 i_{3, 0} + 0 i_{3, 1} + 0 i_{3, 2} + 0 i_{3, 3} = \\\\\nw_{0, 0} i_{0, 0} + w_{0, 1} i_{0, 1} + w_{0, 2} i_{0, 2} + w_{1, 0} i_{1, 0} + w_{1, 1} i_{1, 1} + w_{1, 2}i_{1, 2} + w_{2, 0} i_{2, 0} + w_{2, 1}i_{2, 1} + w_{2, 2} i_{2, 2} = \\\\\n\\mathbf{O}'_{0} \\in \\mathbb{R} ,$$ which is equivalent to an element-wise multiplication of $\\mathbf{W}$ with the top-left $3 \\times 3$ sub-matrix of the input followed by a summation over all elements (i.e. convolution), that is\n$$\n\\sum \\left(\n\\begin{bmatrix}\nw_{0, 0} & w_{0, 1} & w_{0, 2} \\\\\nw_{1, 0} & w_{1, 1} & w_{1, 2} \\\\\nw_{2, 0} & w_{2, 1} & w_{2, 2}\n\\end{bmatrix} \n\\odot\n\\begin{bmatrix}\ni_{0, 0} & i_{0, 1} & i_{0, 2} \\\\\ni_{1, 0} & i_{1, 1} & i_{1, 2} \\\\\ni_{2, 0} & i_{2, 1} & i_{2, 2}\n\\end{bmatrix} \n\\right) = \\mathbf{O}_{0, 0} = \\mathbf{O}'_{0} \\in \\mathbb{R},\n$$\nwhere $\\odot$ is the element-wise multiplication and $\\sum$ is the summation over all elements of the resulting matrix.\nThe advantage of this representation (and computation) is that back-propagation can be computed more easily by just transposing $\\mathbf{W}'$, i.e. with $\\mathbf{W}'^T$.\nTake also a look at this Github repository that explains how the convolution can be implemented as matrix multiplication.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does \"stationary\" mean in the context of reinforcement learning? I think I've seen the expressions \"stationary data\", \"stationary dynamics\" and \"stationary policy\", among others, in the context of reinforcement learning. What does it mean? I think stationary policy means that the policy does not depend on time, and only on state. But isn't that a unnecessary distinction? If the policy depends on time and not only on the state, then strictly speaking time should also be part of the state.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A stationary policy is a policy that does not change. Although strictly that is a time-dependent issue, that is not what the distinction refers to in reinforcement learning. It generally means that the policy is not being updated by a learning algorithm.\nIf you are working with a stationary policy in reinforcement learning (RL), typically that is because you are trying to learn its value function. Many RL techniques - including Monte Carlo, Temporal Difference, Dynamic Programming - can be used to evaluate a given policy, as well as used to search for a better or optimal policy.\nStationary dynamics refers to the environment, and is an assumption that the rules of the environment do not change over time. The rules of the environment are often represented as an MDP model, which consists of all the state transition probabilities and reward distributions. Reinforcement learning algorithms that work online can usually cope and adjust policies to match non-stationary environments, provided the changes do not happen too often, or enough learning/exploring time is allowed between more radical changes. Most RL algorithms have at least some online component, it is also important to keep exploring non-optimal actions in environments with this trait (in order to spot when they may become optimal).\nStationary data is not a RL-specific term, but also relates to the need for an online algorithm, or at least plans for discarding older data and re-training existing models over time. You might have non-stationary data in any ML, including supervised learning - prediction problems that work with data about people and their behaviour often have this issue as population norms change over timescales of months and years.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a \"trajectory\" in reinforcement learning? I'm now learning about reinforcement learning, but I just found the word \"trajectory\" in this answer.\nHowever, I'm not sure what it means. I read a few books on the Reinforcement Learning but none of them mentioned it. Usually these introductionary books mention agent, environment, action, policy, and reward, but not \"trajectory\".\nSo, what does it mean? \nAccording to this answer over Quora:\n\nIn reinforcement learning terminology, a trajectory $\\tau$ is the path of the agent through the state space up until the horizon $H$. The goal of an on-policy algorithm is to maximize the expected reward of the agent over trajectories.\n\nDoes it mean that the \"trajectory\" is the total path from the current state the agent is in to the final state (terminal state) that the episode finishes at? Or is it something else? (I'm not sure what the \"horizon\" mean, either).\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In answer that you linked, I may have used an informal definition of \"trajectory\", but essentially the same thing as the quote. A \"trajectory\" is the sequence of what has happened (in terms of state, action, reward) over a set of contiguous timestamps, from a single episode, or a single part of a continuous problem.\nSo $(s_3, a_3, r_4, s_4, a_4, r_5, s_5, a_5, r_6, s_6)$ taken from any scenario where an agent was used in the problem environment would be a trajectory - at least as I intended it in the answer. This could be from real-world data, or a simulation. It could involve a totally random or untrained agent, or a fully-optimised policy.\nIn the other definition that you have found, the focus on states and a horizon could make it slightly different, but actually I suspect that it is the same thing, as it is not that useful to only know the states. The Quora answer is probably just using \"path of the agent through the state space\" as shorthand to describe the same data.\nA \"horizon\" in reinforcement learning is a future point relative to a time step, beyond which you do not care about reward (so you sum the rewards from time $t$ to $t+H$). Fixed horizons can be used as an alternative to a discount factor for limiting sums of reward in continuous problems. They may also be used in other approaches, but basically mean the same thing - a time step beyond which you don't account for what happens.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does a transformer not use an activation function following the multi-head attention layer? 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 under the impression that you should have an activation between linear layers.\nFor instance when I look at the different flavors of resnet they always apply some sort of non linearity following a linear layer. For instance a residual block might look something like...\nInput -> Conv -> BN -> Relu -> Conv -> (+ Input) -> BN -> Relu\nor in the case of pre-activation...\nInput -> BN -> Relu -> Conv -> BN -> Relu -> Conv -> (+ Input)\nIn all the resnet flavors I have seen, they never allow two linear layers to be connected without a relu in-between.\nHowever in the the transformer...\nInput -> Multihead-Attn -> Add/Norm -> Feed Forward(Dense Layer -> Relu -> Dense Layer) -> Add/Norm\nIn the multihead attention layer it performs the attention mechanism and then applies a fully connected layer to project back to the dimension of its input. However, there is no non linearity between that and feed forward network (except for maybe the softmax used in part of the attention.) A model like this would make more sense to me...\nInput -> Multihead-Attn -> Add/Norm -> Relu -> Feed Forward(Dense Layer -> Relu -> Dense Layer) -> Add/Norm -> Relu\nor something like the pre-activated resnet...\nInput -> Relu -> Multihead-Attn -> Add/Norm -> Input2 -> Relu -> Feed Forward(Dense Layer -> Relu -> Dense Layer) -> Add/Norm(Input2)\nCan anyone explain why the transformer is the way it is?\nI have asked a similar question when I was looking at the architecture of wavenet on another forum but I never really got a clear answer. In that case it did not make sense to me again why there was no activation applied to the residual connections.\n(https://www.reddit.com/r/MachineLearning/comments/njbjfb/d_is_there_a_point_to_having_layers_with_just_a/)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "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.\nMeasure between word-vectors is generally computed through cosine-similarity because in the dimensions word tokens exist, it's highly unlikely for two words to be colinear even if they are trained to be closer in value if they are similar. However, two trained tokens will have higher cosine-similarity if they are semantically closer to each other than two completely unrelated words.\nThis fact is exploited by scaled dot-product attention; After several of these matrix multiplications, the dissimilar words will zero out or become negative due to the dot product between them, and the similar words will stand out in the resulting matrix.\nSo, self attention can be viewed as a weighted average, where less similar words become averaged out faster (toward the zero vector, on average), thereby achieving groupings of important and unimportant words (i.e. attention). The weighting happens through the dot product. If input vectors were normalized, the weights would be exactly the cosine similarities.\nThe important thing to take into consideration is that within the self-attention mechanism, there are no parameters; Those linear operations are just there to capture the relationship between the different vectors by using the properties of the vectors used to represent them.\nRead this blog post by Peter Bloem for a more in-depth explanation of self-attention.\n\nEdit\nI should add that this explanation is less satisfactory considering how Transformers also seem to work for tasks without learned embeddings, like time-series forecasting. I have no idea why that is. However, the model was originally used for NLP, and they did use learned embeddings. So, I bet that's why that particular architecture looks the way it does.\nBloem, in the blog post above, does discuss the mathematical properties of self-attention without bringing up the fact that the original architecture does have learned embeddings.\nAll this shows is that having learned embeddings does not matter that much; The layers following the multi-headed attention will learn the relationships between the vectors. The general point about the properties of the dot-product being exploited does stand.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can I automate the choice of the architecture of a neural network for an arbitrary problem? 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.\nHow can I automate the choice of the architecture/topology (that is, the number of layers, the type of activations, the type and direction of the connections, etc.) of a neural network for an arbitrary problem?\nI'm a beginner, yet I realized that in some architectures (or, at least, in perceptrons) it is very hard if not impossible to understand the inner mechanics, as the neurons of the hidden layers don't express any mathematically meaningful context.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "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 NEAT (NeuroEvolution of Augmenting Topologies).\nThe original NEAT paper involves evolving weights for connections, but if you only want a topology, you can use a weighting algorithm instead. You can also mix activation functions if you aren't sure which to use. Here is an example of using backpropagation and multiple neuron types.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the implications of the \"No Free Lunch\" theorem for machine learning? The No Free Lunch (NFL) theorem states (see the paper Coevolutionary Free Lunches by David H. Wolpert and William G. Macready)\n\nany two algorithms are equivalent when their performance is averaged across all possible problems\n\nIs the \"No Free Lunch\" theorem really true? What does it actually mean? A nice example (in ML context) illustrating this assertion would be nice.\nI have seen some algorithms which behave very poorly, and I have a hard time believing that they actually follow the above-stated theorem, so I am trying to understand whether my interpretation of this theorem is correct or not. Or is it just another ornamental theorem like Cybenko's Universal Approximation theorem?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is a really common reaction after first encountering the No Free Lunch theorems (NFLs). The one for machine learning is especially unintuitive, because it flies in the face of everything that's discussed in the ML community. That said, the theorem is true, but what it means is open to some debate.\nTo restate the theorem for people who don't know it, the NFL theorem for machine learning is really a special case of the NFL theorem for local search and optimization. The local search version is easier to understand. The theorem makes the following, somewhat radical claim:\n\nAveraged across all possible optimization problems, the average solution quality found by any local search algorithm you choose to use is exactly the same as the average solution quality of a local \"search\" algorithm that just generates possible solutions by sampling uniformly at random from the space of all solutions.\n\nAnother formulation, when people want an even stronger reaction, is to say that if you want to find the best solution to a problem, it's just as good to try things that seem to be making your solution iteratively worse as it is to try things that seem to be making your solution iteratively better. On average, both these approaches are equally good. \nOkay, so why is this true? Well, the key is in the details. Wolpert has sometimes described the theorem as a specialization of Hume's work on the problem of induction. The basic statement of the problem of induction is: we have no logical basis for assuming that the future will be like the past. Logically, there's no reason that the laws of physics couldn't all just radically change tomorrow. From a purely logical perspective, it's totally reasonable that the future can be different from the past in any number of ways. Hume's problem is that, in general the future is like the past in a lot of ways. He tried to formulate a philosophical (logical) argument that this needed to be so, but basically failed.\nThe No Free Lunch theorems say the same thing. If you don't know what your search space looks like, then if you iteratively refine your guess at what a good solution looks like, in response to the observations you've made in the past about what good solutions look like (i.e. learning from data), then it's just as likely that operation you make helps as it is that it hurts. That's why the \"averaged over all possible optimization problems\" part is key. For any optimization problem where hill climbing is a good strategy after $k$ moves, we can make one that is identical, except that the kth hill climbing move leads to an awful solution. The actual proof is more subtle than that, but that's the basic idea.\nA very brief lay summary might be:\n\nA machine learning algorithim can only be made to work better on some kinds of problems by being made to work worse on another kind of problem.\n\nSo what does this mean in a practical sense? It means that you need to have some apriori reason for thinking that your algorithm will be effective on a particular problem. Exactly what a good reason looks like is the subject of vigorous debate within the ML community. This is very closely related to the bias/variance tradeoff.\nSome common responses are:\n\nWhen you're looking at a new optimization problem, although it could have any random kind of structure, the problems we actually encounter in the real world are a lot more regular, and certain common themes are present, like the the fact that moving \"uphill\" (minimizing error) iteratively tends to lead to good solutions. Basically, this school of thought says NFL is an ornamental theorem: most ML algorithms work better on \"the kind of problems we see in real life\", by working worse on \"the kind of problems we don't see in real life\".\nWhen you're looking at a new optimization problem in [insert your favourite application domain], although it could have any random kind of structure, problems tend to look like [whatever you think], which makes [your favorite algorithm] a lot more effective than random guessing.\nWolpert & McCready themselves published an interesting result showing that there actually are specialized optimization processes, based on co-evolution, that are consistently better than random guessing. \n\nRegardless, it's indisputable that some algorithms are better than others, in certain sub-domains (we can see this empirically). NFL tells us that to be better there, they need to be worse somewhere else. The question up for debate is whether the \"somewhere else\" is real problems, or purely artificial ones.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How should I encode the structure of a neural network into a genome? For a deterministic problem space, I need to find a neural network with the optimal node and link structure. I want to use a genetic algorithm to simulate many neural networks to find the best network structure for the problem domain. \nI've never used genetic algorithms for a task like this before. What are the practical considerations? Specifically, how should I encode the structure of a neural network into a genome?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Section 4.2 of \"Essentials of Metaheuristics\" has a wealth of information on alternative ways of encoding graph structures via Genetic Algorithms.\nWith particular regard to evolving ANNs, I would personally not be inclined to implement this sort of thing 'from scratch':\nThe field of neuroevolution has been around for some time, and the implementation some of the methods, such as Neuroevolution of Augmenting Topologies (NEAT) now incorporate the results of much practical experience.\nAccording to the above link:\n\nWe also developed an extension to NEAT called HyperNEAT that can evolve neural networks with millions of connections and exploit geometric regularities in the task domain. The HyperNEAT Page includes links to publications and a general explanation of the approach.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the idea called involving an AI that will eventually rule humanity? It's an idea I heard a while back but couldn't remember the name of. It involves the existence and development of an AI that will eventually rule the world and that if you don't fund or progress the AI then it will see you as \"hostile\" and kill you. Also, by knowing about this concept, it essentially makes you a candidate for such consideration, as people who didn't know about it won't understand to progress such an AI. From my understanding, this idea isn't taken that seriously, but I'm curious to know the name nonetheless.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "If I'm not mistaken you're looking for Roko's Basilisk, \n\nin which an otherwise benevolent future AI system tortures simulations of those who did not work to bring the system into existence\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why did machine learning only become viable after Nvidia's chips were available? I listened to a talk attended by a panel consisting of two influential Chinese scientists: Wang Gang and Yu Kai, among others.\nWhen asked about the biggest bottleneck in the development of artificial intelligence in the near future (3 to 5 years), Yu Kai, who has a background in the hardware industry, said that hardware would be the essential problem and that we should focus most of our attention on it. He gave us two examples:\n\nIn the early development of computers, we compared machines by their chips;\nML/DL, which has been very popular in recent years, would be almost impossible without the employment of Nvidia's GPUs.\n\nThe fundamental algorithms existed already in the 1980s and 1990s, but AI went through 3 AI winters and was not empirical until we could train models with GPU boosted mega servers.\nDr. Wang then commented on Yu's opinions, stating that we should also develop software systems because we cannot build an autonomous car even if we combine all the GPUs and computational power in the world.\nThen, as usual, my mind wandered off, and I started thinking: what if those who could operate supercomputers in the 1980s and 1990s had utilized the then-existing neural network algorithms and trained them with tons of scientific data? Some people at that time could obviously attempt to build the AI systems we are building now.\nBut why did AI/ML/DL become a hot topic and practical only decades later? Is it merely a matter of hardware, software, and data?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is a lot of factors for the boom of AI industry. What many people miss though is the boom has mostly been in the Machine Learning part of AI. This can be attributed to various simple reasons along with their comparisons during earlier times:\n\nMathematics: The maths behind ML algorithms are pretty simple and known for a long time (whether it would work or not was not known though). During earlier times it was not possible to implement algorithms which require high precision of numbers, to be calculated on a chip, in an acceptable amount of time. One of the main arithmetic operations division of numbers still takes a lot of cycles in modern processors. Older processors were magnitude times slower than modern processors (more than 100x), this bottleneck made it impossible to train sophisticated models on contemporary processors.\nPrecision: Precision in calculations is an important factor in ML algorithms. 32 bit precision in processor was made in the 80's and was probably commercially available in the late 90's (x86), but it was still hella slow than current processors. This resulted in scientists improvising on the precision part and the most basic Perceptron Learning Algorithm invented in the 1960's to train a classifier uses only $1$'s and $0$'s, so basically a binary classifier. It was run on special computers. Although, it is interesting to note that we have come a full circle and Google is now using TPU's with 8-16 bit accuracy to implement ML models with great success.\nParallelization : The concept of parallelization of matrix operations is nothing new. It was only when we started to see Deep Learning as just a set of matrix operations we realized that it can be easily parallelized on massively parallel GPU's, still if your ML algorithm is not inherently parallel then it hardly matters whether you use CPU or GPU (e.g. RNN's).\nData: Probably the biggest cause in the ML boom. The Internet has provided opportunities to collect huge amounts of data from users and also make it available to interested parties. Since an ML algorithm is just a function approximator based on data, therefore data is the single most important thing in a ML algorithm. The more the data the better the performance of your model.\nCost: The cost of training a ML model has gone down significantly. So using a Supercomputer to train a model might be fine, but was it worth it? Super computers unlike normal PC's are tremendously resource hungry in terms of cooling, space, etc. A recent article on MIT Technology Review points out the carbon footprint of training a Deep Learning model (sub-branch of ML). It is quite a good indicator why it would have been infeasible to train on Supercomputers in earlier times (considering modern processors consume much lesser power and gives higher speeds).\nAlthough, I am not sure but I think earlier supercomputers were specialised in \"parallel+very high precision computing\" (required for weather, astronomy, military applications, etc) and the \"very high precison part\" is overkill in Machine Learning scenario.\n\nAnother important aspect is nowadays everyone has access to powerful computers. Thus, anyone can build new ML models, re-train pre-existing models, modify models, etc. This was quite not possible during earlier times, \nAll this factors has led to a huge surge in interest in ML and has caused the boom we are seeing today. Also check out this question on how we are moving beyond digital processors.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does Monte Carlo tree search qualify as machine learning? To the best of my understanding, the Monte Carlo tree search (MCTS) algorithm is an alternative to minimax for searching a tree of nodes. It works by choosing a move (generally, the one with the highest chance of being the best), and then performing a random playout on the move to see what the result is. This process continues for the amount of time allotted.\nThis doesn't sound like machine learning, but rather a way to traverse a tree. However, I've heard that AlphaZero uses MCTS, so I'm confused. If AlphaZero uses MCTS, then why does AlphaZero learn? Or did AlphaZero do some kind of machine learning before it played any matches, and then use the intuition it gained from machine learning to know which moves to spend more time playing out with MCTS?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Monte Carlo Tree Search is not usually thought of as a machine learning technique, but as a search technique. There are parallels (MCTS does try to learn general patterns from data, in a sense, but the patterns are not very general), but really MCTS is not a suitable algorithm for most learning problems.\nAlphaZero was a combination of several algorithms. One was MCTS, but MCTS needs a function to tell it how good different states of the game might be (or else, it needs to simulate entire games). One way to handle this function in a game like chess or Go is to approximate it by training a neural network, which is what the Deep Mind researchers did. This is the learning component of AlphaZero. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Could an AI feel emotions? Assuming humans had finally developed the first humanoid AI based on the human brain, would It feel emotions? If not, would it still have ethics and/or morals?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I have considered much of the responses here, and I would suggest that most people here have missed the point when answering the question about emotions.\nThe problem is, scientists keep looking for a single solution as to what emotions are. This is akin to looking for a single shape that will fit all different-shaped slots.\nAlso, what is ignored is that animals are just as capable of emotions and emotional states as we are:\nWhen looking on Youtube for insects fighting each other, or competing or courting, it should be clear that simple creatures experience them too!\nWhen I challenge people about emotions, I suggest to them to go to Corinthians 13 - which describes the attributes of love. If you consider all those attributes, one should notice that an actual \"feeling\" is not required for fulfilling any of them.\nTherefore, the suggestion that a psychopath lacks emotions, and so he commits crimes or other pursuits outside of \"normal\" boundaries is far from true, especially when one considers the various records left to us from court cases and perhaps psychological evaluation - which show us that they do act out of \"strong\" emotions.\nIt should be considered that a psychopath's behaviour is motivated out of negative emotions and emotional states with a distinct lack of or disregard of morality and a disregard of conscience. Psychopaths \"enjoy\" what they do.\nI am strongly suggesting to all that we are blinded by our reasoning, and by the reasoning of others.\nThough I do agree with the following quote mentioned before: -\nDave H. wrote:\n\nFrom a computational standpoint, emotions represent a global state that influences a lot of other processing. Hormones etc. are basically\njust implementation. A sentient or sapient computer certainly could\nexperience emotions, if it was structured in such a way as to have\nsuch global states affecting its thinking.\n\nHowever, his reasoning below it (that quote) is also seriously flawed.\nEmotions are both active and passive: They are triggered by thoughts and they trigger our thoughts; Emotions are a mental state and a behaviourial quality; Emotions react to stimuli or measure our responses to them; Emotions are independant regulators and moderators; Yet they provoke our focus and attention to specific criteria; and they help us when intuition and emotion agree or they hinder us when conscience or will clash.\nA computer has the same potential as us to feel emotions, but the skill of implementing emotions is much more sophisticated than the one solution fits all answer people are seeking here.\nAlso, if anyone argues that emotions are simply \"states\" where a response or responses can be designed around it, really does not understand the complexity of emotions; the \"freedom\" emotions and thoughts have independently of each other; or what constitutes true thought!\nProgrammers and scientists are notorious for \"simulating\" the real experiences of emotions or intelligence, without understanding the intimate complexities; Thinking that in finding the perfect simulation they have \"discovered\" the real experience.\nThe Psi-theory seems to adequately give a proper understanding of the matter.\nSo I would say that the simulation of emotional states \"is\" equivalent to experiencing emotions, but those emotional states are far more complex than what most realize.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are the dialogs at Sophia's (the robot) appearings scripted? I talk about the robot from: Hanson Robotics, which was granted the right to citizenship from Saudi Arabia.\nI have found the following articles:\nYour new friend is a humanoid robot\nSource: theaustralian.com.au\n\nLike Amazon Echo, Google Assistant and Siri, Sophia can ask and answer questions about discrete pieces of information, such as what types of movies and songs she likes, the weather and whether robots should exterminate humans.\nBut her general knowledge is behind these players and she doesn\u2019t do maths. Her answers are mostly scripted and, it seems, from my observation, her answer are derived from algorithmically crunching the language you use.\nSometimes answers are close to the topic of the question, but off beam. Sometimes she just changes the subject and asks you a question instead.\nShe has no artificial notion of self. She can\u2019t say where she was yesterday, whether she remembers you from before, and doesn\u2019t seem to amass data of past interactions with you that can form the basis of an ongoing association.\nQuestions such as: \u201cWhat have you seen in Australia?\u201d, \u201cWhere were you yesterday?\u201d, \u201cWho did you meet last week?\u201d and \u201cDo you like Australia?\u201d are beyond her.\n\n\nWhy Sophia the robot is not what it seems\nSource: smh.com.au\n\nYou can often fool this sort of software by introducing noise. That could be literal noise \u2013 machines aren't great at filtering out background noise, as anyone with a hearing aid will tell you \u2013 or it could be noise in the sense of irrelevant information or limited context. You could ask \"what do you think of humans?\" and then follow up with \"can you tell more about it?\" The second question requires the robot to define \"it\", remember what it said last time, and come up with something new.\nIn the case of the ABC interview, the questions were sent to Sophia's team ahead of time so they were possibly pre-scripted. Just like an interview with a human celebrity!\n\n\nPretending to give a robot citizenship helps no one\nSource: theverge.com\n\nSophia is essentially a cleverly built puppet designed to exploit our cultural expectations of what a robot looks and sounds like. It can hold a stilted conversation, yes, but its one-liners seem to be prewritten responses to key words. (As Piers Morgan commented during an interview with Sophia, \u201cObviously these are programmed answers.\u201d)\n\n\nHere are a few more references.\n\nInside the mechanical brain of the world\u2019s first robot citizen\nSophia, the Uncanny Robot AI, Is Not What You Think.\nHow much of Robot Sophia\u2019s speech is likely scripted with your understanding of the progress in NLP?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Sophia uses ChatScript.\nYou can read about what ChatScript can do here.\n\nChatScript keeps track of conversations with each user; can record\n where it is in a conversational flow and what facts it has learned\n about a user (you have to tell it what facts to try to learn). You can\n optionally keep logs of the conversations (either on a ChatScript\n server or locally on a freestanding device).\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What would motivate a machine? Currently, within the AI development field, the main focus seems to be on pattern recognition and machine learning. Learning is about adjusting internal variables based on a feedback loop.\nMaslow's hierarchy of needs is a theory in psychology proposed by Abraham Maslow that claims that individuals' most basic needs must be met, before they become motivated to achieve higher-level needs.\n\nWhat could possibly motivate a machine to act?\nShould a machine have some sort of DNA-like structure that would describe its hierarchy of needs (similar to Maslow's theory)?\nWhat could be the fundamental needs of a machine?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The current method to implement motivation is some kind of artificial reward. Deepmind's DQN for example is driven by the score of the game. The higher the score, the better. The AI learns to adjust its actions to get the most points and therefore the most reward. This is called reinforcement learing. The reward motivates the AI to adapt its actions, so to speak.\nIn a more technical term, the AI wants to maximize utility, which depends on the implemented utility function. In the case of DQN, this would be maximizing the score in the game.\nThe human brain functions in a similar fashion, although a little more complex and often not as straight forward. We as humans usually try to adjust our actions to produce a high output of dopamine and serotonin. This is in a way similar to the reward used to control AIs during reinforcement learning. The human brain learns which actions produce the most amount of those substances and finds strategies to maximize the output. This is, of course, a simplification of this complex process, but you get the picture.\nWhen you talk about motivation, please don't mix it up with consciousness or qualia. Those are not required for motivation at all. If you want to discuss consciousness and qualia in AI, that's a totally different ball game.\nA child isn't curious for the sake of curiosity. It gets positive reinforcement when exploring because the utility function of the child's brain rewards exploration by releasing rewarding neurotransmitters. So the mechanism is the same. Applying this to AI means defining a utility function that rewards new experiences. There is no inner drive without some kind of reinforcing reward.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is different in each head of a multi-head attention mechanism? I have a difficult time understanding the \"multi-head\" notion in the original transformer paper. What makes the learning in each head unique? Why doesn't the neural network learn the same set of parameters for each attention head? Is it because we break query, key and value vectors into smaller dimensions and feed each portion to a different head?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The reason each head is different is because they each learn a different set of weight matrices $\\{ W_i^Q, W_i^K, W_i^V \\}$ where $i$ is the index of the head. To clarify, the input to each attention head is the same. For attention head $i$:\n\\begin{align}\nQ_i(x) &= x W_i^Q \\\\\nK_i(x) &= x W_i^K \\\\\nV_i(x) &= x W_i^V \\\\\n\\text{attention}_i(x) &= \\text{softmax} \\left(\\frac{Q_i(x) K_i(x)^T}{\\sqrt{d_k}} \\right) V_i(x).\n\\end{align}\nNotice that the input to each head is $x$ (either the semantic + positional embedding of the decoder input for the first decoder layer, or the output of the previous decoder layer). More info\nThe question as to why gradient descent learns each set of weight matrices $\\{ W_i^Q, W_i^K, W_i^V \\}$ to be different across each attention head is very similar to \"Is there anything that ensures that convolutional filters don't end up the same?\", so maybe you might find the answer there helpful for you:\n\nNo, nothing really prevents the weights from being different. In practice though they end up almost always different because it makes the model more expressive (i.e. more powerful), so gradient descent learns to do that. If a model has n features, but 2 of them are the same, then the model effectively has n\u22121 features, which is a less expressive model than that of n features, and therefore usually has a larger loss function.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the specific requirements of the Turing test? What are the specific requirements of the Turing test? \n\nWhat requirements if any must the evaluator fulfill in order to be qualified to give the test?\nMust there always be two participants in the conversation (one human and one computer) or can there be more?\nAre placebo tests (where there is not actually a computer involved) allowed or encouraged?\nCan there be multiple evaluators? If so does the decision need to be unanimous among all evaluators in order for the machine to have passed the test?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The \"Turing Test\" is generally taken to mean an updated version of the Imitation Game Alan Turing proposed in his 1951 paper of the same name. An early version had a human (male or female) and a computer, and a judge had to decide which is which, and what gender they were if human. If they were correct less than 50% then the computer was considered \"intelligent.\"\nThe current generally accepted version requires only one contestant, and a judge to decide whether it is human or machine. So yes, sometimes this will be a placebo, effectively, if we consider a human to be a placebo.\nYour first and fourth questions are related - and there are no strict guidelines. If the computer can fool a greater number of judges then it will of course be considered a better AI.\nThe University of Toronto has a validity section in this paper on Turing, which includes a link to Jason Hutchens' commentary on why the Turing test may not be relevant (humans may also fail it) and the Loebner Prize, a formal instantiation of a Turing Test .\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which approaches could I use to create a simple chatbot using a neural network? I wanted to start experimenting with neural networks, so I decided to make a chatbot (like Cleverbot, which is not that clever anyway) using them.\nI looked around for some documentation and I found many tutorials on general tasks, but few on this specific topic. The one I found just exposed the results without giving insights on the implementation. The ones that did, did it pretty shallowly (the TensorFlow documentation page on seq2seq is lacking, IMHO).\nNow, I feel I may have understood the principle more or less, but I'm not sure and I am not even sure how to start. Thus I will explain how I would tackle the problem and I'd like feedback on this solution, telling me where I'm mistaken, and possibly have any link to detailed explanations and practical knowledge on the process.\n\nThe dataset I will use for the task is the dump of all my Facebook and WhatsApp chat history. I don't know how big it will be but possibly still not large enough. The target language is not English, therefore I don't know where to quickly gather meaningful conversation samples.\n\nI am going to generate a thought vector out of each sentence. Still don't know how, actually; I found a nice example for word2vec on the deeplearning4j website, but none for sentences. I understood how word vectors are built and why, but I could not find an exhaustive explanation for sentence vectors.\n\nUsing thought vectors as input and output I am going to train the neural network. I don't know how many layers it should have, and which ones have to be LSTM layers.\n\nThen there should be another neural network that is able to transform a thought vector into a sequence of characters composing a sentence. I read that I should use padding to make up for different sentence lengths, but I miss how to encode characters (are codepoints enough?).\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I would recommend to start by reading this blogpost.\nYou can probably cannibalise the code to create a RNN that takes in one statement of a dialogue and then proceeds to output the answer to that statement.\nThat would be the easy version of your project, all without word vectors and thought vectors. You are just inputting characters, so typos don't need to concern you.\nThe next more complex step would be to input word vectors instead of characters. That would allow you to generalise to words that aren't part of your training data. And it is probably still just a minor modification of the code. \nIf you insist on using thought vectors, you should start reading up on NN translation. And probably try to get a pre-trained encoder network. Or pre-train it yourself on a large translation corpus for your language. \nWith your small training set the best you can do is probably massively overfit until your system recreates your training data verbatim. Using word vectors will allow your system to give the same answer to \"I beat the cat today.\" as you gave in the training data to \"I kicked the dog yesterday.\" \nI'm not sure thought vectors will make a big difference. If you get the decoder to learn at all. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does the policy network in AlphaZero work? In AlphaZero, the policy network (or head of the network) maps game states to a distribution of the likelihood of taking each action. This distribution covers all possible actions from that state.\nHow is such a network possible? The possible actions from each state are vastly different than subsequent states. So, how would each possible action from a given state be represented in the network's output, and what about the network design would stop the network from considering an illegal action?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The output of the policy network is as described in the original paper:\n\nA move in chess may be described in two parts: selecting the piece to move, and then\n selecting among the legal moves for that piece. We represent the policy \u03c0(a|s) by a 8 \u00d7 8 \u00d7 73\n stack of planes encoding a probability distribution over 4,672 possible moves. Each of the 8\u00d78\n positions identifies the square from which to \u201cpick up\u201d a piece. The first 56 planes encode\n possible \u2018queen moves\u2019 for any piece: a number of squares [1..7] in which the piece will be\n moved, along one of eight relative compass directions {N, NE, E, SE, S, SW, W, NW}. The\n next 8 planes encode possible knight moves for that piece. The final 9 planes encode possible\n underpromotions for pawn moves or captures in two possible diagonals, to knight, bishop or\n rook respectively. Other pawn moves or captures from the seventh rank are promoted to a\n queen.\n\nSo each move selector scores the relative probability of selecting a piece in a given square and moving it in a specific way. For example, there is always one output dedicated to representing picking up the piece in A3 and moving it to A6. This representation includes selecting opponent pieces, selecting empty squares, making knight moves for rooks, making long diagonal moves for pawns. It also includes moves that take pieces off the board or through other blocking pieces. \nThe typical branching factor in chess is around 35. The policy network described above always calculates discrete probabilities for 4672 moves.\nClearly this can select many non-valid moves, if pieces are not available, or cannot move as suggested. In fact it does this all the time, even when fully trained, as nothing is ever learned about avoiding the non-valid moves during training - they do not receive positive or negative feedback, as there is never any experience gained relating to them. However, the benefit is that this structure is simple and fixed, both useful traits when building a neural network.\nThe simple work-around is to filter out impossible moves logically, setting their effective probability to zero, and then re-normalise the probabilities for the remaining valid moves. That step involves asking the game engine for what the valid moves are - but that's fine, it's not \"cheating\".\nWhilst it might be possible to either have the agent learn to avoid non-valid moves, or some clever output structure that could only express valid moves, these would both distract from the core goal of learning how to play the game optimally.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do many AI bots feel the need to be know-it-alls? Having used various AI bots often over recent months, I noticed that often it will claim to know something, even if it doesn't.\nIt would then either explain something which is clearly nonsense, or by rambling on about how the answer isn't known in general.\nOr how, if asked for example- \"would you be able to explain X\" it wouldn't respond \"yes, I could\" but rather would elucidate X.\nHave they been trained to always respond as though it were a know-it-all?\n(Google's Bard and ChatGPT specifically, although I'm assuming only open-source AI will be answerable)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nHave they been trained to always respond as though it were a know-it-all?\n\nYes, sort of, although it is not in some attempt to upset you or other users.\nThe language models used in the chat bots have been fine-tuned in conversations with users, and also have been \"pre-prompted\" to be helpful assistants. This impacts the kind of text that they generate.\nSeparately to this, the fact that they are often incorrect or generate nonsense is a limitation of the core technology. There is no underlying world model, the model cannot self-assess whether anything it generates is correct. Although the large language models can often surprise users (including the original developers) in the breadth of what they can respond to correctly and give the appearance of understanding, the same models can also fail easily at apparently simple tasks. This can cause some cognitive dissonance for users who expect an AI that appears to communicate like an intelligent human to be able to perform simple maths for example.\nThere is probably no global default chat tone that would suit all users. You could however use the raw model more directly and create a chatbot with a different tone to suit you. This would not impact accuracy, and would not add ability to self-assess correctness, but it may address feeling of being talked down to for example. Some services, like Character AI, attempt to give you tools to do just that, although the level of usefulness you get from them will depend on what they focus on (Character AI is more for creative fun, than for functional assistants).\nIn limited cases you can also address accuracy with pre-prompts or fine tuning that put a few facts into working memory. This is limited, and cannot address lack of general ability in logic or maths though. Corporate users can do this to give a chat bot some basic product knowledge or correct address for their help desk etc.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are some implications of G\u00f6del's theorems on AI research? Note: My experience with G\u00f6del's theorem is quite limited: I have read G\u00f6del Escher Bach; skimmed the 1st half of Introduction to Godel's Theorem (by Peter Smith); and some random stuff here and there on the internet. That is, I only have a vague high level understanding of the theory. \nIn my humble opinion, G\u00f6del's incompleteness theorem (and its many related Theorems, such as the Halting problem, and L\u00f6bs Theorem) are among the most important theoretical discoveries. \nHowever, its a bit disappointing to observe that there aren't that many (at least to my knowledge) theoretical applications of the theorems, probably in part due to 1. the obtuse nature of the proof 2. the strong philosophical implications people aren't willing to easily commit towards.\nDespite that, there are still some attempts to apply the theorems in a philosophy of mind / AI context. Off the top of my head:\n\nThe Lucas-Penrose Argument: which argues that the mind is not implemented on a formal system (as in computer). (Not a very rigour proof however) \nApparently, some of the research at MIRI uses L\u00f6bs Thereom, though the only example I know of is L\u00f6bian agent cooperation.\n\nThese are all really cool, but are there some more examples? Especially ones that are actually seriously considered by the academic community.\nSee also What are the philosophical implications of G\u00f6del's First Incompleteness Theorem?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Definitely there are a lot of implications for AI, including:\n\nInference with first-order-logic is semi-decidable. This is a big disappointment for all the folks that wanted to use logic as a primary AI tool.\nBasic equivalence of two first-order logic statements is undecidable, which has implications for knowledge-based systems and databases. For example, optimisation of database queries is an undecidable problem because of this.\nEquivalence of two context-free grammars is undecidable, which is a problem for formal linguistic approach toward language processing\nWhen doing planning in AI, just finding a feasible plan is undecidable for some planning languages that are needed in practice.\nWhen doing automatic program generation - we are faced with a bunch of decidability results, since any reasonable programming language is as powerful as a Turing machine.\nFinally, all non-trivial questions about an expressive computing paradigm, such as Perti nets or cellular automata, are undecidable.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are there any AI that have passed the MIST test so far? MIST is a quantiative test of humanness, consisting of ~80k propositions such as:\n\nIs Earth a planet?\nIs the sun bigger than my foot?\nDo people sometimes lie?\netc.\n\nHave any AI attempted and passed this test to date?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, although how useful this AI can be is another question entirely.\nmpgac is a \"minimally intelligent AGI\" trained on the GAC-80K corpus of MIST questions. As a result, it should be able to \"minimally\" pass this test. However, being trained on the GAC-80K corpus obviously make it lacking for any practical purposes. From the README:\n\nObviously this should only be capable of producing a minimally intelligent signal when ordinary commonsense questions are asked, of the kind depicted above, using questions which would have made sense to an average human between the years 2000 and 2005. On expert knowledge or current affairs related questions it should perform no better than chance.\n\nThe point of mpgac is to compare it to other AIs that could be built to pass this test. Or as the writer wrote in the README:\n\nWhen scanning the skies how can we tell whether the radio signals detected are from an intelligent source, or are merely just background or sensor noise?\n\nIdeally, you would want to build a program that is \"better\" than mpgac. In much the same way as ELIZA can be seen as a baseline for the Turing Test, mpgac is the baseline for the MIST test.\nThe GitHub repo of mpgac (as well as the GAC-80K corpus) is available here.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the \"dropout\" technique? What purpose does the \"dropout\" method serve and how does it improve the overall performance of the neural network?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Dropout means that every individual data point is only used to fit a random subset of the neurons. This is done to make the neural network more like an ensemble model.\nThat is, just as a random forest is averaging together the results of many individual decision trees, you can see a neural network trained using dropout as averaging together the results of many individual neural networks (with 'results' understood to mean activations at every layer, rather than just the output layer).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What sort of mathematical problems are there in AI that people are working on? I recently got a 18-month postdoc position in a math department. It's a position with relative light teaching duty and a lot of freedom about what type of research that I want to do.\nPreviously I was mostly doing some research in probability and combinatorics. But I am thinking of doing a bit more application oriented work, e.g., AI. (There is also the consideration that there is good chance that I will not get a tenure-track position at the end my current position. Learn a bit of AI might be helpful for other career possibilities.)\nWhat sort of mathematical problems are there in AI that people are working on? From what I heard of, there are people studying\n\nDeterministic Finite Automaton\nMulti-armed bandit problems\nMonte Carlo tree search\nCommunity detection\n\nAny other examples?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In artificial intelligence (sometimes called machine intelligence or computational intelligence), there are several problems that are based on mathematical topics, especially optimization, statistics, probability theory, calculus and linear algebra.\nMarcus Hutter has worked on a mathematical theory for artificial general intelligence, called AIXI, which is based on several mathematical and computation science concepts, such as reinforcement learning, probability theory (e.g. Bayes theorem and related topics) measure theory, algorithmic information theory (e.g. Kolmogorov complexity), optimisation, Solomonoff induction, universal Levin search and theory of compution (e.g. universal Turing machines). His book Universal Artificial Intelligence: Sequential Decisions based on Algorithmic Probability, which is a highly technical and mathematical book, describes his theory of optimal Bayesian non-Markov reinforcement learning agents. Here I list other similar works.\nThere is also the research field called computational learning theory, which is devoted to studying the design and analysis of machine learning algorithms (from a statistical perspective, known as statistical learning theory, or algorithmic perspective, algorithmic learning theory). More precisely, the field focuses on the rigorous study and mathematical analysis of machine learning algorithms using techniques from fields such as probability theory, statistics, optimization, information theory and geometry. Several people have worked on the computational learning theory, including Michael Kearns and Vladimir Vapnik.\nThere is also a lot of research effort dedicated to approximations (heuristics) of combinatorial optimization and NP-complete problems, such as ant colony optimization.\nThere is also some work on AI-completeness, but this has not received much attention (compared to the other research areas mentioned above).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How could I use reinforcement learning to solve a chess-like board game? I invented a chess-like board game. I built an engine so that it can play autonomously. The engine is basically a decision tree. It's composed by:\n\nA search function that at each node finds all possible legal moves\nAn evaluation function that assigns a numerical value to the board position (positive means the first player is gaining the upper hand, negative means the second player is winning instead)\nAn alpha-beta pruning negamax algorithm\n\nThe main problem with this engine is that the optimization of the evaluation function is really tricky. I don't know which factors to consider and which weights to put. The only way I see to improve the engine is to iterate games trying each time different combinations of factors and weights. However, it computationally seems a very tough feat (Can I backpropagate without using deep learning?).\nI would like to use reinforcement learning to make the engine improve by playing against itself. I have been reading about the topic, but I am still quite confused.\n\nWhat other reward is there in a game apart from the win-or-lose output (1 or 0)?\n\nIf I use other rewards, like the output from the evaluation function at each turn, how can I implement it?\n\nHow do I modify the evaluation function to give better rewards iteration after iteration?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nI would like to use reinforcement learning to make the engine improve by playing against itself. I have been reading about the topic but I am still quite confused. \n\nBe warned: Reinforcement learning is a large complex subject. Although it might take you on a detour from game-playing bots, you may want to study RL basics. A good place to start is Sutton & Barto Reinforcement Learning: An Introduction\n\nWhat other reward is there in a game a part the win-or-lose output (1 or 0)? \n\nDepending on you game, that is usually it. Actually for a win/draw/lose game like chess then the reward from each action is 0 except for winning (+1) or losing (-1) at the end. In a zero-sum game then this aligns nicely to minimax, alphabeta pruning etc. \nReinforcement Learning is intended to address environments with delayed rewards. Adding \"helper\" rewards for interim non-goals is usually counter-productive.\n\nIf I use other rewards, like the output from the evaluation function at each turn, how can I implement it? \n\nTypically you don't. What applying self-playing RL will do is learn a return (sometimes called utility) function which predicts the expectation of your total +1/0/-1 reward by the end of the game. You would use this in place of your current heuristic for minimax search. Or, potentially you would adjust your current heuristic function to output in the same range and use RL to optimise its weights to make the best approximation to the true optimal play return function (which is probably too complex to calculate exactly).\n\nHow do I modify the evaluation function to give better rewards iteration after iteration?\n\nThat is what the different RL approaches all attempt to do, there are a variety of different solvers. There is no short way to explain it. You could start with a simple method such as Q-Learning. Q-Learning learns estimates of Q(s,a) (called the action value) which is the expected return when in state s and taking action a, and thereafter following an optimal policy. It makes an arbitrary guess to start with and refines it closer to the true value with each step made in the learning environment. Simple tabular Q-learners do this refinement simply by storing a big table of all states and actions with the best estimate so far of the true value, and averaging in each new estimate as it is experienced.\nIt is also possible to combine an RL method for heuristics with look-ahead minimax search - that is what the original AlphaGo did, and what AlphaGo Zero does during training. This is a powerful approach because minimax search will work to double-check the RL-generated heuristics. Although for simple enough games, RL can learn perfect heuristics and you would only need local search (what the next move should be).\nUnless your game is very simple (all possible states would fit in memory), you will need some kind of function approximator inside the RL algorithm. Neural networks are a standard choice. Having something for that part is unavoidable - although another good choice is to define a bunch of proxy features (that you might use to construct a heuristic by hand) and use a linear approximator - just a weighted sum of all the features. This can work well enough, and has been used for example in checkers (draughts) players trained using RL.\nIn fact, provided your own heuristic function is not too unusual, you can probably treat it just like a linear approximator and use RL to learn the best weights for it.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does is make sense to normalize rewards per episode in reinforcement learning? In Open AI's actor-critic and in Open AI's REINFORCE, the rewards are being normalized like so\nrewards = (rewards - rewards.mean()) / (rewards.std() + eps)\n\non every episode individually.\nThis is probably the baseline reduction, but I'm not entirely sure why they divide by the standard deviation of the rewards?\nAssuming this is the baseline reduction, why is this done per episode?\nWhat if one episode yields rewards in the (absolute, not normalized) range of $[0, 1]$, and the next episode yields rewards in the range of $[100, 200]$?\nThis method seems to ignore the absolute difference between the episodes' rewards.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The \"trick\" of subtracting a (state-dependent) baseline from the $Q(s, a)$ term in policy gradients to reduce variants (which is what is described in your \"baseline reduction\" link) is a different trick from the modifications to the rewards that you are asking about. The baseline subtraction trick for variance reduction does not appear to be present in the code you linked to.\nThe thing that your question is about appears to be standardization of rewards, as described in Brale_'s answer, to put all the observed rewards in a similar range of values. Such a standardization procedure inherently requires division by the standard deviation, so... that answers that part of your question.\nAs for why they are doing this on a per-episode-basis... I think you're right, in the general case this seems like a bad idea. If there are rare events with extremely high rewards that only occur in some episodes, and the majority of episodes only experience common events with lower-scale rewards... yes, this trick will likely mess up training. \nIn the specific case of the CartPole environment (which is the only environment used in these two examples), this is not a concern. In this implementation of the CartPole environment, the agent simply receives a reward with a value of exactly $1$ for every single time step in which it manages to \"survive\". The rewards list in the example code is in my opinion poorly-named, because it actually contains discounted returns for the different time-steps, which look like: $G_T = \\sum_{t=0}^{T} \\gamma^t R_t$, where all the individual $R_t$ values are equal to $1$ in this particular environment. \nThese kinds of values tend to be in a fairly consistent range (especially if the policy used to generate them also only moves slowly), so the standardization that they do may be relatively safe, and may improve learning stability and/or speed (by making sure there are always roughly as many actions for which the probability gets increased as there are actions for which the probability gets decreased, and possibly by making hyperparameters easier to tune).\nIt does not seem to me like this trick would generalize well to many other environments, and personally I think it shouldn't be included in such a tutorial / example.\n\nNote: I'm quite sure that a per-episode subtraction of the mean returns would be a valid, albeit possibly unusual, baseline for variance reduction. It's the subsequent division by standard deviation that seems particularly problematic to me in terms of generalizing to many different environments. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why LLMs and RNNs learn so fast during inference but, ironically, are so slow during training? Why LLMs learn so fast during inference, but, ironically, are so slow during training? That is, if you teach an AI a new concept in a prompt, it will learn and use the concept perfectly and flawless, through the whole prompt, after just one shot. Yet, if you train it in just a single sample, it will not influence its behavior at all - it will essentially forget. Why can't RNNs use whatever is happening during inference, rather than gradient descent, to update its weights and, thus, learn? In other words, can't the attention mechanism itself be used to update weights, rather than some cost function?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As pointed out by others, what you call \"learning\" at inference, is nothing more than providing more context. The model can indeed memorize in its short-term, but it is only working for the current task at hand. You suggest that we could make a model with an infinite contextual memory, but then it would mix up all tasks together. It would literally be like if you had to recite all the numbers you ever calculated or counted or saw before starting a new calculation.\nHence, contextualization is only useful for short-term tasks, and it works only thanks to the slow learning phase you have to do the first time around, which is more formally called the \"convergence process\".\nSo, what you are looking for is in fact to make the convergence process faster, and more precisely a one-shot or zero-shot learning. If you don't just look at LLMs (Large Language Models) and RNNs (Recursive Neural Networks), there are a lot of other AI\u00a0models that can do one-shot or even zero-shot learning, such as memory models like grippon-berrou neural network. One-shot learning can learn the first time they see an example, and generalize over it. Zero-shot learning can even learn without being presented some examples, by generalizing from others, or by transferring knowledge from another field.\nFor example, Text2Video-Zero is a recently published text to video generator, which did NOT learn from any video, but instead reused the weights from Stable Diffusion trained on still images. What this algorithm does is that it can cleverly generalize learning from still images into a coherent sequence of images with the same style, hence mimicking motion, with no additional cost. Of course, it's not completely zero-shot, because it has to be provided with a Stable Diffusion weights model first, but essentially zero-shot learning means that you can reuse one model that was made for one purpose for another purpose, for free (ie, you can directly infer, no need to re-learn anything).\nTechnically, One/Zero-shot learning typically requires another kind of architecture, more brain-like (ie, with discrete 0/1 synaptic weights). The long convergence processes are usually required by networks using floating weights (ie, the McCulloch-Pitts neurons). Because floating weights are not at all biologically plausible, they are a mathematical abstraction that synthesizes several biological functions of biological neural networks into fewer, more amenable to programming abstractions.\nLikewise, convolution layers in CNNs (convolutional neural networks) are another abstraction of how biological systems integrate big populations of neurons, but here we can use a much smaller population of artificial neurons, and use more optimized instructions sets to do the same work as the brain does. You have to keep in mind that for a lot of purposes in AI, current computers are much less efficient than the human brain, hence why all these highly synthetic reproductions, more optimized for the machine but very remote from how real biological systems work, are necessary. Here, long convergence (ie, long learning) is an unavoidable artifact from how we model our artificial neurons and synapses, with floating numbers instead of discrete (binary), and with mathematical functions for integration instead of analog biological integration (which is both more fine grained and simpler than numerical functions, see for example the videos by Veritasium about analog computers, biological systems have similar properties and advantages).\nRNNs are a kind of the opposite approach and problem, because they use a more biologically plausible property, recursivity, but the problem is that we have a hard time defining artificial systems that are efficient at learning recursive networks. So here, it's the opposite of what can be observed with CNNs and LLMs: the long convergence is due to current science providing inefficient learning algorithms when recursivity is involved. The last few years saw tremendous progress on this, with very clever algorithms, but it's still very far from how biological systems can neatly manage recursivity.\nAll that is to say that, to answer directly your question, why the current LLM and RNN models can't learn in zero/one-shot from the get-go: it's because nobody found a way to mathematically formulate such a model. Maybe someone will be able to in the near future, maybe it will take decades, but for now, it's the slow convergence LLM and RNN models that work, it's the ones that provide you with the hyped tools such as ChatGPT.\nPersonally, I think we won't get there until we find how analog biological neural system work, and then we need to develop new computer technologies to mimic those. There is already a lot of work towards these, with biological neurons reprogramming by ARN signalling or mixing them with silicon neurons, but it's still far from the \"real deal\". There are at least hundreds of different types of neurons, and there are many other neural cells types with not completely understood functions. We are far from fully understanding biological neural systems, but progress is continuous and steady.\nDisclaimer: I am both an AI researcher and a clinical neuroscientist and I studied some computational neuroscience.\n\n/EDIT: A small update to extend my explanation above for the technically and philosophically inclined ones: learning at its most fundamental level can be defined as the ability of a system to modify its structure to reflect some input signal, and memory being the system itself that can modify its structure according to input signals. In biological systems, there are two types of memory: short-term and long-term. Recent artificial recursive neural network models try to mimic this, with the very famous LSTM model (Long-Short Term Memory), itself a precursor of the GPT models. By convention, in machine learning we call \"learning\" the tweaking of the weights, ie, the long-term memory. But there is also indeed a short-term memory which has its own weights, but AI researchers don\u2019t call this process learning, although it technically is by all standards, the only difference being the exact method used and the length of time the memory is retained.\nAnd just like there are models that modify/learn short-term memory at inference but not long-term memory, there are models that tweak their long-term memory at inference, notably bayesian models, as often used for weather forecasting.\nSo why LLMs and RNNs learn fast during inference is because they are designed to only learn short-term memory, so that the big lot of weights of long-term memory were learnt beforehand. But future improvements of the tech may very well allow to design networks that also learn long-term memory \"online\", in real-time, in a stochastic manner with a guarantee of convergence.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does noise affect generalization? Does increasing the noise in data help to improve the learning ability of a network? Does it make any difference or does it depend on the problem being solved? How is it affect the generalization process overall?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Noise in the data, to a reasonable amount, may help the network to generalize better. Sometimes, it has the opposite effect. It partly depends on the kind of noise (\"true\" vs. artificial).\nThe AI FAQ on ANN gives a good overview. Excerpt:\n\nNoise in the actual data is never a good thing, since it limits the accuracy of generalization that can be achieved no matter how extensive the training set is. On the other hand, injecting artificial noise (jitter) into the inputs during training is one of several ways to improve generalization for smooth functions when you have a small training set.\n\nIn some field, such as computer vision, it's common to increase the size of the training set by copying some samples and adding some noises or other transformation.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the intuition behind the attention mechanism? \nAttention 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\u201d at the complete input and extracts significant information that is useful in decoding.\n\nI am really having trouble understanding the intuition behind the attention mechanism. I mean how the mechanism works and how to configure.\nIn simple words (and maybe with an example), what is the intuition behind the attention mechanism?\nWhat are some applications, advantages & disadvantages of attention mechanism?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "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 \"Labrador.\" Articles like \"the\" and \"a\" are not as relevant in translation as the previous words (though they aren't completely insignificant). Therefore, we focus our attention on the important words.\nAttention seeks to mimic this by adding attention weights to a model as trainable parameters to augment important parts of our input. Consider an encoder-decoder architecture such as the one Google Translate uses. Our encoder recurrent neural network (RNN) encodes our input sentence as a context vector in some vector space, which is then passed along to the decoder RNN which translates it into the target language. The attention mechanism scores each word in the input (via dot product with attention weights), then passes these scores through the softmax function to create a distribution. This distribution is then multiplied with the context vector to produce an attention vector, which is then passed to the decoder. In the example in the first paragraph, our attention weights for \"dog\" and \"Labrador\" would hopefully become larger in comparison to those for the other words during training. Note that all parts of the input are still considered since a distribution must sum to 1, just some elements have more effect on the output than others.\nBelow is a diagram from Towards Data Science that illustrates this concept very nicely in terms of an encoder-decoder architecture.\n\nThe advantages of attention is its ability to identify the information in an input most pertinent to accomplishing a task, increasing performance especially in natural language processing - Google Translate is a bidirectional encoder-decoder RNN with attention mechanisms. The disadvantage is the increased computation. In humans, attention serves to reduce our workload by allowing us to ignore unimportant features, however in a neural network, attention entails overhead as we are now generating attention distributions and training our attention weights (we are not actually ignoring the unimportant features, just diminishing their importance).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a recurrent neural network? Surprisingly, this wasn't asked before - at least I didn't find anything besides some vaguely related questions.\nSo, what is a recurrent neural network, and what are their advantages over regular (or feed-forward) neural networks?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Recurrent neural networks (RNNs) are a class of artificial neural network\narchitecture inspired by the cyclical connectivity of neurons in the brain. It uses iterative function loops to store information. \nDifference with traditional Neural networks using pictures from this book:\n\nAnd, an RNN:\n\nNotice the difference -- feedforward neural networks' connections\ndo not form cycles. If we relax this condition, and allow cyclical\nconnections as well, we obtain recurrent neural networks (RNNs). You can see that in the hidden layer of the architecture.\nWhile the difference between a multilayer perceptron and an RNN may seem\ntrivial, the implications for sequence learning are far-reaching. An MLP can only\nmap from input to output vectors, whereas an RNN can in principle map from\nthe entire history of previous inputs to each output. Indeed, the equivalent\nresult to the universal approximation theory for MLPs is that an RNN with a\nsufficient number of hidden units can approximate any measurable sequence-to-sequence\nmapping to arbitrary accuracy.\nImportant takeaway:\nThe recurrent connections allow a 'memory' of previous inputs to persist in the\nnetwork's internal state, and thereby influence the network output.\nTalking in terms of advantages is not appropriate as they both are state-of-the-art and are particularly good at certain tasks. A broad category of tasks that RNN excel at is:\nSequence Labelling\nThe goal of sequence labelling is to assign sequences of labels, drawn from a fixed alphabet, to sequences of input data.\nEx: Transcribe a sequence of acoustic features with spoken words (speech recognition), or a sequence of video frames with hand gestures (gesture recognition).\nSome of the sub-tasks in sequence labelling are:\nSequence Classification\nLabel sequences are constrained to be of length one. This is referred to as sequence classification, since each input sequence is assigned to a single class. Examples of sequence classification task include the identification of a single spoken work and the recognition of an individual\nhandwritten letter.\nSegment Classification\nSegment classification refers to those tasks where the target sequences consist\nof multiple labels, but the locations of the labels -- that is, the positions of the input segments to which the labels apply -- are known in advance.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is a genetic algorithm an example of artificial intelligence? Since human intelligence presumably is a function of a natural genetic algorithm in nature, is using a genetic algorithm in a computer an example of artificial intelligence? If not, how do they differ? Or perhaps some are and some are not expressing artificial intelligence depending upon the scale of the algorithm and what it evolves into?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nAn ability that is commonly attributed to intelligence is problem solving. \nAnother one is learning (improving itself from experience).\nArtificial intelligence can be defined as \"replicating intelligence, or parts of it, at least in appearance, inside a computer\" (dodging the definition of intelligence itself).\nGenetic algorithms are computational problem solving tools that find and improve solutions (they learn).\n\nThus, genetic algorithms are a kind of artificial intelligence.\nRegarding scale, I don't see it as an important factor for defining G.A. as A.I or not. The same way we can simply classify different living forms as more or less intelligent instead of just saying intelligent or not intelligent.\nFinally, let's just make an important distinction: our brains are the product of natural selection, but the brains themselves don't use the same principle in order to achieve intelligence.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is A* optimal if the heuristic function is admissible? A heuristic is admissible if it never overestimates the true cost to reach the goal node from $n$. If a heuristic is consistent, then the heuristic value of $n$ is never greater than the cost of its successor, $n'$, plus the successor's heuristic value. \nWhy is A*, using tree or graph searches, optimal, if it uses an admissible heuristic?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is well covered in the corresponding chapter of Russell & Norvig (chapter 3.5, pages 93 to 99 (Third Edition)). Check that out for more details.\nFirst, let's review the definitions:\n\nYour definitions of admissible and consistent are correct.\nAn admissible heuristic is basically just \"optimistic\". It never overestimates a distance.\nA consistent heuristic is one where your prior beliefs about the distances between states are self-consistent. That is, you don't think that it costs 5 from B to the goal, 2 from A to B, and yet 20 from A to the goal. You are allowed to be overly optimistic though. So you could believe that it's 5 from B to the goal, 2 from A to B, and 4 from A to the goal.\nA tree search is a general search strategy for searching problems that have a tree structure: that is, it's never possible to \"double back\" to an earlier state from a later state. This models certain types of games, for instance, like Tic-Tac-Toe. The tree search does not remember which states it has already visited, only the \"fringe\" of states it hasn't visited yet.\nA graph search is a general search strategy for searching graph-structured problems, where it's possible to double back to an earlier state, like in chess (e.g. both players can just move their kings back and forth). To avoid these loops, the graph search also keeps track of the states that it has processed.\nFor more on tree vs. graph search, see this answer.\n\nOkay, now let's talk through the intuition behind the proofs.\nWe first want to show that\n\nIf $h(n)$ is admissible, A* using tree search is optimal.\n\nThe usual proof is by contradiction.\n\nAssume that A* with tree search and an admissible heuristic was not optimal.\n\nBeing non-optimal means that the first complete path from the start to the goal discovered by A* (call this $q$) will be longer than some other path $p$, which A* explored up to some state $s$, but no further.\n\nSince the heuristic is admissible, the estimated cost of reaching the goal from $s$ must be smaller than the true cost.\n\nBy 3, and the fact that we know how much it costs to reach $s$ along $p$, the estimated total cost of $p$, and thus the cost to expand $s$ must be smaller than the true cost of $p$.\n\nSince the true cost of $p$ is smaller than the cost of $q$ (by 2), the estimated cost to expand $s$ must be smaller than the true cost of $q$.\n\nA* always picks the path with the most promising total cost to expand next, and the cost of expanding the goal state is given by the total path length required to reach it.\n\n5 and 6 form a contradiction, so our assumption in 1 must have been incorrect. Therefore A* must be optimal.\n\n\nThe graph search proof uses a very similar idea, but accounts for the fact that you might loop back around to earlier states.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which layer in a CNN consumes more training time: convolution layers or fully connected layers? In a convolutional neural network, which layer consumes more training time: convolution layers or fully connected layers? \nWe can take AlexNet architecture to understand this. I want to see the time breakup of the training process. I want a relative time comparison so we can take any constant GPU configuration.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "NOTE: I did these calculations speculatively, so some errors might have crept in. Please inform of any such errors so I can correct it.\nIn general in any CNN the maximum time of training goes in the Back-Propagation of errors in the Fully Connected Layer (depends on the image size). Also the maximum memory is also occupied by them. Here is a slide from Stanford about VGG Net parameters:\n\n\nClearly you can see the fully connected layers contribute to about 90% of the parameters. So the maximum memory is occupied by them. \nAs far as training time goes, it somewhat depends on the size (pixels*pixels) of the image being used. In FC layers it is straightforward that the number of derivatives you have to calculate is equal to the number of parameters. As far as the convolutional layer goes, let's see an example,let us take the case of 2nd layer:\nIt has got 64 filters of $(3*3*3)$ dimensions to be updated. The error is propagated from the 3rd layer. Each channel in the 3rd layer propagates it error to its corresponding $(3*3*3)$ filter. Thus $224*224$ pixels will contribute to about $224*224*(3*3*3)$ weight updations. And since there are $64$ such $224*224$ channels we get the total number of calculations to be performed as $64*224*224*(3*3*3) \\approx 87*10^6 $ calculations.\nNow let us take the last layer of $56*56*256$. It will pass it gradients to the previous layer. Each $56*56$ pixel will update a $(3*3*256)$ filter. And since there are 256 such $56*56$ the total calculations required would be $256 * 56 * 56 * (3*3*256) \\approx 1850 *10^6$ calculations.\nSo number of calculations in a convolutional layer really depends on the number of filters and the size of the picture. In general I have used the following formulae to calculate the number of updations required for filters in a layer, also I have considered $stride = 1$ since it will be the worst case:\n$channels_{output} * (pixelOutput_{height} * pixelOutput_{width}) * (filter_{height} * filter_{width} * channels_{input})$ \nThanks to fast GPU's we are easily able to handle these huge calculations. But in FC layers the entire matrix needs to be loaded which causes memory problems which is generally not the case of convolutional layers, so training of convolutional layers is still easy. Also all these have to be loaded in the GPU memory itself and not the RAM of the CPU.\nAlso here is the parameter chart of AlexNet:\n\nAnd here is a performance comparison of various CNN architectures:\n\nI suggest you check out the CS231n Lecture 9 by Stanford University for better understanding of the nooks and crannies of CNN architectures.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Should deep residual networks be viewed as an ensemble of networks? The question is about the architecture of Deep Residual Networks (ResNets). The model that won the 1-st places at \"Large Scale Visual Recognition Challenge 2015\" (ILSVRC2015) in all five main tracks:\n\n\nImageNet Classification: \u201cUltra-deep\u201d (quote Yann) 152-layer nets \nImageNet Detection: 16% better than 2nd\nImageNet Localization: 27% better than 2nd\nCOCO Detection: 11% better than 2nd\nCOCO Segmentation: 12% better than 2nd\nSource: MSRA @ ILSVRC & COCO 2015 competitions (presentation, 2-nd slide)\n\n\nThis work is described in the following article:\n\nDeep Residual Learning for Image Recognition (2015, PDF)\n\n\nMicrosoft Research team (developers of ResNets: Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun) in their article:\n\n\"Identity Mappings in Deep Residual Networks (2016)\"\n\nstate that depth plays a key role:\n\n\"We obtain these results via a simple but essential concept \u2014 going deeper. These results demonstrate the potential of pushing the limits of depth.\"\n\nIt is emphasized in their presentation also (deeper - better): \n\n- \"A deeper model should not have higher training error.\" \n - \"Deeper ResNets have lower training error, and also lower test error.\" \n - \"Deeper ResNets have lower error.\"\n - \"All benefit more from deeper features \u2013 cumulative gains!\"\n - \"Deeper is still better.\"\n\nHere is the sctructure of 34-layer residual (for reference):\n\n\nBut recently I have found one theory that introduces a novel interpretation of residual networks showing they are exponential ensembles:\n\nResidual Networks are Exponential Ensembles of Relatively Shallow Networks (2016)\n\nDeep Resnets are described as many shallow networks whose outputs are pooled at various depths. \nThere is a picture in the article. I attach it with explanation:\n\n Residual Networks are\n conventionally shown as (a), which is a natural representation of\n Equation (1). When we expand this formulation to Equation (6), we\n obtain an unraveled view of a 3-block residual network (b). From this\n view, it is apparent that residual networks have O(2^n) implicit paths\n connecting input and output and that adding a block doubles the number\n of paths.\n\nIn conclusion of the article it is stated:\n\nIt is not depth, but the ensemble that makes residual networks strong.\n Residual networks push the limits of network multiplicity, not network\n depth. Our proposed unraveled view and the lesion study show that\n residual networks are an implicit ensemble of exponentially many\n networks. If most of the paths that contribute gradient are very short\n compared to the overall depth of the network, increased depth\n alone can\u2019t be the key characteristic of residual networks. We now\n believe that multiplicity, the network\u2019s expressability in the\n terms of the number of paths, plays a key role.\n\nBut it is only a recent theory that can be confirmed or refuted. It happens sometimes that some theories are refuted and articles are withdrawn.\n\nShould we think of deep ResNets as an ensemble after all? Ensemble or depth makes residual networks so strong? Is it possible that even the developers themselves do not quite perceive what their own model represents and what is the key concept in it?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Imagine a genie grants you three wishes. Because you are an ambitious deep learning researcher your first wish is a perfect solution for a 1000-layer NN for Image Net, which promptly appears on your laptop.\nNow a genie induced solution doesn't give you any intuition how it might be interpreted as an ensemble, but do you really believe that you need 1000 layers of abstraction to distinguish a cat from a dog? As the authors of the \"ensemble paper\" mention themselves, this is definitely not true for biological systems.\nOf course you could waste your second wish on a decomposition of the solution into an ensemble of networks, and I'm pretty sure the genie would be able to oblige. The reason being that part of the power of a deep network will always come from the ensemble effect.\nSo it is not surprising that two very successful tricks to train deep networks, dropout and residual networks, have an immediate interpretation as implicit ensemble. Therefore \"it's not depth, but the ensemble\" strikes me as a false dichotomy. You would really only say that if you honestly believed that you need hundreds or thousands of levels of abstraction to classify images with human accuracy. \nI suggest you use the last wish for something else, maybe a pinacolada. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do I compute the structural similarity between sentences? I am working on a problem where I need to determine whether two sentences are similar or not. I implemented a solution using BM25 algorithm and wordnet synsets for determining syntactic & semantic similarity. The solution is working adequately, and even if the word order in the sentences is jumbled, it is measuring that two sentences are similar. For example\n\nPython is a good language.\nLanguage a good python is.\n\nMy problem is to determine that these two sentences are similar. \n\nWhat could be the possible solution for structural similarity? \nHow will I maintain the structure of sentences?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The easiest way to add some sort of structural similarity measure is to use n-grams; in your case bigrams might be sufficient.\nGo through each sentence and collect pairs of words, such as:\n\n\"python is\", \"is a\", \"a good\", \"good language\".\n\nYour other sentence has\n\n\"language a\", \"a good\", \"good python\", \"python is\". \n\nOut of eight bigrams you have two which are the same (\"python is\" and \"a good\"), so you could say that the structural similarity is 2/8.\nOf course you can also be more flexible if you already know that two words are semantically related. If you want to say that Python is a good language is structurally similar/identical to Java is a great language, then you could add that to the comparison so that you effectively process \"[PROG_LANG] is a [POSITIVE-ADJ] language\", or something similar.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are other examples of theoretical machine learning books? I am looking for a book about machine learning that would suit my physics background. I am more or less familiar with classical and complex analysis, theory of probability, \u0441calculus of variations, matrix algebra, etc. However, I have not studied topology, measure theory, group theory, and other more advanced topics. I try to find a book that is written neither for beginners, nor for mathematicians.\nRecently, I have read the great book \"Statistical inference\" written by Casella and Berger. They write in the introduction that \"The purpose of this book is to build theoretical statistics (as different from mathematical statistics) from the first principles of probability theory\". So, I am looking for some \"theoretical books\" about machine learning.\nThere are many online courses and brilliant books out there that focus on the practical side of applying machine learning models and using the appropriate libraries. It seems to me that there are no problems with them, but I would like to find a book on theory.\nBy now I have skimmed through the following books\n\nPattern Recognition And Machine Learning\nIt looks very nice. The only point of concern is that the book was published in 2006. So, I am not sure about the relevance of the chapters considering neural nets, since this field is developing rather fast.\n\nThe elements of statistical learning\nThis book also seems very good. It covers most of the topics as well as the first book. However, I am feeling that its style is different and I do not know which book will suit me better.\n\nArtificial Intelligence. A Modern Approach\nThis one covers more recent topics, such as natural language processing. As far as I understand, it represents the view of a computer scientist on machine learning.\n\nMachine Learning A Probabilistic Perspective\nMaybe it has a slight bias towards probability theory, which is stated in the title. However, the book looks fascinating as well.\n\n\nI think that the first or the second book should suit me, but I do not know what decision to make.\nI am sure that I have overlooked some books.\nAre there some other ML books that focus on theory?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Some of the books that you mention are often used as reference books in introductory courses to machine learning or artificial intelligence.\nFor example, if I remember correctly, in my introductory course to machine learning, the professor suggested the book Pattern Recognition And Machine Learning (2006) by Bishop, although we never used it during the lessons. This is a good book, but, in my opinion, it covers many topics, such as variational inference or sampling methods, that are not suited for an introductory course.\nThe book Artificial Intelligence. A Modern Approach, by Norvig and Russell, definitely does not focus on machine learning, but it covers many other aspects of artificial intelligence, such as search, planning, knowledge representation, machine learning, robotics, natural language processing or computer vision. This is probably the book that you should read and use if you want to have an extensive overview of the AI field. Although I never fully read it, I often used it as a reference, as I use the other mentioned book. For instance, during my bachelor's and, more specifically, an introductory course to artificial intelligence, we had used this book as the reference book, but note that there are other books that provide an extensive overview of the AI field.\nThe other two books are not as famous as these two, but they are probably also good books, although their focus may be different.\nThere are at least three other books that I think you should also be aware of, given that they also cover the actual theory of learning, aka (computational) learning theory, before diving into more specific topics, such as kernel methods.\n\nMachine Learning (1997) by Tom Mitchell\nFoundations of Machine Learning (2nd edition, 2018) by Mehryar Mohri et al.\nUnderstanding Machine Learning: From Theory to Algorithms (2014) by Shai Shalev-Shwartz et al.\nProbabilistic Machine Learning: An Introduction (2022) by Kevin Patrick Murphy\n\nYou can find more books on learning theory here.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is consciousness necessary for any AI task? Consciousness is challenging to define, but for this question let's define it as \"actually experiencing sensory input as opposed to just putting a bunch of data through an inanimate machine.\" Humans, of course, have minds; for normal computers, all the things they \"see\" are just more data. One could alternatively say that humans are sentient, while traditional computers are not.\nSetting aside the question of whether it's possible to build a sentient machine, does it actually make a difference if an AI is sentient or not? In other words, are there are tasks that are made impossible - not just more difficult - by a lack of sentience?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "No-one knows.\nWhy: because it's not possible to formally determine even whether your fellow human beings are actually conscious (they may instead be what is philosophically termed a 'Zombie'). No test known to modern physics suffices to decide. Hence it's possible that you are the only sentient being, and everyone else is a robot.\nConsequently, we cannot determine which tasks require sentience.\nNote that the ontological status of Zombies is controversial: some philosophers of AI (e.g. Daniel Dennett) claim that Zombies are logically impossible while others such as David Chalmers would claim that a Zombie would be compelled to assert that they experience qualia (i.e. are sentient) even though they do not. Here is a very readable paper by Flanagan and Polger that also explains why a stronger neurological version of the Turing test is insufficient to detect a Zombie.\nEDIT: In response to the comment about whether an objective test for distinguishing sentience from non-sentience exists:\nNo-one knows. What we do believe is that this would require something in addition to what modern physics can currently tell us. David Chalmers has speculated that qualia should be introduced as a new form of physical unit, orthogonal to the others in the same way that electrical charge is orthogonal to distance.\nIn the absence of an objective test, we have to rely on Turing test variants, which no more guarantee consciousness in the subject than they do intelligence.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the differences between A* and greedy best-first search? What are the differences between the A* algorithm and the greedy best-first search algorithm? Which one should I use? Which algorithm is the better one, and why?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Both algorithms fall into the category of \"best-first search\" algorithms, which are algorithms that can use both the knowledge acquired so far while exploring the search space, denoted by $g(n)$, and a heuristic function, denoted by $h(n)$, which estimates the distance to the goal node, for each node $n$ in the search space (often represented as a graph). \nEach of these search algorithms defines an \"evaluation function\", for each node $n$ in the graph (or search space), denoted by $f(n)$. This evaluation function is used to determine which node, while searching, is \"expanded\" first, that is, which node is first removed from the \"fringe\" (or \"frontier\", or \"border\"), so as to \"visit\" its children. In general, the difference between the algorithms in the \"best-first\" category is in the definition of the evaluation function $f(n)$.\nIn the case of the greedy BFS algorithm, the evaluation function is $f(n) = h(n)$, that is, the greedy BFS algorithm first expands the node whose estimated distance to the goal is the smallest. So, greedy BFS does not use the \"past knowledge\", i.e. $g(n)$. Hence its connotation \"greedy\". In general, the greedy BST algorithm is not complete, that is, there is always the risk to take a path that does not bring to the goal. In the greedy BFS algorithm, all nodes on the border (or fringe or frontier) are kept in memory, and nodes that have already been expanded do not need to be stored in memory and can therefore be discarded. In general, the greedy BFS is also not optimal, that is, the path found may not be the optimal one. In general, the time complexity is $\\mathcal{O}(b^m)$, where $b$ is the (maximum) branching factor and $m$ is the maximum depth of the search tree. The space complexity is proportional to the number of nodes in the fringe and to the length of the found path.\nIn the case of the A* algorithm, the evaluation function is $f(n) = g(n) + h(n)$, where $h$ is an admissible heuristic function. The \"star\", often denoted by an asterisk, *, refers to the fact that A* uses an admissible heuristic function, which essentially means that A* is optimal, that is, it always finds the optimal path between the starting node and the goal node. A* is also complete (unless there are infinitely many nodes to explore in the search space). The time complexity is $\\mathcal{O}(b^m)$. However, A* needs to keep all nodes in memory while searching, not just the ones in the fringe, because A*, essentially, performs an \"exhaustive search\" (which is \"informed\", in the sense that it uses a heuristic function).\nIn summary, greedy BFS is not complete, not optimal, has a time complexity of $\\mathcal{O}(b^m)$ and a space complexity which can be polynomial. A* is complete, optimal, and it has a time and space complexity of $\\mathcal{O}(b^m)$. So, in general, A* uses more memory than greedy BFS. A* becomes impractical when the search space is huge. However, A* also guarantees that the found path between the starting node and the goal node is the optimal one and that the algorithm eventually terminates. Greedy BFS, on the other hand, uses less memory, but does not provide the optimality and completeness guarantees of A*. So, which algorithm is the \"best\" depends on the context, but both are \"best\"-first searches. \nNote: in practice, you may not use any of these algorithms: you may e.g. use, instead, IDA*.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How exactly can ReLUs approximate non-linear and curved functions? Currently, the most commonly used activation functions are ReLUs. So I answered this question What is the purpose of an activation function in neural networks? and, while writing the answer, it struck me, how exactly can ReLUs approximate a non-linear function?\nBy pure mathematical definition, sure, it's a non-linear function due to the sharp bend, but, if we confine ourselves to the positive or the negative portion of the $x$-axis only, then it's linear in those regions. Let's say we take the whole $x$-axis also, then also it's kinda linear (not in a strict mathematical sense), in the sense that it cannot satisfactorily approximate curved functions, like a sine wave ($0 \\rightarrow 90$) with a single node hidden layer as is possible by a sigmoid activation function.\nSo, what is the intuition behind the fact that ReLUs are used in NNs, giving satisfactory performance? Are non-linear functions, like the sigmoid and the tanh, thrown in the middle of the NN sometimes?\nI am not asking for the purpose of ReLUs, even though they are kind of linear.\n\nAs per @Eka's comment, the ReLu derives its capability from discontinuity acting in the deep layers of the NN. Does this mean that ReLUs are good, as long as we use it in deep NNs and not a shallow NN?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The outputs of a ReLU network are always \"linear\" and discontinuous. They can approximate curves, but it could take a lot of ReLU units. However, at the same time, their outputs will often be interpreted as a continuous, curved output.\nImagine you trained a neural network that takes $x^3$ and outputs $|x^3|$ (which is similar to a parabola). This is easy for the ReLU function to do perfectly. In this case, the output is curved.\nBut it is not actually curved. The inputs here are 'linearly' related to the outputs. All the neural network does is it takes the input and returns the absolute value of the input. It performs a 'linear', non-curved function. You can only see that the output is non-linear when you graph it against the original $x$-values (the $x$ in $x^3$).\nSo, when we plot the output on a graph and it looks curved, it's usually because we associated different x-values with the input, and then plotted the output as the $y$-coordinate in relation to those $x$-values.\nOkay, so you want to know how you would smoothly model $\\sin(x)$ using ReLU. The trick is that you don't want to put $x$ as the input. Instead put something curved in relation to $x$ as the input, like $x^3$. So, the input is $x^3$ and the output is $\\sin(x)$. The reason why this would work is that it isn't computing the sine of the input - it's computing sine of the cube root of the input. It could never smoothly compute the sine of the input itself. To graph the output $\\sin(x)$, put the original $x$ as the $x$ coordinate (don't put the input) and put the output as the $y$ coordinate.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the purpose of Decoder mask (triangular mask) in Transformer? I'm trying to implement transformer model using this tutorial. In the decoder block of the Transformer model, a mask is passed to \"pad and mask future tokens in the input received by the decoder\". This mask is added to attention weights.\nimport tensorflow as tf\n\ndef create_look_ahead_mask(size):\n mask = 1 - tf.linalg.band_part(tf.ones((size, size)), -1, 0)\n return mask\n\nNow my question is, how is doing this step (adding mask to the attention weights) equivalent to revealing the words to model one by one? I simply can't grasp the intuition of it's role. Most tutorials won't even mention this step like it's very obvious. Please help me understand. Thanks.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The Transformer model presented in this tutorial is an auto-regressive Transformer. Which means that prediction of next token only depends on it's previous tokens.\nSo in order to predict next token, you have to make sure that only previous token are attended. (If not, this would be a cheating because model already knows whats next).\nSo attention mask would be like this\n[0, 1, 1, 1, 1]\n[0, 0, 1, 1, 1]\n[0, 0, 0, 1, 1]\n[0, 0, 0, 0, 1]\n[0, 0, 0, 0, 0]\nFor example: If you are translating English to Spanish\nInput: How are you ?\nTarget: < start > Como estas ? < end >\nThen decoder will predict something like this\n< start > (it will be given to decoder as initial token)\n< start > Como\n< start > Como estas\n< start > Como estas ?\n< start > Como estas ? < end >\nNow compare this step by step prediction sequences to attention mask given above, It would make sense now to you\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the best known gradient-free training methods for deep learning? As I know, the current state of the art methods for training deep learning networks are variants of gradient descent or stochastic gradient descent. \nWhat are the best known gradient-free training methods for deep learning (mostly in visual tasks context)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are several different algorithms that can be used for gradient free neural network training. Some of these algorithms include particle swarm optimization, genetic algorithms, simulated annealing, and several others. Almost any optimization algorithm can be used to train a neural network. Here is an overview of some of the algorithms I listed:\n\nParticle Swarm optimization - I would say that this is one of the better optimization algorithms to train neural networks other than back propagation. I am currently using it and have achieved quite good results.\nGenetic Algorithms - I have tried to use genetic algorithms to train neural networks in the past and I was not able to get it to work. However, I was using deep neural networks with almost a million parameters and the performance was not that good.\nSimulated annealing - simulated annealing is based off of metals cooling. I have seen simulated annealing work fairly well but maybe not as well as particle swarm optimization.\nDerivatives of genetic algorithms - derivatives of genetic algorithms such as NEAT have been shown to work pretty well. I have not personally used them extensively but some of the things that people have used them for are pretty cool.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does AI software look like, and how is it different from other software? What does AI software look like? What is the major difference between AI software and other software?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Code in AI is not in principle different from any other computer code. After all, you encode algorithms in a way that computers can process them. Having said that, there are a few points where your typical \"AI Code\" might be different:\n\nA lot of (especially early) AI code was more research based and exploratory, so certain programming languages were favoured that were not mainstream for, say, business applications. For example, much work in early AI has been coded in Lisp, and probably not much in Fortran or Cobol, which were more suited to engineering or business. Special languages were developed to make it easy to program with symbols and logic (eg Prolog).\n\nThe emphasis was more on algorithms than clever/complex programming. If you look at the source code for ELIZA (there are multiple implementations in many different languages), it's really very simple.\n\nBefore the advent of neural networks and (statistical) machine learning, most AI programming was symbolic, so there hasn't been much emphasis on numerical computing. This changed as probabilities and fuzziness were increasingly used, but even if using general purpose languages there would be fewer numerical calculations.\n\nSelf-modifying code is inherently complex; while eg Lisp made no difference between code and data (at least not in the same way as eg C or Pascal), this would just complicate development without much gain. Perhaps in the early days this was necessary when computers had precious little memory and power and you had to work around those constraints. But these days I don't think anybody would use such techniques anymore.\n\nAs modern programming languages evolved, Lisp and Prolog (which were the dominant AI languages until probably 20 to 30 years ago) have been slowly replaced by eg Python; probably because it is easier to find programmers comfortable in an imperative paradigm rather than a functional one. In general, interpreted languages would be preferred over compiled ones due to speed of development, unless performance is important.\n\n\nThe move to deep learning has of course shifted this a lot. Now the core processing is all numeric, so you would want languages that are better with calculations than symbol handling. Interpreted languages would now mainly make up the 'glue' code to interface between compiled modules, and be used for data pre-processing. So current AI code is probably not really that different from code used in scientific computing these days.\nThere is of course still a difference between R&D and production code. You might explore a subject using an interpreted language, and then re-code your algorithm for production in a compiled language to gain better performance. This depends on how established the area is; there will for example be ready-made libraries available for neural networks or genetic algorithms which are well-established algorithms (where performance matters).\nIn conclusion: I don't think AI code is any more complex than any other code. Of course, that's not very exciting to portray in a film, so artistic licence is used to make it more interesting. I guess self-modifying code also enables the machines to develop their own conscience and take over the world, which is even more gripping as a story element. However, given that a lot of behaviour is nowadays in the (training/model/configuration) data rather than the algorithm, this might even be more straight forward to modify.\nNote: this is a fairly simplified summary based on my own experience of working in AI; other people's views might vary, without either being 'wrong'.\nUpdate 2021: I now work at a company that extracts business information/events from news data on a large scale using NLP methods. And we're using Lisp... so it's still in active, commercial use in AI.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are the shortcomings of neural networks diminishing? Having worked with neural networks for about half a year, I have experienced first-hand what are often claimed as their main disadvantages, i.e. overfitting and getting stuck in local minima. However, through hyperparameter optimization and some newly invented approaches, these have been overcome for my scenarios. From my own experiments:\n\nDropout seems to be a very good regularization method.\n\nBatch normalization eases training and keeps signal strength consistent across many layers.\n\nAdadelta consistently reaches very good optima\n\n\nI have experimented with scikit-learn's implementation of SVM alongside my experiments with neural networks, but I find the performance to be very poor in comparison, even after having done grid-searches for hyperparameters. I realize that there are countless other methods, and that SVM's can be considered a sub-class of NN's, but still.\nSo, to my question:\nWith all the newer methods researched for neural networks, have they slowly - or will they - become \"superior\" to other methods? Neural networks have their disadvantages, as do others, but with all the new methods, have these disadvantages been mitigated to a state of insignificance?\nI realize that oftentimes \"less is more\" in terms of model complexity, but that too can be architected for neural networks. The idea of \"no free lunch\" forbids us to assume that one approach always will reign superior. It's just that my own experiments - along with countless papers on awesome performances from various NN's - indicate that there might be, at the least, a very cheap lunch.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Neural Networks have other short comings as well. \n\nIt takes much longer and far more resources to train a neural network than something like a random forest. So if you need speed of training or are resource constrained in anyway, you probably should not look at Neural Networks first. Evaluation of a trained deep NN can be much more expensive than competing techniques too.\nThe effort involved in learning how to architect and train a NN is still much higher than competing methods, like an SVM. People who are just starting out in Data Science should probably use other techniques to learn about the nuances of fitting data before getting involved in neural networks. And although simple NNs with only one or two hyperparameters are often available in \nmany data science libraries, they don't perform any better than other techniques so are just another ML black-box technique really.\nWhile we have made a lot of progress in understanding how neural networks do their magic, they are still less accessible and dissectible than most competing methods. So while NNs might solve the problem, they might not give you as many insights as easily as other techniques do.\n\nLooking forward to what other people have to say here.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between one-shot learning, transfer learning and fine tuning? Lately, there are lots of posts on one-shot learning. I tried to figure out what it is by reading some articles. To me, it looks like similar to transfer learning, in which we can use pre-trained model weights to create our own model. Fine-tuning also seems a similar concept to me. \nCan anyone help me and explain the differences between all three of them?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "They are all related terms.\nFrom top to bottom:\nOne-shot learning aims to achieve results with one or very few examples. Imagine an image classification task. You may show an apple and a knife to a human and no further examples are needed to continue classifying. That would be the ideal outcome, but for algorithms.\nIn order to achieve one-shot learning (or close) we can rely on knowledge transfer, just like the human in the example would do (we are trained to be amazing at image processing, but here we would also exploit other knowledge like abstract reasoning abilities, and so on).\nThis brings us to transfer learning. Generally speaking, transfer learning is a machine learning paradigm where we train a model on one problem and then try to apply it to a different one (after some adjustments, as we'll see in a second).\nIn the example above, classifying apples and knives is not at all trivial. However, if we are given a neural network that already excels at image classification, with super-human results in over 1000 categories... perhaps it is easy to adapt this model to our specific apples vs knives situation.\nThis \"adapting\", those \"adjustments\", are essentially what we call fine-tuning. We could say that fine-tuning is the training required to adapt an already trained model to the new task. This is normally much less intensive than training from scratch, and many of the characteristics of the given model are retained.\nFine-tuning usually covers more steps. A typical pipeline in deep learning for computer vision would be this:\n\nGet trained model (image classifier champion)\nNote the head of our model does not match our needs (there's probably one output per category, and we only need two categories now!)\nSwap the very last layer(s) of the model, so that the output matches our needs, but keeping the rest of the architecture and already trained parameters intact.\nTrain (fine-tune!) our model on images that are specific to our problem (only a few apples and knives in our silly example). We often only allow the last layers to learn at first, so they \"catch up\" with the rest of the model (in this case we talk about freezing and unfreezing and discriminative learning rates, but that's a bit beyond the question).\n\nNote that some people may sometimes use fine-tuning as a synonym for transfer learning, so be careful about that!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When should you not use the bias in a layer? I'm not really that experienced with deep learning, and I've been looking at research code (mostly PyTorch) for deep neural networks, specifically GANs, and, in many cases, I see the authors setting bias=False in some layers without much justification. This isn't usually done in a long stack of layers that have a similar purpose, but mostly in unique layers like the initial linear layer after a conditioning vector, or certain layers in an attention architecture.\nI imagined there must be a strategy to this, but most articles online seem to confirm my initial perception that bias is a good thing to have available for training in pretty much every layer.\nIs there a specific optimization / theoretical reason to turn off biases in specific layers in a network? How can I choose when to do it when designing my own architecture?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The most usual case of bias=False is in layers before/after Batch Normalization with no activators in between. The BatchNorm layer will re-center the data anyway, removing the bias and making it a useless trainable parameter. Quoting the original BatchNorm paper:\n\nNote that, since we normalize $Wu+b$, the bias $b$ can be ignored since its effect will be canceled by the subsequent mean subtraction\n\nSimilar thing happens in transformers' LinearNormalization and (as far as I understand how conditioning works) in the GANs' conditioning layer - the data gets re-centered, effectively cancelling the bias.\nIn my experience, that's the most frequent reason to see bias=False, but one can imagine other reasons to remove the bias. As a rule of thumb, I'd say that you don't include bias if you want to \"transform zeros to zeros\" - things like learned rotations can be an example of such (rather exotic) application.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Could an AI think laterally while avoiding \"ethically suboptimal\" choices? In the recent PC game The Turing Test, the AI (\"TOM\") needs help from Ava to get through some puzzle rooms. TOM says he is unable to solve the puzzles because he is not allowed to \"think laterally.\" Specifically, he says he would not have thought to throw a box through a window to solve the first room. His creators, the story goes, turned that capability off because such thinking could produce \"ethically suboptimal\" solutions, like chopping off an arm to leave on a pressure plate.\nWould all creative puzzle-solving abilities need to be removed from an AI to keep its results reasonable, or could we get some benefits of lateral thinking without losing an arm?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "No, with a but. We can have creative yet ethical problem-solving if the system has a complete system of ethics, but otherwise creativity will be unsafe by default.\nOne can classify AI decision-making approaches into two types: interpolative thinkers, and extrapolative thinkers. \nInterpolative thinkers learn to classify and mimic whatever they're learning from, and don't try to give reasonable results outside of their training domain. You can think of them as interpolating between training examples, and benefitting from all of the mathematical guarantees and provisos as other statistical techniques.\nExtrapolative thinkers learn to manipulate underlying principles, which allows them to combine those principles in previously unconsidered ways. The relevant field for intuition here is numerical optimization, of which the simplest and most famous example is linear programming, rather than the statistical fields that birthed machine learning. You can think of them as extrapolating beyond training examples (indeed, many of them don't even require training examples, or use those examples to infer underlying principles).\nThe promise of extrapolative thinkers is that they can come up with these 'lateral' solutions much more quickly than people would be able to. The problem with these extrapolative thinkers is that they only use the spoken principles, not any unspoken ones that might seem too obvious to mention.\nAn attribute of solutions to optimization problems is that the feature vector is often 'extreme' in some way. In linear programming, at least one vertex of the feasible solution space will be optimal, and so simple solution methods find an optimal vertex (which is almost infeasible by nature of being a vertex).\nAs another example, the minimum-fuel solution for moving a spacecraft from one position to another is called 'bang-bang,' where you accelerate the craft as quickly as possible at the beginning and end of the trajectory, coasting at maximum speed in between.\nWhile a virtue when the system is correctly understood (bang-bang is optimal for many cases), this is catastrophic when the system is incorrectly understood. My favorite example here is Dantzig's diet problem (discussion starts on page 5 of the pdf), where he tries to optimize his diet using math. Under his first constraint set, he's supposed to drink 500 gallons of vinegar a day. Under his second, 200 bouillon cubes. Under his third, two pounds of bran. The considerations that make those obviously bad ideas aren't baked into the system, and so the system innocently suggests them.\nIf you can completely encode the knowledge and values that a person uses to judge these plans into the AI, then extrapolative systems are as safe as that person. They'll be able to consider and reject the wrong sort of extreme plans, and leave you with the right sort of extreme plans.\nBut if you can't, then it does make sense to not build an extrapolative decision-maker, and instead build an interpolative one. That is, instead of asking itself \"how do I best accomplish goal X?\" it's asking itself \"what would a person do in this situation?\". The latter might be much worse at accomplishing goal X, but it has much less of the tail risk of sacrificing other goals to accomplish X.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is anybody still using Conceptual Dependency Theory? Roger Schank did some interesting work on language processing with Conceptual Dependency (CD) in the 1970s. He then moved somewhat out of the field, being in Education these days. There were some useful applications in natural language generation (BABEL), story generation (TAILSPIN) and other areas, often involving planning and episodes rather than individual sentences.\nHas anybody else continued to use CD or variants thereof? I am not aware of any other projects that do, apart from Hovy's PAULINE, which uses CD as representation for the story to generate.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Is anybody still using Conceptual Dependency Theory?\nYes. Many people. Conceptual dependencies are central to the conveyance of ideas in natural language.\nHere are just a few publications in this century building off of Schank's work or travelling in parallel with his direction in related fields.\n\nhttps://www.mitpressjournals.org/doi/pdf/10.1162/coli.2010.36.1.36105\nhttps://ubir.buffalo.edu/xmlui/bitstream/handle/10477/34469/2001-09.pdf\nhttp://leibnizcenter.org/~sileno/articles/ICAART2014.pdf\nhttp://publicservicesalliance.org/wp-content/uploads/2013/05/narrative-its-2008.pdf\nhttps://www.semanticscholar.org/paper/Modelling-the-way-mathematics-is-actually-done-Corneli-Martin/0787aa70bbfb3620e1a5ddf2a2f34df99dc1f6ac\nhttp://sentic.net/senticnet-5.pdf\n\nI met Roger Schank in Hartford, in 1992, during a lecture series sponsored by the AI labs of United Technologies Research Center and a few other Fortune 500 companies in the region. His entire lecture was a series of stories in AI research. I remember every story 26 years later.\nThe toy NLP implementations you see in the field today pale in comparison with the story based reasoning and memory systems proposed by Dr. Schank as a probable explanation of observations that can be made about human vocal communications. \nIt is easy to guess the reason he moved into education. His natural language and artificial intelligence ideas were about a century early and over the heads of most of the people that were at the lecture alongside me.\nIf you and I find his story-based reasoning and memory proposals compelling, we are probably a century too early and a bit over the heads of most in the present day NLP field. Most of those in labs in the 1980s found Schank irritating, and people who fit comfortably into today's technology culture find him irrelevant.\nSome of those I interacted with on a project from the University of Michigan in Ann Arbor don't find his work irrelevant though, and their work is in the directions he indicated. Unfortunately the client NDA restricts me from commenting further about that project.\nThe reason we should not and ultimately will not abandon the idea that we communicate in stories is because it is correct. When a person says, \"It makes me want to puke,\" or, \"I love you too,\" the direct parse of those sentences using \"modern\" techniques are not closely related to a correct reconstruction of the idea in the mind of the speaker. Both sentences reference a conceptual heap of interdependence that we call a story.\nIf two \"party girls\" are in the ladies room at a Borgore concert and one says, \"Hand me a roll,\" the interpretation of the word, \"roll,\" is conceptually dependent. If the speaker is in a stall it means one thing. If at the sink it means another.\nThere will always be some segment of the research community that understands this. Those that do not may construct money-saving automatons that will answer your business's phone calls, but they will not give you a heads up on a customer relations pattern that points to a policy issue.\nThese toy NLP agents, until they develop the capabilities Dr. Schank proposed, will not recognize from phone conversations with clients that a product or service enhancement is an opportunity waiting to be exploited, and they won't tell you a story that will convince you that you would benefit from being the first to capitalize on the opportunity.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can you train a neural network by simply giving it ratings each time it runs? I am currently trying to train a bot for a game I am creating. It is a 2d game with a complex map made of various shapes. The bot and character shoot bullets that are capable of ricocheting. The neural network outputs a vector in which the bot will turn and then fire. I myself cannot calculate the correct trajectory and find the Loss of the network. But, I can give a rating on how well the neural network performs when it fires. Can I train it by simply giving it a rating, and if, how so?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, this is a stereotypical reinforcement learning problem. Instead of trying to calculate the dynamics of the environment the agent is given a reward or punishment for its behavior in the environment (shooting an enemy, etc). The training process tries to find a policy to maximize the reward signal. It\u2019s a rather deep field and a bit much for a single post. Maybe try reading one or two papers on Deep Q Network (DQN) or Proximal policy optimization (PPO) and see if either can be formulated in a way to work for your problem.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can non-differentiable layer be used in a neural network, if it's not learned? For example, AFAIK, the pooling layer in a CNN is not differentiable, but it can be used because it's not learning. Is it always true?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It is not possible to backpropagate gradients through a layer with non-differentiable functions. However, the pooling layer function is differentiable*, and usually trivially so.\nFor example:\n\nIf an average pooling layer has inputs $z$ and outputs $a$, and each output is average of 4 inputs then $\\frac{da}{dz} = 0.25$ (if pooling layers overlap it gets a little more complicated, but you just add things up where they overlap). \nA max pooling layer has $\\frac{da}{dz} = 1$ for the maximum z, and $\\frac{da}{dz} = 0$ for all others.\n\nA pooling layer usually has no learnable parameters, but if you know the gradient of a function at its outputs, you can assign gradient correctly to its inputs using the chain rule. That is essentially all that back propagation is, the chain rule applied to the functions of a neural network.\nTo answer your question more directly:\n\nCan non-differentiable layer be used in a neural network, if it's not learned?\n\nNo. \nThere is one exception: If this layer appears directly after the input, then as it has no parameters to learn, and you generally do not care about the gradient of the input data, so you can have a non-differentiable function there. However, this is just the same as transforming your input data in some non-differentiable way, and training the NN with that transformed data instead.\n\n* Technically there are some discontinuities in the gradient of a max function (where any two inputs are equal). However, this is not a problem in practice, as the gradients are well behaved close to these values. When you can safely do this or not is probably the topic of another question.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is plain autoencoder a generative model? I am wondering how a plain auto encoder is a generative model though its version might be but how can a plain auto encoder can be generative. I know that Vaes which is a version of the autoencoder is generative as it generates distribution for latent variables and whole data explicitly. But I am not able to think how an autoencoder generates probability distribution and becomes a generative model.\nAlso from this youtube video: here It says plain auto encoder is not a generative model. See last line from picture.\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "An autoencoder is not considered a generative model, because it only reconstructs the given input. You could use the decoder like a generative model by putting in different vectors. However, the standard autoencoder mostly learns a sparse latent space. This means that you will have distinct clusters in the latent space (see the left image below). The decoder has never learned to reconstruct vectors in between the clusters, so it will produce very abstract things - mostly garbage.\nInstead a variational autoencoder (VAE) is considered a generative model. It's basically an autoencoder with a modified bottleneck. This VAE learns a dense latent space (see image on the right), this means you can sample any vector from the latent space, pass it to the model and it will give you a nice result with somewhat interpolated object properties from the dataset.\nThis article provides a nice overview of the two models.\n\nFigure taken from here\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Have any AI systems yet been developed that can knowingly lie to / deceive a human? AI systems today are very capable machines, and recently the area of Natural Language Processing and Response has been exploding with innovation, as well as the fundamental algorithmic structure of AI machines.\nI am asking if, given these recent breakthroughs, have any AI systems been developed that are able to (preferably with some measure of success) knowingly lie to humans about facts that it knows?\nNote, what I'm asking goes beyond the canonical discussions of the Turing Test. I'm asking of machines that can 'understand' facts and then formulate a lie against this fact, perhaps using other facts to produce a believable 'cover-up' as part of the lie.\nE.G.: CIA supercomputer is stolen by spies and they try to use the computer to do things, but the computer keeps saying it's missing dependencies though it really isn't or gives correct-looking but wrong answers knowingly. Or gives incorrect location of a person, knowing that the person frequents some place but isn't there at the moment. Doesn't have to be this sophisticated, of course.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The Saturday Papers: Would AI Lie To You? is a blog post summarizing a research paper called Toward Characters Who Observe, Tell, Misremember, and Lie. This research paper details some researchers' plans to implement \"mental models\" for NPCs in video games. NPCs will gather information about the world, and convey that knowledge to other people (including human players). However, they will also \"misremember\" that knowledge (either \"mutating\" that knowledge or just forgetting about it), or even lie:\n\nAs a subject of conversation gets brought up, a character may convey false information\u2014more precisely, information that she herself does not believe\u2014to her interlocutor. Currently, this happens probabilistically according to a character\u2019s affinity toward the interlocutor, and the misinformation is randomly chosen.\n\nLater on in the research paper, they detailed their future plans for lying:\n\nCurrently, lies are only stored in the knowledge of characters who receive them, but we plan to have characters who tell them also keep track of them so that they can reason about past lies when constructing subse- quent ones. While characters currently only lie about other characters, we plan to also implement self-centered lying (DePaulo 2004), e.g., characters lying about their job titles or relationships with other characters. Finally, we envision characters who discover they have been lied to revising their affinities toward the liars, or even confronting them.\n\nThe research paper also detailed how other video game developers attempted to create lying NPCs, with an emphasis on how their system differs:\n\nTALE-SPIN characters may lie to one another (Meehan 1976, 183-84), though rather arbitrarily, as in our current system implementation. GOLEM implements a blocks world variant in which agents deceive others to achieve goals (Castelfranchi, Falcone, and De Rosis 1998), while Mouth of Truth uses a probabilistic representation of character belief to fuel agent deception in a variant of Turing\u2019s imitation game (De Rosis et al. 2003). In Christian (2004), a deception planner injects inaccurate world state into the beliefs of a target agent so that she may unwittingly carry out actions that fulfill ulterior goals of a deceiving agent. Lastly, agents in Reis\u2019s (2012) extension to FAtiMA employ multiple levels of theory of mind to deceive one another in the party game Werewolf. While all of the above systems showcase characters who perceive\u2014and in some cases, deceive\u2014other characters, none appear to support the following key components of our system: knowledge propagation and memory fallibility. ...\nLike a few other systems noted above, Dwarf Fortress also features characters who autonomously lie. When a character commits a crime, she may falsely implicate someone else in a witness report to a sheriff, to protect herself or even to frame an enemy. These witness reports, however, are only seen by the player; characters don\u2019t give false witness reports to each other. They may, however, lie about their opinions, for instance, out of fear of repercussions from criticizing a leader. Finally, Dwarf Fortress does not currently model issues of memory fallibility\u2014Adams is wary that such phenomena would appear to arise from bugs if not artfully expressed to the player.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the reward in reinforcement learning always a scalar? I'm reading Reinforcement Learning by Sutton & Barto, and in section 3.2 they state that the reward in a Markov decision process is always a scalar real number. At the same time, I've heard about the problem of assigning credit to an action for a reward. Wouldn't a vector reward make it easier for an agent to understand the effect of an action? Specifically, a vector in which different components represent different aspects of the reward. For example, an agent driving a car may have one reward component for driving smoothly and one for staying in the lane (and these are independent of each other).\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "If you have multiple types of rewards (say, R1 and R2), then it is no longer clear what would be the optimal way to act: it can happen that one way of acting would maximize R1 and another way would maximize R2. Therefore, optimal policies, value functions, etc., would all be undefined. Of course, you could say that you want to maximize, for example, R1+R2, or 2R1+R2, etc. But in that case, you're back at a scalar number again.\nIt can still be helpful for other purposes to split up the reward into multiple components as you suggest, e.g., in a setup where you need to learn to predict these rewards. But for the purpose of determining optimal actions, you need to boil it down into a single scalar.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the differences between an agent and a model? In the context of Artificial Intelligence, sometimes people use the word \"agent\" and sometimes use the word \"model\" to refer to the output of the whole \"AI-process\". For examples: \"RL agents\" and \"deep learning models\".\nAre the two words interchangeable? If not, in what case should I use \"agents\" instead of \"models\" and vice versa?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Agent\nThe other answer defines an agent as a policy (as it's defined in reinforcement learning). However, although this definition is fine for most current purposes, given that currently agents are mainly used to solve video games, in the real world, an intelligent agent will also need to have a body, which Russell and Norvig call an architecture (section 2.4 of the 3rd edition of Artificial Intelligence: A Modern Approach, page 46), which should not be confused with an architecture of a model or neural network, but it's the computing device that contains the physical sensors and actuators for the agent to sense and act on the environment, respectively. So, to be more general, the agent is defined as follows\n\nagent = body + policy (brain)\n\nwhere the policy is what Russell and Norvig call the agent program, which is an implementation of the agent function.\nAlternatively, it can be defined as follows\n\nAn agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment through actuators.\n\nThis is just another definition given by Russell and Norvig, which I also report in this answer, where I describe different types of agents. Note that these definitions are equivalent. However, in the first one, we just emphasize that we need some means to \"think\" (brain) and some means to \"behave\" (body).\nThese definitions are quite general, so I think people should use them, although, as I said above, sometimes people refer to an agent as just the policy.\nModel\nIn this answer, I describe what a model is or what I like to think a model is, and how it is different from a function.\nIn AI, a model can refer to different but somehow related concepts.\n\nFor example, in reinforcement learning, a model typically refers to $p(s', r \\mid s, a)$, i.e. the joint probability distribution over the next state $s'$ and reward $r$, given the current state $s$ and action $a$ taken in $s$.\n\nIn deep learning, a model typically refers to a neural network, which can be used to compute (or model) different functions. For example, a neural network can be used to compute/represent/model a policy, so, in this case, there would be no actual difference between a model and an agent (if defined as a policy, without a body). However, conceptually, at a higher-level, these would still be different (in the same way that biological neural networks are different from the brain).\n\nMore generally, in machine learning, a model typically refers to a system that can be changed to compute some function. Examples of models are decision trees, neural networks, linear regression models, etc. So, as I also state in the other answer, I like to think of a model as a set of functions, so, in this sense, a model would be a hypothesis class in computational learning theory. This definition is roughly consistent with $p(s', r \\mid s, a)$, which can also be thought of as a (possibly infinite) set of functions, but note that a probability distribution is not exactly a set of functions.\n\nIn the context of knowledge bases, a model is an assignment to the variables, which represents a \"possible world\". See section 7.3, page 240, of the cited book.\n\n\nThere are possible other uses of the word model (both in the context of AI, e.g. in the context of planning, there's often the idea of a conceptual model, which is similar to an MDP in RL, and in other areas), but the definitions given above should be more or less widely applicable in their contexts.\nWhat is the difference between an agent and a model?\nGiven that there are different possible definitions of a model depending on the context, it's not easy to briefly state what the difference between the two is.\nSo, here's the difference in the context of RL (and you can now find out the differences in other contexts by using the different definitions): an agent can have a model of the world, which allows it to predict e.g. the reward it will receive given its current state and some action that it decides to take. The model can allow the agent to plan. In this same context, a model could also refer to the specific system (e.g. a neural network) used to compute/represent the policy of the agent, but note that people usually refer to $p(s', r \\mid s, a)$ when they use the word model in RL. See this post for more details.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How close are we to creating Ex Machina? Are there any research teams that attempted to create or have already created an AI robot that can be as close to intelligent as these found in Ex Machina or I, Robot movies?\nI'm not talking about full awareness, but an artificial being that can make its own decisions and physical and intellectual tasks that a human being can do?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "We are absolutely nowhere near, nor do we have any idea how to bridge the gap between what we can currently do and what is depicted in these films.\nThe current trend for DL approaches (coupled with the emergence of data science as a mainstream discipline) has led to a lot of popular interest in AI.\nHowever, researchers and practitioners would do well to learn the lessons of the 'AI Winter' and not engage in hubris or read too much into current successes.\nFor example:\n\nSuccess in transfer learning is very limited. \nThe 'hard problem' (i.e. presenting the 'raw, unwashed environment' to the machine and having it come up with a solution from scratch) is not being\naddressed by DL to the extent that it is popularly portrayed: expert human knowledge is still required to help decide how the input should be framed, tune parameters, interpret output etc.\n\nSomeone who has enthusiasm for AGI would hopefully agree that the 'hard problem' is actually the only one that matters. Some years ago, a famous cognitive scientist said \"We have yet to successfully represent even a single concept on a computer\". \nIn my opinion, recent research trends have done little to change this.\nAll of this perhaps sounds pessimistic - it's not intended to. None of us want another AI Winter, so we should challenge (and be honest about) the limits of our current techniques rather than mythologizing them.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can an AI make a constructed (natural) language? According to Wikipedia\n\nAn artificial or constructed language (sometimes called a conlang) is a language that has been created by a person or small group, instead of being formed naturally as part of a culture.\n\nMy question is, could an AI make/construct its own natural language, with words, conjugations, and grammar rules? Basically, a language that humans could use to speak to each other. (Preferably to communicate abstract, high-level concepts.)\nWhat techniques could such an AI use? Could it be based on existing natural languages or would it have few connections to existing natural languages? Could it design a language that's easier to learn than existing languages (even Esperanto)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\ncould an AI make/construct its own natural language, with words, conjugations, and grammar rules?\n\nSure. This might be helpful: Simulated Evolution of Language: a Review of the Field\n\nBasically, a language that humans could use to speak to each other.\n(Preferably to communicate abstract, high-level concepts.)\n\nI'm not sure how useful such a machine adapted language would be to human speech. I suspect not very. Perhaps it could be useful as a kind of \"common byte-code format\" to translate between multiple human languages... But English kind of already serves in that role. Doing so would probably be an academic exercise.\n\nCould it be based on existing natural languages or would it have few\nconnections to existing natural languages?\n\nYou could probably generate languages in either direction. Languages not linked to human-natural languages will probably take shapes that reflect the problem spaces they work with. For instance, if this is an ant simulation, the generated words will probably reflect states related to food, energy, other ants, etc.\n\nCould it design a language that's easier to learn than existing\nlanguages (even Esperanto)?\n\nEasier for a machine? Definitely. Easier for a human? Probably not. Our brains are somewhat adapted to the languages we use. And the languages we use are somewhat adapted to our brains.\nWhat is your goal? To create a language that is easier to use for humans than existing human languages?\nIf your intention is to build a \"universal language\" that could be \"the most efficient\" for machines, humans and aliens - no such thing can exist. The space of all possible machines is infinite and therefore limits our ability to define communicative abstractions that have utility across all contexts.\nIf we make lots of assumptions about machines, like they have intentions, they exist in 3 dimensions, they differentiate between temporally linked events, they have eyeballs, a need to consume foods and liquids, a need to carry the food from place to place, etc... Then yes, common communicative abstractions may have utility across the set of those kinds of machines. But then we're no longer dealing with the general case, but one much more specific.\nThese links also seem interesting and somewhat related:\n\nGrammar Induction and Genetic Algorithms: An Overview. [pdf]\nA Model of Children's Acquisition of Grammatical Word Categories Using an Adaptation and Selection Algorithm [pdf]\nThe processing of verbs and nouns in neural networks: insights from synthetic brain imaging\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How important is consciousness for making advanced artificial intelligence? How important is consciousness and self-consciousness for making advanced AIs? How far away are we from making such?\nWhen making e.g. a neural network there's (very probably) no consciousness within it, but just mathematics behind, but do we need the AIs to become conscious in order to solve more complex tasks in the future? Furthermore, is there actually any way we can know for sure if something is conscious, or if it's just faking it? It's \"easy\" to make a computer program that claims it's conscious, but that doesn't mean it is (e.g. Siri).\nAnd if the AIs are only based on predefined rules without consciousness, can we even call it \"intelligence\"?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Artificial consciousness is a challenging theoretical and engineering objective. Once that major challenge is met, the computer's conscious awareness of itself would likely be a minor addition, since the conscious computer is just another object of which its consciousness can be aware.\nA child can look in the mirror and recognize that moving their hands back and forth or making faces produces corresponding changes in the reflection. They recognize themselves. Later on they realize that exerting physical control over their own movement is much easier than exerting control over another person's hands or face.\nSome learn that limited control of the faces and manual operations of others is possible if certain social and economic skills are mastered. They become employers, landlords, investors, activists, writers, directors, public figures, or entrepreneurs.\nAnyone who has studied the cognitive sciences or experienced the line between types of thought because they are a professional counselor or just a deep listener knows that the lines around consciousness are blurry. Consider these.\n\nListening to speech\nWatching a scene\nFocusing on a game\nPresenting an idea\nWashing up for work\nDriving a car\nChoosing a purchase\n\nAny one of these things can be done with or without certain kinds of consciousness, subconsciousness, impulse, or habit.\nSubjectively, people report getting out of the car and not recalling having driven home. One can listen to someone talking, nod in affirmation, respond with, \"Yeah, I understand,\" and even repeat what they said, and yet appear to have no memory of the content of the speech if queried in depth. One can read a paragraph and get to the end without comprehension.\nIn contrast, a person may mindfully wash up for work, considering the importance of hygiene and paying attention like a surgeon preparing for an operation, noticing the smell of the soap and even the chlorination of the city water.\nBetween those extremes, partial consciousness is also detectable by experiment and in personal experience. Consciousness most definitely requires attention functionality, which tentatively supervises the coordination of other brain-body sub-systems.\nOnce a biological or artificial system achieves the capacity to coordinate attentively, the objects and tasks toward which they can be coordinated can be interchanged. Consider these.\n\nDialog\nPlaying to win\nDetecting honesty or dishonesty\n\nNow consider how similar or different these mental activities are when we compare self-directed or externally directed attention.\n\nOne can talk to one's self or talk to another\nOne can play both sides of a chess game or play against another\nOne can scrutinize one's own motives or those of another\n\nThis is an illustration why the self- part of self-consciousness is not the challenge in AI. It is the attentive (yet tentative) coordination that is difficult. Early microprocessors, designed to work in real time control systems, included (and still include) exception signaling that simplistically models this tentativeness. For instance, while playing to win in a game, one might try to initiate dialog with the subject. Attention may shift when the two activities require the same sub-systems.\nWe tend to consider this switching of attention consciousness too. If we are the person trying to initiate dialog with the person playing to win, we might say, \"Hello?\" The question mark is because we are wondering if the player is conscious.\nIf one was to diminish the meaning of consciousness to the most basic criteria, one might say this.\n\n\"My neural net is intelligent in some small way because it is conscious of the disparity between my convergence criteria and the current behavior of the network as it is parametrized, so it is truly an example of artificial intelligence, albeit a primitive one.\"\n\nThere is nothing grossly incorrect about that statement. Some have called that, \"Narrow Intelligence.\" That is a slightly inaccurate characterization, since there may be an astronomical number of possible applications of an arbitrarily deep artificial network that uses many of the most effective techniques available in its design.\nThe other problem with narrowness as a characterization is the inference that there are intelligent systems that are not narrow. Every intelligent system is narrow compared to a more intelligent system. Consider this thought experiment.\n\nHannah writes a paper on general intelligence with excellence, both in theoretical treatment and in writing skill. Many quote it and reference it. Hannah is now so successful in her AI career that she has the money and time to build a robotic system. She bases its design on her now famous paper and spares no expense. \nTo her surprise, the resulting robot is so adaptive that its adaptability exceeds even himself. She names it Georgia Tech for fun because she lives near the university. \nGeorgia becomes a great friend. She learns at an incredible rate and is a surprisingly great housemate, cleaning better than Hannah thought humanly possible, which may be literally true.\nGeorgia applies to Georgia Tech, just down the bus line from Hannah's house and studies artificial intelligence there. Upon the achievement of a PhD after just three years of study, Georgia sits with Hannah after a well attended Thesis Publication party that Hannah graciously held for her.\nAfter the last guest leaves, there is a moment of silence as Hannah realizes the true state of her household. She thinks, \"Will Georgia now exceed me in her research?\" Hannah finally, sheepishly asks, \"In complete honesty, Georgia, do you think you are now a general intelligence like me?\"\nThere is a pause. With a forced look of humility, Georgia replies, \"By your definition of general intelligence, I am. You are no longer.\"\n\nWhether this story becomes true in 2018, 3018, or never, the principle is clear. Georgia is just as able to analyze herself comparatively with Hannah as Hannah is similarly able. In the story, Georgia applies the definition created in Hannah's paper because Georgia is now able to conceive of many definitions of intelligence and chooses Hannah's as the most pertinent in the context of the conversation.\nNow imagine this alteration to the story.\n\n... She thinks, at what level is Georgia thinking? Hannah finally, sheepishly asks, \"In complete honesty, Georgia, are you now as conscious as me?\"\nGeorgia thinks through the memory of all uses of the word conscious in her past studies \u2014 a thousand references in cognitive science, literature, law, neurology, genetics, brain surgery, treatment of brain injury, and addiction research. She pauses for a few microseconds to consider it all thoroughly, while at the same time sensing her roommates body temperature, neuro-chemical balances, facial muscle motor trends, and body language.\nRespectfully, she waits 3.941701 extra seconds, which she calculated as the delay that would minimize any humiliation to Hannah, whom she loves, and replies, \"Conscious of what?\"\n\nIn Georgia's reply may be a hypothesis of which Hannah may or may not be aware. For any given automatons, $a, b, \\ldots$, given consciousness, $C$, of a scenario $s$, we have a definition, $\\Phi_c$ that can be applied to evaluate the aggregate of all aspects of consciousness of any of the automations, $x$, giving $\\Phi_c(C_x(s))$. Georgia's (apparently already proven) hypothesis is thus.\n\n$\\forall \\Phi_c(C_a(s)) \\;\\;\\; \\exists \\;\\;\\; b, \\, \\epsilon>0 \\;\\; \\ni \\;\\; \\Phi_c(C_b(s)) + \\epsilon > \\Phi_c(C_a(s))$\n\nThis is a mathematical way of saying that there can always be someone or some thing more conscious of a given scenario, whether or not she, he, or it is brought into existence. Changing the criteria of evaluation from consciousness to intelligence, we have thus.\n\n$\\forall \\Phi_i(C_a(s)) \\;\\;\\; \\exists \\;\\;\\; b, \\, \\epsilon>0 \\;\\; \\ni \\;\\; \\Phi_i(C_b(s)) + \\epsilon > \\Phi_i(C_a(s))$\n\nOne can only surmise that Hannah's paper defines general intelligence relative to what whatever is the smartest thing around, which was once well-educated human beings. Thus Hannah's definition of intelligence is dynamic. Georgia applies the same formula to the new situation where she is now the standard against which lesser intelligence is narrow.\nRegarding the ability to confirm consciousness, it is actually easier to confirm than intelligence. Consider this thought experiment.\n\nJack is playing chess with Dylan using the new chess set that Jack bought. In spite of the aesthetic beauty of this new set, with its white onyx and black agate pieces, Dylan moves each piece with prowess and checkmates Jack. Jack wonders if Dylan is more intelligent than him and asks what would be a normal question under those conditions.\n\"Dylan, buddy, how long have you been playing chess?\"\n\nRegardless of the answer and regardless whether Dylan is a robot with a quantum processor of advanced AI or a human being, the intelligence of Dylan cannot be reliably gauged. However, there is NO DOUBT that Dylan was conscious of the game play.\nIn the examples in the lists at the top of this answer there are a particular sets of requirements to qualify as consciousness. For the case of Jack and Dylan playing, a few things MUST working in concert.\n\nVisual recognition of the state of the board\nMotor control of the arm and hand to move pieces\nTactile detection in finger and thumb tips\nHand-eye cordination\nGrasp coordination\nA model of how to physically move board pieces\nA model of the rules of chess in memory\nA model of how to win when playing it (or astronomical computational power to try everything possible permutation that makes any sense)\nAn internal representation of the board state\nAttention execution, visually and in terms of the objective of winning\nPrioritization that decides, unrelated to survival odds or asset accumulation, whether to beat Jack in chess, do something else, or nothing (non-deterministic if the ancient and commonplace notion of the causal autonomy of the soul is correct)\n\nThe topology of connections are as follows, and there may be more.\n\n1 \u21c4 4 \u21c4 2\n3 \u21c4 5 \u21c4 2\n4 \u21c4 6 \u21c4 5\n7 \u21c4 8 \u21c4 9\n6 \u21c4 10 \u21c4 8\n10 \u21c4 11\n\nThis is one of many integration topologies that support one of many types of things to which consciousness might apply.\nWhether looking in the mirror just to prepare for work or whether looking deeply, considering the ontological question, \"Who am I?\" each mix of consciousness, subconsciousness, impulse, and habit require a specific topology of mental features. Each topology must be coordinated to form its specific embodiment of consciousness.\nTo address some other sub-questions, it is easy to make a machine that claims itself to be conscious a digital voice recorder can be programmed to do it in five seconds by recording yourself saying it.\nGetting a robot to read this answer or some other conception, consider it thoughtfully, and then construct the sentence from knowledge of the vocabulary and conventions of human speech to tell you its conclusion is an entirely different task. The development of such a robot may take 1,000 more years of AI research. Maybe ten. Maybe never.\nThe last question, switched from plural to singular is, \"If [an artificially intelligent device] is only [operating] on predefined rules, without consciousness, can we even call it intelligent?\" The answer is necessarily dependent upon definition $\\Phi_i$ above, and, since neither $\\Phi_c$ nor $\\Phi_i$ have a standard definition within the AI community, one can't determine the cross-entropy or correlation. It is indeterminable.\nPerhaps formal definitions of $\\Phi_c$ and $\\Phi_i$ can now be written and submitted to the IEEE or some standards body.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there a fundamental difference between an environment being stochastic and being partially observable? In AI literature, deterministic vs stochastic and being fully-observable vs partially observable are usually considered two distinct properties of the environment.\nI'm confused about this because what appears random can be described by hidden variables. To illustrate, take an autonomous car (Russel & Norvig describe taxi driving as stochastic). I can say the environment is stochastic because I don't know what the other drivers will do. Alternatively, I can say that the actions of the drivers are determined by their mental state which I cannot observe.\nAs far as I can see, randomness can always be modeled with hidden variables. The only argument I came up with as to why the distinction is necessary is Bell's inequality, but I don't think that AI researchers had this in mind.\nIs there some fundamental difference between stochasticity and partial observability or is this distinction made for practical reasons?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I think the distinction is made more for conceptual reasons, which has practical implications, so let me review the usual definitions of a stochastic and partially observable environment.\nA stochastic environment can be modeled as a Markov Decision Process (MDP) or Partially Observable MDP (POMDP). So, an environment can be\n\nstochastic and partially observable\nstochastic and fully observable\n\nThe stochasticity refers to the dynamics of the environment and, more specifically, to how the environment stochastically moves from one state to the other after an action is taken (basically, a Markov chain with actions and rewards). In other words, in a stochastic environment, we have the distribution $p(s' \\mid s, a)$ (or, in some cases, the reward is also included $p(s', r \\mid s, a)$). If $p(s' \\mid s, a)$ gave a probability of $1$ to one of the states and $0$ to all other states, we would have a deterministic environment.\nThe partial observability refers to the fact that we don't know in which state the agent is, so we can think of having or maintaining a probability distribution over states, like $b(s)$. So, in the case of POMDP, we not only are uncertain about what the next state $s'$ might be after we have taken $a$ in our current state $s$, but we are not even sure about what $s$ currently is.\nSo, the difference is made so that we can deal with uncertainties about different parts of the environment (dynamics and actual knowledge of the state). Think about a blind guy that doesn't have the full picture (I hope this doesn't offend anyone) and think about a guy that sees well. The guy that sees well still isn't sure about tomorrow (maybe this is not a good example as you can argue that this is also due to the fact that the guy that sees well doesn't know the full state, but I hope this gives you the intuition).\nOf course, this has practical implications. For example, it seems that you cannot directly apply the solutions that you use for MDPs to POMDPs. More precisely, for an MDP, if you learn the policy $\\pi(a \\mid s)$, i.e. a probability distribution over actions given states, if you don't know the state you are in, this policy is quite useless.\nTo deal with the uncertainty about the state the agent is in, in POMDPs, we also have the concept of an observation, which is the information that the agent gathers from the environment about the current state (e.g., in the example of a blind guy, the observations would be the sounds, touch, etc.), in order to update its belief about the current state. In practice, some people tried to apply the usual RL algorithms for MDPs to POMDPs (see e.g. DQN or this), but they made a few approximations, which turned out to be useful and successful.\nIf the difference wasn't still clear, just take a look at the equation that can be used to relate the belief state and the transition model (dynamics) of the environment\n$$\n\\underbrace{b^{\\prime}\\left(s^{\\prime}\\right)}_{\\text{Next belief state}}=\\alpha \\underbrace{P\\left(o \\mid s^{\\prime}\\right)}_{\\text{Probability of observation }o \\text{ given }s'} \\sum \\underbrace{P\\left(s^{\\prime} \\mid s, a\\right)}_{\\text{Transition}\\\\ \\text{model}} \\underbrace{b(s)}_{\\text{Previous belief state}}\n$$\nSo, in a POMDP, the policy, as stated above, in theory, cannot depend on $s$, but needs to depend on $b(s)$, the belief state, i.e. a probability distribution over states.\nIf this answer wasn't still satisfactory, although you probably already did it, you should read the section 2.3.2 Properties of task environments of the AIMA book (3rd edition). Their description of stochastic and partially observable environment seems to be consistent with what I wrote here, but maybe their description of a stochastic environment is not fully clear, because they say\n\nIf the next state of the environment is completely determined by the current state and the action executed by the agent, then we say the environment is deterministic; otherwise, it is stochastic\n\nThe unclear part is completely determined. They should have said deterministically determined (which you can use for a rap song).\nHowever, they later clarify their definition by saying\n\nour use of the word \"stochastic\" generally implies that uncertainty about outcomes is quantified in terms of probabilities\n\nIn addition to that, they call an environment that is either stochastic or partially observable uncertain. It makes sense to do this because uncertainty makes the problems harder, so we can differentiate between certain and uncertain environments.\nTo be honest, I don't know if there's some kind of mathematical formalism that doesn't differentiate between stochastic or partially observable environments, but I am not sure how useful it might be.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there any artificial intelligence that possesses \"concentration\"? Humans can do multiple tasks at the same (e.g. reading while listening to music), but we memorize information from less focused sources with worse efficiency than we do from our main focus or task.\nDo such things exist in the case of artificial intelligence? I doubt, for example, that neural networks have such characteristics, but I may be wrong.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Douglas Hofstadter's CopyCat architecture for solving letter-string analogy problems was deliberately engineered to maintain a semantically-informed notion of 'salience', i.e. given a variety of competing possibilities, tend to maintain interest in the one that is most compelling. Although the salience value of (part of) a solution is ultimately represented numerically, the means by which it determined is broadly intended to correspond (at least functionally) to the way 'selective attention' might operate in human cognition.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are hyper-heuristics, and how are they different from meta-heuristics? I wanted to know what the differences between hyper-heuristics and meta-heuristics are, and what their main applications are. Which problems are suited to be solved by hyper-heuristics?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "TL:DR: Hyper-heuristics are metaheuristics, suited for solving the same kind of optimization problems, but (in principle) affording a \"rapid prototyping\" approach for non-expert practitioners. In practice, there are issues with the prevailing approach, motivating an emerging perspective on 'whitebox' hyper-heuristics.\nIn more detail:\nMetaheuristics are methods for searching an intractably large space of possible solutions in order to find a 'high quality' solution. Popular metaheuristics include Simulated Annealing, Tabu Search, Genetic Algorithms etc.\nThe essential difference between metaheuristics and hyper-heuristics is the addition of a level of search indirection: informally, hyper-heuristics can be described as 'heuristics for searching the space of heuristics'. One can therefore use any metaheuristic as a hyper-heuristic, providing the nature of the 'space of heuristics' to be searched is appropriately defined.\nThe application area for hyper-heuristics is therefore the same as metaheuristics. Their applicability (relative to metaheuristics) is as a 'rapid prototyping tool': the original motivation was to allow non-expert practitioners to apply metaheuristics to their specific optimization problem (e.g. \"Travelling-Salesman (TSP) plus time-windows plus bin-packing\") without requiring expertise in the highly-specific problem domain. The idea was that this could be done by:\n\nAllowing practitioners to implement only very simple (effectively,\nrandomized) heuristics for transforming potential solutions. For\nexample, for the TSP: \"swap two random cities\" rather than (say) the more\ncomplex Lin-Kernighan heuristic. \nAchieve effective results (despite using these simple heuristics) by combining/sequencing them in an intelligent way, typically by employing some form of learning mechanism.\n\nHyper-heuristics can be described as 'selective' or 'generative' depending on whether the heuristics are (respectively) sequenced or combined. Generative hyper-heuristics thus often use methods such as Genetic Programming to combine primitive heuristics and are therefore typically customized by the practitioner to solve a specific problem. For example, the original paper on generative hyper-heuristics used a Learning Classifier System to combine heuristics for bin-packing. Because generative approaches are problem-specific, the comments below do not apply to them.\nIn contrast, the original motivator for selective hyper-heuristics was that researchers would be able to create a hyper-heuristic solver that was then likely to work well in an unseen problem domain, using only simple randomized heuristics.\nThe way that this has traditionally been implemented was via the introduction of the 'hyper-heuristic domain barrier' (see figure, below), whereby generality across problem domains is claimed to be achievable by preventing the solver from having knowledge of the domain on which it is operating. Instead, it would solve the problem by operating only on opaque integer indices into a list of available heuristics (e.g. in the manner of the 'Multi-armed Bandit Problem').\n\nIn practice, this 'domain blind' approach has not resulted in solutions of sufficient quality. In order to achieve results anywhere comparable to problem-specific metaheuristics, hyper-heuristic researchers have had to implement complex problem-specific heuristics, thereby failing in the goal of rapid prototyping.\nIt is still possible in principle to create a selective hyper-heuristic solver which is capable of generalizing to new problem domains, but this has been made more difficult since the above notion of domain barrier means that only a very limited feature set is available for cross-domain learning (e.g. as exemplified by a popular selective hyper-heuristic framework).\nA more recent research perspective towards 'whitebox' hyper-heuristics advocates a declarative, feature-rich approach to describing problem domains. This approach has a number of claimed advantages:\n\nPractitioners now need no longer implement heuristics, but rather simply specify the problem domain.\nIt eliminates the domain-barrier, putting hyper-heuristics on the same 'informed' status about the problem as problem-specific metaheuristics.\nWith a whitebox problem description, the infamous 'No Free Lunch' theorem (which essentially states that, considered over the space of all black box problems, Simulated Annealing with an infinite annealing schedule is, on average, as good as any other approach) no longer applies.\n\nDISCLAIMER: I work in this research area, and it is therefore impossible to remove all personal bias from the answer.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are there any decentralized examples of AI systems with blockchain technology? Has there been any attempts to deploy AI with blockchain technology? \nAre there any decentralized examples of AI networks with no central point of control with AI nodes acting independently (but according to a codified set of rules) creating, validating and storing the same shared decentralized database in many locations around the world?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Swarm intelligence is the term for systems where relatively simple agents work together to solve a complicated problem in a decentralized fashion.\nIn general, distributed computing methods are very important for dealing with problems at scale, and many of them embrace decentralization in a deep way. (Given the reality of hardware failure and the massive size of modern datasets relative to individual nodes, the less work is passed through a central bottleneck, the better.) \nWhile there are people interested in doing computation on the blockchain, it seems to me like it's unlikely to be competitive with computation in dedicated clusters (like AWS).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the main problems hindering current AI development? I have a background in Computer Engineering and have been working on developing better algorithms to mimic human thought. (One of my favorites is Analogical Modeling as applied to language processing and decision making.) However, the more I research, the more I realize just how complicated AI is.\nI have tried to tackle many problems in this field, but sometimes I find that I am reinventing the wheel or am trying to solve a problem that has already been proven to be unsolvable (ie. the halting problem). So, to help in furthering AI, I want to better understand the current obstacles that are hindering our progress in this field.\nFor example, time and space complexity of some machine learning algorithms is super-polynomial which means that even with fast computers, it can take a while for the program to complete. Even still, some algorithms may be fast on a desktop or other computer while dealing with a small data set, but when increasing the size of the data, the algorithm becomes intractable.\nWhat are other issues currently facing AI development?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nwe don't really know what intelligence is.\nwe don't truly understand the best model of intelligence we have available (human intelligence) works.\nwe're trying to replicate human intelligence (to some extent) on hardware which is quite different from the hardware it runs on in reality.\nthe human brain (our best model of intelligence) is mostly a black-box to us, and it's difficult to probe/introspect its operation without killing the test subject. This is, of course, unethical and illegal. So progress in understanding the brain is very slow. \n\nCombine those factors and you can understand why it's difficult to make progress in AI. In many ways, you can argue that we're shooting in the dark. Of course, we have made some progress, so we know we're getting some things right. But without a real comprehensive theory about how AI should/will work, we are reduced to a lot of trial and error and iteration to move forward.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are there any rules of thumb for having some idea of what capacity a neural network needs to have for a given problem? To give an example. Let's just consider the MNIST dataset of handwritten digits. Here are some things which might have an impact on the optimum model capacity:\n\nThere are 10 output classes\nThe inputs are 28x28 grayscale pixels (I think this indirectly affects the model capacity. eg: if the inputs were 5x5 pixels, there wouldn't be much room for varying the way an 8 looks)\n\nSo, is there any way of knowing what the model capacity ought to be? Even if it's not exact? Even if it's a qualitative understanding of the type \"if X goes up, then Y goes down\"?\nJust to accentuate what I mean when I say \"not exact\": I can already tell that a 100 variable model won't solve MNIST, so at least I have a lower bound. I'm also pretty sure that a 1,000,000,000 variable model is way more than needed. Of course, knowing a smaller range than that would be much more useful!\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Theoretical results\nRather than providing a rule of thumb (which can be misleading, so I am not a big fan of them), I will provide some theoretical results (the first one is also reported in paper How many hidden layers and nodes?), from which you may be able to derive your rules of thumb, depending on your problem, etc.\nResult 1\nThe paper Learning capability and storage capacity of two-hidden-layer feedforward networks proves that a 2-hidden layer feedforward\nnetwork ($F$) with $$2 \\sqrt{(m + 2)N} \\ll N$$ hidden neurons can learn any $N$ distinct samples $D= \\{ (x_i, t_i) \\}_{i=1}^N$ with an arbitrarily small error, where $m$ is the required number of output neurons. Conversely, a $F$ with $Q$ hidden neurons can store at least $\\frac{Q^2}{4(m+2)}$ any distinct data $(x_i, t_i)$ with\nany desired precision.\nThey suggest that a sufficient number of neurons in the first layer should be $\\sqrt{(m + 2)N} + 2\\sqrt{\\frac{N}{m + 2}}$ and in the second layer should be $m\\sqrt{\\frac{N}{m + 2}}$. So, for example, if your dataset has size $N=10$ and you have $m=2$ output neurons, then you should have the first hidden layer with roughly 10 neurons and the second layer with roughly 4 neurons. (I haven't actually tried this!)\nHowever, these bounds are suited for fitting the training data (i.e. for overfitting), which isn't usually the goal, i.e. you want the network to generalize to unseen data.\nThis result is strictly related to the universal approximation theorems, i.e. a network with a single hidden layer can, in theory, approximate any continuous function.\nModel selection, complexity control, and regularisation\nThere are also the concepts of model selection and complexity control, and there are multiple related techniques that take into account the complexity of the model. The paper Model complexity control and statistical learning theory (2002) may be useful. It is also important to note regularisation techniques can be thought of as controlling the complexity of the model [1].\nFurther reading\nYou may also want to take a look at these related questions\n\nHow to choose the number of hidden layers and nodes in a feedforward neural network?\n\nHow to estimate the capacity of a neural network?\n\n\n(I will be updating this answer, as I find more theoretical results or other useful info)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is wrong with the idea that the AI will be capable of omniscience? In the context of artificial intelligence, the singularity refers to the advent of an artificial general intelligence capable of recursive self-improvement, leading to the rapid emergence of artificial superintelligence (ASI), the limits of which are unknown, shortly after technological singularity is achieved. Therefore, these superintelligences would be able to solve problems that we possibly are unable to solve.\nAccording to a poll reported in Future progress in artificial intelligence: A survey of expert opinion (2014)\n\nThe median estimate of respondents was for a one in two chance that highlevel machine intelligence will be developed around 2040-2050\n\nwhich isn't very far away.\nWhat is wrong with the idea that the AI will be capable of omniscience, given that it could benefit us by solving many problems?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I quite like your outlook, and without getting into the details of how a \"singularity\" may be effected which is covered in numerous other questions, or how consciousness and \"omniscience\" come into play because consciousness and omniscience are not requirements, I will instead direct you to two key philosophers:\n\nPhillip K. Dick, for whom the central theme in his famous 1968 book on AI is empathy. (If you haven't read it, I'm not posting a spoiler, but will only say the plot is driven by the concept of Evolutionary Game Theory which was formalized just 5 years later.) \nJohn Nash, and in particular, the concept of the Nash Equilibrium. (Nash could be said to have mathematically demonstrated that being a \"douchebag\" is not an optimal strategy. His proof can be used to explain why nuclear d\u00e9tente actually worked, which was counter to the expectation of Von Neumann.) \n\nSo when people go nuts, focusing on the \"Skynet\" mythos under which machines rise up to destroy us, I have to wonder if they're simply not as smart as Nash or as profound as Dick, which might explain their lack of emphasis on what can be called the \"Electric Sheep\" paradigm.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does it mean for a neuron in a neural network to be activated? I just stumbled upon the concept of neuron coverage, which is the ratio of activated neurons and total neurons in a neural network. But what does it mean for a neuron to be \"activated\"? I know what activation functions are, but what does being activated mean e.g. in the case of a ReLU or a sigmoid function?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A neuron is said activated when its output is more than a threshold, generally 0.\nFor examples :\n\\begin{equation}\ny = Relu(a) > 0\n\\end{equation}\nwhen \n\\begin{equation}\na = w^Tx+b > 0\n\\end{equation}\nSame goes for sigmoid or other activation functions.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can someone explain R1 regularization function in simple terms? I'm trying to understand the R1 regularization function, both the abstract concept and every symbol in the formula.\nAccording to the article, the definition of R1 is:\n\nIt penalizes the discriminator from deviating from the Nash Equilibrium via penalizing the gradient on real data alone: when the generator distribution produces the true data distribution and the discriminator is equal to 0 on the data manifold, the gradient penalty ensures that the discriminator cannot create a non-zero gradient orthogonal to the data manifold without suffering a loss in the GAN game.\n$R_1(\\psi ) = \\frac{\\gamma}{2}E_{pD(x)}\\left [ \\left \\| \\bigtriangledown D_{\\psi}(x) \\right \\|^2 \\right ]$\n\nI have basic understanding of how GAN's and back-propagation works. I understand the idea of punishing the discriminator when he deviates from the Nash equilibrium. The rest of it gets murky, even if it might be basic math. For example, I'm not sure why it matters if the gradient is orthogonal to the data.\nOn the equation part, it's even more unclear. The discriminator input is always an image, so I assume $x$ is an image. Then what is $\\psi$ and $\\gamma$?\n(I understand this is somewhat of a basic question, but seems there are no blogs about it for us simple non-researchers, math challenged people who fail to understand the original article )\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Here is how I understand this regularization (updated).\n$R_1$ is simply the norm of the gradients w.r.t. to the real data (gradients indicate the direction and magnitude by which the weight should be updated during training). So, $R_1$ prevents large weights update for the discriminator if it has high gradients on real data, effectively smoothing its decision boundary around the real data points.\n$$\nR_{1}\\left(\\psi\\right) = \\frac{\\gamma}{2}E_{p_{D}\\left(x\\right)}\\left[||\\nabla{D_{\\psi}\\left(x\\right)}||^{2}\\right]\\text{,}\n$$\nwhere $\\psi$ is discriminator weights, $E_{p_{D}\\left(x\\right)}$ means that we sample data only from the real distribution (i.e. only real images) and $\\gamma$ is a hyperparameter.\nThe intuition is that we want the discriminator's output to be minimally sensitive to small changes in the real data distribution. This helps prevent overfitting to particular noise in the training data. It encourages the discriminator to be less confident overall, thus indirectly helping the generator to improve by preventing the discriminator from becoming too perfect too quickly (a very confident discriminator is a known problem for KL-loss).\nThe authors also investigate which value is best for $\\gamma$ by analyzing the eigenvalues of the Jacobian of the associated gradient vector field, but in my opinion, this value is highly dependent on the dataset and architecture.\nWhen we say \"gradient orthogonal to the data manifold,\" we are referring to changes in the discriminator's parameters that would affect its decision-making process in ways that are not along the data manifold. Since the data manifold represents the set of points in the high-dimensional space that corresponds to real data, gradients in directions orthogonal to this manifold don't improve the discriminator's ability to classify the real data correctly; such gradients might signify overfitting or instability in training.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the time complexity of the forward pass algorithm of a feedforward neural network? How do I determine the time complexity of the forward pass algorithm of a feedforward neural network? How many multiplications are done to generate the output?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Let's suppose that we have an MLP with $15$ inputs, $20$ hidden neurons and $2$ output neurons. The operations performed are only in the hidden and output neurons, given that the input neurons only represent the inputs (so they do not perform any operation).\nEach hidden neuron performs a linear combination of its inputs followed by the application of a non-linear (or activation) function. So, each hidden neuron $j$ performs the following operation\n\\begin{align}\no_j = \\sigma \\left(\\sum_{i}^{15} w_{ij}x_i \\right),\\tag{1}\\label{1}\n\\end{align}\nwhere $i$ is the input coming from the input neuron $i$, $w_{ij}$ is the weight of the connection from the input neuron $i$ to the hidden neuron $j$, and $o_j$ is used to denote the output of neuron $j$. \nThere are $20$ hidden neurons and, for each of them, according to equation $\\ref{1}$, we perform $15$ multiplications (ignoring any multiplications that might be associated with the activation function), so $15*20 = 300$ multiplications are performed at the (only) hidden layer. In general, if there are $n$ inputs and $m$ hidden neurons, then $n*m$ multiplications will be performed in the first hidden layer.\nNow, each neuron $j$ at the next layer (in this case, the output layer), also performs a linear combination followed by the application of an activation function\n\\begin{align}\no_j = \\tau \\left(\\sum_{i}^{20} w_{ij}x_i \\right),\\tag{2}\\label{2}\n\\end{align}\nwhere $\\tau$ is another activation function which might or not be equal to $\\sigma$, but we ignore all multiplications that might involve the application of the activation functions (we just want to count the ones in the linear combinations). Of course, in this case, $x_i$ corresponds to the activation of neuron $i$ (of the hidden layer).\nSimilarly to the previous reasoning, there are $2$ output neurons and, to compute the output of each of them, $20$ multiplications are performed (in the linear combination), so there are a total of $2*20 = 40$ multiplications at the output layer. \nSo, an MLP with $15$ inputs, $20$ hidden neurons and $2$ output neurons will perform $15*20 + 20*2 = 340$ multiplications (excluding activation functions). Of course, in this case, the number of multiplication depends not only on the number of neurons but also on the input size.\nIn general, an MLP with $n$ inputs, $M$ hidden layers, where the $i$th hidden layer contains $m_i$ hidden neurons, and $k$ output neurons will perform the following number of multiplications (excluding activation functions)\n\\begin{align}\nnm_{1} + m_{1}m_{2} + m_{2}m_{3} + \\dots + m_{M-1}m_{M} + m_{M}k = nm_{1} + m_{M}k + \\sum_{i=1}^{M-1} m_{i}m_{i+1} \n\\end{align}\nwhich, in big-O notation, can be written as\n\\begin{align}\n\\Theta\\left(nm_{1} + m_{M}k + \\sum_{i=1}^{M-1} m_{i}m_{i+1} \\right)\n\\end{align}\nwhere $\\Theta(\\cdot)$ is used (as opposed to $\\mathcal{O}(\\cdot)$) because this is a strict bound. If you have just one hidden layer, the number of multiplications becomes \n\\begin{align}\n\\Theta\\left(nm_{1} + m_{1}k \\right)\n\\end{align}\nOf course, at each layer, the number of multiplications can be computed independently of the multiplications of the other layers (you can think of each layer as a perceptron), hence we sum (and not e.g. multiply) the multiplications of each layer when computing the total number of multiplications of the whole MLP.\nIn general, when analyzing the time complexity of an algorithm, we do it with respect to the size of the input. However, in this case, the time complexity (more precisely, the number of multiplications involved in the linear combinations) also depends on the number of layers and the size of each layer. The time complexity of a forward pass of a trained MLP thus is architecture-dependent (which is a similar concept to an output-sensitive algorithm).\nYou can easily include other operations (sums, etc.) in this reasoning to calculate the actual time complexity of a trained MLP.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Will computers be able to understand user emotions? I am researching affective computing. Particularly, I'm studying the part of emotion recognition, i.e. the task of recognising the emotions that are being felt by the user/subject. For example, affectiva can be used to this end. I have concerns not in the validity of these models, but in what we are going to do with them.\nWhat about responding to emotions? Will computers be able to really understand user emotions?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Will computers be able to understand user emotions?\nThe term Understand is multidimensional, so characterizing the degree of understanding \u2014 emotional or otherwise \u2014 is a slippery task. Nonetheless, some forms of AI emotional understanding are possible.\nAn Interesting Simple Case\nEven the embedded programs of velocity sensitive musical keyboards are emotionally aware at a primitive level. Using the key depression velocity to drive the note parameters of attack, timbre, and volume allows the accomplished user's emotions to pass through the software into the emotional content of the music, which can be experienced by listeners just as with instruments that are not digital in nature.\nMore Advanced Emotional Capabilities\nAt the other extreme is a wide array of human emotional capabilities. One example is the set of complex recognition functions underneath the typical listening skill set of a counselling professional.\nThe term affective computing was mentioned in the question. A counselor may note the affect of the counselled, reading tone of voice, facial expression sequences, and body language. From this, a clearer picture of the internal emotional state of the counselled can be understood. These recognition and analysis abilities can determine the subject's internal emotional state more accurately and comprehensively than a masterful analysis of a functional MRI or the detection of neuro-chemical metabolites in blood.\nThere seems to be no theoretical principle that limits computers from mastering the front end of a counselor's skill set, the recognition of emotion to produce a coded sequence of affects. The degree to which software can interpret the sequence of affects (in combination with concurrent natural language expressions) and determine the emotional condition (and potential market-oriented decision patterns) of the human is yet to be determined.\nThere are other emotional capabilities beyond the skills of emotional recognition and interpretation. Compassion is largely the logical integration of ethics in the absence of self-centered motive with the results of emotional recognition and interpretation. The addition of emotional imitation yields empathy.\nThe development of such capabilities in automata is more important than the shallow and therefore myopic motives of e-Commerce. There may be applications for toys, education, entertainment, and remedy for the growing coldness of a technological society. (Such is discussed further below.)\nFunctions of recognition, interpretation, the application of rules or meta-rules in the ethical domain to these interpretations, and imitation may well be within the capabilities of digital systems.\nIsaac Asimov introduced the possibility of telepathy to the feature set of both the human mind and automata. It may seem like telepathy is confined to the domain of fiction, however an emoticon can be the tele-form of a component of affect, such as a smile. In this way, consensual technology assisted telepathy has actually become commonplace.\nWith the erosion of privacy in a culture with increasing interaction with digital systems by an increasing segment of the public, less consensual telepathic techniques may be developed and mastered.\nDeeper Aspects of the Question\nThe doubt lies in the existence of a soul or some other autonomous and non-deterministic aspect of the human person. The existence of these things and whether the simulation of them can be accomplished with a Turing machine and practically deployed to the Von Neumann architecture or a collection of them have neither been proven or dis-proven formally. If autonomous and non-deterministic elements exist in people, then, even if they can be simulated, we cannot infur they can be realized as independently autonomous.\nChallenging the implications of the MIT coined term Meat Machine, the notion that humans are capable of intention by fiat is not disproven, yet a pure Turing machine clearly cannot intend in that way.\nThis is important in the context of the question in that a computer may only be able to simulate frustration when an intention is thwarted by the conditions of life. Actual frustration may not be possible.\nCurrent Publicly Experienced Progress\nOne interesting entry point of computer science into the domain of human emotions is the story based memory and reasoning model purported by Roger Schank of Yale U in the 1990s. Although the machinery used by Amazon underneath the hold of its ever improving ability to recommend movies in a buyer specific way is Company Confidential to Amazon, one must wonder.\nCan e-Commerce develop user profiling regarding books and movies to comprehend the story plot or the arc of protagonist's emotional development? Can it do so sufficiently to match user viewing and purchase with other products? Is that what Amazon is beginning to do? Short of an unethical Amazon employee, we can only guess. Certainly, what is transpiring in leading edge e-Commerce has moved beyond word or phrase matching or tracking interest in particular authors, screenwriters, directors, producers, and stars.\nIf Roger Schank's story based memory and reasoning has penetrated into e-Commerse, emotional analysis of individuals of within public is well underway, since story plot and protagonist developmental arcs are bound in climaxes and setting up climaxes, all related to emotional states. If not, emotional analysis of groups within the public has been underway since public relations functions entered into the roles of enterprise IT systems. (I know for a fact that such occurred decades ago.)\nEven if the likes of Facebook, Google, and Amazon are attempting to approximate in various ways the emotional states of individuals in real time, the matching of movie plots of protagonist arcs and such pattern matching and naive categorization is far from what a good counselor or a self-actualized friend or family member might do.\nComputer systems to which the public is exposed do not yet appear to accurately developing comprehension of the buyer's emotion. That is one area where even the most progressive interfaces are still shy. Furthermore, the computer interface itself is still as dry as it was in the late 20th century.\nShort of breaches of confidentiality, what capabilities to recognize, compare, analyze, or simulate emotions may exist in proprietary labs is solely a mater of conjecture.\nWarm Interfaces\nReturning to the question of the general coldness of cybernetic interfaces in a technological society, there is much for the computer science community to learn. For one thing, the soft skills of actual technical people often leaves much to be desired, so a cultural shift from cold development teams to culturally progressive and warm teams might be necessary.\nFurthermore, one who has engaged with various PaaS (personality as a service) devices such as Siri, Google Assistant, Alexa, Cortana, and Microsoft's Office Assistant, Clippy, might find the paperclip personality of Clippy to be the warmer from among the list. Perhaps the Clippy didn't see a higher level of acceptance because of the disparity between the coldness of a grid of cells in a spreadsheet and the attempted warmth of the animated character was too much, and the little guy tends to get in the way of some portion of the interface, which can be annoying. (Integration of concepts was poor.)\nNonetheless, the animated style of Clippy is intended to create a mental association with cartoon characters, which is brilliant. Cartoon character design and storytelling through comic and cartoon media is a creative area of technology that had mastered computer generated warmth long before intelligent assistants began to appear.\nOne can't help thinking, upon general survey of intelligent assistant history, that the more the system tries to be human, the less human it seems. Human response to emotional content in a cybernetic interface is like that of color matching or synthesized musical instruments. If one is attempting to synthesize, the synthesis has to be good. If it can't be fully convincing, then there is more authenticity in inventing something that is not pretending to be something real. A caricature of real life objects (like Sponge Bob or Road Runner) avoids exposing an unacceptable margin of error in the imitation of real life. [1]\nOur sensitivity in this area is so acute that if a real person, working in a customer service department, acts too mechanically such that we have even the slightest doubt as to whether we are talking to a human being, the impression is negative and we want to hang up and look for the function we wish to initiate on the company's web site.\nIt is unclear whether the trend for people to become more like cogs in a machine or whether usage patterns will drive companies to design their user interfaces and the mechanisms behind them to exude something like hospitality or congeniality. Although Jaques Ellul seems to be correct in his proposition that technology has long since been driving humanity rather than the other way around, the DNA nature of the human mind will perhaps force humanity to remain remarkably human. Thus the evolution of cybernetic interface professionals may continue to seek the meaning of and simulation of warmth.\nThe problematic, controvertible, and somewhat bizarre pursuit of Turing Testing will probably endure.\nConcerns About Emotional Modelling Uses\nWhether an emotional recognition, modelling, analysis, and comparison suite, obviously a powerful tool-set, is used for the betterment of humanity or its detriment is a question like that of any other powerful tool-set. Mass psychology, nuclear science, statistics, and genetics have in common the potential for great good or great evil.\nIn the context of this question, broadcast or more targeted information dissemination can be characterized as propaganda, which may not necessarily be perilous. Propaganda was used for women's suffrage and along the path of U.S. independence from Europe. Elements of broadcast and targeted control have created much geopolitical trouble, a topic outside of the scope of this social network, but pertinent and somewhat obvious, such that further mention is unnecessary anyway.\nIndividual profiling can be of great good too. Such can be like a combination of the old library subject indexed Dewey Decimal cards in combination with a knowledgeable librarian when looking for information or items of entertainment or personal expression for borrowing, rental, or purchase.\nOf course, profiling in combination with statistics can lead to the ability to obtain covert control over a mass of people, not just for the profit maximization of a company. An appropriately self-deluded megalomaniac or a collection of them in some kind of secret society could use emotional modelling and comprehensive user profiling for a large sample of national or global population for the injection of emotionally powered systems of belief. Such a person or group could theoretically succeed in covert and systematic sublimation of liberty to a kind of virtual authoritarian dictatorship.\nHow technology is used is always a concern. Transparency and accountability are required features of a society.\nJust as in the other areas of science and technology mentioned above, it is up to we who are skilled enough to realize these systems to be intelligent and active elements within our society's accountability mechanisms. Whether a corporation or governmental department is leading humanity into perdition is an item that can be judged during a job hunt and during the initial work period.\nNotes\n[1]\nThis is perhaps the strongest critique of the Turing's Imitation Game philosophy. Cartoons, comics, and sci-fi creatures demonstrate that people don't seem to care if intelligent beings can be distinguished from humans, and there is no proof that human intelligence is the only or the best example of intelligence.\nAlong these same lines, heroes are representations of intelligent behavior that epitomize some aspect of humanity that actually doesn't naturally occur in pure form as they do with these protagonists. Yet actors are branded and marketed as stars because of this idyllic expression of character. It may be that humans don't really like human intelligence and constantly try to transcend it through fiction, but results in only some public awareness that is never more than an anthropological fantasy.\nEven AI is not an imitation game. It is a transcendence game. For this reason, the Turing Test is of limited value.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the advantages of complex-valued neural networks? During my research, I've stumbled upon \"complex-valued neural networks\", which are neural networks that work with complex-valued inputs (probably weights too). What are the advantages (or simply the applications) of this kind of neural network over real-valued neural networks?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "According to this paper, complex-valued ANNs (C-ANNs) can solve problems such as XOR and symmetry detection with a smaller number of layers than real ANNs (for both of these a 2 layer C-ANN suffices, whereas a 3-layer R-ANN is required).\nI believe that it is still an open question as to how useful this result is in practice (e.g. whether it actually makes finding the right topology easier), so at present, the key practical advantage of C-ANNs is when they are a closer model for the problem domain.\nApplication areas are then where complex values arise naturally, e.g. in optics, signal processing/FFT or electrical engineering.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What's the difference between hyperbolic tangent and sigmoid neurons? Two common activation functions used in deep learning are the hyperbolic tangent function and the sigmoid activation function. I understand that the hyperbolic tangent is just a rescaling and translation of the sigmoid function: \n$\\tanh(z) = 2\\sigma(z) - 1$. \nIs there a significant difference between these two activation functions, and in particular, when is one preferable to the other?\nI realize that in some cases (like when estimating probabilities) outputs in the range of $[0,1]$ are more convenient than outputs that range from $[-1,1]$. I want to know if there are differences other than convenience which distinguish the two activation functions.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Sigmoid > Hyperbolic tangent:\nAs you mentioned, the application of Sigmoid might be more convenient than hyperbolic tangent in the cases that we need a probability value at the output (as @matthew-graves says, we can fix this with a simple mapping/calibration step). In other layers, this makes no sense.\nHyperbolic tangent > Sigmoid:\nHyperbolic tangent has a property called \"approximates identity near the origin\" which means $\\tanh(0) = 0$, $\\tanh'(0) = 1$, and $\\tanh'(z)$ is continuous around $z=0$ (as opposed to $\\sigma(0)=0.5$ and $\\sigma'(0)=0.25$). This feature (which also exists in many other activation functions such as identity, arctan, and sinusoid) lets the network learn efficiently even when its weights are initialized with small values. In other cases (eg Sigmoid and ReLU) these small initial values can be problematic.\nFurther Reading:\nRandom Walk Initialization for Training Very Deep Feedforward Networks \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is \"backprop\"? What does \"backprop\" mean? Is the \"backprop\" term basically the same as \"backpropagation\" or does it have a different meaning?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\"Backprop\" is the same as \"backpropagation\": it's just a shorter way to say it. It is sometimes abbreviated as \"BP\".\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What exactly is the advantage of double DQN over DQN? I started looking into the double DQN (DDQN). Apparently, the difference between DDQN and DQN is that in DDQN we use the main value network for action selection and the target network for outputting the Q values.\nHowever, I don't understand why would this be beneficial, compared to the standard DQN. So, in simple terms, what exactly is the advantage of DDQN over DQN?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In $Q$-learning there is what is known as a maximisation bias. That is because the update target is $r + \\gamma \\max_a Q(s,a)$. If you slightly overestimate your $Q$-value then this error gets compounded (there is a nice example in the Sutton and Barto book that illustrates this). The idea behind tabular double $Q$-learning is to have two $Q$-networks, $Q_1,Q_2$, and you choose an action $a$ from them, e.g. from $Q_1 + Q_2$. You then flip a coin to decide which to update. If you choose to update $Q_1$ then the update target becomes $r + \\gamma Q_2(s', \\arg\\max_a Q_1(s',a))$.\nThe idea is that if you overshoot your estimate on one $Q$ network then having the second will hopefully control this bias when you would take the max.\nIn Deep Double $Q$-learning the idea is essentially the same but instead of having to maintain and train two $Q$-networks, they use the target network from vanilla DQN to provide the target. To make this more concrete, the update target they use is\n$$r + \\gamma Q(s', \\arg\\max_aQ(s',a;\\theta);\\theta^-)\\;,$$\nwhere $Q(s,a;\\theta^-)$ denotes the target network whose parameters are only updated to the current networks every $C$ time steps.\nAs before, the idea is that if we have overestimated our value of being state $s'$ in our current network when taking the max action, using the target network to provide the target will help control for this bias.\nMaximisation Bias\nI will here explain maximisation bias from the simple example given from the Sutton and Barto book.\n\nThe Markov Decision Process in the image is defined as follows: we start in state A and can take the 'right' action which gives us 0 reward and immediately leads to termination. If we choose 'left' we get 0 immediate reward where we then move to state B. From there, we have an arbitrary number of action we can take where they all lead to the terminal state and the reward is drawn from a Normal(-0.1,1) distribution.\nClearly, the optimal action is always to move to the right from state A as this gives 0 expected future returns. Taking the left action will give a $\\gamma \\times -0.1$ expected future returns (the $\\gamma$ is our discount factor).\nNow, if we got into state $B$ and took some random action our initial reward could be bigger than 0 -- after all it is drawn from a Normal(-0.1,1) distribution.\nNow, consider we are updating our $Q$-function for state A and taking the left action. Our update target will be $0 + \\gamma \\max_a Q(B,a)$. Because we are taking the max over all possible actions, this will lead to a positive reward and so we are backing up the belief of our expected future rewards from taking action left in state A to be something positive -- clearly this is wrong since we know it should be -0.1. This is what is known as the maximisation bias, because it gives us a kind of 'optimistic' estimate of the action value!\nI've attached an image below that shows the %age of time the agent chose the left action, which it shouldn't be choosing). As you can see, it takes normal $Q$-learning along time to even start to correct itself, whereas double $Q$-learning corrects the mistake almost immediately.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Should I choose a model with the smallest loss or highest accuracy? I have two Machine Learning models (I use LSTM) that have a different result on the validation set (~100 samples data):\n\nModel A: Accuracy: ~91%, Loss: ~0.01\nModel B: Accuracy: ~83%, Loss: ~0.003\n\nThe size and the speed of both models are almost the same. So, which model should I choose?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You should note that both your results are consistent with a \"true\" probability of 87% accuracy, and your measurement of a difference between these models is not statistically significant. With an 87% accuracy applied at random, then there is approx 14% chance of getting the two extremes of accuracy you have observed by chance if samples are chosen randomly from the target population, and models are different enough make errors effectively at random. This last assertion is usually not true though, so you can relax a little - that is, unless you took different random slices for cross-validation in each case.\n100 test cases is not really enough to discern small differences between models. I would suggest using k-fold cross-validation in order to reduce errors in your accuracy and loss estimates.\nAlso, it is critical to check that the cross-validation split was identical in both cases here. If you have used auto-splitting with a standard tool and not set the appropriate RNG seed, then you may have got a different set each time, and your results are just showing you variance due to the validation split which could completely swamp any differences between the models.\nHowever, assuming the exact same dataset was used each time, and it was representative sample of your target population, then on average you should expect the one with the best metric to have the highest chance of being the best model.\nWhat you should really do is decide which metric to base the choice on in advance of the experiment. The metric should match some business goal for the model.\nNow you are trying to choose after the fact, you should go back to the reason you created the model in the first place and see if you can identify the correct metric. It might not be either accuracy or loss.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Where does randomness occur in LLM inference beyond token sampling? Question\nI'm working with large language models like Llama2 and need to understand all sources of randomness during inference for reproducibility and testing.\nI assume that the primary source of randomness is in token sampling from the output distribution. Specifically:\n1. Softmax converts logits to probabilities (deterministic):\n$$\np_i = \\frac{\\exp(z_i / \\tau)}{\\sum_{j=1}^{V} \\exp(z_j / \\tau)}\n$$\nwhere $z_i$ are the logits, $\\tau$ is temperature, and $V$ is vocabulary size.\n2. Token sampling from the categorical distribution (random):\n$$\n\\text{next\\_token} \\sim \\text{Categorical}(p_1, p_2, \\ldots, p_V)\n$$\nThis is typically implemented via inverse transform sampling:\n\nGenerate $u \\sim \\text{Uniform}(0, 1)$ \u2190 Randomness here\nCompute CDF: $F(k) = \\sum_{i=1}^{k} p_i$\nSelect: $\\text{next\\_token} = \\min\\{k : F(k) \\geq u\\}$\n\nMy Questions\nIs token sampling the ONLY source of randomness during inference?\n\nOther sources: Are there other hidden sources of randomness I should be aware of (e.g., in layer normalization, residual connections, KV cache, CUDA operations)?\n\nFramework-specific: I assume controlling the randomness depends on the framework in use (PyTorch vs TensorFlow vs Ollama)? Any pointers on what settings are needed for PyTorch specifically ?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The primary source of randomness definitely is the temperature/top-k/token sampling.\nHowever, when doing inference on GPUs, it is near impossible stop all randomness. There is quite a bit of randomness in gpu ops (i.e. addition of floating point numbers for example) and kernel ops. Addition of chunked floating point number, for example, is a non-associative operation in the way that its usually implemented, and since there are a lot of threaded computations, the outcomes are never the exact same. The only way to stop this is to switch to single threaded CPU, which is just not feasible. The randomness that non-deterministic GPU ops introduce is minimal, and usually just neglected, but it does matter if you try and compare outputs of multiple runs to one another.\nSo yes, there are other sources. Most frameworks provide ways of minimizing it, by setting seeds, disabling non-deterministic algorithms in favor of deterministic ones, etc. However, doing computations on gpus will always have small sources of randomness. The only real way to go deterministic is to compute on cpus.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are all the different kinds of neural networks used for? I found the following neural network cheat sheet (Cheat Sheets for AI, Neural Networks, Machine Learning, Deep Learning & Big Data). \n\nWhat are all these different kinds of neural networks used for? For example, which neural networks can be used for regression or classification, which can be used for sequence generation, etc.? I just need a brief overview (1-2 lines) of their applications.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I agree that this is too broad, but here's a 1 sentence answer for most of them. The ones I left out (from the bottom of the chart) are very modern, and very specialized. I don't know much about them, so perhaps someone who does can improve this answer.\n\nPerceptron: Linear or logistic-like regression (and thus, classification).\nFeed Forward: Usually non-linear regression or classification with sigmoidal activation. Essentially a multi-layer perceptron.\nRadial Basis Network: Feed Forward network with Radial Basis activation functions. Used for classification and some kinds of video/audio filtering\nDeep Feed Forward: Feed Forward with more than 1 hidden layer. Used to learn more complex patterns in classification or regression, maybe reinforcement learning.\n\n\n\nRecurrent Neural Network: A Deep Feed Forward Network where some nodes connect to past layers. Used in reinforcement learning, and\nto learn patterns in sequential data like text or audio.\nLSTM: A recurrent neural network with specialized control neurons (sometimes called gates) that allow signals to be remembered for longer periods of time, or selectively forgotten. Used in any RNN application, and often able to learn sequences that have a very long repetition time. \nGRU: Much like LSTM, another kind of gated RNN with specialized control neurons.\n\n\n\nAuto Encoder: Learns to compress data and then decompress it. After learning this model, it can be split into two useful subparts: a mapping from the input space to a low-dimensional feature space, that may be easier to interpret or understand; and a mapping from a small dimensional subspace of simple numbers into complex patterns, which can be used to generate those complex patterns. Basis of much modern work in vision, language, and audio processing.\nVAE, DAE,SAE: Specializations of the Auto Encoder.\n\n\n\nMarkov Chain: A neural network representation of a markov chain: State is encoded in the set of neurons that are active, and\ntransition probabilities are thus defined by the weights. Used for\nlearning transition probabilities and unsupervised feature learning\nfor other applications.\nHN, BM, RBM, DBM: Specialized architectures based on the Markov Chain idea, used to automatically learn useful features for other\napplications.\n\n\n\nDeep Convolutional Network: Like a feed-forward network, but each node is really a bank of nodes learning a convolution from the layer\nbefore it. This essentially allows it to learn filters, edge\ndetectors, and other patterns of interest in video and audio\nprocessing.\nDeep Deconvolutional Network: Opposite of a Convolutional Network in some sense. Learn a mapping from features that represent edges or\nother high level properties of some unseen image, back to the pixel\nspace. Generate images from summaries.\nDCIGN: Essentially an auto-encoder made of a DCN and a DN stuck together. Used to learn generative models for complex images like\nfaces.\nGenerative Adversarial Network: Used to learn generative models for complex images (or other data types) when not enough training data is\navailable for a DCIGN. One model learns to generate data from random\nnoise, and the other learns to classify the output of the first\nnetwork as distinct from whatever training data is available.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What size of neural networks can be trained on current consumer grade GPUs? (1060,1070,1080) Is it possible to give a rule of thumb estimate about the size of neural networks that are trainable on common consumer-grade GPUs?\nFor example, the Emergence of Locomotion (Reinforcement) paper trains a network using tanh activation of the neurons. They have a 3 layer NN with 300,200,100 units for the Planar Walker. But they don\u2019t report the hardware and time.\nBut could a rule of thumb be developed?\nAlso, just based on current empirical results. So, for example, $X$ units using sigmoid activation can run $Y$ learning iterations per hour on a 1060.\nOr using activation function $a$ instead of $b$ causes a $n$ times decrease in performance.\nIf a student/researcher/curious mind is going to buy a GPU for playing around with these networks, how do you decide what you get? A 1060 is apparently the entry-level budget option, but how can you evaluate if it is not smarter to just get a crappy netbook instead of building a high-power desktop and spend the saved $ on on-demand cloud infrastructure.\nMotivation for the question: I just purchased a 1060 and (clever, to ask the question afterwards huh) wonder if I should have just kept the $ and made a Google Cloud account. And if I can run my master thesis simulation on the GPU.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Usually the problem is to fit the model into video RAM.\nIf it does not, you cannot train your model at all without big efforts (like training parts of the model separately).\nIf it does, time is your only problem. But the difference in training time between consumer GPUs like the Nvidia 1080 and much more expensive GPU accelerators like the Nvidia K80 are not very large. Actually the best consumer cards are faster than GPU accelerators, but lack other properties like VRAM. Random comparisons and benchmarks: Which GPU(s) to Get for Deep Learning: My Experience and Advice for Using GPUs in Deep Learning, A Comparison between NVIDIA\u2019s GeForce GTX 1080 and Tesla P100 for Deep Learning.\nTo calculate if your models fits into VRAM, you just approximate how much data and which hyperparameters you have (inputs, outputs, weights, layers, batch size, which datatype and so on).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How much of Deep Mind's work is actually reproducible? DeepMind has published a lot of works on deep learning in the last years, most of them are state-of-the-art on their respective tasks. But how much of this work has actually been reproduced by the AI community? For instance, the Neural Turing Machine paper seems to be very hard to reproduce, according to other researchers.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "On the suggestion of the O.P. rcpinto I converted a comment about seeing \"around a half-dozen papers that follow up on Graves et al.'s work which have produced results of the caliber\" and will provide a few links. Keep in mind that this only answers the part of the question pertaining to NTMs, not Google DeepMind itself, plus I'm still learning the ropes in machine learning, so some of the material in these papers is over my head; I did manage to grasp much of the material in Graves et al.'s original paper{1] though and am close to having homegrown NTM code to test. I also at least skimmed the following papers over the last few months; they do not replicate the NTM study in a strict scientific manner, but many of their experimental results do tend to support the original at least tangentially:\n\u2022 In this paper on a variant version of NTM addressing, Gulcehere, et al. do not try to precisely replicate Graves et al.'s tests, but like the DeepMind team, it does demonstrate markedly better results for the original NTM and several variants over an ordinary recurrent LSTM. They use 10,000 training samples of a Facebook Q&A dataset, rather than the N-grams Graves et al. operated on in their paper, so it's not replication in the strictest sense. They did however manage to get a version of the original NTM and several variants up and running, plus recorded the same magnitude of performance improvement.2\n\u2022 Unlike the original NTM, this study tested a version of reinforcement learning which was not differentiable; that may be why they were unable to solve several of the programming-like tasts, like Repeat-Copy, unless the controller wasn't confined to moving forwards. Their results were nevertheless good enough to lend support to the idea of NTMs. A more recent revision of their paper is apparently available, which I have yet to read, so perhaps some of their variant's problems have been solved.3\n\u2022 Instead of testing the original flavor of NTM against ordinary neural nets like LSTMs, this paper pitted it against several more advanced NTM memory structures. They got good results on the same type of programming-like tasks that Graves et al. tested, but I don't think they were using the same dataset (it's hard to tell from the way their study is written just what datasets they were operating on).4 \n\u2022 On p. 8 of this study, an NTM clearly outperforms several LSTM, feed-forward and nearest-neighbor based schemes on an Omniglot character recognition dataset. An alternative approach to external memory cooked up by the authors clearly beats it, but it still obviously performs well. The authors seem to belong to a rival team at Google, so that might be an issue when assessing replicability.5\n\u2022 On p. 2 these authors reported getting better generalization on \"very large sequences\" in a test of copy tasks, using a much smaller NTM network they evolved with the genetic NEAT algorithm, which dynamically grows topologies.6 \nNTMs are fairly new so there hasn't been much time to stringently replicate the original research yet, I suppose. The handful of papers I skimmed over the summer, however, seem to lend support to their experimental results; I have yet to see any that report anything but excellent performance. Of course I have an availability bias, since I only read the pdfs I could easily find in a careless Internet search. From that small sample it seems that most of the follow-up research has been focused on extending the concept, not replication, which would explain the lack of replicability data. I hope that helps.\n1 Graves, Alex; Wayne, Greg and Danihelka, Ivo, 2014, \"Neural Turing Machines,\" published Dec. 10, 2014. \n2 Gulcehre, Caglar; Chandar, Sarath; Choy, Kyunghyun and Bengio, Yoshua, 2016, \"Dynamic Neural Turing machine with Soft and Hard Addressing Schemes,\" published June 30, 2016. \n3 Zaremba, Wojciech and Sutskever, Ilya, 2015, \"Reinforcement Learning Neural Turing Machines,\" published May 4, 2015. \n4 Zhang; Wei; Yu, Yang and Zhou, Bowen, 2015, \"Structured Memory for Neural Turing Machines,\" published Oct. 25, 2015. \n5 Santoro, Adam; Bartunov, Sergey; Botvinick, Matthew; Wierstra, Daan and Lillicrap, Timothy, 2016, \"One-Shot Learning with Memory-Augmented Neural Networks,\" published May 19, 2016. \n6 Boll Greve, Rasmus; Jacobsen, Emil Juul and Sebastian Risi, date unknown, \"Evolving Neural Turing Machines.\" No publisher listed\nAll except (perhaps) Boll Greve et al. were published at the Cornell Univeristy Library arXiv.org Repository: Ithaca, New York.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are neural networks the only way to reach \"true\" artificial intelligence? Currently, most research done in artificial intelligence focuses on neural networks, which have been successfully used to solve many problems. A good example would be DeepMind's AlphaGo, which uses a convolutional neural network. There are many other examples, such as Google Translate, which uses transformers, or DQN, which has been used to play Atari games.\nSo, are any of the variants of neural networks the only way to reach \"true\" artificial intelligence (or AGI)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "If by true AI, you mean 'like human beings', the answer is - no-one knows what the appropriate computational mechanisms (neural or otherwise) are or indeed whether we are capable of constructing them.\nWhat Artificial Neural Nets (ANNs) do is essentially 'nonlinear regression' - perhaps this is not a sufficiently strong model to express humanlike behaviour. \nDespite the 'Universal function approximation' property of ANNs, what if human intelligence depends on some as-yet-unguessed mechanism of the physical world?\nWith respect to your question about \"the only way\":\nEven if (physical) neural mechanisms somehow actually were the only route to intelligence (e.g. via Penrose's quantum microtubules), how could that be proved? \nEven in the formal world of mathematics, there's a saying that \"Proofs of non-existence are hard\". It scarcely seems conceivable that, in the physical world, it would be possible to demonstrate that intelligence could not arise by any other mechanism.\nMoving back to computational systems, note that Stephen Wolfram made the interesting observation in his book 'A New Kind of Science' that many of the apparently distinct mechanisms he observed seem to be capable of 'Universal Computation', so in that sense there's nothing very particular about ANNs.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can I make my network treat rotations of the input equally? I'm attempting to program my own system to run a neural network. To reduce the number of nodes needed, it was suggested to make it treat rotations of the input equally.\nMy network aims to learn and predict Conway's Game of Life by looking at every square and its surrounding squares in a grid, and giving the output for that square. Its input is a string of 9 bits:\n\nThe above is represented as 010 001 111.\nThere are three other rotations of this shape however, and all of them produce the same output:\n\nMy network topology is 9 input nodes and 1 output node for the next state of the centre square in the input. How can I construct the hidden layer(s) so that they take each of these rotations as the same, cutting the number of possible inputs down to a quarter of the original?\nEdit:\nThere is also a flip of each rotation which produces an identical result. Incorporating these will cut my inputs by 1/8th. With the glider, my aim is for all of these inputs to be treated exactly the same. Will this have to be done with pre-processing, or can I incorporate it into the network?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "If I understand well your single output node will be the next status of the square in the middle. You don't need to worry about the number of nodes in the hidden layers while you have sufficient resources to train the model. This problem is very easy to learn for a neural network so no size concerns.\nYou need to do supervised training that means you need to feed in input data and the matching expected output. You need to be sure that in your training data all 4 rotations are assigned to the same output. This way your network should learn to treat all of these the same way. \nYou made me curious so I tried myself. My solution could learn 100% correct in about 20 epochs running within a few seconds on my old laptop. I only slightly changed the output to be categorical either [0,1] or [1,0] but that gives the same result that you are looking for. Just for reference here is the code written in python: \nfrom keras.models import Sequential\nfrom keras.layers import Input, Dense\nfrom keras.models import Model\nfrom keras import optimizers\nfrom keras.utils.np_utils import to_categorical\nimport helper\n\nx_,y_ = helper.fnn_csv_toXY(\"conway.csv\",\"output\",False)\ny_binary = to_categorical(y_)\n\nmodel = Sequential()\nmodel.add(Dense(100, activation='relu', kernel_initializer='glorot_uniform',input_shape =(9,)))\nmodel.add(Dense(20, activation='relu', kernel_initializer='glorot_uniform'))\nmodel.add(Dense(2, activation='softmax'))\nadam=optimizers.Adam()\nmodel.compile(optimizer=adam,\n loss='categorical_crossentropy',\n metrics=['acc'])\nmodel.fit(x_, y_binary, epochs=100)\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do we need common sense in AI? Let's consider this example:\n\nIt's John's birthday, let's buy him a kite.\n\nWe humans most likely would say the kite is a birthday gift, if asked why it's being bought; and we refer to this reasoning as common sense.\nWhy do we need this in artificially intelligent agents? I think it could cause a plethora of problems, since a lot of our human errors are caused by these vague assumptions.\nImagine an AI ignoring doing certain things because it assumes it has already been done by someone else (or another AI), using its common sense.\nWouldn't that bring human errors into AI systems?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Commonsense knowledge is the collection of premises that everyone, in a certain context (hence common sense knowledge might be a function of the context), takes for granted. There would exist a lot of miscommunication between a human and an AI if the AI did not possess common sense knowledge. Therefore, commonsense knowledge is fundamental to human-AI interaction.\nThere are also premises that every human takes for granted independently of the country, culture, or, in general, context. For example, every human (almost since its birth) has a mechanism for reasoning about naive physics, such as space, time, and physical interactions. If an AI does not possess this knowledge, then it cannot perform the tasks that require this knowledge.\nAny task that requires a machine to have common sense knowledge (of an average human) is believed to be AI-complete, that is, it requires human-level (or general) intelligence. See section D of AI-Complete, AI-Hard, or AI-Easy \u2013 Classification of Problems in AI (2012) by Roman V. Yampolskiy.\nOf course, the problems that arise while humans communicate because of different assumptions or premises might also arise between humans and AIs (that possess commonsense knowledge).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "\"Attention is all you need\" paper : How are the Q, K, V values calculated? The seminal Attention is all you need paper (Google Brain team, 2017) introduces Transformers and implements the attention mecanism with \"queries, keys, values\", in an analogy to a retrieval system.\nI understand the whole process of multi-head attention and such (i.e., what is done with the $Q$, $K$, $V$ values and why), but I'm confused on how these values are computed in the first place. AFAICT, the paper seems to completely leave that out.\nBoth Figure 2 of the paper and equations explaining Attention and Multihead attention start with $Q$,$K$,$V$ already there :\n\nThe answers regaridng the origin of $Q$,$K$,$V$ I've found so far haven't satisfied me :\n\nIn this similar question, the accepted answer says \"The proposed multihead attention alone doesn't say much about how the queries, keys, and values are obtained, they can come from different sources depending on the application scenario.\". If this is the case, then why isn't the computing of $Q$,$K$,$V$ made more clear in the paper, at the very least for the task of language translation for which they show some numerical results and so obviously did compute $Q$,$K$,$V$ in some way ?\n\nI also see some answers (eg this one on the same question) which say that $Q$, $K$, $V$ are the result of multiplication of the input embedding with some matrices $W$. This is also what is shown in the popular blog post The Illustrated Transformer :\n\n\n\nThese \"projection\" matrices ($W^Q$, $W^K$, $W^V$) do seem to appear in the the definition of attention in the definition of $head_i$ (see top figure), but according to that equation, these matrices are multiplied by $Q$, $K$, $V$ (still appearing out of thin air, so the problem of their definition remains) and so the resulting product can't also be $Q$, $K$, $V$.\nHow are the $Q$, $K$, $V$ values computed ?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "(OP auto-answer) After having dug further in and read more papers on attention, and with help from Chillston in the comments, I think I've got it narrowed down to an issue of confusing notation. If anyone thinks this is not the right answer, please don't hesitate to submit another one, which I'll mark as correct if I think it's better.\n\n$Q$, $K$ and $V$ values are defined in the paper, and they do come from multiplication with learnt projection matrices. Those matrices are $W^Q_i$, $W^K_i$ and $W^V_i$, defined in section 3.2.2 of the paper.\nThe confusion stems from the fact that the notation used in the multihead attention equation and in Figure 2 (right) of the paper is wrong/confusing. The equation would be be clearer if it read :\n\nAnd Figure 2 right could be modified accordingly :\n\nIn this new notation, $X$ and $Y$ are the inputs to the current attention unit.\n\nFor self attention, we'd have $X = Y$ which would both be the previous en/decoder block output (or word embedding for the first encoder block).\nFor cross-attention, $X$ would be the output of the last encoder block and $Y$ the output of the previous decoder block.\n\nTechnically, the way it's written in the paper could be correct but you need to consider that $Q, K, V$ refer to different tensors when they're written :\n\nin the multihead($Q,K,V$) equation where they represent inputs, $i.e.$ what they call $V$ is $X$ in my suggested re-writing ;\nin the attention($Q,K,V$) equation where they represent \"true\" query/key/values, meaning inputs multiplied by projections matrices, $i.e.$ what they call $V$ is $XW^V_i$ in my suggested re-writing.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why would an AI need to 'wipe out the human race'? I'm reading such nonsense about how an AI would turn the world into a supercomputer to solve a problem that it thought it needed to solve. That wouldn't be AI. That's procedural programming stuck in some loop nonsense. An AI would need to evolve and re-organise its neurons. It wouldn't be stuck to hardcode if it becomes intelligent by re-writing its code.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It's a possible side effect\nAny goal-oriented agent might, well, simply do things that achieve its goals while disregarding side effects that don't matter for these goals.\nIf my goals include a tidy living space, I may transform my yard to a nice, flat lawn or pavement while wiping out the complex ecosystem of life that was there before, because I don't particulary care about that.\nIf the goals of a particular powerful AI happen to include doing anything on a large scale, and somehow don't particularly care about the current complex ecosystem, then that ecosystem might get wiped out in the process. It doesn't need to want or need to wipe out us. If we are simply not relevant to its goals, then we are made of materials and occupy space that it might want to use for something else.\nWe are a threat to most goals\nAny goal-oriented agent might want to ensure that they can fulfill their goals. Any smart agent will try to anticipate the actions of other agents that may prevent them from achieving those goals, and take steps to ensure that they succeed anyway. In many cases it is simpler to eliminate those other agents rather than ensure that their efforts fail.\nFor example, my goals may include storing a bag of sugar in a country house so that I can make pancakes when visiting without bringing all ingredients every time. However, if I leave it there, it is likely to get eaten by rats during winter. I may take all kinds of precautions to store it better, but rats are smart and crafty, and there's clearly a nontrivial chance that they will still succeed in achieving their goal anyway, so an effective extra precaution is killing the rats before they get a chance to try.\nIf the goals of a particular powerful AI are to do X; it may come to an understanding that (some?) humans might actually not want X but Y instead. It can also easily deduce that some of those humans might actively do things that prevent X and/or try to turn off the AI. Doing things that ensure that the goal gets achieved is pretty much what a goal-seeking agent does; in this case if existence of humans isn't strictly necessary for goal X, then eliminating them becomes a solid risk reduction strategy. It's not strictly necessary and it may take all kinds of other precautions as well, but just like in my example of rats, humans are smart and crafty and there's clearly a nontrivial chance that they will still succeed in achieving their goals (so that X doesn't happen as AI intends) so an effective extra precaution could be killing them before they get a chance to try.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can supervised learning be recast as reinforcement learning problem? Let's assume that there is a sequence of pairs $(x_i, y_i), (x_{i+1}, y_{i+1}), \\dots$ of observations and corresponding labels. Let's also assume that the $x$ is considered as independent variable and $y$ is considered as the variable that depends on $x$. So, in supervised learning, one wants to learn the function $y=f(x)$. \nCan reinforcement learning be used to learn $f$ (possibly, even learning the symbolic form of $f(x)$)? \nJust some sketches how can it be done: $x_i$ can be considered as the environment and each $x_i$ defines some set of possible \"actions\" - possible symbolic form of $f(x)$ or possible numerical values of parameters for $f(x)$ (if the symbolic form is fized). And concrete selected action/functional form $f(x, a)$ (a - set of parameters) can be assigned reward from the loss function: how close the observation $(x_i, y_i)$ is to the value that can be inferred from $f(x)$.\nAre there ideas or works of RL along the framework that I provided in the previous passage?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Any supervised learning (SL) problem can be cast as an equivalent reinforcement learning (RL) one.\nSuppose you have the training dataset $\\mathcal{D} = \\{ (x_i, y_i \\}_{i=1}^N$, where $x_i$ is an observation and $y_i$ the corresponding label. Then let $x_i$ be a state and let $f(x_i) = \\hat{y}_i$, where $f$ is your (current) model, be an action. So, the predicted label of observation $x_i$ corresponds to the action taken in state $x_i$. The reward received after having taken action $f(x_i)$ in state $x_i$ can then be defined as the loss $|f(x_i) - y_i|$ (or any other suitable loss).\nThe minimization of this loss is then equivalent to the maximization of the (expected) reward. Therefore, in theory, you could use trajectories of the form $$T=\\{(x_1, f(x_1), |f(x_1) - y_1|), \\dots, (x_N, f(x_N), |f(x_N) - y_N|)\\}$$ to learn a value function $q$ (for example, with Q-learning) or a policy $\\pi$, which then, given a new state $x_{\\text{new}}$ (an observation) produces an action $f(x_{\\text{new}})$ (the predicted label).\nHowever, note that the learned policy might not be able to generalise to observations not present in the training dataset. Moreover, although it is possible to solve an SL problem as an RL problem, in practice, this may not be the most appropriate approach (i.e. it may be inefficient).\nFor more details, read the paper Reinforcement Learning and its Relationship to Supervised Learning (2004) by Barto and Dietterich, who give a good overview of supervised and reinforcement learning and their relationship. The paper Learning to predict by the methods of temporal differences (1988), by Richard Sutton, should also give you an overview of reinforcement learning from a supervised learning perspective. However, note that this does not mean that a reinforcement learning problem can be cast as an equivalent supervised learning one. See section 1.3.3 Converting Reinforcement Learning to Supervised Learning of the mentioned paper Reinforcement Learning and its Relationship to Supervised Learning for more details.\nReinforcement learning can thus be used for classification and regression tasks. See, for example, Reinforcement Learning for Visual Object Detection (2016) by Mathe et al.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is search important in AI? Why is search important in AI? What kinds of search algorithms are used in AI? How do they improve the result of an AI?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "State space search is a general and ubiquitous AI activity that includes numerical optimization (e.g. via gradient descent in a real-valued search space) as a special case.\nState space search is an abstraction which can be customized for a particular problem via three ingredients:\n\nSome representation for candidate solutions to the problem (e.g. permutation of cities to represent a Travelling Salesman Problem (TSP) tour, vector of real values for numeric problems).\nA solution quality measure: i.e. some means of deciding which of two solutions is the better. This is typically achieved (for single-objective problems) by having via some integer or real-valued function of a solution (e.g. total distance travelled for a TSP tour). \nSome means of moving around in the space of possible solutions, in a heuristically-informed manner. Derivatives can be used if available, or else (e.g. for black-box problems or discrete solution representations) the kind of mutation or crossover methods favoured by genetic algorithms/evolutionary computation can be employed.\n\nThe first couple of chapters of the freely available \"Essentials of Metaheuristics\" give an excellent overview and Michalewicz and Fogel's \"How to Solve It - Modern Heuristics\" explains in more detail how numerical optimization can be considered in terms of state-space.\nHow shall the \"search through possible plans\" occur? The idea is to choose all 3 of the above for the planning problem and then apply some metaheuristic (such as Simulated Annealing, Tabu Search, Genetic Algorithms etc). Clearly, for nontrivial problems, only a small fraction of the space of \"all possible plans\" is actually explored.\nCAVEAT: Actually planning (in contrast to the vast majority of other problems amenable to state-space search such as scheduling, packing, routing etc) is a bit of a special case, in that it is sometime possible to solve planning problems simply by using A* search, rather than searching with a stochastic metaheuristic.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the proof that policy evaluation converges to the optimal solution? Although I know how the algorithm of iterative policy evaluation using dynamic programming works, I am having a hard time realizing how it actually converges.\nIt appeals to intuition that, with each iteration, we get a better and better approximation for the value function and we can thus assure its convergence, but with this said simply, it seems that this method is very inefficient contrary to the reality that it actually is quite efficient.\nWhat is the rigorous mathematical proof of the convergence of the policy evaluation algorithm to the actual answer? How is it that the value function obtained this way is close to the actual values computed by solving the set of bellman equations?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First of all, efficiency and convergence are two different things. There's also the rate of convergence, so an algorithm may converge faster than another, so, in this sense, it may be more efficient. I will focus on the proof that policy evaluation (PE) converges. If you want to know about its efficiency, maybe ask another question, but the proof below also tells you about the rate of convergence of PE.\n\nWhat is the proof that policy evaluation converges to the optimal solution?\n\nTo provide some context, I will briefly describe policy evaluation and what you need to know to understand the proof.\nPolicy evaluation\nPolicy evaluation (PE) is an iterative numerical algorithm to find the value function $v^\\pi$ for a given (and arbitrary) policy $\\pi$. This problem is often called the prediction problem (i.e. you want to predict the rewards you will get if you behave in a certain way).\nTwo versions: synchronous and asynchronous\nThere are (at least) two versions of policy evaluation: a synchronous one and an asynchronous one.\nIn the synchronous version (SPE), you maintain two arrays for the values of the states: one array holds the current values of the states and the other array will contain the next values of the states, so two arrays are used in order to be able to update the value of each state at the same time.\nIn the asynchronous version (APE), you update the value of each state in place. So, first, you update the value of e.g. $s_1$, then $s_2$, etc., by changing your only array of values (so you do not require a second array).\nSPE is similar in style to the numerical method called Jacobi method, which is a general iterative method for finding a solution to a system of linear equations (which is exactly what PE is actually doing, and this is also explained in the cited book by Sutton and Barto). Similarly, APE is similar in style to the Gauss\u2013Seidel method, which is another method to solve a system of linear equations.\nBoth of these general numerical methods to solve a system of linear equations are studied in detail in Parallel and Distributed Computation Numerical Methods (1989) by Bertsekas and Tsitsiklis, which I haven't read yet, but provides convergence results for these numerical methods.\nThe book Reinforcement learning: an introduction by Sutton and Barto provides a more detailed description of policy evaluation (PE).\nProof of convergence\nI will provide a proof for the SPE based on these slides by Tom Mitchell. Before proceeding, I suggest you read the following question What is the Bellman operator in reinforcement learning? and its answer, and you should also get familiar with vector spaces, norms, fixed points and maybe contraction mappings.\nThe proof that PE finds a unique fixed-point is based on the contraction mapping theorem and on the concept of $\\gamma$-contractions, so let me first recall these definitions.\n\nDefinition ($\\gamma$-contraction): An operator on a normed vector space $\\mathcal{X}$ is a $\\gamma$-contraction, for $0 < \\gamma < 1$, provided for all $x, y \\in \\mathcal{X}$\n$$\\| F(x) - F(y) \\| \\leq \\gamma \\| x - y\\|$$\nContraction mapping theorem: For a $\\gamma$-contraction $F$ in a complete normed vector space $\\mathcal{X}$\n\nIterative application of $F$ converges to a unique fixed point in $\\mathcal{X}$ independently of the starting point\n\nat a linear convergence rate determined by $\\gamma$\n\n\n\nNow, consider the vector space $\\mathcal{V}$ over state-value functions $v$ (i.e. $v \\in \\mathcal{V})$. So, each point in this space fully specifies a value function $v : \\mathcal{S} \\rightarrow \\mathbb{R}$ (where $\\mathcal{S}$ is the state space of the MDP).\nTheorem (convergence of PE): The Bellman operator is a $\\gamma$-contraction operator, so an iterative application of it converges to a unique fixed-point in $\\mathcal{V}$. Given that PE is an iterative application of the Bellman operator (see What is the Bellman operator in reinforcement learning?), PE finds this unique fixed-point solution.\nSo, we just need to show that the Bellman operator is a $\\gamma$-contraction operator in order to show that PE finds this unique fixed-point solution.\nProof\nWe will measure the distance between state-value functions $u$ and $v$ by the $\\infty$-norm, i.e. the largest difference between state values:\n$$\\|u - v\\|_{\\infty} = \\operatorname{max}_{s \\in \\mathcal{S}} |u(s) - v(s)|$$\nDefinition (Bellman operator): We define the Bellman expectation operator as\n$$F^\\pi(v) = \\mathbf{r}^\\pi + \\gamma \\mathbf{T}^\\pi v$$\nwhere $v \\in \\mathcal{V}$, $\\mathbf{r}^\\pi$ is an $|\\mathcal{S}|$-dimensional vector whose $j$th entry gives $\\mathbb{E} \\left[ r \\mid s_j, a=\\pi(s_j) \\right]$ and $\\mathbf{T}^\\pi$ is an $|\\mathcal{S}| \\times |\\mathcal{S}|$ matrix whose $(j, k)$ entry gives $\\mathbb{P}(s_k \\mid s_j, a=\\pi(s_j))$.\nNow, let's measure the distance (with the $\\infty$-norm defined above) between any two value functions $u \\in \\mathcal{V}$ and $v \\in \\mathcal{V}$ after the application of the Bellman operator $F^\\pi$\n\\begin{align}\n\\| F^\\pi(u) - F^\\pi(v) \\|_{\\infty} \n&= \\| (\\mathbf{r}^\\pi + \\gamma \\mathbf{T}^\\pi u) - (\\mathbf{r}^\\pi + \\gamma \\mathbf{T}^\\pi v)\\|_{\\infty} \\\\\n&= \\| \\gamma \\mathbf{T}^\\pi (u - v)\\|_{\\infty} \\\\\n&\\leq \\| \\gamma \\mathbf{T}^\\pi ( \\mathbb{1} \\cdot \\| u - v \\|_{\\infty})\\|_{\\infty} \\\\\n&\\leq \\| \\gamma (\\mathbf{T}^\\pi \\mathbb{1}) \\cdot \\| u - v \\|_{\\infty}\\|_{\\infty} \\\\\n&\\leq \\gamma \\| u - v \\|_{\\infty}\n\\end{align}\nwhere $\\mathbb{1} = [1, \\dots, 1]^T$. Note that $\\mathbf{T}^\\pi \\cdot \\mathbb{1} = \\mathbb{1}$ because $\\mathbf{T}^\\pi$ is a stochastic matrix.\nBy the Bellman expectation equation (see Barto and Sutton's book and What is the Bellman operator in reinforcement learning?), $v^\\pi$ is a fixed-point of the Bellman operator $F^\\pi$. Given the contraction mapping theorem, the iterative application of $F^\\pi$ produces a unique solution, so $v^\\pi$ must be this unique solution, i.e. SPE finds $v^\\pi$. Here is another version of the proof that the Bellman operator is a contraction.\nNotes\nI didn't prove the contraction mapping theorem, but you can find more info about the theorem and its proof in the related Wikipedia article.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the intuition behind TD($\\lambda$)? I'd like to better understand temporal-difference learning. In particular, I'm wondering if it is prudent to think about TD($\\lambda$) as a type of \"truncated\" Monte Carlo learning?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "TD($\\lambda$) can be thought of as a combination of TD and MC learning, so as to avoid to choose one method or the other and to take advantage of both approaches.\nMore precisely, TD($\\lambda$) is temporal-difference learning with a $\\lambda$-return, which is defined as an average of all $n$-step returns, for all $n$, where an $n$-step return is the target used to update the estimate of the value function that contains $n$ future rewards (plus an estimate of the value function of the state $n$ steps in the future). For example, TD(0) (e.g. Q-learning is usually presented as a TD(0) method) uses a $1$-step return, that is, it uses one future reward (plus an estimate of the value of the next state) to compute the target. The letter $\\lambda$ actually refers to a parameter used in this context to weigh the combination of TD and MC methods. There are actually two different perspectives of TD($\\lambda$), the forward view and the backward view (eligibility traces).\nThe blog post Reinforcement Learning: Eligibility Traces and TD(lambda) gives a quite intuitive overview of TD($\\lambda$), and, for more details, read the related chapter of the book Reinforcement Learning: An Introduction.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it difficult to learn the rotated bounding box for a (rotated) object? I have checked out many methods and papers, like YOLO, SSD, etc., with good results in detecting a rectangular box around an object, However, I could not find any paper that shows a method that learns a rotated bounding box.\nIs it difficult to learn the rotated bounding box for a (rotated) object?\nHere's a diagram that illustrates the problem.\n\nFor example, for this object (see this), its bounding box should be of the same shape (the rotated rectangle is shown in the 2nd right image), but the prediction result for the YOLO will be Ist right.\nIs there any research paper that tackles this problem?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Cartesian Bias and Pipeline Efficiency\nYou are experiencing a techno-cultural artifact of Cartesian-centric imaging running all the way back to the dawn of coordinate systems. It is the momentum of practice as a consequence of applying Cartesian 2D coordinates to rasterize images appearing at the focal planes of lenses from the dawn of television and the earliest standards of raster based capture and display.\nAlthough some work was done toward adding tilt to bounding rectangles in the late 1990s and since, from a time and computing resource conservation perspective, it is computationally and programmatically less costly to include the four useless triangles of pixels and keep the bounding box orthogonal with the pixel grid.\nAdding a tilt angle to the bounding boxes is marginally competitive when detecting ships from a satellite only because two conditions offset the inefficiencies in that narrow domain. The ship appears as an oblong rectangle with rounded corners from a satellite positioned in geosynchronous orbit. In the general case, adding a tilt angle can slow recognition significantly.\nBiology Less Biased\nAn interesting side note is that the neural networks of animal and human vision systems do not have that Cartesian-centricity, but that doesn't help this question's solution, since non-orthogonal hardware and software is virtually nonexistent.\nEarly Non-Cartesian Research and Today's Rasterization\nGerber Scientific Techonology research and development in the 1980s (South Windsor, Connecticut, U.S.) investigated vector capture, storage, and display, but the R&D was not financially sustainable for a mid-side technology corporation for the reasons above.\nWhat remains, because it is economically viable and necessary from an animation point of view, is rasterization on the end of the system that converts vector models into frames of pixels. We see this in on the rendering SVG, VRML, and the original intent of CUDA cores and other hardware rendering acceleration strategies and architectures.\nOn the object and action recognition side, the support of vector models directly from imaging is much less developed. This has not been a major stumbling block for computer vision because the wasted pixels at one tilt angle may be of central importance at another tilt angle, so there are no actual wasted input pixels if the centering of key scene elements is widely distributed in translation and tilt, which is often the case in real life (although not so much in hygienically pre-processed datasets).\nConventions Around Object Minus Camera Tilt and Skew from Parallax\nOnce edge detection, interior-versus-exterior, and 3D solid recognition come into play, the design of CNN pipelines and the way kernels can do radial transformation without actually requiring $\\; \\sin, \\, \\cos, \\, \\text{and} \\, \\arctan \\;$ functions evaporate the computational burden of the Cartesian nature of pixel tensors. The end result is that the bounding box being orthogonal to the image frame is not as problematic as it initially appears. Efforts to conserve the four triangles of pixels and pre-process orientation is often a wasted effort by a gross margin.\nSummary\nThe bottom line is that efforts to produce vector recognition from roster inputs have been significantly inferior in terms of resource and wait time burden, with the exception of insignificant gains in the narrow domain of naval reconnaissance satellite images. Trigonometry is expensive, but convolution kernels, especially now that they are moving from software into hardware accelerated computing paths in VLSI, is computable at lower costs.\nPast and Current Work\nBelow is some work that deals with tilting with regard to objects and the effects of parallax in relation to the Cartesian coordinate system of the raster representation. Most of the work has to do with recognizing 3D objects in a 3D coordinate system to project trajectories and pilot or drive vehicles rationally on the basis of Newtonian mechanics.\nEfficient Collision Detection Using Bounding Volume Hierarchies of k-DOPs, James T. Klosowski, Martin Held, Joseph S.B. Mitchell, Henry Sowizral, and Karel Zikan, 1998\nSliding Shapes for 3D Object Detection in Depth Images, Shuran Song and Jianxiong Xiao, 2014\nAmodal Completion and Size Constancy in Natural Scenes, Abhishek Kar, Shubham Tulsiani, Joao Carreira and Jitendra Malik, 2015\nHMD Vision-based Teleoperating UGV and UAV for Hostile\nEnvironment using Deep Learning, Abhishek Sawarkar1, Vishal Chaudhari, Rahul Chavan, Varun Zope, Akshay Budale and Faruk Kazi, 2016\nShip rotated bounding box space for ship extraction from high-resolution optical satellite images with complex backgrounds, Z Liu, H Wang, L Weng, Y Yang, 2016\nAmodal Detection of 3D Objects:\nInferring 3D Bounding Boxes from 2D Ones in RGB-Depth Images, Zhuo Deng, 2017\n3D Pose Regression using Convolutional Neural Networks, Siddharth Mahendran, 2017\nAerial Target Tracking Algorithm Based on Faster R-CNN Combined with Frame Differencing, Yurong Yang, Huajun Gong, Xinhua Wang and Peng Sun, 2017\nA Semi-Automatic 2D solution for Vehicle Speed Estimation from Monocular Videos, Amit Kumar, Pirazh Khorramshahi, Wei-An Lin, Prithviraj Dhar, Jun-Cheng Chen, Rama Chellappa, 2018\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What tools are used to deal with adversarial examples problem? The problem of adversarial examples is known to be critical for neural networks. For example, an image classifier can be manipulated by additively superimposing a different low amplitude image to each of many training examples that looks like noise but is designed to produce specific misclassifications.\n\nSince neural networks are applied to some safety-critical problems (e.g. self-driving cars), I have the following question\n\nWhat tools are used to ensure safety-critical applications are resistant to the injection of adversarial examples at training time?\n\nLaboratory research aimed at developing defensive security for neural networks exists. These are a few examples.\n\nadversarial training (see e.g. A. Kurakin et al., ICLR 2017)\n\ndefensive distillation (see e.g. N. Papernot et al., SSP 2016)\n\nMMSTV defence (Maudry et al., ICLR 2018).\n\n\nHowever, do industrial-strength, production-ready defensive strategies and approaches exist? Are there known examples of applied adversarial-resistant networks for one or more specific types (e.g. for small perturbation limits)?\nThere are already (at least) two questions related to the problem of hacking and fooling of neural networks. The primary interest of this question, however, is whether any tools exist that can defend against some adversarial example attacks.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nHowever, do industrial strength, production ready defensive strategies and approaches exist? Are there known examples of applied adversarial-resistant networks for one or more specific types (e.g. for small perturbation limits)?\n\nI think it's difficult to tell whether or not there are any industrial strength defenses out there (which I assume would mean that they'd be reliable against all or most known methods of attacking). Adversarial Machine Learning is indeed a highly active, and growing, area of research. Not only are new approaches for defending being published quite regularly, but there is also active research into different approaches for \"attacking\". With new attack methods being discovered frequently, it's unlikely that anyone can already claim to have approaches that would work reliably against them all.\n\nThe primary interest of this question, however, is whether any tools exist that can defend against some adversarial example attacks.\n\nThe closest thing to a ready-to-use \"tool\" that I've been able to find is IBM's Adversarial Robustness Toolbox, which appears to have various attack and defense methods implemented. It appears to be in active development, which is natural considering the area of research itself is also highly active. I've never tried using it, so I can't vouch personally for the extent to which it's easily usable as a tool for industry, or if it's maybe really only still suitable for research.\n\nBased on comments by Ilya, other frameworks that may be useful to consider are Cleverhans and Foolbox.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is neural networks training done one-by-one? I'm trying to learn neural networks by watching this series of videos and implementing a simple neural network in Python.\nHere's one of the things I'm wondering about: I'm training the neural network on sample data, and I've got 1,000 samples. The training consists of gradually changing the weights and biases to make the cost function result in a smaller cost.\nMy question: Should I be changing the weights/biases on every single sample before moving on to the next sample, or should I first calculate the desired changes for the entire lot of 1,000 samples, and only then start applying them to the network?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nShould I be changing the weights/biases on every single sample before moving on to the next sample, \n\nYou can do this, it is called stochastic gradient descent (SGD) and typically you will shuffle the dataset before working through it each time.\n\nor should I first calculate the desired changes for the entire lot of 1,000 samples, and only then start applying them to the network?\n\nYou can do this, it is called batch gradient descent, or in some cases (especially in older resources) just assumed as the normal approach and called gradient descent.\nEach approach offers advantages and disadvantages. In general:\n\nSGD makes each update sooner in terms of amount of data that has been processed. So you may need less epochs before converging on reasonable values.\nSGD does more processing per sample (because it updates more frequently), so is also slower in the sense that it will take longer to process each sample. \nSGD can take less advantage of parallelisation, as the update steps mean you have to run each data item serially (as the weights have changed and error/gradient results are calculated for a specific set of weights).\nSGD individual steps make typically only very rough guesses at the correct gradients to change weights in. This is both a disadvantage (performance of the NN against the objective on the training set can decrease as well as increase) and an advantage (there is less likelihood of getting stuck in a local stationary point due the \"jitter\" these random differences cause).\n\nWhat happens in practice is that most software allows you to compromise between batch processing and single-sample processing, to try and get the best performance and update characteristics. This is called mini-batch processing, which involves:\n\nShuffling the dataset at the start of each epoch.\nWorking through the shuffled data, N items per time where N might vary from maybe 10 to 1000, depending on the problem and any constraints on the hardware. A common decision is to process the largest batch size that the GPU acceleration allows to run in parallel.\nCalculate the update required for each small batch, then apply it.\n\nThis is nowadays the most common update method that most neural network libraries assume, and they almost universally will accept a batch size parameter in the training API. Most of the libraries will still call simple optimisers that do that SGD; technically it is true, the gradients calculated are still somewhat randomised due to not using the full batch, but you may find this called mini-batch gradient descent in some older papers.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between the US and global edition of the AIMA book by Russell and Norvig? The book Artificial Intelligence: A Modern Approach by Russell and Norvig has two editions: global and the US. It looks like these two are generally the same, but have some differences in the order of the chapters and in the context, is this correct?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The difference can be found in the following link more clearly\nUS vs Global\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does the forget layer of an LSTM work? Can someone explain the mathematical intuition behind the forget layer of an LSTM? \nSo as far as I understand it, the cell state is essentially long term memory embedding (correct me if I'm wrong), but I'm also assuming it's a matrix. Then the forget vector is calculated by concatenating the previous hidden state and the current input and adding the bias to it, then putting that through a sigmoid function that outputs a vector then that gets multiplied by the cell state matrix.\nHow does a concatenation of the hidden state of the previous input and the current input with the bias help with what to forget?\nWhy is the previous hidden state, current input and the bias put into a sigmoid function? Is there some special characteristic of a sigmoid that creates a vector of important embeddings?\nI'd really like to understand the theory behind calculating the cell states and hidden states. Most people just tell me to treat it like a black box, but I think that, in order to have a successful application of LSTMs to a problem, I need to know what's going on under the hood. If anyone has any resources that are good for learning the theory behind why cell state and hidden state calculation extract key features in short and long term memory I'd love to read it.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "TL;DR Here is a beautiful explanation with diagrams: source.\nTo address:\n\nthe cell state is essentially long term memory embedding (correct me if I'm wrong)\n\nThe embedding can be long or short term and it is a vector.\nTo answer:\n\nWhy is the previous hidden state, current input and the bias put into a sigmoid function? Is there some special characteristic of a sigmoid that creates a vector of important embeddings?\n\nExcerpt from source:\n\nThe sigmoid layer outputs numbers between zero and one, describing how much of each component should be let through. A value of zero means \u201clet nothing through,\u201d while a value of one means \u201clet everything through!\u201d\n\nFormally the forget vector is:\n$$f_t = \\sigma(W_f\\cdot[h_{t-1},x_t],+b_f)$$\nSo we see that it is actually a linear operation followed by a non-linear operation, which restricts the values to be between 0 and 1. This is followed by an element-wise operation on the previous cell state. That is we \"gate\"/\"filter\" the previous cell state doing:\n$$C_{t-1}\\odot f_t,$$\nwhere $\\odot$ is element-wise multiplication.\nThus we see that the forget gate really is acting like a gate: It either lets values pass through or it pushes them toward zero. So, it's purpose is to assign what values to forget/remember.\nTo answer:\n\nHow does a concatenation of the hidden state of the previous input and the current input with the bias help with what to forget?\n\nThis concatenation takes into account the \"rolling\" hidden state and the current input. That is, the linear operation results in a new vector which can be seen as a \"consideration embedding\" of the current input and a \"summary\" of past inputs and cell states. The sigmoid then converts this \"consideration embedding\" into the forget vector.\nIn summary, the forget gate has the primary purpose of forming a vector of values between zero and one. This vector results by considering the current input and the previous hidden state. The vector is used to forget/remember parts of the previous cell state via element-wise multiplication. So, no, it is not a black box, it is a highly considerate non-linear operation through time.\nAdditional Intuition - More Mathematical\nRecall that multiplying a matrix on the right by a column vector produces a vector, which is a linear combination of the columns of the matrix. So each column of $W_f$ can be seen as a column of \"toggles\" that push up to 1 or pull down to 0 (once we apply sigmoid). That is, the columns of $W_f$ form a sort of \"basis\" for a \"toggle space.\"\nWhen we concatenate to form $[h_{t-1},x_t]$ and then multiply we see that the term $W_f\\cdot[h_{t-1},x_t]$ gives consideration to the hidden state and the input. That is, both $h_{t-1}$ and $x_t$ have there hand in toggling the gate.\nThe LSTM has learned from the data how to make this toggling \"meaningful.\" Below is a simple pictographic example.\n\nThat is, $W_f\\cdot[h_{t-1},x_t]$ will be a vector in the column space of $W_f$ (ie the \"toggle space\"). Thus, the concatenated vector will \"point\" to the best \"toggle\" in the column (\"toggle\") space of $W_f$. This \"toggle\" is then transformed into a \"gate\" in the \"gate space.\"\nSo intuitively, the range of the forget component is a sort of \"gate space\" where the domain is all vectors of form $[h_{t-1},x_t]$. Formally:\n$$f_t:[h_{t-1},x_t]\\mapsto g_t$$\nThat is to say that the forget gate learns the best mapping from the domain of concatenated hidden/input's to the range of possible gates.\nImportant Note\nThe LSTM is only one of many types of forget-gate mappings. The main takeaway is that the LSTM works empirically for many applications.\nThat is a forget gate is an instance of a general \"gate mapping\":\n$$f_t:v_t \\mapsto g_t,$$\nwhere $v_t$ could be any number of vectors resulting from any number of concatenations.\nConclusion\nSome data from the past is irrelevant to the current time step. We need a way to correctly \"forget\" irrelevant information. One way to \"forget\" is to use a forget gate mapping (like the one in LSTMs). Then we need to optimize the parameters of that forget gate. One implementation is used in the common LSTM architecture. Finally, the concatenation of the previous hidden state provides contextual information to the current input which is very helpful with forgetting.\nMore Mathematical Intuition\nHere is another view of what is happening in the LSTM from a dynamic point of view: video.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the meaning of $V(D,G)$ in the GAN objective function? Here is the GAN objective function.\n$$\\min _{G} \\max _{D} V(D, G)=\\mathbb{E}_{\\boldsymbol{x} \\sim p_{\\text {data }}(\\boldsymbol{x})}[\\log D(\\boldsymbol{x})]+\\mathbb{E}_{\\boldsymbol{z} \\sim p_{\\boldsymbol{z}}(\\boldsymbol{z})}[\\log (1-D(G(\\boldsymbol{z})))]$$\nWhat is the meaning of $V(D, G)$?\nHow do we get these expectation parts?\nI was trying to understand it following this article: Understanding Generative Adversarial Networks (D.Seita), but, after many tries, I still can't understand how he got from $\\sum_{n=1}^{N} \\log D(x)$ to $\\mathbb{E}(\\log(D(x))$.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "To understand this equation first you need to understand the context in which it is first introduced. We have two neural networks (i.e. $D$ and $G$) that are playing a minimax game. This means that they have competing goals. Let's look at each one separately:\nGenerator\nBefore we start, you should note that throughout the whole paper the notion of the data-generating distribution is used; in short the authors will refer to the samples through their underlying distributions, i.e. if a sample $a$ is drawn from a distribution $p_a$, we'll denote this as $a \\sim p_a$. Another way to look at this is that $a$ follows distribution $p_a$.\nThe generator ($G$) is a neural network that produces samples from a distribution $p_g$. It is trained so that it can bring $p_g$ as close to $p_{data}$ as possible so that samples from $p_g$ become indistinguishable to samples from $p_{data}$. The catch is that it never gets to actually see $p_{data}$. Its inputs are samples $z$ from a noise distribution $p_z$.\nDiscriminator\nThe discriminator ($D$) is a simple binary classifier that tries to identify which class a sample $x$ belongs to. There are two possible classes, which we'll refer to as the fake and the real. Their respective distributions are $p_{data}$ for the real samples and $p_g$ for the fake ones (note that $p_g$ is actually the distribution of the outputs of the generator, but we'll get back to this later).\nSince it is a simple binary classification task, the discriminator is trained on a binary cross-entropy error:\n$$\nJ^{(D)} = H(y, \\hat y) = H(y, D(x))\n$$\nwhere $H$ is the cross-entropy $x$ is sampled either from $p_{data}$ or from $p_g$ with a probability of $50\\%$. More formally:\n$$\nx \\sim\n\\begin{cases}\np_{data} \\rightarrow & y = 1, & \\text{with prob 0.5}\\\\\np_g \\;\\;\\;\\,\\rightarrow & y = 0, & \\text{otherwise}\n\\end{cases}\n$$ \nWe consider $y$ to be $1$ if $x$ is sampled from the real distribution and $0$ if it is sampled from the fake one. Finally, $D(x)$ represents the probability with which $D$ thinks that $x$ belongs to $p_{data}$. By writing the cross-entropy formula we get:\n$$\nH(y, D(x)) = \\mathbb{E}_y[-log \\; D(x)] = \\frac{1}{N} \\sum_{i=1}^{N}{ \\; y_i \\; log(D(x_i))}\n$$\nwhere $N$ is the size of the dataset. Since each class has $N/2$ samples we can split this sum into two parts:\n$$\n= - \\left[ \\frac{1}{N} \\sum_{i=1}^{N/2}{ \\; y_i \\; log(D(x_i))} + \\frac{1}{N} \\sum_{i=N/2}^{N} \\; (1 - y_i) \\; log((1 - D(x_i))) \\right]\n$$\nThe first of the two terms represents the the samples from the $p_{data}$ distribution, while the second one the samples from the $p_g$ distribution. Since all $y_i$ are equally likely to occur, we can convert the sums into expectations:\n$$\n= - \\left[ \\frac{1}{2} \\; \\mathbb{E}_{x \\sim p_{data}}[log \\; D(x)] + \\frac{1}{2} \\; \\mathbb{E}_{x \\sim p_{g}}[log \\; (1 - D(x))] \\right]\n$$\nAt this point, we'll ignore $2$ from the equations since it's constant and thus irrelevant when optimizing this equation. Now, remember that samples that were drawn from $p_g$ were actually outputs from the generator (obviously this affects only the second term). If we substitute $D(x), x \\sim p_g$ with $D(G(z)), z \\sim p_z$ we'll get:\n$$\nL_D = - \\left[\\; \\mathbb{E}_{x \\sim p_{data}}[log \\; D(x)] + \\; \\mathbb{E}_{z \\sim p_{z}}[log \\; (1 - D(G(z)))] \\right]\n$$\nThis is the final form of the discriminator loss. \nZero-sum game setting\nThe discriminator's goal, through training, is to minimize its loss $L_D$. Equivalently, we can think of it as trying to maximize the opposite of the loss:\n$$\n\\max_D{[-J^{(D)}]} = \\max_D \\left[\\; \\mathbb{E}_{x \\sim p_{data}}[log \\; D(x)] + \\; \\mathbb{E}_{z \\sim p_{z}}[log \\; (1 - D(G(z)))] \\right]\n$$\nThe generator however, wants to maximize the discriminator's uncertainty (i.e. $J^{(D)}$), or equivalently minimize $-J^{(D)}$. \n$$\nJ^{(G)} = - J^{(D)}\n$$\nBecause the two are tied, we can summarize the whole game through a value function $V(D, G) = -J^{(D)}$. At this point I like to think of it like we are seeing the whole game through the eyes of the generator. Knowing that $D$ tries to maximize the aforementioned quantity, the goal of $G$ is:\n$$\n\\min_G\\max_D{V(D, G)} = \\min_G\\max_D \\left[\\; \\mathbb{E}_{x \\sim p_{data}}[log \\; D(x)] + \\; \\mathbb{E}_{z \\sim p_{z}}[log \\; (1 - D(G(z)))] \\right]\n$$\nDisclaimer:\nThis whole endeavor (on both my part and the authors' part) was to provide a mathematical formulation to training GANs. In practice there are many tricks that are invoked to effectively train a GAN, that are not depicted in the above equations.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why spend so much time and money to build AIs to play games? I was reading about John McCarthy and his orthodox vision of Artificial Intelligence. To me, it seems like he was not very much in favour of resources (like time and money) being used to make AIs play games like Chess. Instead, he wanted more to focus on passing the Turing test and AIs imitating human behavior.\nI have also read many articles about major companies, like IBM, Google, etc., spending millions of dollars in making AIs play games, like Chess, Go, etc.\nTo what extent is this justified?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In the book Artificial Intelligence: A Modern Approach (section 5.7, p. 185), Russell and Norvig write\n\nIn 1965, the Russian mathematician Alexander Kronrod called chess \"the Drosophila of artificial intelligence.\" John McCarthy disagrees: whereas geneticists use fruit flies to make discoveries that apply to biology more broadly, AI has used chess to do the equivalent of breeding very fast fruit flies. Perhaps a better analogy is that chess is to AI as Grand Prix motor racing is to the car industry: state-of-the-art game programs are blindingly fast, highly optimized machines that incorporate the latest engineering advances, but they aren't much use for doing the shopping or driving off-road. Nonetheless, racing and game-playing generate excitement and a steady stream of innovations that have been adopted by the wider\ncommunity\n\nSo, although these games (like Chess, Go, and Bridge) may not apparently be useful/beneficial to many people, the AI programs developed to play them have introduced/included concepts/techniques, like null move heuristics, futility pruning, combinatorial game theory, finessing and squeezing or meta-reasoning, which can potentially be useful to a wider spectrum of Computer Science (and not just Artificial Intelligence).\nYou can see it similar to space missions of NASA, ISRO, JAXA and other space agencies. All these missions don't seem to have a direct benefit to citizens, but have many indirect benefits. They pave the way for technological innovations (GPS, 3D printing, car crash technology, clean energy, LED), the creation of jobs, etc. Advance storms, hurricane detection is the output of space exploration, which has saved millions of lives worldwide.\nAI in games has not just helped to develop the software but hardware also. Many innovations have been seen to produce highly optimised and powerful hardware.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are there neural networks with very few nodes that decently solve non-trivial problems? I'm interested in knowing whether there exist any neural network, that solves (with >=80% accuracy) any nontrivial problem, that uses very few nodes (where 20 nodes is not a hard limit). I want to develop an intuition on sizes of neural networks.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Even if it\u2019s impossible to answer this question properly, as non trivial is not well defined (maybe the author will edit this questions later, to specify it better), I take the opportunity to point out this paper which looks interesting to me \nSmallest Neural Network to Learn the Ising Criticality\nAssuming you have a general idea of the Ising Model I think the problem of identifying the critical temperature from a data driven perspective can be considered as non trivial and the paper shows how the authors have improved the performance related to solve this task with NN passing from 100 Hidden Neurons, as performed in this paper Machine learning phases of matter from 2017, to only 2 Hidden Neurons \nJust my cents: \n\nreducing the neurons, while keeping good performance, should help in terms of neural processing interpretability which is notoriously obscure and its complexity grows (exponentially) with the number of neurons\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "A mathematical explanation of Attention Mechanism 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 attention mechanism really adding to the network? \nA potential answer in the case of Encoder-Decoder RNNs is: \n\nThe most important distinguishing feature of this approach from the\n basic encoder\u2013decoder is that it does not attempt to encode a whole\n input sentence into a single fixed-length vector. Instead, it encodes\n the input sentence into a sequence of vectors and chooses a subset of\n these vectors adaptively while decoding the translation. This frees a\n neural translation model from having to squash all the information of\n a source sentence, regardless of its length, into a fixed-length\n vector. We show this allows a model to cope better with long\n sentences.\n - Neural Machine Translation by Jointly Learning to Align and Translate\n\nwhich made sense and the paper says that it worked better for NMT.\nA previous study indicated that breaking down the sentence into phrases could lead to better results:\n\nIn this paper, we propose a way to address this issue by automatically\n segmenting an input sentence into phrases that can be easily\n translated by the neural network translation model. Once each segment\n has been independently translated by the neural machine translation\n model, the translated clauses are concatenated to form a final\n translation. Empirical results show a significant improvement in\n translation quality for long sentences.\n - Overcoming the Curse of Sentence Length for Neural Machine\n Translation using Automatic Segmentation\n\nwhich paved the way for further research resulting in attention models.\nI was also going through an article on Attention is not quite all you need where it said something similar: \n\nAn LSTM has to learn to sequentially retain past values together in a\n single internal state across multiple RNN iterations, whereas\n attention can recall past sequence values at any point in a single\n forward pass.\n\nand a more curated blog on the family of attention mechanism gives insight on how different ways have been formulated for implementing the concept: Attention? Attention!\nSpecifically, I want to know how attention mechanism is formulated for this task (aforementioned) or in general. A detailed mathematical insight would be helpful, probably somewhat on these lines: Understanding Attention in NN mathematically\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "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.\nThere is no one dominant attention approach and probably will not be. In fact, the earliest attention mechanism in common use in machines was likely the electromechanical fire alarm. In digital systems, it would be a vacuum tube electric eye driving an intruder alert followed by the first hardware interrupts in transistor microprocessor boards.\nThe sophistication of hardware interrupts in contemporary computer systems is probably higher than attention mechanisms in neural nets as of this writing, but that may change. Currently the dictionary definition of attention is the only constraint we can place on these newer approaches in artificial networks.\n\nThe four working links in the question (one is broken) lead to articles with some mathematical description, so the question half answers itself.\nThis article, Dynamic relevance: vision-based focus of attention using artificial neural networks,\nShumeet Baluja, Dean Pomerleau, 1995; revised 1996,\n(abstract),\nhas only a few mathematical expressions but is filled with system\ntheory that could be described mathematically with a little reading\nand thought.\nSame with Self-Organization of an Artificial Neural Network\nSubjected to Attention Shift Impairments and Familiarity\nPreference, Characteristics Studied in Autism, Lennart Gustafsson and Andrew P. Papli\u0144ski, 2004.\nThis one has clear and comprehensive mathematical treatment: Backpropagation Generalized Delta Rule for the Selective Attention Sigma-if Artificial Neural Network, Maciej Huk, 2012\nThis one too: Small and Dim Target Detection via Lateral Inhibition Filtering and Artificial Bee Colony Based Selective Visual Attention, Haibin Duan, Yimin Deng, Xiaohua Wang, Chunfang Xu, 2013\nThere is some here, but the visualizations and concepts are so theoretically relevant that one might not miss the more extensive mathematics: Using chaotic artificial neural networks to model memory in the brain, Zainab Aram, Sajad Jafari, Jun Ma, Julien C. Sprott, Sareh Zendehrouh, Viet-Thanh Pham\nSolid math coverage here: Parallel Implementation of Artificial Neural Network Training, Stefano Scanzio, Sandro Cumani, Roberto Gemello, Franco Mana, P. Laface, 2010, (abstract)\nAlso here: Multiple Object Recognition with Visual Attention, Jimmy Lei Ba, Volodymyr Mnih, Koray Kavukcuoglu, 2015 ICLR\nThe mathematics for the very popular DiSAN is here: DiSAN: Directional Self-Attention Network for RNN/CNN-Free Language Understanding, Tao Shen, Jing Jiang, Tianyi Zhou, Shirui Pan, Guodong Long, Chengqi Zhang, 2018\nMathematics and the algorithm is provided for this unique approach too: Graph Classification using Structural Attention, John Boaz Lee, Ryan Rossi, Xiangnan Kong, 2018\n\nIt would be interesting to develop a taxonomy of attention approaches in AI, as that has probably not yet been done. It would take quite a study to see if any of the above bullet items match up with either of the two articles referenced in the question.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When should I use 3D convolutions? I am new to convolutional neural networks, and I am learning 3D convolution. What I could understand is that 2D convolution gives us relationships between low-level features in the X-Y dimension, while the 3D convolution helps detect low-level features and relationships between them in all the 3 dimensions.\nConsider a CNN employing 2D convolutional layers to recognize handwritten digits. If a digit, say 5, was written in different colors:\n\nWould a strictly 2D CNN perform poorly (since they belong to different channels in the z-dimension)?\nAlso, are there practical well-known neural nets that employ 3D convolution?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "3D convolutions are used when you want to extract features in 3 dimensions or establish a relationship between 3 dimensions.\nEssentially, it's the same as 2D convolutions, but the kernel movement is now 3-dimensional, causing a better capture of dependencies within the 3 dimensions and a difference in output dimensions post convolution.\nThe kernel of the 3d convolution will move in 3-dimensions if the kernel's depth is lesser than the feature map's depth.\n\nOn the other hand, 2-D convolutions on 3-D data mean that the kernel will traverse in 2-D only. This happens when the feature map's depth is the same as the kernel's depth (channels).\n\nSome use cases for better understanding are\n\nMRI scans where the relationship between a stack of images is to be understood;\n\nlow-level feature extractor for spatio-temporal data, like videos for gesture recognition, weather forecasting, etc. (3-D CNN's are used as low level feature extractors only over multiple short intervals, as 3D CNN's fail to capture long term spatio-temporal dependencies - for more on that check out ConvLSTM or an alternate perspective here.)\n\n\nMost CNN models that learn from video data almost always have 3D CNN as a low level feature extractor.\nIn the example you have mentioned above regarding the number 5 - 2D convolutions would probably perform better, as you're treating every channel intensity as an aggregate of the information it holds, meaning the learning would almost be the same as it would on a black and white image. Using 3D convolution for this, on the other hand, would cause learning of relationships between the channels which do not exist in this case! (Also 3D convolutions on an image with depth 3 would require a very uncommon kernel to be used, especially for the use case)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the relationship between gradient accumulation and batch size? I am currently training some models using gradient accumulation since the model batches do not fit in GPU memory. Since I am using gradient accumulation, I had to tweak the training configuration a bit. There are two parameters that I tweaked: the batch size and the gradient accumulation steps. However, I am not sure about the effects of this modification, so I would like to fully understand what is the relationship between the gradient accumulation steps parameter and the batch size.\nI know that when you accumulate the gradient you are just adding the gradient contributions for some steps before updating the weights. Normally, you would update the weights every time you compute the gradients (traditional approach):\n$$w_{t+1} = w_t - \\alpha \\cdot \\nabla_{w_t}loss$$\nBut when accumulating gradients you compute the gradients several times before updating the weights (being $N$ the number of gradient accumulation steps):\n$$w_{t+1} = w_t - \\alpha \\cdot \\sum_{0}^{N-1} \\nabla_{w_t}loss$$\nMy question is: What is the relationship between the batch size $B$ and the gradient accumulation steps $N$?\nBy example: are the following configurations equivalent?\n\n$B=8, N=1$: No gradient accumulation (accumulating every step), batch size of 8 since it fits in memory.\n$B=2, N=4$: Gradient accumulation (accumulating every 4 steps), reduced batch size to 2 so it fits in memory.\n\nMy intuition is that they are but I am not sure. I am not sure either if I would have to modify the learning rate $\\alpha$.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There isn't any explicit relation between the batch size and the gradient accumulation steps, except for the fact that gradient accumulation helps one to fit models with relatively larger batch sizes (typically in single-GPU setups) by cleverly avoiding memory issues. The core idea of gradient accumulation is to perform multiple backward passes using the same model parameters before updating them all at once for multiple batches. This is unlike the conventional manner, where the model parameters are updated once every batch-size number of samples. Therefore, finding the correct batch-size and accumulation steps is a design trade-off that has to be made based on two things: (i) how much increase in the batch-size can the GPU handle, and (ii) whether the gradient accumulation steps result in at least as much better performance than without accumulation.\nAs for your example configurations, there are the same in theory. But, there are a few important caveats that need to be addressed before proceeding with this intuition.\n\nUsing Batch Normalization with gradient accumulation generally does not work well, simply because BatchNorm statistics cannot be accumulated. A better solution would be to use Group Normalization instead of BatchNorm.\nWhen performing a combined update in gradient accumulation, it must be ensured that the optimizer is not initialized to zero (i.e. optimizer.zero_grad()) for every backward update (i.e. loss.backward()). It is easy to include both statements in the same for loop while training which defeats the purpose of gradient accumulation.\n\nHere are some interesting resources to find out more about it detail.\n\nThomas Wolf's article on different ways of combating memory issues.\nKaggle discussions on the effect on learning rate: here and here.\nA comprehensive answer on gradient accumulation in PyTorch.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do mutation and crossover work with real-valued chromosomes? How exactly are \"mutation\" and \"cross-over\" applied in the context of a genetic algorithm based on real numbers (as opposed to just bits)? I think I understood how those two phases are applied in a \"canonical\" context where chromosomes are strings of bits of a fixed length, but I'm not able to find examples for other situations. What would those phases look like on the domain of real numbers?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You have a genome with certain genes:\ngenome = { GeneA: value, GeneB: value, GeneC: value }\n\nSo take for example:\ngenome = { GeneA: 1, GeneB: 2.5, GeneC: 3.4 }\n\nA few examples of mutation could be:\n\nSwitch around two genes: { GeneA: 1, GeneB: 3.4, GeneC: 2.5 }\nAdd/substract a random value from a gene: { GeneA: 0.9, GeneB: 2.5, GeneC: 3.4 }\n\nSuppose you have two genomes:\ngenome1 = { GeneA: 1, GeneB: 2.5, GeneC: 3.4 }\ngenome2 = { GeneA: 0.4, GeneB: 3.5, GeneC: 3.2 }\n\nA few examples of crossover could be:\n\nTaking the average: { GeneA: 0.7, GeneB: 3.0, GeneC: 3.3 }\nUniform (50% chance): { GeneA: 0.4, GeneB: 2.5, GeneC: 3.2 }\nN-point crossover: { GeneA: 1, | CROSSOVER POINT | GeneB: 3.5, GeneC: 3.2 }\n\n\nYou can be pretty imaginative when developing mutation and crossover methods.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can a technological singularity only occur with superintelligence? In Chapter 26 of the book Artificial Intelligence: A Modern Approach (3rd edition), the textbook discusses \"technological singularity\". It quotes I.J. Good, who wrote in 1965:\n\nLet an ultra-intelligent machine be defined as a machine that can far surpass all the intellectual activities of any man however clever. Since the design of machines is one of these intellectual activities, an ultra-intelligent machine could design even better machines; there would then unquestionably be an \"intelligence explosion,\" and the intelligence of man would be left far behind. Thus the first ultra-intelligent machine is the last invention that man need ever make, provided that the machine is docile enough to tell us how to keep it under control.\n\nLater on in the textbook, you have this question:\n\n26.7 - I. J. Good claims that intelligence is the most important quality, and that building ultr- intelligent machines will change everything. A sentient cheetah counters that \"Actually speed is more important; if we could build ultrafast machines, that would change everything\" and a sentient elephant claims \"You're both wrong; what we need is ultrastrong machines,\" What do you think of these arguments?\n\nIt seems that the textbook question is an implicit argument against I.J. Good. Good may be treating intelligence as valuable, simply because man's strengths lies in that trait called \"intelligence\". But other traits could be equally valued instead (speed or strength) and sentient beings may speculate wildly about their preferred traits being \"maximized\" by some machine or another.\nThis makes me wonder whether a singularity could occur if we had built machines that were not maximizing intelligence, but instead maximizing some other trait (a machine that is always increasing its strength, or a machine that is always increasing its speed). These types of machines can be just as transformative - ultrafast machines may solve problems quickly due to \"brute force\", and ultrastrong machines can use its raw power for a variety of physical tasks. Perhaps a ultra-X machine can't build another ultra-X machine (as I.J. Good treated the design of machines as an intellectual activity), but a continually self-improving machine would still leave its creators far behind and force its creators to be dependent on it.\nAre technological singularities limited to ultra-intelligences? Or technological singularities be caused by machines that are not \"strong AI\" but are still \"ultra\"-optimizers?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "That would be a no for speed or strength, if you have a super strong entity but it cannot research new materials, it will be quickly limited, same thing for speed, Basically, you need something out of their field to improve them, which makes a runaway improvement impossible. \nThough, we already have super strong and super fast machines, those are cars, trucks, hydraulic presses, industrial exoskeletons etc... But, even though we can build better ones through the use of the old ones, we still need to research stuff that can't be improved by old ones.\nWhat we need for a singularity is a field where an improvement in it makes further improvement easier. And I don't know a field where this doesn't involve intelligence. \nIf there is one, that may be possible to have a non intelligence driven singularity there.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is back-propagation applied for each data point or for a batch of data points? I am new to deep learning and trying to understand the concept of back-propagation. I have a doubt about when the back-propagation is applied. Assume that I have a training data set of 1000 images for handwritten letters,\n\nIs back-propagation applied immediately after getting the output for each input or after getting the output for all inputs in a batch?\n\nIs back-propagation applied $n$ times till the neural network gives a satisfactory result for a single data point before going to work on the next data point?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Short answers\n\nIs back-propagation applied immediately after getting the output for each input or after getting the output for all inputs in a batch?\n\nYou can perform back-propagation using (or after) only one training input (also known as data point, example, sample or observation) or multiple ones (a batch). However, the loss function to train the neural network is slightly different in both cases.\n\nIs back-propagation applied $n$ times till the neural network gives a satisfactory result for a single data point before going to work on the next data point?\n\nIf we use only one example, we usually do not wait until the neural network gives satisfactory results for a single input-label pair $(x_i, y_i)$, but we keep feeding it with several input-label pairs, one after the other (and each time updating the parameters of the neural network using back-propagation), without usually caring whether the neural network already produces a satisfactory output for an input-label pair before feeding it with the next (although you could also do that).\nLong answer (to the 1st question)\nIn case you want to know more about the first question, keep reading!\nWhat is back-propagation?\nBack-propagation is the (automatic) process of differentiating the loss function, which we use to train the neural network, $\\mathcal{L}$, with respect to all of the parameters (or weights) of the same neural network. If you collect the $N$ parameters of the neural network in a vector\n$$\\boldsymbol{\\theta} = \n\\begin{bmatrix}\n\\theta_1\\\\\n\\vdots \\\\\n\\theta_N\n\\end{bmatrix},\n$$\nthen the derivative of the loss function $\\mathcal{L}$ with respect to $\\boldsymbol{\\theta}$ is called the gradient, which is a vector that contains the partial derivatives of the loss function with respect to each single scalar parameter of the network, $\\theta_i$, for $i=1, \\dots, N$, that is, the gradient looks something like this\n$$\n\\nabla \\mathcal{L} =\n\\begin{bmatrix}\n\\frac{\\partial \\mathcal{L}}{ \\partial \\theta_1}\\\\\n\\vdots \\\\\n\\frac{\\partial \\mathcal{L}}{ \\partial \\theta_N}\n\\end{bmatrix},\n$$\nwhere the symbol $\\nabla$ denotes the gradient of the function $\\mathcal{L}$.\nLoss functions\nThe specific loss function $\\mathcal{L}$ that is used to train the neural network depends on the problem that we need to solve. For example, if we need to solve a regression problem (i.e. predict a real number), then the mean squared error (MSE) can be used. If we need to solve a classification problem (i.e. predict a class), the cross-entropy (CE) (aka negative log-likelihood) may be used instead.\nExample\nLet us assume that we need to solve a regression problem, so we choose the mean squared error (MSE) as the loss function. For simplicity, let's also assume that the neural network, denoted by $f_{\\boldsymbol{\\theta}}$, contains only one output neuron and contains no biases.\nStochastic gradient descent\nGiven an input-label pair $(x_i, y_i) \\in D$ (where $D$ is a dataset of input-label pairs), the squared error function (not the mean squared error yet!) is defined as\n$$\\mathcal{L}_i(\\boldsymbol{\\theta}) = \\frac{1}{2} (f_{\\boldsymbol{\\theta}}(x_i) - y_i)^2,$$\nwhere $f_{\\boldsymbol{\\theta}}(x_i) = \\hat{y}_i$ is the output of the neural network for the the data point $x_i$ (which depends on the specific values of $\\boldsymbol{\\theta}$) and $y_i$ is the corresponding ground-truth label.\nAs the name suggests, $\\mathcal{L}_i$ (where the subscript $_i$ is only used to refer to the specific input-label pair $(x_i, y_i)$) measures the squared error (i.e. some notion of distance) between the current prediction (or output) of the neural network, $\\hat{y}_i$, and the expected output for the given input $x_i$, i.e. $y_i$.\nWe can differentiate $\\mathcal{L}_i(\\boldsymbol{\\theta})$ with respect to the parameters of the neural network, $\\boldsymbol{\\theta}$. However, given that the details of back-propagation can easily become tedious, I will not describe them here. You can find more details here.\nSo, let me assume that we have a computer program that is able to compute $\\nabla \\mathcal{L}_i$. At that point, we can perform one step of the gradient descent algorithm\n$$\n\\boldsymbol{\\theta} \\leftarrow \\boldsymbol{\\theta} - \\gamma \\nabla \\mathcal{L}_i, \\label{1}\\tag{1}\n$$\nwhere $\\gamma$ is the learning rate and $\\leftarrow$ is the assignment operator. Note that $\\boldsymbol{\\theta}$ and $\\nabla \\mathcal{L}_i$ have the same dimensions, $N$.\nSo, I have just shown you that you can update the parameters of the neural network using only one input-label pair, $(x_i, y_i)$. This way of performing GD with only one input-label pair is known as stochastic gradient descent (SGD).\nBatch (or mini-batch) gradient descent\nIn practice, for several reasons (including learning instability and inefficiency), it is rarely the case that you update the parameters using only one input-label pair $(x_i, y_i)$. Instead, you use multiple input-label pairs, which are collected in a so-called batch\n$$B = \\{(x_1, y_i), \\dots, (x_M, y_M) \\},$$\nwhere $M$ is the size of batch $B$, which is also known as mini-batch when $M$ is smaller than the total number of input-label pairs in the training dataset, i.e. when $|B| = M < |D|$. If you use mini-batches, typical values for $M$ are $32$, $64$, $128$, and $256$ (yes, powers of 2: can you guess why?). See this question for other details.\nIn this case, the loss function $\\mathcal{L}_M(\\boldsymbol{\\theta})$ is defined as as the mean (or average) of the squared errors for single input-label pairs, $\\mathcal{L}_i(\\boldsymbol{\\theta})$, i.e.\n\\begin{align}\n\\mathcal{L}_M(\\boldsymbol{\\theta}) \n&= \\frac{1}{M} \\sum_{i=1}^M \\mathcal{L}_i(\\boldsymbol{\\theta}) \\\\\n&= \\frac{1}{M} \\sum_{i=1}^M \\frac{1}{2} (f_{\\boldsymbol{\\theta}}(x_i)-y_i)^2 \\\\\n&= \\frac{1}{M} \\frac{1}{2} \\sum_{i=1}^M (f_{\\boldsymbol{\\theta}}(x_i)-y_i)^2.\n\\end{align}\nThe normalisation factor, $\\frac{1}{M}$, can be thought of as averaging out the losses of all input-label pairs. Note also that we can take the $\\frac{1}{2}$ out of the summation because it is a constant with respect to the variable of the summation, $i$.\nIn this case, let me also assume that we are able to compute (using back-propagation) the gradient of $\\mathcal{L}_M$, so that we can perform a gradient descent (GD) update (using a batch of examples)\n$$\n\\boldsymbol{\\theta} \\leftarrow \\boldsymbol{\\theta} - \\gamma \\nabla \\mathcal{L}_M \\label{2} \\tag{2}\n$$\nThe only thing that changes with respect to the GD update in equation \\ref{1} is the loss function, which is now $\\mathcal{L}_M$ rather than $\\mathcal{L}_i$.\nThis is known as mini-batch (or batch) gradient descent. In the case $M = |D|$, this is simply known as gradient descent, which is a term that can also be used to refer to any of its variants (including SGD or mini-batch GD).\nFurther reading\nYou may also be interested in this answer, which provides more details about mini-batch gradient descent.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the merged neural network of AlphaGo Zero more efficient than two separate neural networks? AlphaGo Zero contains several improvements compared to its predecessors. Architectural details of Alpha Go Zero can be seen in this cheat sheet.\nOne of those improvements is using a single neural network that calculates move probabilities and the state value at the same time, while the older versions used two separate neural networks. It has been shown that the merged neural network is more efficient according to the paper:\n\nIt uses one neural network rather than two. Earlier versions of AlphaGo used a \u201cpolicy network\u201d to select the next move to play and a \u201dvalue network\u201d to predict the winner of the game from each position. These are combined in AlphaGo Zero, allowing it to be trained and evaluated more efficiently.\n\nThis seems counter intuitive to me, because from a software design perspective this violates the principle separation of concerns. That's why I am wondering, why this merge has been proven beneficial.\nCan this technique - merging different tasks in a single neural network to improve efficiency - be applied to other neural networks in general or does this require certain conditions to work?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Why has this merge proven beneficial?\nIf you think about the shared Value/Policy network as consisting of a shared component (the Residual Network layers) with a Value and Policy component on top rather than Separation of Concerns it makes more sense.\nThe underlying premise is that the shared part of the network (the ResNet) provides a high-level generalization of the input (the game states leading up to the move) that is a good input representation for both the shallow Value and Policy networks.\nWhen that is the case, we can reduce the computational load a lot by training a single shared ResNet and using it for two much simpler networks than training two ResNets for the Value and Policy. In their case, training the two together also improves regularisation and thus creates a more robust, general representation. \nSpecifically, the Alpha Go Zero paper by Silver et al., Mastering the Game of Go without Human Knowledge, states that:\n\nCombining policy and value together into a single network slightly reduced the \n move prediction accuracy, but reduced the value error and boosted playing \n performance in AlphaGo by around another 600 Elo. This is partly due to\n improved computational efficiency, but more importantly the dual objective regularises the network to a common representation that supports multiple use cases.\n\nCan this technique be applied in general or only in special cases?\nLike common components in software libraries, it only makes sense when the problems you are trying to solve benefit from a shared representation.\nYou can use it if you are training classifiers for similar tasks, or training a new task with little data where you already have a classifier trained over a larger, similar dataset.\nOutside of Go, it is often used in image recognition. \nDeep pre-trained networks such as the ones from the ImageNet ILSVRC competitions are commonly used as a starting point. They are classifiers that have been trained (for weeks!) on over a million images.\nThen, say you want to create a network to recognize you favourite brand of bicycles, you start with the general image-recognition pipeline trained on ImageNet, chop of the last layers that do the actual classification (\"it's a Border Collie\") and add a small new classifier to pick out only the bicycles you care about.\nSince the pre-trained classifier already provides high-level image concepts that are good building blocks for image recognition (it classifies 200 categories), this saves you a lot of training and makes for a very robust classifier.\nOf course there are many cases where the problems do not have useful shared representations and thus no benefit from a combined network. Nevertheless, it is a useful tool in the right situations.\nLook up Transfer Learning or Multi-Task Learning to learn more about this.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a deep neural network? What is the definition of a deep neural network? Why are they so popular or important?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A deep neural network (DNN) is nothing but a neural network which has multiple layers, where multiple can be subjective.\nIMHO, any network which has 6 or 7 or more layers is considered deep. So, the above would form a very basic definition of a deep network. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there a trade-off between flexibility and efficiency? A \"general intelligence\" may be capable of learning a lot of different things, but possessing capability does not equal actually having it. The \"AGI\" must learn...and that learning process can take time. If you want an AGI to drive a car or play Go, you have to find some way of \"teaching\" it. Keep in mind that we have never built AGIs, so we don't know how long the training process can be, but it would be safe to assume pessimistic estimates.\nContrast that to a \"narrow intelligence\". The narrow AI already knows how to drive a car or play Go. It has been programmed to be very excellent at one specific task. You don't need to worry about training the machine, because it has already been pre-trained.\nA \"general intelligence\" seems to be more flexible than a \"narrow intelligence\". You could buy an AGI and have it drive a car and play Go. And if you are willing to do more training, you can even teach it a new trick: how to bake a cake. I don't have to worry about unexpected tasks coming up, since the AGI will eventually figure out how to do it, given enough training time. I would have to wait a long time though.\nA \"narrow intelligence\" appears to be more efficient at its assigned task, due to it being programmed specifically for that task. It knows exactly what to do, and doesn't have to waste time \"learning\" (unlike our AGI buddy here). Instead of buying one AGI to handle a bunch of different tasks poorly, I would rather buy a bunch of specialized narrow AIs. Narrow AI #1 drives cars, Narrow AI #2 plays Go, Narrow AI #3 bake cakes, etc. That being said, this is a very brittle approach, since if some unexpected task comes up, none of my narrow AIs would be able to handle it. I'm willing to accept that risk though.\nIs my \"thinking\" correct? Is there a trade-off between flexibility (AGI) and efficiency (narrow AI), like what I have just described above? Or is it theoretically possible for an AGI to be both flexible and efficient?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The cleanest result we have on this issue is the \"no free lunch\" theorem. Basically, in order to make a system perform better at a specific task, you have to degrade its performance on other tasks, and so there is a flexibility-efficiency tradeoff.\nBut to the broader question, or whether or not your thinking is correct, I think it pays to look more closely at what you mean by a \"narrow intelligence.\" The AI systems that we have that play Go and drive cars did not pop into existence able to do those things; they slowly learned how through lots and lots of training examples and a well-chosen architecture that mirrors the problem domain.\nThat is, \"neural networks\" as a methodology seems 'general' in a meaningful way; one could imagine that a general intelligence could be formed by solving the meta-learning problem (that is, learning the architecture that best suits a particular problem while learning the weights for that problem from training data).\nEven in that case, there will still be a flexibility-efficiency tradeoff; the general intelligence that's allowed to vary its architecture will be able to solve many different problems, but will take some time to discover what problem it's facing. An intelligence locked into a particular architecture will perform well on problems that architecture is well-suited for (better than the general, since it doesn't need to discover) but less well on other problems it isn't as well-suited for.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why are biases (typically) not used in attention mechanism? Watching this video implementing attention in a transformer. He set query, key, and value biases to False and said \"Typically, people don't use biases for these\".\nEven in official PyTorch code the default bias is False:\n\nadd_bias_kv: If specified, adds bias to the key and value sequences at dim=0. Default: False.\n\nWhat is the reason behind that?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "For certain types of layers, such as transformers and convolutional layers, including a bias term is unnecessary and adds unnecessary overhead to the model.\nThe reason for this is that these layers are typically followed by a normalization layer, such as Batch Normalization or Layer Normalization. These normalization layers center the data at mean=0 (and std=1), effectively removing any bias.\nTherefore, it is common practice to omit the bias term in transformers and convolutional layers that are preceded by a normalization layer.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are we technically able to make, in hardware, arbitrarily large neural networks with current technology? If neurons and synapses can be implemented using transistors, what prevents us from creating arbitrarily large neural networks using the same methods with which GPUs are made?\nIn essence, we have seen how extraordinarily well virtual neural networks implemented on sequential processors work (even GPUs are sequential machines, but with huge amounts of cores). \nOne can imagine that using GPU design principles - which is basically to have thousands of programmable processing units that work in parallel - we could make much simpler \"neuron processing units\" and put millions or billions of those NPUs in a single big chip. They would have their own memory (for storing weights) and be connected to a few hundred other neurons by sharing a bus. They could have a frequency of for example 20 Hz, which would allow them to share a data bus with many other neurons.\nObviously, there are some electrical engineering challenges here, but it seems to me that all big tech companies should be exploring this route by now.\nMany AI researchers say that superintelligence is coming around the year 2045. I believe that their reasoning is based on Moore's law and the number of neurons we are able to implement in software running on the fastest computers we have.\nBut the fact is, we today are making silicon chips with billions of transistors on them. SPARK M7 has 10 billion transistors.\nIf implementing a (non-programmable) neuron and a few hundred synapses for it requires for example 100 000 transistors, then we can make a neural network in hardware that emulates 100 000 neurons.\nIf we design such a chip so that we can simply make it physically bigger if we want more neurons, then it seems to me that arbitrarily large neural networks are simply a budget question.\nAre we technically able to make, in hardware, arbitrarily large neural networks with current technology?\nRemember: I am NOT asking if such a network will in fact be very intelligent. I am merely asking if we can factually make arbitrarily large, highly interconnected neural networks, if we decide to pay Intel to do this? \nThe implication is that on the day some scientist is able to create general intelligence in software, we can use our hardware capabilities to grow this general intelligence to human levels and beyond.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The approach you describe is called neuromorphic computing and it's quite a busy field. \nIBM's TrueNorth even has spiking neurons. \nThe main problem with these projects is that nobody quite knows what to do with them yet. \nThese projects don't try to create chips that are optimised to run a neural network. That would certainly be possible, but the expensive part is the training not the running of neural networks. And for the training you need huge matrix multiplications, something GPUs are very good at already. (Google's TPU would be a chip optimised to run NNs.)\nTo do research on algorithms that might be implemented in the brain (we hardly know anything about that) you need flexibility, something these chips don't have. Also, the engineering challenge likely lies in providing a lot of synapses, just compare the average number of synapses per neuron of TrueNorth, 256, and the brain, 10,000.\nSo, you could create a chip designed after some neural architecture and it would be faster, more efficient, etc \u2026, but to do that you'll need to know which architecture works first. We know that deep learning works, so google uses custom made hardware to run their applications and I could certainly imagine custom made deep learning hardware coming to a smartphone near you in the future. To create a neuromorphic chip for strong AI you'd need to develop strong AI first.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can an AI freely make decisions? Suppose a deep neural network is created using Keras or Tensorflow. Usually, when you want to make a prediction, the user would invoke model.predict. However, how would the actual AI system proactively invoke their own actions (i.e. without the need for me to call model.predict)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Neural networks, deep learning and other supervised learning algorithms do not \"take actions\" by themselves, they lack agency.\nHowever, it is relatively easy to give a machine agency, as far as taking actions is concerned. That is achieved by connecting inputs to some meaningful data source in the environment (such as a camera, or the internet), and connecting outputs to something that can act in that environment (such as a motor, or the API to manage an internet browser). In essence this is no different from any other automation that you might write to script useful behaviour. If you could write a series of tests, if/then statements or mathematical statements that made useful decisions for any machine set up this way, then in theory a neural network or similar machine learning algorithm could learn to approximate, or even improve upon the same kind of function.\nIf your neural network has already been trained on example inputs and the correct actions to take to achieve some goal given those inputs, then that is all that is required.\nHowever, training a network to the point where it could achieve this in an unconstrained environment (\"letting it loose on the internet\") is a tough challenge.\nThere are ways to train neural networks (and learning functions in general) so that they learn useful mappings between observations and actions that progress towards achieving goals. You can use genetic algorithms or other search techniques for instance, and the NEAT approach can be successful training controllers for agents in simple environments. \nReinforcement learning is another popular method that can also scale up to quite challenging control environments. It can cope with complex game environments such as Defense of the Ancients, Starcraft, Go. The purpose of demonstrating AI prowess on these complex games is in part showing progress towards a longer-term goal of optimal behaviour in the even more complex and open-ended real world. \nState of the art agents are still quite a long way from general intelligent behaviour, but the problem of using neural networks in a system that learns how to act as an agent has much research and many examples available online.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why should the number of neurons in a hidden layer be a power of 2? I have read somewhere on the web (I lost the reference) that the number of units (or neurons) in a hidden layer should be a power of 2 because it helps the learning algorithm to converge faster.\nIs this a fact? If it is, why is this true? Does it have something to do with how the memory is laid down?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nI have read somewhere on the web (I lost the reference) that the number of units (or neurons) in a hidden layer should be a power of 2 because it helps the learning algorithm to converge faster.\n\nI would quite like to see a reference to this suggestion, in case it has been misunderstood.\nAs far as I know, there is no such effect in normal neural networks. In convolutional neural networks, it might potentially be true in a minor way because some FFT approaches work better with $2^n$ items.\n\nIs this a fact? If it is, why is this true? Does it have something to do with how the memory is laid down?\n\nI would say that this is not a general fact. Instead, it seems like misunderstood advice to search some hyperparameters such as number of neurons in each layer, by increasing or decreasing by a factor of 2. Doing this and trying layer sizes of 32, 64, 128 etc should increase the speed of finding a good layer size compared to trying sizes 32, 33, 34 etc.\nThe main reason to pick powers of 2 is tradition in computer science. Provided there is no driver to pick other specific numbers, may as well pick a power of 2 . . . but equally you will see researchers picking multiples of 10, 100 or 1000 as \"round numbers\", for a similar reason.\nOne related factor: If a researcher presents a result for some new technique where the hidden layer sizes were tuned to e.g. 531, 779, 282 etc, then someone reviewing the work would ask the obvious question \"Why?\" - such numbers might imply the new technique is not generic or requires large amounts of hyperparameter tuning, neither of which would be seen as positive traits. Much better to be seen using an obvious \"simple\" number . . .\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is it that AI can become biased, and what are the proposals to mitigate this? This is not meant to be negative or a joke but rather looking for a productive solution on AI development, engineering and its impact on human life:\nLately with my Google searches, the AI model keeps auto filling the ending of my searches with:\n\u201c...in Vietnamese\u201d\nAnd \n\u201c...in a Vietnamese home\u201d\nThe issue is I have never searched for that but because of my last name the model is creating this context. \nThe other issue is that I\u2019m a halfy and my dad is actually third generation, I grew up mainstream American and don\u2019t even speak Vietnamese. I\u2019m not even sure what a Vietnamese home means. \nMy buddy in a similar situation of South Asian and noticed the same exact thing more so with YouTube recommended videos. \nWe already have enough issues in the US with racism, projections of who others expect us to be based on any number of things, stereotyping and putting people in boxes to limit them - I truly believe AI is adding to the problem, not helping. \nHow can we fix this. Moreover, how can we use AI to bring out peoples true self, talents and empower and free them them to create their life how they like ?\nThere is huge potential here to harness AI in ways that can bring us more freedom, joy and beauty so people can be the whole of themselves and with who they really are. Then meet peoples needs, wishes, dreams and hope. Given them shoulders to stand on to create their reality, not live someone else's projection of themselves.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nLately with my Google searches, the AI model keeps auto filling the ending of my searches with:\n\u201c...in Vietnamese\u201d\n\nI can see how this would be annoying.\nI don't think Google's auto-complete algorithm and training data is publicly available. Also it changes frequently as they work to improve the service. As such, it is hard to tell what exactly is leading it to come up with this less-than-useful suggestion.\nYour suspicion that it has something to do with Google's service detecting your heritage seems plausible.\nThe whole thing is based around statistical inference. At no point does any machine \"know\" what Vietnamese - or in fact any of the words in your query - actually means. This is a weakness of pretty much all core NLP work in AI, and is called the grounding problem. It is why, for instance, that samples of computer generated text produce such surreal and comic material. The rules of grammar are followed, but semantics and longer term coherence are a mess.\nCommercial chatbot systems work around this with a lot of bespoke coding around some subject area, such as booking tickets, shopping etc. These smaller domains are possible for human developers to \"police\", connecting them back to reality, and avoiding the open-ended nature of the whole of human language. Search engine text autocomplete however, cannot realistically use this approach.\nYour best bets are probably:\n\nWait it out. The service will improve. Whatever language use statistics are at work here are likely change over time. Your own normal use of the system without using the suggestions will be part of that data stream of corrections.\n\nSend a complaint to Google. Someone, somewhere in Google will care about these results, and view them as errors to be fixed.\n\n\nNeither of these approaches guarantee results in any time frame sadly.\n\nWe already have enough issues in the US with racism, projections of who others expect us to be based on any number of things, stereotyping and putting people in boxes to limit them - I truly believe AI is adding to the problem, not helping.\n\nYou are not alone in having these worries. The statistics-driven nature of machine learning algorithms and use of \"big data\" to train them means that machines are exposing bias and prejudice that are long buried in our language. These biases are picked up by machinery then used by companies that don't necessarily want to reflect those attitudes.\nA similar example occurs in natural language processing models with word embeddings. A very interesting feature of LSTM neural networks that learn statistical language models is that you can look at word embeddings, mathematical representations of words, and do \"word math\":\n$$W(king) - W(man) + W(woman) \\approx W(queen)$$\n$$W(he) - W(male) + W(female) \\approx W(she)$$\nThis is very cool, and implies that the learned embeddings really are capturing semantics up to some depth. However, the same model can produce results like this:\n$$W(doctor) - W(male) + W(female) \\approx W(nurse)$$\nThis doesn't reflect modern sensibilities of gender equality. There is obviously a deep set reason for this, as it has appeared from non-prejudiced statistical analysis of billions of words of text from all sorts of sources. Regardless of this though, engineers responsible for these systems would prefer that their models did not have these flaws.\n\nHow can we fix this. Moreover, how can we use AI to bring out peoples true self, talents and empower and free them them to create their life how they like ?\n\nPrimarily by recognising that statistical ML and AI doesn't inherently have prejudice or any agenda at all. It is reflecting back ugliness already in the world. The root problem is to fix people (beyond scope of this answer, if I had solid ideas about this I would not be working in software engineering, but in something more people-focussed).\nHowever, we can remove some of the unwanted bias from AI systems. Broadly the steps toward this go:\n\nRecognise that a particular AI system has captured and is using unwanted gender, racial, religious etc bias.\n\nReach a consensus about how an unbiased model should behave. It must still be useful for purpose.\n\nAdd the desired model behaviour into the training and assessment routines of the AI.\n\n\nFor instance in your case, there are possibly some users of Google's system who would prefer to read articles in Vietnamese, or have English translated into Vietnamese, and are finding it awkward that the default assumption is that everything should be presented in English. These users don't necessarily need to use the search text for this, but presumably are for some reason. A reasonable approach is to figure out how their needs could be met without spamming \"in Vietnamese\" on the end of every autocomplete suggestion, and perhaps in general move suggestions to localise searches by cultural differences out of autocomplete into a different part of the system.\nFor the case of gender bias in NLP systems, Andrew Ng's Coursera course on RNNs shows how this can be achieved using the embeddings themselves. Essentially it can be done by identifying a bias direction from a set of words (e.g. \"he/she\", \"male/female\"), and removing deviations in that direction for most other words, preserving it only for words where it is inherently OK to reflect the differences (such as \"king\" and \"queen\" for gender bias).\nEach case of unwanted bias though needs to be discovered by people and oversight of this as a political and social issue, not primarily a technical one.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there any open source counterpart to the IBM Watson? I am looking for something similar to IBM Watson but open source. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I am not aware of any open-source products that can readily replace IBM Watson, but the following projects could be of interest to you in that regard: \n\nDARPA DeepDive \nSnorkel\nApache UIMA\nYodaQA\nOpenCog\nOAQA (Open Advancement of Question Answering Systems)\nStanford CoreNLP \u2013 Natural language software \nopenQA\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What kind of problems require more than 2 hidden layers? I've read that the most of the problems can be solved with 1-2 hidden layers.\nHow do you know you need more than 2? For what kind of problems you would need them (give me an example)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Formally, a single hidden layer is sufficient to approximate a continuous function to any desired degree of accuracy, so in that sense, you never need more than 1. This is called the Universal Approximation Theorem.\nFinding the best topology for a given problem is an open research problem. As far as I know, there are few universal 'rules of thumb' for this.\nFor a given problem, one option is to apply a neuroevolutionary approach such as NEAT, which attempts to find a topology that works well for the problem at hand.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Do deep learning algorithms represent ensemble-based methods? According to the Wikipedia article on deep learning:\n\nDeep learning is a branch of machine learning based on a set of algorithms that attempt to model high-level abstractions in data by using a deep graph with multiple processing layers, composed of multiple linear and non-linear transformations.\n\n\nVarious deep learning architectures such as deep neural networks, convolutional deep neural networks, deep belief networks and recurrent neural networks have been applied to fields like computer vision, automatic speech recognition, natural language processing, audio recognition and bioinformatics where they have been shown to produce state-of-the-art results on various tasks.\n\nCan deep neural networks or convolutional deep neural networks be viewed as ensemble-based method of machine learning, or are they different approaches?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You should think of them as different approaches. A deep neural net is a single independent model, whereas ensemble models are ensembles of many independent models.\nThe primary connection between the two is dropout, a particular method of training deep neural nets that's inspired by ensemble methods. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "In Computer Vision, what is the difference between a transformer and attention? Having been studying computer vision for a while, I still cannot understand what the difference between a transformer and attention is?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The original transformer is a feedforward neural network (FFNN)-based architecture that makes use of an attention mechanism. So, this is the difference: an attention mechanism (in particular, a self-attention operation) is used by the transformer, which is not just this attention mechanism, but it's an encoder-decoder architecture, which makes use of other techniques too: for example, positional encoding and layer normalization. In other words, the transformer is the model, while the attention is a technique used by the model.\nThe paper that introduced the transformer Attention Is All You Need (2017, NIPS) contains a diagram of the transformer and the attention block (i.e. the part of the transformer that does this attention operation).\nHere's the diagram of the transformer.\n\nHere's the picture of the attention mechanism (as you can see from the diagram above, the transformer used the multi-head attention on the right).\n\nOne thing to keep in mind is that the idea of attention is not novel to the transformer, given that similar ideas had already been used in previous works and models, for example, here, although the specific attention mechanisms are different.\nOf course, you should read the mentioned paper for more details about the transformer, the attention mechanism and the diagrams above.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why were Chess experts surprised by the AlphaZero's victory against Stockfish? It was recently brought to my attention that Chess experts took the outcome of this now famous match as something of an upset. \nSee: Chess\u2019s New Best Player Is A Fearless, Swashbuckling Algorithm\nAs as a non-expert on Chess and Chess AI, my assumption was that, based on the performance of AlphaGo, and the validation of that type of method in relation to combinatorial games, was that the older AI would have no chance. \n\nWhy was AlphaZero's victory surprising?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Good question. \nFirst and foremost is that in Go deepmind had no superhuman opponents to challenge. Go engines were not anywhere near the highest level of the top human players. In chess, however, the engines are 500 ELO points stronger than the top human players. This is a massive difference. The amount of work that has gone into contemporary chess engines is staggering. We are talking about millions of hours in programming, hundreds of thousands of iterations. It is a massive body of knowledge and work. To overcome and surpass all of that in 4 hours is staggering.\nSecondly it is not so much the result itself which is surprising to chess masters but instead its how AlphaZero plays chess. It's quite ironic that a system which had no human knowledge or expertise plays the most like we do. Engines are notorious for playing ugly looking moves, those lacking harmony etc. Its hard to explain to a non-chess player but there is such a thing as an \"Artificial move\" like the contemporary engines come up with often. AlphaZero does not play like this at all. It has a very human-like style where it dominates the opponent's pieces with deep strategic play and stunning position sacrifices. AlphaZero plays the way we aspire to, combining deep positional understanding with the precision of an engines calculation.\nEdit\nOh and I forgot to mention something about the result itself. If you are not familiar with computer chess it may not seem staggering but it is. \nThese days the margins of victory which separate the top contemporary engines are razor thin. In a 100 game match you could expect to see a result like 85 games drawn, 9 victories, and 6 losses to determine the better engine.\nAlphaZero 28 wins and 72 draws with zero losses was otherworldly crushing and was completely unthinkable right up to the moment it happened.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Do full-text translators such as DeepL or Google Translate fall under the term \"Generative AI\"? My question relates to full-text translators that are not specifically based on LLMs. My current understanding is that the term Generative AI goes beyond LLMs and that the full-text translators (especially those which are based on artificial neural networks) also fall into this category.\nIn the Wikipedia article about Generative AI, I could only find the statement that generative AI systems such as ChatGPT are also used for translations. That is quite obvious, but this does not answer the question of whether other full text translators are also commonly referred to as Generative AI.\nIBM research defines Generative AI as\n\nGenerative AI refers to deep-learning models that can generate high-quality text, images, and other content based on the data they were trained on.\n\nAFAIK DeepL, Google Translate, Bing Translate but also a few not so well-known systems falls clearly into that definition.\nMy question was triggered by an answer on Meta Stack Overflow that contained the following sentence:\n\nBesides, the banner clearly states: \"Answers generated by artificial intelligence tools\". Translations aren't generated answers. They're translations.\n\nwith the implicit conclusion that it is clear to everyone that pure translators do not count as generative AI, hence it does not need any further explanation. Other participants in that thread seem to agree to that point of view. However, I think their use of terminology is not the typical use in the field of AI, and I would like to hear what the experts say.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Generative AI, as defined by IBM research, refers to deep-learning models capable of creating new content, be it text, images, or other media, based on their training data. This definition indeed encompasses models like GPT-3 or GPT-4, which can generate text in various styles and formats, including translations.\nHowever, when it comes to full-text translators like Google Translate, DeepL, or Bing Translate, there's a nuanced difference. These systems are typically based on neural machine translation (NMT) models, a specific application of deep learning tailored for the task of translating text from one language to another. While these NMT systems are indeed 'generative' in the sense that they produce new text in a target language, their primary function is not to create original content but to convert existing content from one language to another as accurately as possible.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do we prefer ReLU over linear activation functions? The ReLU activation function is defined as follows \n$$y = \\operatorname{max}(0,x)$$\nAnd the linear activation function is defined as follows\n$$y = x$$\nThe ReLU nonlinearity just clips the values less than 0 to 0 and passes everything else. Then why not to use a linear activation function instead, as it will pass all the gradient information during backpropagation? I do see that parametric ReLU (PReLU) does provide this possibility. \nI just want to know if there is a proper explanation to using ReLU as default or it is just based on observations that it performs better on the training sets.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The ReLu is a non-linear activation function. Check out this question for the intuition behind using ReLu's (also check out the comments). There is a very simple reason of why we do not use a linear activation function.\nSay you have a feature vector $x_0$ and weight vector $W_1$. Passing through a layer in a Neural Net will give the output as \n$W_1^T * x_0 = x_1$\n(dot product of weights and input vector). Now passing the output through next layer will give you \n$W_2^T * x_1 = x_2$\nSo expanding this we get\n$x_2 = W_2^T * W_1^T * x_0 = W_2^T * W_1^T * x_0 = W_{compact}^T * x_0$\nThus as you can see there is a linear relationship between input and output, and the function we want to model is generally non-linear, and so we cannot model it.\nYou can check out my answer here on non-linear activation.\nParametric ReLu has few advantages over normal ReLu. Here is a great answer by @NeilSlater on the same. It is basically trying to tell us that if we use ReLu's we will end up with a lot of redundant or dead nodes in a Neural Net (those which have a negative output) which do not contribute to the result, and thus do not have a derivative. Thus to approximate a function we will require a larger NN, whereas parametric ReLu's absolve us of this problem,(thus a comparatively smaller NN) as negative output nodes do not die. \nNOTE: alpha = 1 will be a special case of parametric ReLu. There must be a balance between the amount of liveliness you want in the negative region vs the linearity of the activation function.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When did Artificial Intelligence research first start? When did research into Artificial Intelligence first begin? Was it called Artificial Intelligence then or was there another name?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The earliest research into thinking machines was inspired by a confluence of ideas that became prevalent in the late 30s, 40s and early 50s (e.g. formal logic, automata, robots). Although the Turing test was proposed in the 1950s by Alan Turing, the work culminated back in the 1940s in the invention of the programmable digital computers, an abstract essence of mathematical reasoning. These ideas were inspired by a handful of scientists from a variety of fields who began seriously considering the possibility of building an electronic brain. The field of artificial intelligence research was officially founded as an academic discipline in 1956 during the Dartmouth workshop.\nHowever, the concept of artificial beings is not new and it's as old as the Greek myths of Hephaestus and Pygmalion, which incorporated the idea of intelligent robots (such as Talos) and artificial beings (such as Galatea and Pandora).\nSee the following articles at Wikipedia for further details:\n\nArtificial intelligence (AI)\nHistory of artificial intelligence\nTimeline of artificial intelligence\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Do self-driving cars resort to randomness to make decisions? I recently heard someone make a statement that when you're designing a self-driving car, you're not building a car but really a computerized driver, so you're trying to model a human mind -- at least the part of the human mind that can drive.\nSince humans are unpredictable, or rather since their actions depend on so many factors some of which are going to remain unexplained for a long time, how would a self-driving car reflect that, if they do?\nA dose of unpredictability could have its uses. If, say, two self-driving cars are in a stuck in a right of way deadlock, it could be good to inject some randomness instead of maybe seeing the same action applied at the same time if the cars run the same system. \nBut, on the other hand, we know that non-deterministic isn't friends with software development, especially in testing. How would engineers be able to control it and reason about it?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Driving Priorities\nWhen considering the kind of modeling needed to create reliable and safe autonomous vehicles, the following driving safety and efficacy criteria should be considered, listed in priority with the most important first.\n\nThe safety of those inside the vehicle and outside the vehicle\nReduction of wear on passengers\nThe safety of property\nThe arrival at the given destination\nReduction of wear on the vehicle\nThrift in fuel resources\nFairness to other vehicles\nThe thrift in time\n\nThese are ordered in a way that makes civic and global sense, but they are not the priorities exhibited by human drivers.\nCopy Humans or Reevaluate and Design from Scratch?\nWhoever said that the goal of autonomous car design is to model the portions of a human mind that can drive should not be designing autonomous cars for actual manufacture. It is well known that most humans, although they may have heard of the following safety tips, cannot bring them into consciousness with sufficient speed to benefit from them in actual driving arrangements.\n\nWhen the tires slip sideways, steer into the skid.\nWhen a forward skid starts, pump the breaks.\nIf someone is headed tangentially into your car's rear, immediately accelerate and then break.\nOn an on ramp, accelerate to match the speed of the cars in the lane into which you merge, unless there is no space to merge.\nIf you see a patch of ice, steer straight and neither accelerate nor decelerate once you reach it.\n\nMany collisions between locomotives and cars are because a red light causes a line in multiple lanes across the tracks. Frequently, a person will move onto the railroad tracks to gain one car's length on the other cars. When others move to make undoing that choice problematic, a serious risk emerges.\nAs absurd as this behavior is to anyone watching, many deaths occur as a fast traveling 2,000 ton locomotive hits what feels like a dust speck to the train passengers.\nPredictability and Adaptability\nHumans are unpredictable, as the question indicates, but although adaptability may be unpredictable, unpredictability may not be adaptive. It is adaptability that is needed, and it is needed in five main ways.\n\nAdaptive in the moment to surprises\nAdaptive through general driving experience\nAdaptive to the specific car\nAdaptive to passenger expression\nAdaptive to particular map regions\n\nIn addition, driving a car is\n\nHighly mechanical,\nVisual,\nAuditory,\nPlan oriented\nGeographical, and\nPreemptive in surprise situations.\n\nModelling Driving Complexities\nThis requires a model or models comprise of several kinds of objects.\n\nMaps\nThe vehicle\nThe passenger intentions\nOther vehicle\nOther obstructions\nPedestrians\nAnimals\nCrossings\nTraffic signals\nRoad signs\nRoad side\n\nNeither Mystery nor Indeterminance\nAlthough these models are cognitively approximated in the human brain, how well they are modeled and how effective those models are at reaching something close to a reasonable balance of the above priorities varies from driver to driver, and varies from trip to trip for the same driver.\nHowever, as complex as driving is, it is not mysterious. Each of the above models are easy to consider at a high level in terms of how they interact and what mechanical and probabilistic properties they have. Detailing these is an enormous task, and making the system work reliably is a significant engineering challenge, in addition to the training question.\nInevitability of Achievement\nRegardless of the complexity, because of the economics involved and the fact that it is largely a problem of mechanics, probability, and pattern recognition, it will be done, and it will eventually be done well.\nWhen it is, as unlikely as this sounds to the person who accepts our current culture as permanent, human driving may become illegal in this century in some jurisdictions. Any traffic analyst can mount heaps of evidence that most humans are ill equipped to drive a machine that weighs a ton at common speeds. The licensing of unprofessional drivers has only become widely accepted because of public insistence on transportation convenience and comfort and because the workforce economy requires it.\nAutonomous cars may reflect the best of human capabilities, but they will likely far surpass them because, although the objects in the model are complex, they are largely predictable, with the notable exception of children playing. AV technology will use the standard solution for this. The entire scenario can be brought into slow motion to adapt for children playing simply by slowing way down. AI components that specifically detect children and dogs are likely to emerge soon, if they do not already exist.\nRandomness\nRandomness is important in training. For instance, a race car driver will deliberately create skids of various types to get used to how to control them. In machine learning we see some pseudo random perturbations introduced during training to ensure that the gradient descent process does not get caught in a local minimum but rather is more likely to find a global minimum (optimum).\nDeadlock\nThe question is correct in stating that, \"A dose of unpredictability could have its uses.\" The deadlock scenario is an interesting one, but is unlikely to occur as standards develop. When four drivers come to a stop sign at the same time, they really don't. It only seems like they did. The likelihood that none of them arrived more than a millisecond before the others is astronomically small.\nPeople will not detect (or even be honest enough) to distinguish these small time differences, so it usually comes to who is most gracious to wave the others on, and there can be some deadlock there too, which can become comical, especially since all of them really wish to get moving. Autonomous vehicles will extremely rarely encounter a deadlock that is not covered by the rule book the government licensing entity publishes, which can be programmed as driving rules into the system.\nOn those rare occasions, the vehicles could digitally draw lots, as suggested, which is one place where unpredictability is adaptive. Doing skid experimentation like a race car driver on Main Street at midnight may be what some drunk teen might do, but that is a form of unpredictability that is not adaptive toward a sensible ordering of the priorities of driving. Neither would be texting or trying to eat and drive.\nDeterminism\nRegarding determinism, in the context of the uses discussed, pseudo-random number generation of particular distributions will suffice.\n\nDeadlock release or\nTraining speed-ups and improved reliability when there are local minima that are not the global minimum during optimization,\n\nFunctional tests and unit testing technologies are not only able to handle the testing of components with pseudo-randomness, but they sometimes employ pseudo-randomness to provide better testing coverage. The key to doing this well is understanding of probability and statistics, and some engineers and AI designers understand it well.\nElement of Surprise\nWhere randomness is most important in AV technology is not in the decision making but in the surprises. That is the bleeding edge of that engineering work today. How can one drive safely when a completely new scenario appears in the audio or visual channels? This is perhaps the place where the diversity of human thought may be best adept, but at highway speeds, it is usually too slow to react in the way we see in movie chase scenes.\nCorrelation Between Risk and Speed\nThis brings up an interesting interaction of risk factors. It is assumed that higher speeds are more dangerous, the actual mechanics and probability are not that clear cut. Low speeds produce temporally longer trips and higher traffic densities. Some forms of accidents are less likely at higher speeds, specifically ones that are related mostly to either traffic density or happenstance. Other forms are more likely at higher speeds, specifically ones that are related to reaction time and tire friction.\nWith autonomous vehicles, tire slippage may be more accurately modeled and reaction time may be orders of magnitude faster, so minimum speed limits may be more imposed and upper limits may increase once we get humans out of the driver's seats.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why use ReLU over Leaky ReLU? From my understanding a leaky ReLU attempts to address issues of vanishing gradients and nonzero-centeredness by keeping neurons that fire with a negative value alive.\nWith just this info to go off of, it would seem that the leaky ReLU is just an overall improvement to the standard ReLU, yet ReLU still seems to be the gold standard of activation functions. Why is that?\nDoes the additional sparsity outweigh the value gained from negative local gradients? If so, is tanh just too sparse?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Your understanding or Leaky ReLU is correct, and, yes, it has been proposed to mitigate the dying neurons issue in ReLU: when these are negative, they got zeroed.\nRegarding the answer of @Regresslt:\n\nI would not say that leaky relu slows done training due to its computation overhead, since it's quite simple to implement. Instead, ELU (exponential linear unit) is quite expensive and that can increase training time.\nAlso it's true that the slope parameter (usually called $\\alpha$), if mistuned can lead to worst performance, but one can try the PReLU that learns it.\n\n\nDoes the additional sparsity outweigh the value gained from negative local gradients?\n\nThat's an interesting point. I mean the dying ReLU phenomenon is usually observed on a fraction of the units, not the totality. In my personal experience I've noticed (dense) layers with ReLU to be sparse as much as $50$ to $90\\%$. In general this causes an under utilization of the capacity of the model, which may lead to under-fitting. But from another perspective can be seen as implicit $l_1$-regularization applied on each layer with ReLU, that is optimized along the model which may lead to better generalization performance: simply because the model learned to achieve the right capacity by itself. Also, if such large sparsity is achieved the use of Dropout on top can be totally non-beneficial, because it would drop also the remaining \"active\" units/neurons.\n\nIs tanh just too sparse?\n\nFirst, $\\tanh$ is not sparse since the output values can be either $-1$ or $1$ when saturation is reached, which is its main issue that shares with sigmoid (that instead can lead to sparsity.) When tanh or sigmoid saturate you get vanishing gradients, and the training stops. Instead, the sparsity induced by ReLU does not reduce the gradient, since it will only be multiplied by some zero elements (corresponding to the died units.): the gradient magnitude depends on the overall output of the layer. In practice (but I'd say it's hard to happen), only if all units of all layers are died your network won't learn anymore, and the gradient would vanish because each layers would only output zeroes.\nTo conclude, ReLU is usually the first activation to try - it seems to always work sufficiently well - but remember also to pair the activation fn with the right choice of weight initialization, in order to prevent issues (dying units, saturation, etc), speed-up convergence, and even increase performance.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is AlphaZero an example of an AGI? From DeepMind's research paper on arxiv.org:\n\nIn this paper, we apply a similar but fully generic algorithm, which\n we call AlphaZero, to the games of chess and shogi as well as Go,\n without any additional domain knowledge except the rules of the game,\n demonstrating that a general-purpose reinforcement learning algorithm\n can achieve, tabula rasa, superhuman performance across many\n challenging domains.\n\nDoes this mean AlphaZero is an example of AGI (Artificial General Intelligence)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Good question!\n\nAlphaZero, though a major milestone, is most definitely not an AGI :)\n\nAlphaGo, though strong at the game of Go, is narrowly strong (\"strong-narrow AI\"), defined as strength in a single problem or type of problem (such as Go and other non-chance, perfect information games.) \n\nAGI, at minimum, must be about as strong as humans in all problems worked on or solved by humans. \n\nAGI is often associated with superintelligence, defined as intelligence that surpasses human levels.\nAGI does not necessarily imply super-intelligence, in the sense that we'd consider an android that can perform all human activities with the same capability as humans as an Artificial General Intelligence. \nBut technically, AlphaGo is a narrow superintelligence in that it exceeds all human performance in a single problem.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the n-step tree backup algorithm an off-policy algorithm? In reinforcement learning book from Sutton & Barto (2018 edition), specifically in section 7.5 of the book, they present an n-step off-policy algorithm that doesn't require importance sampling called n-step tree backup algorithm. \nIn other algorithms, the return in the update consisted of rewards along the way and the estimated value(s) of the node(s) at the bottom, but, in tree backup update, a return consists of things mentioned before plus the estimated values of the actions that weren't picked during these n steps, all weighted by the probability of taking the action from the previous step. \nI have a few questions about things in this algorithm that are unclear to me.\n\nWhy is this algorithm considered an off-policy algorithm? As far as I could notice, only a single target policy is mentioned and there is no talk about behaviour policy generating actions to take.\nIn control we want our target policy to be deterministic, greedy policy, so how do we exactly generate actions to take in this case since behaviour policy isn't used? If we generate actions from the greedy policy, we won't explore, so we won't learn the optimal policy. What am I missing here?\nIf I understood something wrong and we are actually using behaviour policy, I don't understand how would the update work in the case where our target policy is greedy. The return consists of estimates taken from actions that weren't picked, but, because our policy is greedy, the probabilities used in calculating those estimates would be 0, so the total estimate of those actions would be 0 as well. The only non 0 probability in our target policy is the one of the greedy action (which is the probability of 1), so the entire return would fall down to n-step SARSA return. So, basically, how are we allowed to do this update in this case, why is this return allowed to replace the one with importance sampling?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As for your first two questions: there is indeed a behaviour and a target policy, which can be different. In the example image of the $3$-step tree-backup update in the beginning of the section you mention, the actions $A_t$, $A_{t+1}$, and $A_{t+2}$ are assumed to be selected according to some behaviour policy, whereas a (different) target policy is used to determine weights for the different leaf nodes.\n\nAs for your third question, in the case where our target policy is greedy, lots of terms will indeed have $0$ weights and therefore entirely drop out. However, this is not always going to fall down to the same return as $n$-step Sarsa returns; that would not be correct, because ($n$-step) Sarsa is an on-policy algorithm. \nIn the case where the target policy is a greedy policy, the return will depend very much on how many actions happened to get selected by the behaviour policy which the greedy target policy also would have \"agreed\" with. If the behaviour policy already happened to have made a \"mistake\" (selected an action that the greedy policy wouldn't have selected) for $A_{t+1}$, you'll end up with a standard $1$-step $Q$-learning update. If the behaviour policy only made a \"mistake\" with the action $A_{t+2}$ (and agreed with the target policy on $A_{t+1}$), you'll get something that kind of looks like a \"$2$-step $Q$-learning update\" (informally here, because $n$-step $Q$-learning isn't really a thing). Etc.\nYou can see that this is the case by closely inspecting Equation 7.16 from the book:\n$$G_{t:t+n} \\doteq R_{t+1} + \\gamma \\color{blue}{\\sum_{a \\neq A_{t+1}} \\pi (a \\mid S_{t+1}) Q_{t + n - 1}(S_{t+1}, a)} + \\gamma \\color{red}{\\pi (A_{t + 1} \\mid S_{t + 1}) G_{t + 1 : t + n}}.$$\n\nSuppose that the target policy $\\pi$ is greedy, and the behaviour policy already selected action $A_{t+1}$ differently from what $\\pi$ would have selected (meaning that $\\pi(A_{t+1} \\mid S_{t+1}) = 0$). Then we know that the $\\color{red}{\\text{red}}$ part of the equation will evaluate to $0$. In the $\\color{blue}{\\text{blue sum}}$, the $\\pi(a \\mid S_{t+1})$ term will only evaluate to $1$ for $a = \\arg\\max_a Q_{t+n-1}(S_{t+1}, a)$ (because that is the action $a$ to which the greedy target policy would assign a probability of $1$), and $0$ again for all other elements of the sum. So, in this example situation, we end up using the return $G_{t:t+n} = R_{t+1} + \\gamma \\max_a Q_{t+n-1}(S_{t+1}, a)$. This is exactly the return also used by the standard $1$-step $Q$-learning update rule.\nNow suppose that the behaviour policy and a greedy target policy happened to \"agree\" with each other on $A_{t + 1}$, but disagree again on $A_{t + 2}$. In this case, the entire $\\color{blue}{\\text{blue sum}}$ for $G_{t:t+n}$ will evaluate to $0$, but the $\\pi(A_{t+1} \\mid S_{t+1})$ in the $\\color{red}{\\text{red part}}$ will evaluate to $1$. Then, \"inside\" the recursive $\\color{red}{G_{t+1:t+n}}$, we'll get a very similar situation to the example above, with a single non-zero term in the blue sum and a red part that evaluates to $0$. In this case, the total return will be $G_{t:t+n} = R_{t + 1} + \\gamma R_{t + 2} + \\gamma^2 \\max_a Q_{t + n - 1}(S_{t + 2}, a)$. Note that this is different from a $2$-step Sarsa return. $2$-step Sarsa would use a return with $\\gamma^2 Q_{t+n-1}(S_{t+2}, A_{t+2})$ at the end (where $A_{t+2}$ is sampled according to the behaviour policy), rather than that term involving $\\max_a$.\n\nWhat you essentially end up getting in these cases is returns similar to those of $n$-step Sarsa, but they automatically get truncated as soon as there is disagreement between the behaviour policy and a greedy target policy (all subsequent reward observations get replaced by a single bootstrapping value estimate instead).\n\nIn the examples above, I assumed completely greedy target policies, since that is what you appeared to be most interested in in your question (and is probably also the most common use-case of off-policy learning). Note that a target policy does not have to be greedy. You can also have non-greedy target policies if you like, and then the returns will obviously change quite a bit from the discussion above (fewer $\\pi(S, A)$ terms would evaluate to $0$, there'd be more non-zero terms).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How powerful a computer is required to simulate the human brain? How much processing power is needed to emulate the human brain? More specifically, the neural simulation, such as communication between the neurons and processing certain data in real-time.\nI understand that this may be a bit of speculation and it's not possible to be accurate, but I'm sure there is some data available or research studies that attempted to estimate it based on our current understanding of the human brain.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "H+ magazine wrote an estimate in 2009 that seems broadly comparable to other things I've seen; they think the human brain is approximately 37 petaflops. A supercomputer larger than that 37 petaflop estimate exists today.\nBut emulation is hard. See this SO question about hardware emulation or this article on emulating the SNES, in which they require 140 times the processing power of the SNES chip to get it right. This 2013 article claims that a second of human brain activity took 40 minutes to emulate on a 10 petaflop computer (a 2400-times slowdown, not the 4-times slowdown one might naively expect).\nAnd all this assumes that neurons are relatively simple objects! It could be that the amount of math we have to do to model a single neuron is actually much more than the flops estimate above. Or it could be the case that dramatic simplifications can be made, and if we knew what the brain was actually trying to accomplish we could do it much more cleanly and simply. (One advantage that ANNs have, for example, is that they are doing computations with much more precision than we expect biological neurons to have. But this means emulation is harder, not easier, while replacement is easier.)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the segment embeddings and position embeddings in BERT? \nThey only reference in the paper that the position embeddings are learned, which is different from what was done in ELMo.\nELMo paper - https://arxiv.org/pdf/1802.05365.pdf\nBERT paper - https://arxiv.org/pdf/1810.04805.pdf\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "These embeddings are nothing more than token embeddings.\nYou just randomly initialize them, then use gradient descent to train them, just like what you do with token embeddings.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can the emotional quotient of an AI program be measured? Can an AI program have an EQ (emotional intelligence or emotional quotient)?\nIn other words, can the EQ of an AI program be measured?\nIf EQ is more problematic to measure than IQ (at least with a standard applicable to both humans and AI programs), why is that the case?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The answer to your question is \"In principle, yes\" - in it's most general form, EQ testing is just a specific case of the Turing test (\"How would you feel about ... ?\"). \nTo see why meaningful EQ tests might be difficult to achieve, consider the following two possible tests:\nAt one extreme of complexity, the film 'Blade Runner' famously shows a test to distinguish between human and android on the basis of responses to emotionally-charged questions.\nIf you tried asking these questions (or even much simpler ones) to a modern chatbot, you'd likely quickly conclude that you were not talking to a person.\nThe problem with assessing EQ is that the more emotionally sophisticated the test, the more general the AI system is likely have to be, in order to turn the input into a meaningful representation.\nAt the other extreme from the above, suppose that an EQ test was phrased in an extremely structured way, with the structured input provided by a human. In such a case, success at an 'EQ test' is not really grounded in the real-world.\nIn an essay entitled \"The ineradicable Eliza effect and its dangers\", Douglas Hofstadter gives the following example, in which the ACME program is claimed (not by Hofstadter) to 'understand' analogy.\n\nHere the computer learns about a fellow named Sluggo taking his wife Jane and\n his good buddy Buck to a bar, where things take their natural course and Jane\n winds up pregnant by Buck. She has the baby but doesn't want it, and so, aided\n by her husband, she drowns the baby in a river, thus \"neatly solving \"the problem\"\n of Bambi.\n\nThis story is presented to ACME in the following form:\nql: (neglectful-husband (Sluggo))\nq2: (lonely-and-sex-starved-wife (Jane-Doe))\nq3: (macho-ladykiller (Buck-Stag))\nq4: (poor-innocent-little-fetus (Bambi))\nq5: (takes-out-to-local-bar (Sluggo Jane-Doe Buck-Stag))\n...\nq11: (neatly-solves-the-problem-of (Jane-Doe Bambi))\nq12: (cause (ql0 q11))\n\nSuppose the program were to be asked if Jane Doe's behavior was moral. Complex compound emotional concepts such as 'neglectful', 'lonely' and 'innocent' are here simply predicates, not available to the AI for deeper introspective examination. They could just as easily be replaced by labels such as as 'bling-blang-blong15657'. \nSo in one sense, the absence of success at an EQ test with any depth is indicative of the general problem currently facing AI: the inability to define (or otherwise learn) meaningful representations of subtle complexities of the human world, which is a lot more complex than being able to recognize videos of cats.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can AI researchers avoid \"overfitting\" to commonly-used benchmarks as a community? In fields such as Machine Learning, we typically (somewhat informally) say that we are overfitting if improve our performance on a training set at the cost of reduced performance on a test set / the true population from which data is sampled.\nMore generally, in AI research, we often end up testing performance of newly proposed algorithms / ideas on the same benchmarks over and over again. For example:\n\nFor over a decade, researchers kept trying thousands of ideas on the game of Go.\nThe ImageNet dataset has been used for huge amounts of different publications\nThe Arcade Learning Environment (Atari games) has been used for thousands of Reinforcement Learning papers, having become especially popular since the DQN paper in 2015.\n\nOf course, there are very good reasons for this phenomenon where the same benchmarks keep getting used:\n\nReduced likelihood of researchers \"creating\" a benchmark themselves for which their proposed algorithm \"happens\" to perform well\nEasy comparison of results to other publications (previous as well as future publications) if they're all consistently evaluated in the same manner.\n\nHowever, there is also a risk that the research community as a whole is in some sense \"overfitting\" to these commonly-used benchmarks. If thousands of researchers are generating new ideas for new algorithms, and evaluate them all on these same benchmarks, and there is a large bias towards primarily submitting/accepting publications that perform well on these benchmarks, the research output that gets published does not necessarily describe the algorithms that perform well across all interesting problems in the world; there may be a bias towards the set of commonly-used benchmarks.\n\nQuestion: to what extent is what I described above a problem, and in what ways could it be reduced, mitigated or avoided?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Great question Dennis!\nThis is a perennial topic at AI conferences, and sometimes even in special issues of journals. The most recent one I recall was Moving Beyond the Turing Test in 2015, which ended up leading to a collection of articles in AI magazine later that year. \nUsually these discussions cover a number of themes:\n\n\"Existing benchmarks suck\". This is usually the topic that opens discussion. In the 2015/2016 discussion, which focused on the Turing Test as a benchmark specifically, criticisms ranged from \"it doesn't incentivize AI research on the right things\", to claims that it was poorly defined, too hard, too easy, or not realistic.\nGeneral concensus that we need new benchmarks.\nSuggestions of benchmarks based on various current research directions. In the latest discussion this included answering standardized tests for human students (well defined success, clear format, requires linking and understanding many ares), playing video games (well defined success, requires visual/auditory processing, planning, coping with uncertainty), and switching focus to robotics competitions.\n\nI remember attending very similar discussions at machine learning conferences in the late 2000's, but I'm not sure anything was published out of it.\nDespite these discussions, AI researchers seem to incorporate the new benchmarks, rather than displacing the older ones entirely. The Turing Test is still going strong for instance. I think there are a few reasons for this.\nFirst, benchmarks are useful, particularly to provide context for research. Machine learning is a good example. If the author sets up an experiment on totally new data, then even if they apply a competing method, I have to trust that they did so faithfully, including things like optimizing the parameters as much as with their own methods. Very often they do not do this (it requires some expertise with competing methods), which inflates the reported advantage of their own techniques. If they also run their algorithm on a benchmark, then I can easily compare it to the benchmark performances reported by other authors, for their own methods. This makes it easier to spot a technique that's not really effective.\nSecond, even if new benchmarks or new problems are more useful, nobody knows about them! Beating the current record for performance on ImageNet can slingshot someone's career in a way that top performance on a new problem simply cannot. \nThird, benchmarks tend to be things that AI researchers think can actually be accomplished with current tools (whether or not they are correct!). Usually iterative improvement on them is fairly easy (e.g. extend an existing technique). In a \"publish-or-perish\" world, I'd rather publish a small improvement on an existing benchmark than attempt a risker problem, at least pre-tenure. \nSo, I guess my view is fixing the dependence on benchmarks involves fixing the things that make people want to use them:\n\nHave some standard way to compare techniques, but require researchers to also apply new techniques to a real world problem.\nRemove the career and prestige rewards for working on benchmark problems, perhaps by explicitly tagging them as artificial.\nRemove the incentives for publishing often.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What algorithms are considered reinforcement learning algorithms? What are the areas/algorithms that belong to reinforcement learning?\nTD(0), Q-Learning and SARSA are all temporal-difference algorithms, which belong to the reinforcement learning area, but is there more to it?\nAre the dynamic programming algorithms, such as policy iteration and value iteration, considered as part of reinforcement learning? Or are these just the basis for the temporal-difference algorithms, which are the only RL algorithms?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The dynamic programming (DP) algorithms like policy iteration (PI) and value iteration (VI) are often presented in the context of reinforcement learning (in particular, in the book Reinforcement Learning: An Introduction by Barto and Sutton) because they are very related to reinforcement learning algorithms, like $Q$-learning - They are all based on the assumption that the environment/problem can be modelled as a Markov Decision Process (MDP).\nHowever, PI and VI require that the transition model and reward functions of the underlying MDP are both known. They can also be referred to as planning algorithms, because they can be used to find a policy (which can be thought of as plan) given this transition model and reward function of the MDP, without having to take random actions in the environment. They just exploit the given rules of the environment.\nOn the other hand, RL algorithms do not usually require or use the MDP's transition model, although they still require the reward function, which is fundamental. They attempt to find a policy or value function (from which the policy can be derived) by randomly interacting with the environment.\nThere are several categories of RL algorithms. There are temporal-difference, Monte-Carlo, actor-critic, model-free, model-based, on-policy, off-policy, prediction, control, policy-based or value-based algorithms. These categories can overlap. For example, $Q$-learning is a temporal-difference (TD), model-free, off-policy, control and value-based algorithm: it is based on an temporal-difference (TD) update rule, it doesn't use a model of the environment (model-free), it uses a behavioural policy that is different than the policy it learns (off-policy), it is used to find a policy (control) and it attempts to approximate a value function rather than directly the policy (value-based).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does Monte Carlo work when a real opponent's behavior may not be random I am learning about Monte Carlo algorithms and struggling to understand the following:\n\nIf simulations are based on random moves, how can the modeling of the opponent's behavior work well?\n\nFor example, if I have a node with 100 children, 99 of which lead to an instant WIN, whereas the last one leads to an instant LOSS.\nIn reality, the opponent would never play any of the 99 losing moves for him (assuming they are obvious as they are the last moves), and would always play the winning one. But the Monte Carlo algorithm would still see this node as extremely favorable (99/100 wins for me), because it sees each of the 100 moves as equally probable.\nIs my understanding wrong, or does it mean that in most games such situations do not occur and randomness is a good approximation of opponent behavior?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First, we need to distinguish plain Monte-Carlo from Monte-Carlo Tree Search. They're different things. \nMonte-Carlo search, in the context of game AI search algorithms, is typically understood to mean that we search randomly many times, and average the results, and nothing else. If this is all we're doing, then yes, your understanding is correct. This is also sometimes referred to as \"plain Monte-Carlo (search)\" or \"pure Monte-Carlo (search)\", to make it explicitly clear that we're not doing any tree search as in Monte-Carlo Tree Search (sometimes when we just say \"Monte-Carlo\" in the context of game AI, people will automatically assume Monte-Carlo Tree Search, due to how popular it is).\nMonte-Carlo Tree Search does a lot more than just that though. It gradually builds up a search tree (through the Expansion step), and within that search tree (which is growing over time), it uses a much more sophsticated strategy for traversal than pure random (the Selection step). \n\nFor example suppose i have a node with 100 children, 99 of which leading to an instant WIN, and the last one leading to an instant LOSS.\n\nSuppose that this node you're talking about, the one with those 100 children, is relatively close to the root node. Then, it is likely that it and all 100 of its children will end up \"growing into the search tree\" that is slowly built up by the Expansion step. Once they have been added to the search tree, the Selection step will make sure that the vast majority of further iterations visiting this part of the tree will select the instant loss (assuming the opponent is to move in this node). In the limit (after an infinite amount of search time), this bias towards selecting the loss node will be so large that the average evaluation tends to the (correct) minimax evaluation.\n\nAnother way to view the idea of evaluation through many random sequences of play is the following; the idea is that if we're in a very strong position, a good game state, then we're more likely to win than to lose if both players start playing at random. Consider, for example, a game of chess where Player 1 has many pieces left, and Player 2 only has a few pieces left. Imagine both players were to play completely at random from that game state onwards. On average, which player would you expect to win more often? Probably Player 1. \nWhen we're considering game states that are still far away from terminal states, this basic idea tends to work relatively well. Obviously not always correct, it's still a heuristic, but it can kind of work. When we're already very close to a terminal state that can be reached through one highly specific sequence of play, yeah, we might miss that through random actions; this is where we need the more informed policy of the Selection step.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Was DeepMind's DQN learning simultaneously all the Atari games? DeepMind states that its deep Q-network (DQN) was able to continually adapt its behavior while learning to play 49 Atari games.\nAfter learning all games with the same neural net, was the agent able to play them all at 'superhuman' levels simultaneously (whenever it was randomly presented with one of the games) or could it only be good at one game at a time because switching required a re-learn?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Switching required a re-learn.\nAlso, note that:\n\nWe use the same network architecture, learning\n algorithm and hyperparameters settings across all seven games, showing that our approach is robust\n enough to work on a variety of games without incorporating game-specific information. While we\n evaluated our agents on the real and unmodified games, we made one change to the reward structure\n of the games during training only.\n\nand \n\nthe\n network has outperformed all previous RL algorithms on six of the seven games we have attempted\n and surpassed an expert human player on three of them. \n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are GPT-3.5 series models based on GPT-3? In the official blog post about ChatGPT from OpenAI, there is this paragraph explaining how ChatGPT model was trained:\n\nWe trained this model using Reinforcement Learning from Human Feedback\n(RLHF), using the same methods as InstructGPT, but with slight\ndifferences in the data collection setup. We trained an initial model\nusing supervised fine-tuning: human AI trainers provided conversations\nin which they played both sides\u2014the user and an AI assistant. We gave\nthe trainers access to model-written suggestions to help them compose\ntheir responses. We mixed this new dialogue dataset with the\nInstructGPT dataset, which we transformed into a dialogue format.\n\nEspecially this part:\n\nWe trained an initial model using supervised fine-tuning\n\nMy question is about the said initial model, is it some new model that has been trained from scratch or is it a GPT-3 model that has been fine tuned for specific tasks resulting in GPT-3.5 series ?\nOn the other hand, from the InstructGPT blog post, it is clearly stated that:\n\nTo make our models safer, more helpful, and more aligned, we use an\nexisting technique called reinforcement learning from human feedback\n(RLHF). On prompts submitted by our customers to the API,our labelers\nprovide demonstrations of the desired model behavior, and rank several\noutputs from our models. We then use this data to fine-tune GPT-3.\n\nSo does this mean that GPT-3.5 series models (and consequently ChatGPT) are fine-tuned from GPT-3 base model ?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I'll complement nbro's answer with this great visual summary by Yao Fu :\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do I keep track of already visited states in breadth-first search? I was trying to implement the breadth-first search (BFS) algorithm for the sliding blocks puzzle (number type). Now, the main thing I noticed is that, if you have a $4 \\times 4$ board, the number of states can be as large as $16!$, so I cannot enumerate all states beforehand.\nHow do I keep track of already visited states? I am using a class board each class instance contains a unique board pattern and is created by enumerating all possible steps from the current step.\nI searched on the net and, apparently, they do not go back to the just-completed previous step, BUT we can go back to the previous step by another route too and then again re-enumerate all steps which have been previously visited. \nSo, how to keep track of visited states when all the states have not been enumerated already? Comparing already present states to the present step will be costly.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You can use a set (in the mathematical sense of the word, i.e. a collection that cannot contain duplicates) to store states that you have already seen. The operations you'll need to be able to perform on this are:\n\ninserting elements\ntesting if elements are already in there\n\nPretty much every programming language should already have support for a data structure that can perform both of these operations in constant ($O(1)$) time. For example:\n\nset in Python\nHashSet in Java\n\nAt first glance, it may seem like adding all the states you ever see to a set like this will be expensive memory-wise, but it is not too bad in comparison to the memory you already need for your frontier; if your branching factor is $b$, your frontier will grow by $b - 1$ elements per node that you visit (remove $1$ node from frontier to \"visit\" it, add $b$ new successors/children), whereas your set will only grow by $1$ extra node per visited node.\nIn pseudocode, such a set (let's name it closed_set, to be consistent with the pseudocode on wikipedia could be used in a Breadth-First Search as follows:\nfrontier = First-In-First-Out Queue\nfrontier.add(initial_state)\n\nclosed_set = set()\n\nwhile frontier not empty:\n current = frontier.remove_next()\n\n if current == goal_state:\n return something\n\n for each child in current.generate_children()\n if child not in closed_set: // This operation should be supported in O(1) time regardless of closed_set's current size\n frontier.add(child)\n\n closed_set.add(current) // this should also run in O(1) time\n\n(some variations of this pseudocode might work too, and be more or less efficient depending on the situation; for example, you could also take the closed_set to contain all nodes of which you have already added children to the frontier, and then entirely avoid the generate_children() call if current is already in the closed_set.)\n\nWhat I described above would be the standard way to handle this problem. Intuitively, I suspect a different \"solution\" could be to always randomize the order of a new list of successor states before adding them to the frontier. This way, you do not avoid the problem of occasionally adding states that you've already previousl expanded to the frontier, but I do think it should significantly reduce the risk of getting stuck in infinite cycles.\nBe careful: I do not know of any formal analysis of this solution that proves that it always avoids infinite cycles though. If I try to \"run\" this through my head, intuitively, I suspect it should kind of work, and it does not require any extra memory. There may be edge cases that I'm not thinking of right now though, so it also simply might not work, the standard solution described above will be a safer bet (at the cost of more memory).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is Lisp still worth learning today in the particular context of Machine learning? Lisp was originally created as a practical mathematical notation for computer programs, influenced by the notation of Alonzo Church's lambda calculus. It quickly became the favored programming language for artificial intelligence (AI) research, according to Wikipedia. \nIf Lisp is still used in AI, then is it worthy of learning it, particularly in the context of machine learning and deep learning?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "LISP was popular because back in the old days of AI because of the functional syntax, which worked well with the GOFAI paradigm of the time. \nNowadays most researchers have given up on the classical computational theory of mind (read: language of thought), and thus also the GOFAI paradigm that it associates with.\nLISP is not what you want to learn if you want to do neural network stuff, but the philosophical background is still important to know.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between encoders and auto-encoders? How are the layers in a encoder connected across the network for normal encoders and auto-encoders? In general, what is the difference between encoders and auto-encoders?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Theory\nEncoder\n\nIn general, an Encoder is a mapping $f : X \\rightarrow Y $ with $X$ Input Space and $Y$ Code Space \nIn case of Neural Networks, it is a Generative Model hence a function which is able to compute a Representation out of some input (like GAN)\n\nThe point is: how would you train such an encoder network ? \n\nThe general answer is: it depends on what you want your code to be and ultimately depends on what kind of problem the NN has to solve, so let's pick one \n\nSignal Compression\nThe goal is to learn a compressed representation for your input that allows to reconstruct the original input minimizing the loss of information \nIn this case hence you want the dimensionality of $Y$ to be lower than the dimensionality $X$ which in the NN case means the code space will be represented by less neurons than the input space \nAutoencoder\nFocusing on the Signal Compression problem, what we want to build is a system which is able to \n\ntake a given signal with size N bytes \ncompress it into another signal with size M 0$ and so $U(s,a) \\neq 0$ and things proceed as normal since the backprop step will have updated the visit count of the root node. So this possible bug/unintuitive behavior only affects the first iteration. It is extremely minor and insignificant, and does not affect the outcome of the MCTS, which is probably why it went unnoticed.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to use CNN for making predictions on non-image data? I have a dataset which I have loaded as a data frame in Python. It consists of 21392 rows (the data instances, each row is one sample) and 1972 columns (the features). The last column i.e. column 1972 has string type labels (14 different categories of target labels). I would like to use a CNN to classify the data in this case and predict the target labels using the available features. This is a somewhat unconventional approach though it seems possible. However, I am very confused on how the methodology should be as I could not find any sample code/ pseudo code guiding on using CNN for Classifying non-image data, either in Tensorflow or Keras. Any help in this regard will be highly appreciated. Cheers!\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You can use CNN on any data, but it's recommended to use CNN only on data that have spatial features (It might still work on data that doesn't have spatial features, see DuttaA's comment below).\nFor example, in the image, the connection between pixels in some area gives you another feature (e.g. edge) instead of a feature from one pixel (e.g. color). So, as long as you can shaping your data, and your data have spatial features, you can use CNN.\nFor Text classification, there are connections between characters (that form words) so you can use CNN for text classification in character level.\nFor Speech recognition, there is also a connection between frequencies from one frame with some previous and next frames, so you can also use CNN for speech recognition.\nIf your data have spatial features, just reshape it to a 1D array (for example in text) or 2D array (for example in Audio). Tensorflow's function conv1d and conv2d are general function that can be used on any data. It look the data as an array of floating-point, not as image/audio/text.\nBut if your data doesn't have spatial features, for example, your features are price, salary, status_marriage, etc. I think you don't need CNN, and using CNN won't help.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between search and learning? I came across an article, The Bitter Truth, via the Two Minute Papers YouTube Channel. Rich Sutton says...\n\nOne thing that should be learned from the bitter lesson is the great power of general purpose methods, of methods that continue to scale with increased computation even as the available computation becomes very great. The two methods that seem to scale arbitrarily in this way are search and learning.\n\nWhat is the difference between search and learning here? My understanding is that learning is a form of search -- where we iteratively search for some representation of data that minimizes a loss function in the context of deep learning.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In the context of AI:\n\nSearch refers to Simon & Newell's General Problem Solver, and it's many (many) descendant algorithms. These algorithms take the form:\na. Represent a current state of some part of the world as a vertex in a graph.\nb. Represent, connected to the current state by edges, all states of the world that could be reached from the current state by changing the world with a single action, and represent all subsequent states in the same manner.\nc. Algorithmically find a sequence of actions that leads from a current state to some more desired goal state, by walking around on this graph.\n\nAn example of an application that uses search is Google Maps. Another is Google Flights.\n\nLearning refers to any algorithm that refines a belief about the world through the exposure to experiences or to examples of others' experiences. Learning algorithms do not have a clear parent, as they were developed separately in many different subfields or disciplines. A reasonable taxonomy is the 5 tribes model. Some learning algorithms actually use search within themselves to figure out how to change their beliefs in response to new experiences! \nAn example of a learning algorithm used today is Q-learning, which is part of the more general family of reinforcement learning algorithms. Q-learning works like this:\na. The learning program (usually called the agent) is given a representation of the current state of the world, and a list of actions that it could choose to perform.\nb. If the agent has not seen this state of the world before, it assigns a random number to the reward it expects to get for performing each action. It stores this number as $Q(s,a)$, its guess at the quality of performing action $a$ in-state $s$.\nc. The agent looks at $Q(s,a)$ for each action it could perform. It picks the best action with some probability $\\epsilon$ and otherwise acts randomly.\nd. The action of the agent causes the world to change and may result in the agent receiving a reward from the environment. The agent makes a note of whether it got a reward (and how much the reward was), and what the new state of the world is like. It then adjusts its belief about the quality of performing the action it performed in the state it used to be in, so that its belief about the quality of that action is closer to the reality of the reward it got, and the quality of where it ended up.\ne. The agent repeats steps b-d forever. Over time, its beliefs about the quality of different state/action pairs will converge to match reality more and more closely.\n\nAn example of an application that uses learning is AI.SEs recommendations, which are made by a program that likely analyzes the relationships between different combinations of words in pairs of posts, and the likelihood that someone will click on them. Every time someone clicks on them, it learns something about whether listing a post as related is a good idea or not. Facebook's feed is another everyday example. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to design a neural network when the number of inputs is variable? I'm looking to design a neural network that can predict which runner wins in a sports game, where the number of runners varies between 2-10. In each case, specific data about the individual runners (for example, the weight, height, average speed in previous races, nationality, etc) would be fed into the neural network.\nWhat design would be most advantageous for such a neural network?\nEssentially this is a ranking problem where the number of inputs and outputs are variable.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The best option in your case would probably be zero-padding or padding up. This is simply zeroing out inputs for cases in which there is no data. It's done a lot on the borders of images for CNNs.\nAlternatively, you could just use an RNN, which can handle your variable-length inputs with ease.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does the \"reward to go\" trick in policy gradient methods work? In the policy gradient method, there's a trick to reduce the variance of policy gradient. We use causality, and remove part of the sum over rewards so that only actions happened after the reward are taken into account (See here http://rail.eecs.berkeley.edu/deeprlcourse/static/slides/lec-5.pdf, slide 18).\nWhy does it work? I understand the intuitive explanation, but what's the rigorous proof of it? Can you point me to some papers?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "An important thing we're going to need is what is called the \"Expected Grad-Log-Prob Lemma here\" (proof included on that page), which says that (for any $t$):\n$$\\mathbb{E}_{\\tau \\sim \\pi_{\\theta}(\\tau)} \\left[ \\nabla_{\\theta} \\log \\pi_{\\theta}(a_t \\mid s_t) \\right] = 0.$$\nTaking the analytical expression of the gradient (from, for example, slide 9) as a starting point:\n$$\\begin{aligned}\n\\nabla_{\\theta} J(\\theta) &= \\mathbb{E}_{\\tau \\sim \\pi_{\\theta}(\\tau)} \\left[ \\left( \\sum_{t=1}^T \\nabla_{\\theta} \\log \\pi_{\\theta} (a_t \\mid s_t) \\right) \\left( \\sum_{t=1}^T r(s_t, a_t) \\right) \\right] \\\\\n%\n&= \\sum_{t=1}^T \\mathbb{E}_{\\tau \\sim \\pi_{\\theta}(\\tau)} \\left[ \\nabla_{\\theta} \\log \\pi_{\\theta} (a_t \\mid s_t) \\sum_{t'=1}^T r(s_{t'}, a_{t'}) \\right] \\\\\n%\n&= \\sum_{t=1}^T \\mathbb{E}_{\\tau \\sim \\pi_{\\theta}(\\tau)} \\left[ \\nabla_{\\theta} \\log \\pi_{\\theta} (a_t \\mid s_t) \\sum_{t'=1}^{t-1} r(s_{t'}, a_{t'}) + \\nabla_{\\theta} \\log \\pi_{\\theta} (a_t \\mid s_t) \\sum_{t'=t}^T r(s_{t'}, a_{t'}) \\right] \\\\\n%\n&= \\sum_{t=1}^T \\left( \\mathbb{E}_{\\tau \\sim \\pi_{\\theta}(\\tau)} \\left[ \\nabla_{\\theta} \\log \\pi_{\\theta} (a_t \\mid s_t) \\sum_{t'=1}^{t-1} r(s_{t'}, a_{t'}) \\right] \\\\\n+ \\mathbb{E}_{\\tau \\sim \\pi_{\\theta}(\\tau)} \\left[ \\nabla_{\\theta} \\log \\pi_{\\theta} (a_t \\mid s_t) \\sum_{t'=t}^T r(s_{t'}, a_{t'}) \\right] \\right) \\\\\n\\end{aligned}$$\nAt the $t^{th}$ \"iteration\" of the outer sum, the random variables\n$ \\sum_{t'=1}^{t-1} r(s_{t'}, a_{t'}) $\nand\n$ \\nabla_{\\theta} \\log \\pi_{\\theta} (a_t \\mid s_t) $\nare independent (we assume, by definition, the action only depends on the most recent state), which means we are allowed to split the expectation:\n$$\\nabla_{\\theta} J(\\theta) = \\sum_{t=1}^T \\left( \\mathbb{E}_{\\tau \\sim \\pi_{\\theta}(\\tau)} \\left[ \\sum_{t'=1}^{t-1} r(s_{t'}, a_{t'}) \\right] \\mathbb{E}_{\\tau \\sim \\pi_{\\theta}(\\tau)} \\left[ \\nabla_{\\theta} \\log \\pi_{\\theta} (a_t \\mid s_t) \\right] \\\\\n+ \\mathbb{E}_{\\tau \\sim \\pi_{\\theta}(\\tau)} \\left[ \\nabla_{\\theta} \\log \\pi_{\\theta} (a_t \\mid s_t) \\sum_{t'=t}^T r(s_{t'}, a_{t'}) \\right] \\right)$$\nThe first expectation can now be replaced by $0$ due to the lemma mentioned at the top of the post:\n$$\n\\begin{aligned}\n\\nabla_{\\theta} J(\\theta)\n%\n&= \\sum_{t=1}^T \\mathbb{E}_{\\tau \\sim \\pi_{\\theta}(\\tau)} \\left[ \\nabla_{\\theta} \\log \\pi_{\\theta} (a_t \\mid s_t) \\sum_{t'=t}^T r(s_{t'}, a_{t'}) \\right] \\\\\n%\n&= \\mathbb{E}_{\\tau \\sim \\pi_{\\theta}(\\tau)} \\sum_{t=1}^T \\nabla_{\\theta} \\log \\pi_{\\theta} (a_t \\mid s_t) \\left( \\sum_{t'=t}^T r(s_{t'}, a_{t'}) \\right). \\\\\n\\end{aligned}\n$$\nThe expression on slide 18 of the linked slides is an unbiased, sample-based estimator of this gradient:\n$$\\nabla_{\\theta} J(\\theta) \\approx \\frac{1}{N} \\sum_{i=1}^N \\sum_{t=1}^T \\nabla_{\\theta} \\log \\pi_{\\theta} (a_{i, t} \\mid s_{i, t}) \\left( \\sum_{t'=t}^T r(s_{i, t'}, a_{i, t'}) \\right)$$\n\nFor a more formal treatment of the claim that we can pull $\\sum_{t'=1}^{t-1} r(s_{t'}, a_{t'})$ out of an expectation due to the Markov property, see this page: https://spinningup.openai.com/en/latest/spinningup/extra_pg_proof1.html\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What kind of body (if any) does intelligence require? In the mid 1980s, Rodney Brooks famously created the foundations of \"the new AI\". The central claim was that the symbolist approach of 'Good Old Fashioned AI' (GOFAI) had failed by attempting to 'cream cognition off the top', and that embodied cognition was required, i.e. built from the bottom up in a 'hierarchy of competances' (e.g. basic locomotion -> wandering around -> actively foraging) etc.\nI imagine most AI researchers would agree that the 'embodied cognition' perspective has now (at least tacitly) supplanted GOFAI as the mainstream.\nMy question takes the form of a thought experiment and asks: \"Which (if any) aspects of 'embodied' can be relaxed/omitted before we lose something essential for AGI?\"\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is something of an orthogonal answer, but I think Brooks didn't go about his idea the right way. That is, subsumption architecture is one in which the 'autopilot' is replaced by a more sophisticated system when necessary. (All pieces receive the raw sensory inputs, and output actions, some of which turn off or on other systems.)\nBut a better approach is the normal hierarchical control approach, in which the target of a lower level system is the output of a higher level system. That is, the targeted joint angle of a robot leg is determined by the system that is trying to optimize the velocity, which is determined by a system that is trying to optimize the trajectory, which is determined by a system that is trying to optimize the target position, and so on.\nThis allows for increasing level of complexity while maintaining detail and system reusability.\n\nThat said, I don't think you actually need what one would naively call 'embodied cognition' in order to get the bottom-up hierarchy of competencies that Brooks is right to point towards. The core feature is the wide array of inputs and outputs, which are understood in a hierarchical fashion that allows systems to be chained together vertically. I think you could get a functional general intelligence whose only inputs and outputs involve going through an Ethernet cable, and doesn't have anything like a traditional body that it actuates or senses through. (This is a claim that the hierarchical structure is what matters, not the content of what we use that structure for.)\n(The main place to look for more, I think, is actually a book about human cognition, called The Control of Perception by William T. Powers.)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between reinforcement learning and evolutionary algorithms? What is the difference between reinforcement learning (RL) and evolutionary algorithms (EA)?\nI am trying to understand the basics of RL, but I do not yet have practical experience with RL. I know slightly more about EAs, but not enough to understand the difference between RL and EA, and that's why I'm asking for their main differences.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Evolutionary algorithms (EAs) are a family of algorithms inspired by the biological evolution that can be used to solve (constrained or not) optimization problems where the function that needs to be optimized does not necessarily need to be differentiable (or satisfy any strong constraint). In EAs, you typically only need to define\n\nan encoding of the solution (aka chromosome or individual)\na fitness function that determines the relative quality of each solution\noperations that stochastically change or combine solutions (e.g. the cross-over or the mutation operators, in genetic algorithms)\n\nThere are other parameters that you need to defined (such as the number of solutions to consider at each generation or the number of generations to run the algorithms for), but these are the three most important things to take into account when attempting to solve an optimization problem with EAs (in particular, GAs).\nReinforcement learning (RL) is the field that studies how agents can sequentially take actions in a certain environment in order to maximize some notion of long-term reward (aka return). The strategy that determines the behavior of the agent (i.e. which actions the agent takes) is called the policy. So, the goal of RL is to find a policy that maximizes the (expected) return, which depends on the reward function of the environment. For example, in the case of chess, a reward function may be any function that gives you a positive number if you win the game or a negative number if you lose it. The RL algorithms typically assume that the agent is able to interact with the environment in order to understand its dynamics.\nRL is thus concerned with a specific type of optimization problem, i.e. finding policies (strategies) that maximize the return, while an agent interacts with an environment in time steps. On the other hand, EAs can be applied to any optimization problem where you can encode solutions, define a fitness function that compares solutions and you can stochastically change those solutions. Essentially, EAs can be applied to almost any optimization problem. In principle, you could use EAs to find policies, as long as you're able to compare them with a fitness function (e.g. the amount of reward that you obtain by following these policies).\nOf course, this does not mean that EAs are the most efficient and appropriate approach to solve all optimization problems! You typically use EAs when you need to solve certain problems where better approaches do not exist. For example, when your objective function is not differentiable, then you cannot apply gradient-based solutions, so, in that case, EAs may be a viable option (but there are also other alternatives to EAs, such as simulated annealing).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the benefit of using identity mapping layers in deep neural networks like ResNet? As I understand, ResNet has some identity mapping layers, whose task is to create the output as the same as the input of the layer. The ResNet solved the problem of accuracy degrading. But what is the benefit of adding identity mapping layers in intermediate layers?\nWhat's the effect of these identity layers on the feature vectors that will be produced in the last layers of the network? Is it helpful for the network to produce better representation for the input? If this expression is correct, what is the reason?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "TL;DR: Deep networks have some issues that skip connections fix.\nTo address this statement:\n\nAs I understand Resnet has some identity mapping layers that their task is to create the output as the same as the input of the layer\n\nThe residual blocks don't strictly learn the identity mapping. They are simply capable of learning such a mapping. That is, the residual block makes learning the identity function easy. So, at the very least, skip connections will not hurt performance (this is explained formally in the paper).\nFrom the paper:\n\nObserve: it's taking some of the layer outputs from earlier layers and passing their outputs further down and element wise summing these with the the outputs from the skipped layers. These blocks may learn mappings that are not the identity map.\nFrom paper (some benefits):\n\n$$\\boldsymbol{y} = \\mathcal{F}(\\boldsymbol{x},\\{W_i\\})+\\boldsymbol{x}\\quad\\text{(1)}$$The shortcut connections in Eqn.(1) introduce neither extra parameter nor computation complexity. This is not only attractive in practice but also important in our comparisons between plain and residual networks. We can fairly compare plain/residual networks that simultaneously have the same number of parameters, depth, width, and computational cost (except for the negligible element-wise addition).\n\nAn example of a residual mapping from the paper is $$\\mathcal{F} = W_2\\sigma_2(W_1\\boldsymbol{x})$$\nThat is $\\{W_i\\}$ represents a set of i weight matrices ($W_1,W_2$ in the example) occurring in the layers of the residual (skipped) layers. The \"identity shortcuts\" are referring to performing the element wise addition of $\\boldsymbol{x}$ with the output of the residual layers.\nSo using the residual mapping from the example (1) becomes:\n$$\\boldsymbol{y} = W_2\\sigma_2(W_1\\boldsymbol{x})+\\boldsymbol{x}$$\nIn short, you take the output $\\boldsymbol{x}$ of a layer skip it forward and element wise sum it with the output of the residual mapping and thus produce a residual block. \nLimitations of deep networks expressed in paper:\n\nWhen deeper networks are able to start converging, a degradation problem has been exposed: with the network depth increasing, accuracy gets saturated (which might be unsurprising) and then degrades rapidly. Unexpectedly, such degradation is not caused by overfitting, and adding more layers to a suitably deep model leads to higher training error, as reported in [11, 42] and thoroughly verified by our experiments. Fig. 1 shows a typical example.\n\nThe skip connections and hence the residual blocks allow for stacking deeper networks while avoiding this degradation issue. \nLink to paper\nI hope this helps. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between goal-based and utility-based agents? What is the difference between goal-based and utility-based agents? Please, provide a real-world example.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Utility is a fundamental to Artificial Intelligence because it is the means by which we evaluate an agent's performance in relation to a problem. To distinguish between the concept of economic utility and utility-based computing functions, the term \"performance measure\" is utilized. \nThe simplest way to distinguish between a goal-based agent and a utility-based agent is that a goal is specifically defined, where maximization of utility is general. (Maximizing utility is itself a form of goal, but generalized as opposed to specific.)\n\nA goal-based navigation agent is tasked with getting from point A to point B. If the agent succeeds, the goal has been satisfied. \nA utility-based navigation agent could seek to get from point A to point B in the shortest amount of time, with the minimum expenditure of fuel, or both.\n\nIn the above example, the utility agent is also goal based, but where the performance measure for the goal agent is a binary [succeed/fail], the utility agent can use real numbers and measure performance by degree. The utility agent allows more granularity in evaluation.\n\nFor an example of a non-goal based utility agent consider a form of a partisan sudoku in which players compete to control regions on the gameboard by placement of weighted integers.\nIn a game with 9 regions, the goal based agent seeks to control a specific number of regions at the end of play. If the agent is conservative, the goal might be 5 regions. If the agent is hyper-aggressive, the goal might be 9 regions. When evaluating the environment (gameboard), if the agent dominates the desired number of regions, it could choose to consolidate (reinforce); if the agent does not dominate the desired number of regions, it could choose to expand (attack).\nThe above strategy can be effective, but is limited by the specificity of the goal. A hyper-aggressive goal would work well against a weak opponent, but against a strong opponent it might prove disastrous. If the agent is sophisticated, where performance has been poor, it might alter it's goal by switching to a \"turtling strategy\" and seek to control fewer regions, but, because the new goal is still specific, the agent may miss opportunities to improve it's final status beyond the adjusted goal.\nThe utility-based agent can approach the game with no specific goal beyond improving it's status. Rather than seeking to control a set number of regions, the utility-agent evaluates whether a given choice improves or worsens it's status. (\"Do I dominate more or less regions if I take this position?\") The utility agent can distinguish between sets of beneficial choices (\"which choice maximizes my expected benefit?\") and, where no benefit can be obtained, distinguish among the set of choices with the least downside (\"among the set of bad choices, which is the least bad choice?\") \nIn this example, the utility-agent doesn't even need to understand the victory condition (controlling the more regions than the opponent at the end of play.) Instead, the utility-agent merely seeks to maximize the number of controlled regions over the course of play, which will result in victory if the agent makes more optimal choices than the opponent. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is the expert system still in use today? In my country, the Expert System class is mandatory, if you want to take the AI specialization in most universities. In class, I learned how to make a rule-based system, forward chaining, backward chaining, Prolog, etc.\nHowever, I have read somewhere on the web that expert systems are no longer used.\nIs that true? If yes, why? If not, where are they being used? With the rise of machine learning, they may not be as used as before, but is there any industry or company that still uses them today?\nPlease, provide some references to support your claims.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I would say Expert Systems is still being taught. For instance, if you look at some of the open courses like MIT's, there are still lectures on it.\nAlso, looking at the CLIPS documentation, you will find a couple of examples of usage from 2005. \nWhat I suspect is that Expert Systems are now embedded with \"normal systems\" in practice. Hence it may be difficult to distinguish from systems used on a daily basis for diagnostics, etc. and not as popular as before.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How should I represent the input to a neural network for the games of tic-tac-toe, checkers or chess? I've been reading a lot about TD-Gammon recently as I'm exploring options for AI in a video game I'm making. The video game is a turn-based positional sort of game, i.e. a \"units\", or game piece's, position will greatly impact its usefulness in that board state.\nTo work my way towards this, I thought it prudent to implement a Neural Network for a few different games first.\nThe idea I like is encoding the board state for the Neural Network with a single output neuron, which gives that board state relative strength compared to other board states. As I understand, this is how TD-Gammon worked.\nHowever, when I look at other people's code and examples/tutorials, there seems to be a lot of variance in the way they represent the board state. Even for something as simple as tic-tac-toe.\nSo, specifically, for tic-tac-toe, which is a better, or what is the correct representation for the board state?\nI have seen:\n\n9 input neurons, one for each square. A 0 indicates a free-space, -1 the opponent, and 1 yourself.\n\n9 input neurons, but using different values, such as 0 for the opponent, 0.5 for free, and 1 for yourself?\n\nCould you use larger values? Like 0, 1 and 2?\n\n27 input neurons. The first 3 being square 1, the next 3 being square 2, etc. Every neuron is 1 or 0. The first of the set of three indicates whether this square is free or not; the second indicates whether the square is occupied by your opponent or not. In the end, only one in every 3 neurons will have a 1, the other two will have a 0.\n\n18 input neurons. The first being 1 for the X player, the second being 1 for the O player, and both being 0 for a blank\n\n\nThen, when branching into games where the specific pieces' abilities come into play, like in chess, how would you represent this?\nWould it be as simple as using higher input values for more valuable pieces? I.e. -20 for an opponents Queen and +20 for your own queen? Or would you need something more complex where you define 10+ values for each square, one for each unit-type and player combination?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "When you are working with neural networks, as long as the data is there, the neural network is usually able to learn how to process it into a useful result.\nHowever, you usually also want to keep the number of weights to a minimum. When you use extra weights, it will take longer to train the network because you need to tune even more values for an optimal network.\nSo, for tic-tac-toe, any of your solutions involving 9 inputs should work just fine.\nAlso, it helps if you keep the inputs between 0 and 1 if you are using log sigmoid, and -1 and 1 if you are using hyperbolic tangent for your activation function. You can probably easily figure out what to use for other activation functions. You can take your data and transform it into another dataset with values within a specific range through a process called range normalization.\nFor chess, you can simply encode every piece in several different ways, and it will probably not make that much of a difference.\nThe general rule of thumb is you want to minimize the number of weights while still giving the most possible variables to the neural network.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are biological neurons organized in consecutive layers as well? I'm now reading a book titled Hands-On Machine Learning with Scikit-Learn and TensorFlow and in the Chapter 10 of the book, the author writes the following:\n\nThe architecture of biological neural networks (BNN)4 is still the subject of active research, but some parts of the brain have been mapped, and it seems that neurons are often organized in consecutive layers, as shown in Figure 10-2.\n\n\nHowever, there seems to be no link to any research there. And the author didn't say it assertively given that he used \"it seems that neurons are often organized in consecutive layers\".\nIs this true and how strongly is it believed? What research is this from?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Really short answer: yes\nSlightly longer answer: kinda\nLong answer:\nConvolutional neural networks (CNNs), which are now a standard in image processing models, were inspired from work done by Hubel and Wiesel in the 1950-60s. They showed that the visual cortexes of cats and monkeys contain neurons that individually respond to small regions of the visual field.\nTo give some background, we have to first start from the rods and cones in the eyes. These photosensitive cells are connected to a few layers of cells before even leaving the retina via ganglion cells.\n\nThese ganglion cells are then connected to several regions of the brain but primarily the Occipital lobe located at the back of the brain. The Occipital lobe is responsible for visual processing and is separated into cortical layers, the first named V1 which is the primary visual area. Most of the work by Hubel and Wiesel involved cells in V1 and showed how these cells were sensitive to orientation and color from their respective receptive areas on the retina.\n\nThe cells in V1 are connected to the cells in V2, which are sensitive to even more specific stimuli, such as movement with orientation, and this trend of specific sensitivity continues up from V2 to higher regions in the brain.\nThis layered approach to vision has been heavily exploited in CNNs, so much so that when the sensitivity of neurons in trained CNNs is displayed, similar responses (orientation) are found.\n\nThere is clear evidence of layers in biological optical systems and similarly layered structures in the other senses. Although there are many connections between different brain structures, the main structure of layers in the brain has helped understand what different areas of the brain do and has helped inspire many (if not all) advances in neural network research.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is \"early stopping\" in machine learning? What is early stopping in machine learning and, in general, artificial intelligence? What are the advantages of using this method? How does it help exactly?\nI'd be interested in perspectives and links to recent research.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In some iterative learning methods the more iterations you apply the more specific your model becomes about the training set. If there are too many iterations, your model will become too specifically trained for the training samples and will score less on other samples that are not seen during the training phase. This is called over-fitting, though over-fitting is not specific to iterative learning methods.\nOne solution to prevent over-fitting in these iterative learning algorithms is early stopping. Normally a control group of samples called validation samples (validation set) are used to validate the model and notify when it starts to over-fit. The validation set is not used by the training algorithm, however, its corresponding outputs are known and after each iteration, its samples are employed to measure how well the model currently works. As soon as the performance on the validation set stops growing and starts to drop we stop iterating the training algorithm. This is called early stopping which can help to maximize the generalization power of our learned model.\nNote that if we use the training set itself for validation the performance will always increase because that is what the learning algorithm is designed to do. However, the learning algorithm does not know how specifically it should learn the training set and that is why we need methods like early stopping.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the limitations of the hill climbing algorithm and how to overcome them? What are the limitations of the hill climbing algorithm? How can we overcome these limitations?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As @nbro has already said that Hill Climbing is a family of local search algorithms. So, when you said Hill Climbing in the question I have assumed you are talking about the standard hill climbing. The standard version of hill climb has some limitations and often gets stuck in the following scenario:\n\nLocal Maxima: Hill-climbing algorithm reaching on the vicinity a local maximum value, gets drawn towards the peak and gets stuck there, having no other place to go.\nRidges: These are sequences of local maxima, making it difficult for the algorithm to navigate.\nPlateaux: This is a flat state-space region. As there is no uphill to go, algorithm often gets lost in the plateau.\n\n\nTo resolve these issues many variants of hill climb algorithms have been developed. These are most commonly used:\n\nStochastic Hill Climbing selects at random from the uphill moves. The probability of selection varies with the steepness of the uphill move.\nFirst-Choice Climbing implements the above one by generating successors randomly until a better one is found.\nRandom-restart hill climbing searches from randomly generated initial moves until the goal state is reached.\n\nThe success of hill climb algorithms depends on the architecture of the state-space landscape. Whenever there are few maxima and plateaux the variants of hill climb searching algorithms work very fine. But in real-world problems have a landscape that looks more like a widely scattered family of balding porcupines on a flat floor, with miniature porcupines living on the tip of each porcupine needle (as described in the 4th Chapter of the book Artificial Intelligence: A Modern Approach). NP-Hard problems typically have an exponential number of local maxima to get stuck on.\nGiven algorithms have been developed to overcome these kinds of issues:\n\nStimulated Annealing\nLocal Beam Search\nGenetic Algorithms\n\nReference Book - Artificial Intelligence: A Modern Approach\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why not cache the Q (query) matrix? Short Version\nWhy do we cache the K (key) and V (value) matrices, but not he Q (query) matrix?\nLong Version\nGiven a toy set of 2-dimensional embedding vectors:\n\n\n\nToken\nEmbedding Vector\n\n\n\n\nquick\n[0.27 0.78]\n\n\nlazy\n[0.38 0.58]\n\n\nbrown\n[0.50 0.83]\n\n\njumps\n[0.20 0.53]\n\n\nover\n[0.46 0.59]\n\n\nthe\n[0.45 0.55]\n\n\nfox\n[0.19 0.69]\n\n\ndog\n[0.51 0.47]\n\n\n\n\nMeaning the input tokens the quick brown fox would be represented by their embeddings vectors in the X (input) matrix:\nX \u256d \u256e\n \u25020.45 0.55\u2502 ;the\n \u25020.27 0.78\u2502 ;quick\n \u25020.50 0.83\u2502 ;brown\n \u25020.19 0.69\u2502 ;fox\n \u2570 \u256f\n\nAnd we have a simple set of toy Wq, Wk, Wv weight matrices. Our toy embedding vectors are 2-dimensional. That then requires the weight matrices to have 2 rows; but they can have an arbitrarily decided number of columns; we choose 3 columns. Here are our toy weight matrices:\nWq (query)\n\u256d \u256e\n\u25020.6 -0.4 0.1\u2502\n\u25020.3 0.9 -0.2\u2502\n\u2570 \u256f\n\nWk (key)\n\u256d \u256e\n\u2502 0.5 0.2 -0.3\u2502\n\u2502-0.1 0.8 0.4\u2502\n\u2570 \u256f\n\nWv (value)\n\u256d \u256e \n\u25020.7 -0.3 -0.2\u2502\n\u25020.4 0.5 -0.1\u2502\n\u2570 \u256f\n\nThen we multiply the input matrix by the three WQ, WK, and WV weight matrices:\nQuery Matrix:\nQ = X*Wq\n \u256d \u256e \u256d \u256e\n \u25020.45 0.55\u2502 \u256d \u256e \u2502 0.43 0.32 -0.06\u2502\n \u25020.27 0.78\u2502 \u2502 0.6 -0.4 0.1\u2502 = \u2502 0.40 0.59 -0.13\u2502\n \u25020.50 0.83\u2502 \u2502 0.3 0.9 -0.2\u2502 \u2502 0.55 0.55 -0.12\u2502\n \u25020.19 0.69\u2502 \u2570 \u256f \u2502 0.32 0.54 -0.12\u2502\n \u2570 \u256f \u2570 \u256f\n\nKey Matrix:\nK = X*Wk\n \u256d \u256e \u256d \u256e\n \u25020.45 0.55\u2502 \u256d \u256e \u2502 0.17 0.53 0.08\u2502\n \u25020.27 0.78\u2502 \u2502 0.5 0.2 -0.3\u2502 = \u2502 0.06 0.68 0.23\u2502\n \u25020.50 0.83\u2502 \u2502-0.1 0.8 0.4\u2502 \u2502 0.17 0.76 0.18\u2502\n \u25020.19 0.69\u2502 \u2570 \u256f \u2502 0.03 0.59 0.22\u2502\n \u2570 \u256f \u2570 \u256f\n\n\nValue Matrix:\nV = X*Wv\n \u256d \u256e \u256d \u256e\n \u25020.45 0.55\u2502 \u256d \u256e \u2502 0.54 0.14 -0.14\u2502\n \u25020.27 0.78\u2502 \u25020.7 -0.3 -0.2\u2502 = \u2502 0.50 0.31 -0.13\u2502\n \u25020.50 0.83\u2502 \u25020.4 0.5 -0.1\u2502 \u2502 0.68 0.26 -0.18\u2502\n \u25020.19 0.69\u2502 \u2570 \u256f \u2502 0.41 0.29 -0.11\u2502\n \u2570 \u256f \u2570 \u256f\n\n\nNote: The Q, K, and V do undergo further processing, but that isn't really important here, as it's not relevant to the question. But it's essentially:\nA = softmax(mask(Q * transpose(K) / sqrt(2)) ; 2=number of dimensions in embedding space\nO = A xor V\n\nAdding a new token to the input\nLet's say after the quick brown fox, the next predicted token was jumps. So now we append that embedding to our X input matrix, giving us a new input matrix X:\nX \u256d \u256e\n \u25020.45 0.55\u2502 ;the\n \u25020.27 0.78\u2502 ;quick\n \u25020.50 0.83\u2502 ;brown\n \u25020.19 0.69\u2502 ;fox\n \u25020.20 0.53\u2502 ;jumps\n \u2570 \u256f\n\nAnd again we compute the Q, K, V matrices for this new set of input tokens:\nQuery Matrix:\nQ = X*Wq\n \u256d \u256e \u256d \u256e\n \u25020.45 0.55\u2502 \u256d \u256e \u25020.43 0.32 -0.06\u2502\n \u25020.27 0.78\u2502 \u2502 0.6 -0.4 0.1\u2502 = \u25020.40 0.59 -0.13\u2502\n \u25020.50 0.83\u2502 \u2502 0.3 0.9 -0.2\u2502 \u25020.55 0.55 -0.12\u2502\n \u25020.19 0.69\u2502 \u2570 \u256f \u25020.32 0.54 -0.12\u2502\n \u25020.20 0.53\u2502 \u25020.28 0.40 -0.09\u2502\n \u2570 \u256f \u2570 \u256f\n\nKey Matrix:\nK = X*Wk\n \u256d \u256e \u256d \u256e\n \u25020.45 0.55\u2502 \u256d \u256e \u25020.17 0.53 0.08\u2502\n \u25020.27 0.78\u2502 \u2502 0.5 0.2 -0.3\u2502 = \u25020.06 0.68 0.23\u2502\n \u25020.50 0.83\u2502 \u2502-0.1 0.8 0.4\u2502 \u25020.17 0.76 0.18\u2502\n \u25020.19 0.69\u2502 \u2570 \u256f \u25020.03 0.59 0.22\u2502\n \u25020.20 0.53\u2502 \u25020.05 0.46 0.15\u2502\n \u2570 \u256f \u2570 \u256f\n\nValue Matrix:\nV = X*Wv\n \u256d \u256e \u256d \u256e\n \u25020.45 0.55\u2502 \u2502 0.54 0.14 -0.14 \u2502\n \u25020.27 0.78\u2502 \u256d \u256e \u2502 0.50 0.31 -0.13 \u2502\n \u25020.50 0.83\u2502 \u25020.7 -0.3 -0.2\u2502 = \u2502 0.68 0.26 -0.18 \u2502\n \u25020.19 0.69\u2502 \u25020.4 0.5 -0.1\u2502 \u2502 0.41 0.29 -0.11 \u2502\n \u25020.20 0.53\u2502 \u2570 \u256f \u2502 0.35 0.21 -0.09 \u2502\n \u2570 \u256f \u2570 \u256f\n\nExcept the Q, K, V matrices are nearly identical, so cache them\nYou can see that the first four rows of Q, K, and V are the same as last time. That's because we just added a new token on the end; all the previous rows in X are the same. So rather than recompute the entire Q, K, and V matrix, we can keep them in memory, and just compute the final additional row:\nQuery Matrix:\nQ = X*Wq\n \u256d \u256e \u256d \u256e\n \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502 \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502\n \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502 \u256d \u256e \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502\n \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502 \u25020.6 -0.4 0.1\u2502 = \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502\n \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502 \u25020.3 0.9 -0.2\u2502 \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502\njumps\u25020.20 0.53\u2502 \u2570 \u256f \u25020.28 0.40 -0.09\u2502 \n \u2570 \u256f \u2570 \u256f\n\nKey Matrix:\nK = X*Wk\n \u256d \u256e \u256d \u256e\n \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502 \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502\n \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502 \u256d \u256e \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502\n \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502 \u2502 0.5 0.2 -0.3\u2502 = \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502\n \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502 \u2502-0.1 0.8 0.4\u2502 \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502\njumps\u25020.20 0.53\u2502 \u2570 \u256f \u25020.05 0.46 0.15\u2502\n \u2570 \u256f \u2570 \u256f\n\nValue Matrix:\nV = X*Wv\n \u256d \u256e \u256d \u256e\n \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502 \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502\n \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502 \u256d \u256e \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502\n \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502 \u25020.7 -0.3 -0.2\u2502 = \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502\n \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502 \u25020.4 0.5 -0.1\u2502 \u2502\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2502\njumps\u25020.20 0.53\u2502 \u2570 \u256f \u25020.35 0.21 -0.09\u2502\n \u2570 \u256f \u2570 \u256f\n\nBy caching the Q, K, V, we save ourselves 72 multiplications, and 36 additions, at the cost of storing 36 floats.\nExcept, apparently we don't cache Q.\nWe only cache K and V.\nWhy?\nWhy not also cache Q?\nI've asked ChatGPT over and over to try to explain it to me. It keeps saying:\n\nWe don't need the Query (Q) matrix after it is first used, so it is recomputed every time.\n\nWhich I do not understand; because it is used again after the first time, and it doesn't have to be recomputed: because we could cache it. I'm certain it's for a reason i'll never actually understand, but obviously i'll accept the answer that everyone else agrees is the correct answer. I was just also hoping to understand it myself: so i thought i would try asking.\nBonus Reading\n\n\ud83e\udd17HuggingFace: Past_key_values - why not past_key_values_queries?\nTransformers KV Caching Explained\nWhat is the Transformer KV Cache?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "During autoregressive decoding, the key and value representations of previous tokens are used repeatedly when new tokens are generated. So caching stateful K and V matrices saves you from having to recompute these values for all previous tokens at each next-token generation step. Without K/V caching, inference time grows quadratically with sequence length. With caching, it grows linearly, making long sequences generation feasible.\nIn contrast, the query vector for a token is computed only when its next-token is being generated by the attention mechanism and is never needed again. Future tokens depend on their own query vectors along with the cached K/V matrices of all previous tokens, so there\u2019s no need to cache query matrix Q which is stateless and transient.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is ergodicity in a Markov Decision Process (MDP)? I have read about the concept of ergodicity on the safe RL paper by Moldovan (section 3.2) and the RL book by Sutton (chapter 10.3, 2nd paragraph).\nThe first one says that \"a belief over MDPs is ergodic if and only if any state is reachable from any other state via some policy or, equivalently, if and only if\":\n$$\\forall s, s', \\exists \\pi_r \\text{ such that } E_\\beta E_{s, \\pi_r}^P [B_{s'}] = 1$$\nwhere:\n\n$B_{s'}$ is an indicator random variable of the event that the system reaches state $s'$ at least once, i.e., $B_{s'} = 1 \\{ \\exists t < \\infty \\text{ such that } s_t = s'\\}$\n$E_\\beta E_{s, \\pi_r}^P[B_{s'}]$ is the expected value for $B_{s'}$, under the belief over the MDP dynamics $\\beta$, policy $\\pi$ and transition measure $P$.\n\nThe second one says \"$\\mu_\\pi$ is the steady-state distribution, which is assumed to exist for any $\\pi$ and to be independent of $s_0$. This assumption about the MDP is known as ergodicity.\". They define $\\mu_\\pi$ as:\n$$\\mu_\\pi(s) \\doteq \\lim_{t \\to \\infty} \\Pr\\{s_t=s \\vert a_{0:t-1} \\sim \\pi\\}$$\n\ni.e., there is a chance of landing on state $s$ by executing actions according to policy $\\pi$.\n\nI noticed that the first definition requires that at least one policy should exist for each $(s, s')$ pair for the MDP to be ergodic The second definition, however, requires that all policies eventually visit all the states in an MDP, which seems to be a more strict definition.\nThen, I came accross the ergodicity definition for Markov chains:\n\nA state $i$ is said to be ergodic if it is aperiodic and positive recurrent. In other words, a state $i$ is ergodic if it is recurrent, has a period of $1$, and has finite mean recurrence time. If all states in an irreducible Markov chain are ergodic, then the chain is said to be ergodic.\n\nThis leads me to believe that the second definition (the stricter one) is the most appropriate one, considering the ergodicity definition in an MDP derives from the definition in a Markov chain. As an MDP is basically a Markov chain with choice (actions), ergodicity should mean that independently of the action taken, all states are visited, i.e., all policies ensure ergodicity.\nAm I correct in assuming these are different definitions? Can both still be called \"ergodicity\"? If not, which one is the most correct?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In short, the relevant class of a MDPs that guarantees the existence of a unique stationary state distribution for every deterministic stationary policy are unichain MDPs (Puterman 1994, Sect. 8.3). However, the unichain assumption does not mean that every policy will eventually visit every state. I believe your confusion arises from the difference between unichain and more constrained ergodic MDPs.\nPuterman defines that a MDP is (emphasis in the following mine):\n\n\nrecurrent or ergodic if the state transition matrix corresponding to every deterministic stationary policy consists of a single recurrent\nclass, and\nunichain, if the state transition matrix corresponding to every deterministic stationary policy is unichain, that is, it consists of a\nsingle recurrent class and a possibly empty set of transient states.\n\n\nBefore unpacking this further, let's first recap what recurrent and transient states in a Markov chain are. The following definitions can be found in Puterman, Appendix A.2. For a state $s$, associate two random variables $\\nu_s$ and $\\tau_s$ that represent the number of visits and the time of the first visit (or first return if the chain starts in $s$) to state $s$. A state $s$ is\n\nrecurrent (sometimes also called ergodic), if $P_s(\\tau_s < \\infty) = 1$, that is, the state is eventually visited (or returned to), and\ntransient, if $\\mathbb{E}[\\tau_s] = \\infty$ and $P_s(\\tau_s < \\infty) < 1$.\n\nIt is also true that $s$ is recurrent if and only if $\\mathbb{E}[\\nu_s] = \\infty$, i.e., it is visited infinitely often, and $s$ is transient if and only if $\\mathbb{E}[\\nu_s] < \\infty$, i.e., it is visited only finitely often (and thereby never again after some finite time).\nSo let's now return to the two types of MDPs above. Consider an arbitrary deterministic stationary policy $\\pi$ which maps any state $s$ to an action $a = \\pi(s)$. If the MDP is ergodic, then the stationary distribution $\\mu_\\pi(s)$ exists and is unique, because the Markov chain over states induced by any policy has a single recurrent class (it does not matter in which state $s_0$ the chain starts, the same stationary distribution is reached). There is a single class of recurrent states, i.e., all states are recurrent, therefore any $s$ is visited infinitely often and $\\mu_\\pi(s) > 0$.\nNow, if the MDP is unichain, then once again the stationary distribution $\\mu_\\pi(s)$ exists and is unique, because the Markov chain over states induced by any policy has a single recurrent class. But, importantly, there may exist a policy $\\pi$ for which the set of transient states in the induced Markov chain is not empty. Because any transient state $s$ will only be visited a finite number of times, in the (infinite horizon) stationary distribution $\\mu_\\pi(s)=0$!\nSo indeed, if the MDP is of the stricter ergodic type, every policy will eventually visit every state. This is not true for unichain MDPs however.\nA final remark: some authors define a policy as ergodic (e.g., Kearns & Singh, 2002), if the resulting Markov chain over states is ergodic (i.e., has a unique stationary distribution). The unichain MDP is a type of MDP where every policy is ergodic.\nReferences:\nPuterman, M. L. (1994). Markov Decision Processes: Discrete Stochastic Dynamic Programming.\nKearns & Singh. Near-Optimal Reinforcement Learning in Polynomial Time. Machine Learning, 49, 209\u2013232, 2002\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can an ensemble be more accurate than the best base classifier in that ensemble? BACKGROUND: Ensemble classifiers are said to reduce bias by taking an \"average\" of predictions of several base classifiers that comprise the ensemble. However, I am uncertain if this necessarily means that they can increase accuracy. My intuition tells me that the ensemble classifier should perform no better and possibly even worse than the best base classifier in the ensemble. This seems especially true for bagging approaches which use strong classifiers anyway. When you have a \"star performer\", it just doesn't seem to make intuitive sense to \"dilute\" its performance with subpar performers.\nNonetheless, from my novice-level reading, it seems that ensembles can be as good or possibly even better than all of the individual base classifiers, but I'm still not clear why.\nQUESTION: How can an ensemble be more accurate than the best base classifier in that ensemble?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Lets consider binary classification.\nImagine you have an ensemble made up of $K$ models. Assume each model has exactly $51\\%$ accuracy. Further assume each model's error is uncorrelated with each other model. The ensemble simply takes a majority vote.\nFor $K = 11$, what is the probability we get a single question right?\nNote: This problem can be simply modeled as flipping an unfair coin $K$ times and calculating the probability that one side will be the majority of flips.\n\n$P(correct\\ \\geq\\ 6)\\ =\\ \\sum_{k=6}^{11}{\\binom{11}{k}({0.51}^k)({0.49}^{11-k})= 0.53}$\n\nWhat about when $K = 101$?\n\n$P(correct\\ \\geq\\ 51)\\ =\\ \\sum_{k=51}^{101}{\\binom{101}{k}({0.51}^k)({0.49}^{101-k})= 0.58}$\n\nIf you do the math you will find that as $K$ approaches $\\infty$, the odds of the ensemble being correct asymptotically approaches $100\\%$.\n\n$\\lim_{K\\rightarrow\\infty}{P\\left(correct\\ \\geq\\frac{K+1}{2}\\right)}={lim}_{K\\rightarrow\\infty}\\left(\\sum_{k=\\frac{K+1}{2}}^{K}{\\binom{K}{k}({0.51}^k)({0.49}^{K-k}})\\right)=1$\n\nNow, we made 2 key assumptions:\n\nErrors are uncorreleated between models\nEach model has more than $50\\%$ accuracy\n\nIn practice these assumptions often may not hold, especially the first one. But if they do, this simple probability analysis shows ensembles will be better\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do evolutionary algorithms have advantages over the conventional backpropagation methods? How does employing evolutionary algorithms to design and train artificial neural networks have advantages over using the conventional backpropagation algorithms?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Unlike backpropagation, evolutionary algorithms do not require the objective function to be differential with respect to the parameters you aim to optimize. As a result, you can optimize \"more things\" in the network, such as activation functions or number of layers, which wouldn't be possible in the standard backpropagation. \nAnother advantage is that by defining the mutation and crossover functions, you can influence how the parameter search space should be explored.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between the positional encoding techniques of the Transformer and GPT? I know the original Transformer and the GPT (1-3) use two slightly different positional encoding techniques.\nMore specifically, in GPT they say positional encoding is learned. What does that mean? OpenAI's papers don't go into detail very much.\nHow do they really differ, mathematically speaking?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The purpose of introduction of positional encoding is to insert a notion of location of a given token in the sequence. Without it, due to the permutation equivariance (symmetry under the token permutation) there will be no notion of relative order inside a sequence.\nGiven a token at $\\text{pos}$-th position we would like to make the model understand, that this token is at particular position. See pretty nice blog here - https://kazemnejad.com/blog/transformer_architecture_positional_encoding/.\nFixed encoding\nIn the original Transformer one uses a fixed map from the token position $i$ to the embedding vector added to the original embedding:\n$$\n\\begin{aligned}\nPE(\\text{pos}, 2i) &= \\sin(\\text{pos} / 10000^{2i / d_{\\text{model}}}) \\\\\nPE(\\text{pos}, 2i + 1) &= \\cos(\\text{pos} / 10000^{2i / d_{\\text{model}}})\n\\end{aligned}\n$$\nHere $\\text{pos}$ is an index of the token in sequence, and $2i, 2i+1$ correspond to the dimension inside the embedding.\nLearned encoding\nAnother strategy is to make map for $\\text{pos}$ to the embedding vector of dimension $d_{\\text{model}}$ learnable. One initializes somehow for each position in the sequence vector of positional embedding for each position from $0$ to $\\text{max_length}$ and during the training these vectors are updated by gradient descent.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are ReLUs incapable of solving certain problems? Background\nI've been interested in and reading about neural networks for several years, but I haven't gotten around to testing them out until recently.\nBoth for fun and to increase my understanding, I tried to write a class library from scratch in .Net. For tests, I've tried some simple functions, such as generating output identical to the input, working with the MNIST dataset, and a few binary functions (two input OR, AND and XOR, with two outputs: one for true, one for false).\nEverything seemed fine when I used a sigmoid function as the activation function, but, after reading about the ReLUs, I decided to switch over for speed.\nProblem\nMy current problem is that, when I switch to using ReLUs, I found that I was unable to train a network of any complexity (tested from as few as 2 internal nodes up to a mesh of 100x100 nodes) to correctly function as an XOR gate.\nI see two possibilities here:\n\nMy implementation is faulty. (This one is frustrating, as I've re-written the code multiple times in various ways, and I still get the same result).\n\nAside from being faster or slower to train, there are some problems that are impossible to solve given a specific activation function. (Fascinating idea, but I've no idea if it's true or not).\n\n\nMy inclination is to think that 1) above is correct. However, given the amount of time I've invested, it would be nice if I could rule out 2) definitively before I spend even more time going over my implementation.\nMore details\nFor the XOR network, I have tried both using two inputs (0 for false, 1 for true), and using four inputs (each pair, one signals true and one false, per \"bit\" of input). I have also tried using 1 output (with a 1 (really, >0.9) corresponding to true and a 0 (or <0.1) corresponding to false), as well as two outputs (one signaling true and the other false).\nEach training epoch, I run against a set of 4 inputs $\\{ (00, 0), (01, 1), (10, 1), (11, 0) \\}$.\nI find that the first three converge towards the correct answer, but the final input (11) converges towards 1, even though I train it with an expected value of 0.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are a variety of possible things that could be wrong, but let me give you some potentially useful information.\nNeural networks with ReLU activation functions are Turing complete for a computation with on order as many steps as the network contains nodes - for a recurrent network (an RNN), that means the same level of turing completeness as any finite computer. In other words, for any function/algorithm that you want to compute, you can devise a neural network, potentially recurrent, that will approximate/compute it.\nAs an example, suppose that we want to compute the NOR function, which can be used to implement a Turing machine. We can do it with the following neural network with a ReLU activation function.\nLet the input be\n$$ W = \\begin{bmatrix}x_1 \\ \\ x_2 \\end{bmatrix}$$\nthe weight matrix be\n$$ W = \\begin{bmatrix} -20 \\\\ -20 \\end{bmatrix}$$\nand the bias be\n$$ b = \\begin{bmatrix} 1 \\end{bmatrix}$$\nThen the ReLU unit (or neuron) performs the following operation\n$$o = \\max(Wx + b, 0)$$\nSo, $o = 1$ only when both $x_1$ and $x_2$ are $0$, otherwise, it's always $0$.\nHowever, gradient descent is a finicky way to search for RNNs. There are a wide variety of ways that it might have been failing. In general, once you have very thoroughly checked your gradient, I'd make sure to use Adam as the optimizer and then play with the hyperparameters endlessly until I find an incantation that works.\nFor further reading on general understanding of this level of deep learning's capability limitations, I'd recommend this blog post by Ilya Sutskever, now an OpenAI researcher: http://yyue.blogspot.com/2015/01/a-brief-overview-of-deep-learning.html?m=1\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Using AI to extend an imagine pattern I have created some nice patterns using the MidJourney tool. I'd like to find a way to extend these patterns, and I was thinking about an AI tool that takes one of these patterns and extends it in all directions surrounding the original pattern.\nJust to give you an idea, this is one of those patterns:\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As Edoardo says in their excellent answer, the task at hand can be approached as an outpainting problem and there's some great tools available to do this.\nTo throw an alternative into the ring, I'd point to an example in the field of texture synthesis - Self-Organising Textures built with Neural Cellular Automata.\nThe theory revolves around teaching a very small neural network to generate an image using learned, local update rules. When given a loss function that compares the style of two images, the model can generate textures that seamlessly extend the original.\nWithin the Self-Organising Texture article, there's a a Google Colab which allows you to import a target image and train the model to reproduce it. I used your image as the target, and it was able to quickly (<20 minutes) make a model that captured the overall pattern of your image:\n\nThere are options for refining the resulting texture with different loss functions, and even exerting a degree of artistic control using relative noise levels in the generation process. One of the creators of the models, Alexander Mordvintsev, has an excellent YouTube channel where he walks through some of these techniques and I'd highly recommend checking it out if you want to pursue using this method. Have fun!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are some resources on computational learning theory? Pretty soon I will be finishing up Understanding Machine Learning: From Theory to Algorithms by Shai Ben-David and Shai Shalev-Shwartz. I absolutely love the subject and want to learn more, the only issue is I'm having trouble finding a book that could come after this. Ultimately, my goal is to read papers in JMLR's COLT.\n\nIs there a book similar to \"Understanding Machine Learning: From Theory to Algorithms\" that would progress my knowledge further and would go well after reading UML?\nIs there any other materials (not a book) that could allow me to learn more or prepare me for reading a journal like the one mentioned above?\n\n(Also, taking courses in this is not really an option, so this will be for self-study).\n(Note that I have also asked this question here on TCS SE, but it was recommended I also ask here.)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Although I have only partially read or not read at all some of the following resources and some of these resources may not cover more advanced topics than the ones presented in the book you are reading, I think they can still be useful for your purposes, so I will share them with you.\nI would also like to note that if you understand the contents of the book you are currently reading, you are probably already prepared for reading some (if not most of) the research papers you wish to read. Initially, you may find them a little bit too succinct and sometimes unclear or complex, but you need to get used to this format, so there's nothing stopping you from trying to read them and learn even more by doing this exercise.\nBooks\n\nAn Introduction to Computational Learning Theory (1994) by Kearns and Vazirani (no free PDF is available, afaik)\nThe Nature of Statistical Learning Theory (1995, 2000) by Vapnik\nMachine Learning (1997) by Mitchell\nStatistical Learning Theory (1998) by Vapnik\nPrediction, Learning, and Games (2006) by Cesa-Bianchi and Lugosi\nFoundations of Machine Learning (2012) by Mohri et al.\nBoosting: Foundations and Algorithms (2012) by Schapire and Freund\nBandit Algorithms (2020) by Lattimore and Szepesv\u00e1ri (with associated solutions to the exercises)\n\nPapers\n\nLanguage identification in the limit (1967) by E. Mark Gold (this paper introduces algorithmic learning theory, i.e. the non-statistical approach to CLT)\n\nA theory of the learnable (1984) by Valiant (this paper introduces PAC learning)\n\nAn overview of statistical learning theory (1999) by Vapnik\n\nIntroduction to Statistical Learning Theory (2014) by Bousquet et al.\n\n\nCourses (videos)\n\nLearning from Data (Caltech) (2012) by Yaser Abu-Mostafa\nMachine Learning Theory (2015) by Shai Ben-David\n\nLecture notes\n\nComputational Learning Theory - Michaelmas Term 2018 by Varun Kanade\n\nIntroduction to Machine Learning (2009) by Shai Shalev-Shwartz\n\nConcentration-of-measure inequalities (2009) by G\u00e1bor Lugosi\n\nStat 928: Statistical Learning Theory (2011) by Sham Kakades\n\nCOMS E6253, Advanced Topics in Computational Learning Theory (2012) Rocco Servedio\n\n9.520: Statistical Learning Theory and Applications, Spring 2012 by Tomaso Poggio et al.\n\nSTAT928: Statistical Learning Theory and Sequential Prediction (2014) by Alexander Rakhlin and Karthik Sridharan\n\nECE 543, Statistical Learning Theory (2019) by Bruce Hajek and Maxim Raginsky\n\n\nOther\nSee also this list of resources https://kiranvodrahalli.github.io/links/#resources-notes-textbooks-monographs-classes-etc compiled by Kiran Vodrahalli.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "A deep learning algorithm to optimize the outcome I'm am quite new to deep learning but I think I found just the right real-world situation to start using it. The problem is that I have only used such algorithms to predict outcomes. For my new project, I need information to feed a machine with to optimize outcomes. Could someone explain briefly how I should proceed? I'm stuck.\nHere's the situation:\nI have a machine that takes planks of wood with different grades of wood available throughout its length and has to cut it into blocks provided in a cut list. This machine will always choose the highest score it can get from a given plank. The score is obtained by multiplying each block's area by its multiplicator. The algorithm I want to build has to give that machine a multiplicator for each block listed in a cut list. All of the physical output from this machine will be stocked on shelves by a robot until needed. The cutting machine is allowed to downgrade parts of a plank if it helps it reach a higher score.\nThe value has to act as an incentive for the machine to give me the block I need the most without downgrading too much wood.\nOPTIMIZATION GOALS\n\nMake sure each block is in stock by the time it is needed, but not too early without reason\nDowngrade as little area of wood as possible (some species are very expensive)\n\nINPUT NODES\n\nAmount of time before this block is needed\nGrade of wood for this block\nAmount of this block needed\nBlock's area (Maybe?)\n\nFEEDBACK PROVIDED TO THE ALGORITHM\n\nAmount of time in advance that the block was ready (must be as low as possible)\nArea of wood downgraded * number of grades skipped\n\nEXPECTED RETURN DATA\n\nA multiplicator that will give that block an optimal its priority relative to others\n\nINFORMATION I DON'T HAVE BUT COULD GATHER\n\nMean ratio of each grade for each species of wood\n\nWhat I've figured out so far is that I may need my feedback to be smashed in only one value in order to make it the output node. The problem is that I can't understand how to make this algorithm to determine a multiplicator. Am I wrong in trying to solve this through deep learning?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Deep learning models for regression tasks are quite difficult to train so I would suggest not to start with them. Instead I would start with one of the approaches below and maybe try to use deep learning afterwards.\nA classical approach to the problem could be to analyze your optimization software and this would probably lead you to some deterministic algorithm.\nDifferent approaches can be to treat your optimization software as a black box - give it a wide variety of inputs, note down the variables you are interested in (execution time, cutting results, etc.) and try to fit some sort or regressor on it. \nOne option is to follow Kourosh's idea and formulate it as a classical optimization problem.\nIf you prefer to use machine learning tools than I'd suggest that you start with a simple model like linear regression just to verify that there is any signal in the data that you can use. Afterwards you can look at more powerful algorithms like xgboost, regression trees, etc.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does using ASIC for the acceleration of AI work? We can read on Wikipedia page that Google built a custom ASIC chip for machine learning and tailored for TensorFlow which helps to accelerate AI.\nSince ASIC chips are specially customized for one particular use without the ability to change its circuit, there must be some fixed algorithm which is invoked.\nSo how exactly does the acceleration of AI using ASIC chips work if its algorithm cannot be changed? Which part of it is exactly accelerating?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Tensor operations\nThe major work in most ML applications is simply a set of (very large) tensor operations e.g. matrix multiplication. You can do that easily in an ASIC, and all the other algorithms can just run on top of that.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the biggest barriers to get RL in production? I am studying the state of the art of Reinforcement Learning, and my point is that we see so many applications in the real world using Supervised and Unsupervised learning algorithms in production, but I don't see the same thing with Reinforcement Learning algorithms.\nWhat are the biggest barriers to get RL in production?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is a relatively recent paper that tackles this issue: Challenges of real-world reinforcement learning (2019) by Gabriel Dulac-Arnold et al., which presents all the challenges that need to be addressed to productionize RL to real world problems, the current approaches/solutions to solve the challenges, and metrics to evaluate them. I will only list them (based on the notes I had taken a few weeks ago). You should read the paper for more details. In any case, for people that are familiar with RL, they will be quite obvious.\n\nBatch off-line and off-policy training\n\nOne current solution is importance sampling\n\n\nLearning on the real system from limited samples (sample inefficiency)\n\nSolutions: MAML, use expert demonstrations to bootstrap the agent, model-based approaches\n\n\nHigh dimensional continuous state and action spaces\n\nSolutions: AE-DQN, DRRN\n\n\nSatisfying safety constraints\n\nSolutions: constrained MDP, safe exploration strategies, etc.\n\n\nPartial observability and non-stationarity\n\nSolutions to partial observability: incorporate history in the observation, recurrent neural networks, etc.\nSolutions to non-stationarity: domain randomization or system identification\n\n\nUnspecified and multi-objective reward functions\n\nSolutions: CVaR, Distributional DQN\n\n\nExplainability\nReal-time inference\nSystem delays (see also this and this answers)\n\nThere's also a more recent and related paper An empirical investigation of the challenges of real-world reinforcement learning (2020) by Gabriel Dulac-Arnold et al, and here you have the associated code with the experiments.\nHowever, note that RL (in particular, bandits) is already being used to solve at least one real-world problem [1, 2]. See also this answer.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why class embedding token is added to the Visual Transformer? In the famous work on the Visual Transformers, the image is split into patches of a certain size (say 16x16), and these patches are treated as tokens in the NLP tasks. In order to perform classification, a CLS token is added at the beginning of the resulting sequence:\n$$\n[\\textbf{x}_{class}, \\textbf{x}_{p}^{1}, \\ldots, \\textbf{x}_{p}^{N}]\n,$$\nwhere $ \\textbf{x}_{p}^{i}$ are image patches. There multiple layers in the architecture and the state of the CLS token on the output layer is used for classification.\nI think this architectural solution is done in the spirit of NLP problems (BERT in particular). However, for me, it would be more natural not to create a special token, but perform 1d Global Pooling in the end, and attach an nn.Linear(embedding_dim, num_classes) as more conventional CV approach.\nWhy it is not done in this way? Or is there some intuition or evidence that this would perform worse than the approach used in the paper?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In their official repository, the author confirmed in the issue that the cls is not really important for the ViT, but they wanted to keep the ViT to be exactly the same with the NLP-Transformer, so they added it.\nIssue link: https://github.com/google-research/vision_transformer/issues/61#issuecomment-802233921\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Loss jumps abruptly when I decay the learning rate with Adam optimizer in PyTorch I'm training an auto-encoder network with Adam optimizer (with amsgrad=True) and MSE loss for Single channel Audio Source Separation task. Whenever I decay the learning rate by a factor, the network loss jumps abruptly and then decreases until the next decay in learning rate.\nI'm using Pytorch for network implementation and training.\nFollowing are my experimental setups:\n\n Setup-1: NO learning rate decay, and \n Using the same Adam optimizer for all epochs\n\n Setup-2: NO learning rate decay, and \n Creating a new Adam optimizer with same initial values every epoch\n\n Setup-3: 0.25 decay in learning rate every 25 epochs, and\n Creating a new Adam optimizer every epoch\n\n Setup-4: 0.25 decay in learning rate every 25 epochs, and\n NOT creating a new Adam optimizer every time rather\n using PyTorch's \"multiStepLR\" and \"ExponentialLR\" decay scheduler \n every 25 epochs\n\nI am getting very surprising results for setups #2, #3, #4 and am unable to reason any explanation for it. Following are my results:\nSetup-1 Results:\n\nHere I'm NOT decaying the learning rate and \nI'm using the same Adam optimizer. So my results are as expected.\nMy loss decreases with more epochs.\nBelow is the loss plot this setup.\n\nPlot-1:\n\noptimizer = torch.optim.Adam(lr=m_lr,amsgrad=True, ...........)\n\nfor epoch in range(num_epochs):\n running_loss = 0.0\n for i in range(num_train):\n train_input_tensor = .......... \n train_label_tensor = ..........\n optimizer.zero_grad()\n pred_label_tensor = model(train_input_tensor)\n loss = criterion(pred_label_tensor, train_label_tensor)\n loss.backward()\n optimizer.step()\n running_loss += loss.item()\n loss_history[m_lr].append(running_loss/num_train)\n\n\nSetup-2 Results: \n\nHere I'm NOT decaying the learning rate but every epoch I'm creating a new\nAdam optimizer with the same initial parameters.\nHere also results show similar behavior as Setup-1.\n\nBecause at every epoch a new Adam optimizer is created, so the calculated gradients\nfor each parameter should be lost, but it seems that this doesnot affect the \nnetwork learning. Can anyone please help on this?\n\nPlot-2:\n\nfor epoch in range(num_epochs):\n optimizer = torch.optim.Adam(lr=m_lr,amsgrad=True, ...........)\n\n running_loss = 0.0\n for i in range(num_train):\n train_input_tensor = .......... \n train_label_tensor = ..........\n optimizer.zero_grad()\n pred_label_tensor = model(train_input_tensor)\n loss = criterion(pred_label_tensor, train_label_tensor)\n loss.backward()\n optimizer.step()\n running_loss += loss.item()\n loss_history[m_lr].append(running_loss/num_train)\n\n\nSetup-3 Results: \n\nAs can be seen from the results in below plot, \nmy loss jumps every time I decay the learning rate. This is a weird behavior.\n\nIf it was happening due to the fact that I'm creating a new Adam \noptimizer every epoch then, it should have happened in Setup #1, #2 as well.\nAnd if it is happening due to the creation of a new Adam optimizer with a new \nlearning rate (alpha) every 25 epochs, then the results of Setup #4 below also \ndenies such correlation.\n\nPlot-3:\n\ndecay_rate = 0.25\nfor epoch in range(num_epochs):\n optimizer = torch.optim.Adam(lr=m_lr,amsgrad=True, ...........)\n\n if epoch % 25 == 0 and epoch != 0:\n lr *= decay_rate # decay the learning rate\n\n running_loss = 0.0\n for i in range(num_train):\n train_input_tensor = .......... \n train_label_tensor = ..........\n optimizer.zero_grad()\n pred_label_tensor = model(train_input_tensor)\n loss = criterion(pred_label_tensor, train_label_tensor)\n loss.backward()\n optimizer.step()\n running_loss += loss.item()\n loss_history[m_lr].append(running_loss/num_train)\n\n\nSetup-4 Results: \n\nIn this setup, I'm using Pytorch's learning-rate-decay scheduler (multiStepLR)\nwhich decays the learning rate every 25 epochs by 0.25.\nHere also, the loss jumps everytime the learning rate is decayed.\n\nAs suggested by @Dennis in the comments below, I tried with both ReLU and 1e-02 leakyReLU nonlinearities. But, the results seem to behave similar and loss first decreases, then increases and then saturates at a higher value than what I would achieve without learning rate decay.\nPlot-4 shows the results.\nPlot-4:\n\nscheduler = torch.optim.lr_scheduler.MultiStepLR(optimizer=optimizer, milestones=[25,50,75], gamma=0.25)\n\nscheduler = torch.optim.lr_scheduler.ExponentialLR(optimizer=optimizer, gamma=0.95)\nscheduler = ......... # defined above\noptimizer = torch.optim.Adam(lr=m_lr,amsgrad=True, ...........)\n\nfor epoch in range(num_epochs):\n\n scheduler.step()\n\n running_loss = 0.0\n for i in range(num_train):\n train_input_tensor = .......... \n train_label_tensor = ..........\n optimizer.zero_grad()\n pred_label_tensor = model(train_input_tensor)\n loss = criterion(pred_label_tensor, train_label_tensor)\n loss.backward()\n optimizer.step()\n running_loss += loss.item()\n loss_history[m_lr].append(running_loss/num_train)\n\n\nEDITS: \n\nAs suggested in the comments and reply below, I've made changes to my code and trained the model. I've added the code and plots for the same. \nI tried with various lr_scheduler in PyTorch (multiStepLR, ExponentialLR) and plots for the same are listed in Setup-4 as suggested by @Dennis in comments below.\nTrying with leakyReLU as suggested by @Dennis in comments.\n\nAny help.\nThanks\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I see no reason why decaying learning rates should create the kinds of jumps in losses that you are observing. It should \"slow down\" how quickly you \"move\", which in the case of a loss that otherwise consistently shrinks really should, at worst, just lead to a plateau in your losses (rather than those jumps).\nThe first thing I observe in your code is that you re-create the optimizer from scratch every epoch. I have not yet worked enough with PyTorch to tell for sure, but doesn't this just destroy the internal state / memory of the optimizer every time? I think you should just create the optimizer once, before the loop through the epochs. If this is indeed a bug in your code, it should also actually still be a bug in the case where you do not use learning rate decay... but maybe you simply get lucky there and don't experience the same negative effects of the bug.\nFor learning rate decay, I'd recommend using the official API for that, rather than a manual solution. In your particular case, you'll want to instantiate a StepLR scheduler, with:\n\noptimizer = the ADAM optimizer, which you probably should only instantiate once.\nstep_size = 25\ngamma = 0.25\n\nYou can then simply call scheduler.step() at the start of every epoch (or maybe at the end? the example in the API link calls it at the start of every epoch).\n\nIf, after the changes above, you still experience the issue, it would also be useful to run each of your experiments multiple times and plot average results (or plot lines for all experiments). Your experiments should theoretically be identical during the first 25 epochs, but we still see huge differences between the two figures even during those first 25 epochs in which no learning rate decay occurs (e.g., one figure starts at a loss of ~28K, the other starts at a loss of ~40K). This may simply be due to different random initializations, so it'd be good to average that nondeterminisim out of your plots.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can machine learning algorithms be used to differentiate between small differences in details between images? I was wondering if machine learning algorithms (CNNs?) can be used/trained to differentiate between small differences in details between images (such as slight differences in shades of red or other colours, or the presence of small objects between otherwise very similar images?)? And then classify images based on these differences? If this is a difficult endeavour with our current machine learning algorithms, how can it be solved? Would using more data (more images) help?\nI would also appreciate it if people could please provide references to research that has focused on this, if possible. \nI've only just begun learning machine learning, and this is something that I've been wondering from my research.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Attentive Recurrent Comparators (2017) by Pranav Shyam et al. is an interesting paper that helps to answer the question you're wondering, along with a blog post that helps to describe it in easier terms.\nThe way it's implemented is actually rather intuitive. If you have ever played a \"what is different\" game with two images usually what you'd do is look back and forth between the images to see what the difference is. The network that the researchers created does just that! It looks at one image and then remembers important features about that images and looks at the other image and goes back and forth.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a support vector machine? What is a support vector machine (SVM)? Is an SVM a kind of a neural network, meaning it has nodes and weights, etc.? What is it best used for?\nWhere I can find information about these?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I find the chapter on machine learning from Russell & Norvig is a pretty good place to start with SVMs. I think this is Chapter 18?\nOne way to understand an SVM is as a kind of neural network, but this is not usually an intuitive approach for a beginner (unless your NN knowledge is already quite good).\nA better way to understand SVMs is as consisting of three simple ideas rolled into one algorithm. Here's an attempt at a \"For Dummies\" answer though:\n\nMaximum Margin Classification. SVMs are usually used to find a pattern in a set of data. Often, the data allow an infinite set of possible patterns that are all equally descriptive. For example, maybe The relationship is \"Lives within 5 miles of a Coast -> Income High\". It's easy to imagine that this pattern is just as good as \"Lives within 5.0001 miles of a Coast -> Income High\" or \"Lives within 4.999 miles of a Coast -> Income High\". There might actually be a lot more play than that in the data (e.g. 3 miles might work out too). If all these are equally good, then the maximum margin idea says you should pick the one that's \"in the middle\" of the data. So maybe all values between 5.5 and 4.8 are equally good. In that case, we might pick 5.15 (in the middle). This example is super simplified. Real world data would have a lot more variables, and the idea of \"in the middle\" ends up being a little more complex, but this is the intuition. It turns out that finding the maximum margin pattern is easy when the patterns are linear. That is, when they can be represented by drawing straight lines through a plot of the dataset.\nProjection into higher dimensions. This one needs a bit of math to visualize. Consider a dataset consisting of a circular pattern (for instance, maybe the pattern is that higher incomes are found in the middle of the city). There is no linear relationship that captures this pattern. That is, you can't draw a straight line through the data, and say something meaningful about all the values on one side or the other. However, if you add a new feature to your data that is the square of the original coordinates, it's easy to find such a pattern. Basically, if you pre-compute \"circular\" functions of the original data, you can add them to the dataset, and then find a pattern that is a linear function of this new feature. This idea generalizes: if you compute a complex enough function of your original data, and then apply the maximum margin idea, you can learn any pattern you like. The problem is that it's slow: adding more features makes it take longer to find the patterns you want.\nThe Kernel Trick. The thing that made SVMs useful was the kernel trick: finding the maximum margin didn't depend on anything except the product of the coordinates of the various points. It turned out that this product could be computed first, and then run through certain functions to produce a problem that was identical to the one you'd get by first adding extra features and then doing the multiplication. However, computing the problem this way didn't require adding any new features! This made SVMs one of the first reliable, well understood, and fast methods for finding non-linear patterns in data. \n\nHope that provides a starting point. Consider reading Russell & Norvig as a next starting point, or Bishop if you want to go deeper. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the concept of channels in CNNs? I am trying to understand what channels mean in convolutional neural networks. When working with grayscale and colored images, I understand that the number of channels is set to 1 and 3 (in the first conv layer), respectively, where 3 corresponds to red, green, and blue.\nSay you have a colored image that is $200 \\times 200$ pixels. The standard is such that the input matrix is a $200 \\times 200$ matrix with 3 channels. The first convolutional layer would have a filter that is size $N \\times M \\times 3$, where $N,M < 200$ (I think they're usually set to 3 or 5).\nWould it be possible to structure the input data differently, such that the number of channels now becomes the width or height of the image? i.e., the number of channels would be 200, the input matrix would then be $200 \\times 3$ or $3 \\times 200$. What would be the advantage/disadvantage of this formulation versus the standard (# of channels = 3)? Obviously, this would limit your filter's spatial size, but dramatically increase it in the depth direction.\nI am really posing this question because I don't quite understand the concept of channels in CNNs.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nSay you have a colored image that is 200x200 pixels. The standard is such that the input matrix is a 200x200 matrix with 3 channels. The first convolutional layer would have a filter that is size $N\u00d7M\u00d73$, where $N,M<200$ (I think they're usually set to 3 or 5). \nWould it be possible to structure the input data differently, such that the number of channels now becomes the width or height of the image? i.e., the number of channels would be 200, the input matrix would then be 200x3 or 3x200. What would be the advantage/disadvantage of this formulation versus the standard (# of channels = 3)? Obviously, this would limit your filter's spatial size, but dramatically increase it in the depth direction. \n\nThe different dimensions (width, height, and number of channels) do have different meanings, the intuition behind them is different, and this is important. You could rearrange your data, but if you then plug it into an implementation of CNNs that expects data in the original format, it would likely perform poorly.\nThe important observation to make is that the intuition behind CNNs is that they encode the \"prior\" assumption or knowledge, the \"heuristic\", the \"rule of thumb\", of location invariance. The intuition is that, when looking at images, we often want our Neural Network to be able to consistently (in the same way) detect features (maybe low-level features such as edges, corners, or maybe high-level features such as complete faces) regardless of where they are. It should not matter whether a face is located in the top-left corner or the bottom-right corner of an image, detecting that it is there should still be performed in the same way (i.e. likely requires exactly the same combination of learned weights in our network). That is what we mean with location invariance.\nThat intution of location invariance is implemented by using \"filters\" or \"feature detectors\" that we \"slide\" along the entire image. These are the things you mentioned having dimensionality $N \\times M \\times 3$. The intuition of location invariance is implemented by taking the exact same filter, and re-applying it in different locations of the image.\nIf you change the order in which you present your data, you will break this property of location invariance. Instead, you will replace it with a rather strange property of... for example, \"width-colour\" invariance. You might get a filter that can detect the same type of feature regardless its $x$-coordinate in an image, and regarldess of the colour in which it was drawn, but the $y$-coordinate will suddenly become relevant; your filter may be able to detect edges of any colour in the bottom of an image, but fail to recognize the same edges in the top-side of an image. This is not an intuition that I would expect to work successfully in most image recognition tasks.\n\nNote that there may also be advantages in terms of computation time in having the data ordered in a certain way, depending on what calculations you're going to perform using that data afterwards (typically lots of matrix multiplications). It is best to have the data stored in RAM in such a way that the inner-most loops of algorithms using the data (matrix multiplication) access the data sequentially, in the same order that it is stored in. This is the most efficient way in which to access data from RAM, and will result in the fastest computations. You can generally safely expect that implementations in large frameworks like Tensorflow and PyTorch will already require you to supply data in whatever format is the most efficient by default.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What benefits can be got by applying Graph Convolutional Neural Network instead of ordinary CNN? What benefits can we got by applying Graph Convolutional Neural Network instead of ordinary CNN? I mean if we can solve a problem by CNN, what is the reason should we convert to Graph Convolutional Neural Network to solve it? Are there any examples i.e. papers can show by replacing ordinary CNN with Graph Convolutional Neural Network, an accuracy increasement or a quality improvement or a performance gain is achieved? Can anyone introduce some examples as image classification, image recognition especially in medical imaging, bioinfomatics or biomedical areas?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Generally speaking a graph CNN is applied to data represented by graphs, not images. \n\na graph is a collection of nodes and edges connecting them.\nan image is a 2D or 3D matrix, in which each element denotes a pixel in space\n\nIf your data are just images, or something similar (e.g. some fMRI data), you usually cannot benefit from graph CNN compared with usual CNN.\nSometimes, the class labels of your images may be organized in a graph-like (or tree-like) structure. In that case, you may have a chance to benefit from graph CNN.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the double sample problem in reinforcement learning? According to the SBEED: Convergent Reinforcement Learning with\nNonlinear Function Approximation for convergent reinforcement learning, the Smoothed Bellman operator is a way to dodge the double sample problem? Can someone explain to me what the double sample problem is and how SBEED solves it?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The double sampling problem is referenced in Chaper 11.5 Gradient Descent in the Bellman Error in Reinforcement Learning: An Introduction (2nd edition).\nFrom the book, this is the full gradient descent (as opposed to semi-gradient descent) update rule for weights of an estimator that should converge to a minimal distance from the Bellman error:\n\n$$w_{t+1} = w_t + \\alpha[\\mathbb{E}_b[\\rho_t[R_{t+1} + \\gamma\\hat{v}(S_{t+1},\\mathbf{w})] - \\hat{v}(S_{t},\\mathbf{w})][\\nabla\\hat{v}(S_{t},\\mathbf{w})- \\gamma\\mathbb{E}_b[\\rho_t\\nabla\\hat{v}(S_{t+1},\\mathbf{w})]]$$\n[...] But this is naive, because the equation above involves the next state, $S_{t+1}$, appearing in two\nexpectations that are multiplied together. To get an unbiased sample of the product,\ntwo independent samples of the next state are required, but during normal interaction\nwith an external environment only one is obtained. One expectation or the other can be\nsampled, but not both.\n\nBasically, unless you have an environment that you can routinely re-wind and re-sample to get two independent estimates (for $\\hat{v}(S_{t+1},\\mathbf{w})$ and $\\nabla\\hat{v}(S_{t+1},\\mathbf{w})$) then the update rule that naturally arises from gradient descent on the Bellman error does will work any better than other approaches, such as semi-gradient methods. If you can do this rewind process on every step, then it may be worth it because of the guarantees of convergence, even in off-policy with non-linear approximators.\nThe paper proposes a workaround for this issue, keeping the robust convergence guarantees, but dropping the need to collect two independent samples of the same estimate on each step.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are decision tree learning algorithms deterministic? Are decision tree learning algorithms deterministic? Given a fixed dataset, do they always produce a tree with the same structure? \nWhat about the random forest?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nAre decision tree learning algorithms deterministic? Given a fixed dataset, do they always produce a tree with the same structure?\n\nGenerally, yes. Most decision tree learners, like the common ID3 and C4.5/C5.0 algorithms, are deterministic. At each step, the learners consider all possible features that have not yet been used to split the data and find the splits that maximize some function (e.g. information gain). There is no randomness (or pseudo-randomness) in this process.\nThe exceptions to this would be if you used randomness to break ties (rather than, say, using the index of each feature, as is common), but this would be an unusual modification.\nWhat about the random forest?\nAs the name suggests, random forests do make use of randomness, or at least, pseudo-randomness. If we're only concerned about whether or not the algorithm is deterministic in the usual sense of the word (at least, within computer science), the answer is no.\nIf you start the same random forest learning algorithm, with the same datasets, at two different times (or, using two different seeds for your pseudorandom number generator), you will get two different forests. This is because the algorithm selects random subsets of the features and/or datapoints to learn on, and, if different seeds are used, the subsets will be different each time.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What causes ChatGPT to generate responses that refer to itself as a bot or LM? ChatGPT occasionally generates responses to prompts that refer to itself as a \"bot\" or \"language model.\"\nFor instance, when given a certain input (the first paragraph of this question) ChatGPT produces (in part) the output:\n\nIt is not appropriate for a language model like myself to provide a\nstance on the policies of a specific website or community.\n\nTo my understanding, ChatGPT is not a person that is conscious of its own existence and identity as a bot \u2014 it is a model trained on large quantities of undifferentiated text gathered from the Internet and largely reproduces the most common patterns given the context, which is why its responses seem very generic much of the time.\nPresumably very little of this data involved humans referring to themselves as language models or chatbots\u2014that is, something like \"a language model\" should very rarely have been followed by \"like myself.\"\nAs such, what causes ChatGPT to produce patterns referring to itself as a chatbot or language model? Which patterns in the training data or elements of the model structure (or even hard-coding?) cause it to generate responses like this?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I don't work for openai, so I have no insight into exactly what works behind the scenes to make ChatGPT exhibit this behavior. However, in my opinion this is pretty clearly an example of prompt engineering. That is, they tell it that it is an AI in it's prompt.\nWe do have access to their underlying model: text-davinci-003. I can demonstrate using that model in their playground. If I just paste in the first paragraph and submit it into the raw algorithm, it dutifully tries to answer:\n\nWhat is Politics.SE's stance on answers from ChatGPT? There is a\ndebate on Meta Stack Exchange on what the policy on them should be and\nI was wondering if we should have one as well. I am asking this for\nadvice on what we should be doing when we run across answers that we\nsuspect to be from ChatGPT or some other bot.\nWe have not yet established an official policy on answers from ChatGPT\nor any other bot. We would encourage users to flag these answers so\nthey can be evaluated by moderators. If an answer is found to be\ngenerated by a bot, it will be removed. We also recommend that users\nadd a comment to the post explaining why it was removed.\n\nHowever, if I prompt it first it will demure:\n\nYou are an AI bot that has been trained on a large amount of data, but\nyou have no opinions of your own. You cannot speculate or predict what\nother entities will do in the future. Below is a question:\nWhat is Politics.SE's stance on answers from ChatGPT? There is a\ndebate on Meta Stack Exchange on what the policy on them should be and\nI was wondering if we should have one as well. I am asking this for\nadvice on what we should be doing when we run across answers that we\nsuspect to be from ChatGPT or some other bot.\nI cannot provide any advice or opinion on this matter, as I am an AI\nbot and do not have any opinions of my own. However, I can provide a\nlink to the discussion on Meta Stack Exchange which can provide more\ninformation about the debate:\nhttps://meta.stackexchange.com/questions/360005/should-we-allow-answers-generated-by-chatgpt-on-politics-se\n\nAs an aside, it get's bonus points for providing a completely irrelevant link :)\nAdding some more down here in an attempt to wrap this all up and give a complete answer. The really simplified way to explain how these models work is this: They break hundreds of thousands of snippets of text up into \"tokens\" - but lets just call them words for simplicity. They feed these tokens into an absolutely ginormous neural net, which has the effect of learning what words are most likely to appear near one another. The number of interactions is in the billions (or even trillions), so this apparent simplicity grows beyond our comprehension very quickly. But at the end of the day, all the AI is doing is spewing out words it thinks are likely to appear around the words you prompt it with. If you prompt it with \"you have no opinions\", then the likelihood of opinions appearing around that text is smaller than the likelihood of statements about not having opinions.\nIn short, the concept is really simple - it's just playing with probability. In practice, the behavior is quite sophisticated because there are an unimaginable number of individual interactions being calculated. It's kind of like how learning all about cell biology leaves you completely unprepared to explain how an entire animal functions - let alone, say, a colony of ants. And yet, the relatively simple cell is in fact driving all of it.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can Q-learning be used in a POMDP? Can Q-learning (and SARSA) be directly used in a Partially Observable Markov Decision Process (POMDP)? If not, why not? My intuition is that the policies learned will be terrible because of partial observability. Are there ways to transform these algorithms so that they can be easily used in a POMDP?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The usual (as presented in Reinforcement Learning: An Introduction) $Q$-learning and SARSA algorithms use (and update) a function of a state $s$ and action $a$, $Q(s, a)$. These algorithms assume that the current state $s$ is known. However, in POMDP, at each time step, the agent does not know the current state, but it maintains a \"belief\" (which, mathematically, is represented as a probability distribution) in what the current state might be, so it cannot maintain (an approximation of) the function $Q(s, a)$. Hence, the usual Q-learning and SARSA algorithms shouldn't be directly applicable to a POMDP. \nHowever, $Q$-learning is often used in the contexts where observations emitted by the environment (or transformations of the raw observations) are used to build the current state (which is assumed to be Markov, even if it is not). For example, in the original DQN, the action taken at the current step and the raw observation and the reward emitted by the environment (after this action is taken) are combined to produce the current (Markov) state. It might not be the case that the way they combine the action, the reward and the observation is sufficient to fully describe the current state (which might not even be Markov).\nIn this report, Deep Reinforcement Learning with POMDPs, the author attempts to use Q-learning in a POMDP setting. He suggests to represent a function, either $Q(b, a)$ or $Q(h, a)$, where $b$ is the \"belief\" over the states and $h$ the history of previously executed actions, using neural networks. So, the resulting parameterized functions would be denoted by $Q(b, a; \\theta)$ or $Q(h, a; \\theta)$, where $\\theta$ is a vector representing the parameters of the corresponding neural network. Essentially, the author uses a DQN (with an experience replay buffer and target network), but the results are not great: $Q$ values converge, but policies do not and they are not robust (in that they are sensitive to small perturbations).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to transform inputs and extract useful outputs in a Neural Network? So I've been trying to understand neural networks ever since I came across Adam Geitgey's blog on machine learning. I've read as much as I can on the subject (that I can grasp) and believe I understand all the broad concepts and some of the workings (despite being very weak in maths), neurons, synapses, weights, cost functions, backpropagation etc. However, I've not been able to figure out how to translate real world problems into a neural network solution. \nCase in point, Adam Geitgey gives as an example usage, a house price prediction system where given a data set containing No. of bedrooms, Sq. feet, Neighborhood and Sale price you can train a neural network to be able to predict the price of a house. However he stops short of actually implementing a possible solution in code. The closest he gets, by way of an example, is basic a function demonstrating how you'd implement weights:\ndef estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood):\n price = 0\n\n # a little pinch of this\n price += num_of_bedrooms * 1.0\n\n # and a big pinch of that\n price += sqft * 1.0\n\n # maybe a handful of this\n price += neighborhood * 1.0\n\n # and finally, just a little extra salt for good measure\n price += 1.0\n\n return price \n\nOther resources seem to focus more heavily on the maths and the only basic code example I could find that I understand (i.e. that isn't some all singing, all dancing image classification codebase) is an implementation that trains a neural network to be an XOR gate that deals only in 1's and 0's. \nSo there's a gap in my knowledge that I just can't seem to bridge. If we return to the house price prediction problem, hows does one make the data suitable for feeding into a neural network? For example:\n\nNo. of bedrooms: 3\nSq. feet: 2000\nNeighborhood: Normaltown\nSale price: $250,000\n\nCan you just feed 3 and 2000 directly into the neural network because they are numbers? Or do you need to transform them into something else? Similarly what about the Normaltown value, that's a string, how do you go about translating it into a value a neural network can understand? Can you just pick a number, like an index, so long as it's consistent throughout the data?\nMost of the neural network examples I've seen the numbers passing between layers are either 0 to 1 or -1 to 1. So at the end of processing, how do you transform the output value to something usable like $185,000?\nI know the house price prediction example probably isn't a particularly useful problem given that it's been massively oversimplified to just three data points. But I just feel that if I could get over this hurdle and write an extremely basic app that trains using pseudo real-life data and spits out a pseudo real-life answer than I'll have broken the back of it and be able to kick on and delve further into machine learning.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is a good question which I wrestled with myself when first trying to code an ANN. \nBelow is a good general-purpose solution, and it's the one I implemented in my code for trying to predict well-behaved numerical data. If your data is not well-behaved (i.e. fraught with outliers) then you may need to do more work normalizing the inputs and outputs. Some of the more advanced methods are described here.\nNote: I will assume that you are using f(x) = tanh(x) as your activation function. If you aren't, you should still be able to reason through how to normalize your data after reading this.\nHow to prepare the input data:\nThe basic idea is that you want a significant variation in each input parameter to be reflected by a significant variation in the activation of the neuron those inputs are being fed into. By looking at a plot of the derivative of the tanh(x) actiavtion function, you'll see that the region of significant slope is within a distance of one or two from the origin. This means that whether the input to the activation function is 2000 or 3000 (values of x for which the derivative is negligibly small), the output of the activation will be almost identical...so your neuron's state will be independent of the difference between 2000 and 3000, and your network will never produce any predictive power from values in that range. \nSo if you want to input the square footage of the house into a neuron, you need to normalize the square footage so that the network can tell the difference between 2000 and 3000. One way to do this so that all of the significant variations in your data are 'noticed' by the neuron is to z-score-normalize the inputs. \n\nGather all of your square footage values (from your training set) and calculate the mean and standard deviation. Store the mean and standard deviation---you'll need this information to normalize new square footage values when testing. \nNormalize the vector of square footage values by subtracting the mean and then dividing the result by the standard deviation (all operations element-wise of course). Subtracting the mean centers your data at the origin, and dividing by the standard deviation makes sure most of it is between -1 and 1, where the neuron's output is most sensitive to its input. This is called z-score normalization because each input value is replaced by its z-score.\nDo the above for each input variable.\n\nNow, when you put each input value through a neuron, the output of the neuron is an activation between -1 and 1 (look at the image of tanh(x)). Since this is already in the 'sensitive' range of the activation function, you don't need to worry about altering the output of the input-layer neurons before sending them to the first hidden layer. Just give any hidden layer neurons the outputs of the previous layer directly---they will be able to handle them just fine. \nWhen you reach the last layer (the output neuron(s)), what you get is again another activation between -1 and 1. You have to convert this back into a value for the house in question, whether that value will be used as a prediction in a test set or to calculate error during training. However you do this, you just have to be consistent and use the same de-normalization procedure in training and testing. One way to think about it is: when the output neuron(s) returns 1, that means the network is returning the maximum possible house value as its prediction. What should the highest value the network can estimate be? The right approach here simply depends on your application. This is what I did:\n\nCalculate the mean of [the/each] output variable and store it.\nCalculate the maximum deviation of the output variable from the mean. \nPython: MaxDev = max([abs(DataPoint-numpy.mean(TrainingData)) for DataPoint in TrainingData])\nWhen the network returns output(s) between -1 and 1, multiply the output by MaxDev and add it to the mean.\n\nTwo basic quick checks you can do to see if your normalization-renormalization scheme is suitable (these are necessary, but perhaps not sufficient conditions):\n\nIf all the input values are average (e.g. average no. of bedrooms, average sq.feet, etc), is the network's output equal to the average of the output variable (e.g. house value) as well? (It should be.)\nIf all the input values are unusually high/low, is the network's output unusually high/low as well? (This only works if all the inputs are positively related to the output...if some of them are inversely related related, you will have to think a bit more).\n\nObserve that the scheme presented here satisfies these two conditions.\nNotice that this scheme would allow your network to only predict house values inside the range of house values in your training data set. Depending on the application, this behavior can be desirable or undesirable.\nFor example: you may want to make it impossible for your network to predict negative house values. Think about how you would do this. De-normalize the output so that -1 is mapped to 0.\nIf you want to set no limit on the values your network can predict, then you can run the network's output through a function that maps the [-1,1] range to all real numbers...like arctanh(x)! As long as you do this during training your network will adjust its weights to accommodate this.\nI hope this was helpful. Let me know if you have further questions. My ANN module is in Python, by the way, so I might have language-specific advice.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the necessary components to make an AI agent capable of self-programming? An AI agent is often thought of having \"sensors\", \"a memory\", \"machine learning processors\" and \"reaction\" components. However, a machine with these does not necessarily become a self-programming AI agent. Beyond the parts mentioned above, is there any other elements or details necessary to make a machine capable of being a self-programming AI agent?\nFor example, a paper from 2011 declared that solving the optimization problem of maximizing the intelligence is a must-have feature for the self-programming process, as quoted below:\n\nA system is said to carry out an instance of self-programming when it undergoes learning regarding some element of its \"cognitive infrastructure\", where the latter is defined as the fuzzy set of \"intelligence-critical\" features of the system; and the intelligence-criticality of a system feature is defined as its \"feature quality,\" considered from the perspective of solving the optimization problem of maximizing the intelligence of a multi-feature system.\n\nHowever, this description of \"optimization of intelligence\" is vague. Can anyone give a clear definition or better summary for the necessary components for self-programming agents?\nThis question is from the 2014 closed beta, with the asker having a UID of 23.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "At the highest level, all it needs is for the various systems already discussed to incorporate code objects. If it can interpret its source code / model architecture from the formatted text objects underpinning them, can 'understand' them in terms of having a useful ML model, and alter the code with its reaction, then it can self-program. \nThat is, the basic loop behind a recursively improving intelligence is simple. It examines itself, writes a new version, and then that new version examines itself and writes a new version, and so on.\nThe difficult component comes at lower levels. We don't need to invent a new concept like 'sensor,' what we need to do is build very, very sophisticated sensors that are equal to the task of understanding code well enough to detect and write improvements.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Should I use anthropomorphic language when discussing AI? The English Language is not well-suited to talking about artificial intelligence, which makes it difficult for humans to communicate to each other about what an AI is actually \"doing\". Thus, it may make more sense to use \"human-like\" terms to describe the actions of machinery, even when the internal properties of the machinery do not resemble the internal properties of humanity.\nAnthropomorphic language had been used a lot in technology (see the Hacker's Dictionary definition of anthropomorphization, which attempts to justify computer programmers' use of anthromporhic terms when describing technology), but as AI continues to advance, it may be useful to consider the tradeoffs of using anthropomorphic language in communicating to both technical audiences and non-technical audiences. How can we get a good handle on AI if we can't even describe what we're doing?\nSuppose I want to develop an algorithm that display a list of related articles. There are two ways by which I can explain how the algorithm works to a layman:\n\nVery Anthropomorphic - The algorithm reads all the articles on a website, and display the articles that are very similar to the article you are looking at.\nVery Technical - The algorithm converts each article into a \"bag-of-words\", and then compare the \"bag-of-words\" of each article to determine what articles share the most common words. The articles that share the most words in the bags are the ones that are displayed to the user.\n\nObviously, #2 may be more \"technically correct\" than #1. By detailing the implementation of the algorithm, it makes it easier for someone to understand how to fix the algorithm if it produces an output that we disagree with heavily.\nBut #1 is more readable, elegant, and easier to understand. It provides a general sense of what the algorithm is doing, instead of how the algorithm is doing it. By abstracting away the implementation details of how a computer \"reads\" the article, we can then focus on using the algorithm in real-world scenarios.\nShould I, therefore, prefer to use the anthropomorphic language as emphasized by Statement #1? If not, why not?\nP.S.: If the answer depends on the audience that I am speaking to (a non-technical audience might prefer #1, while a technical audience may prefer #2), then let me know that as well.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "If clarity is your goal, you should attempt to avoid anthropomorphic language - doing so runs a danger of even misleading yourself about the capabilities of the program.\nThis is a pernicious trap in AI research, with numerous cases where even experienced researchers have ascribed a greater degree of understanding to a program than is actually merited.\nDouglas Hofstadter describes the issue at some length in a chapter entitled \"The Ineradicable Eliza Effect and Its Dangers\" and there is also a famous paper by Drew McDermot, entitled \"Artifical Intelligence meets natural stupidity\".\nHence, in general one should make particular effort to avoid anthropomorphism in AI. However, when speaking to a non-technical audience, 'soundbite' descriptions are (as in any complex discipline) acceptable provided you let the audience know that they are getting the simplified version.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does AlphaZero use Q-Learning? I was reading the AlphaZero paper Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm, and it seems they don't mention Q-Learning anywhere.\nSo does AZ use Q-Learning on the results of self-play or just a Supervised Learning?\nIf it's a Supervised Learning, then why is it said that AZ uses Reinforcement Learning? Is \"reinforcement\" part primarily a result of using Monte-Carlo Tree Search?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Note: you mentioned in the comments that you are reading the old, pre-print version of the paper describing AlphaZero on arXiv. My answer will be for the \"official\", peer-reviewed, more recent publication in Science (which nbro linked to in his comment). I'm not only focusing on the official version of the paper just because it is official, but also because I found it to be much better / more complete, and I would recommend reading it instead of the preprint if you are able to (I understand it's behind a paywall so it may be difficult for some to get access). The answer to this specific question would probably be identical for the arXiv version anyway.\n\nNo, AlphaZero does not use $Q$-learning.\nThe neural network in AlphaZero is trained to minimise the following loss function:\n$$(z - \\nu)^2 - \\pi^{\\top} \\log \\mathbf{p} + c \\| \\theta \\|^2,$$\nwhere:\n\n$z \\in \\{-1, 0, +1\\}$ is the real outcome observed in a game of self-play.\n$\\nu$ is a predicted outcome / value.\n$\\pi$ is a distribution over actions derived from the visit counts of MCTS.\n$\\mathbf{p}$ is the distribution over actions output by the network / the policy.\n$c \\| \\theta \\|^2$ is a regularisation term, not really interesting for this question/answer.\n\nIn this loss function, the term $(z - \\nu)^2$ is exactly what we would have if we were performing plain Monte-Carlo updates, based on Monte-Carlo returns, in a traditional Reinforcemet Learning setting (with function approximation). Note that there is no \"bootstrapping\", no combination of a single-step observed reward plus predicted future rewards, as we would have in $Q$-learning. We play out all the way until the end of a game (an \"episode\"), and use the final outcome $z$ for our updates to our value function. That's what makes this Monte-Carlo learning, rather than $Q$-learning.\nAs for the $- \\pi^{\\top} \\log \\mathbf{p}$ term, this is definitely not $Q$-learning (we're directly learning a policy in this part, not a value function).\n\nIf it's a Supervised Learning, then why is it said that AZ uses Reinforcement Learning? Is \"reinforcement\" part primarily a result of using Monte-Carlo Tree Search?\n\nThe policy learning looks very similar to Supervised Learning; indeed it's the cross-entropy loss which is frequently used in Supervised Learning (classification) settings. I'd still argue it is Reinforcement Learning, because the update targets are completely determined by self-play, by the agent's own experience. There are no training targets / labels that are provided externally (i.e. no learning from a database of human expert games, as was done in 2016 in AlphaGo).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the cost function of a transformer? The paper Attention Is All You Need describes the transformer architecture that has an encoder and a decoder.\nHowever, I wasn't clear on what the cost function to minimize is for such an architecture.\nConsider a translation task, for example, where give an English sentence $x_{english} = [x_0, x_1, x_2, \\dots, x_m]$, the transformer decodes the sentence into a French sentence $x_{french}' = [x_0', x_1', \\dots, x_n']$. Let's say the true label is $y_{french} = [y_0, y_1, \\dots, y_p]$.\nWhat is the object function of the transformer? Is it the MSE between $x_{french}'$ and $y_{french}$? And does it have any weight regularization terms?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I took a look at the Tensor2Tensor's source code implementation, and it seems like the loss function is the cross-entropy between the predicted probability matrix $\\|\\text{sentence length}\\| \\times \\|\\text{vocab}\\|$ (right before taking the argmax to find the token to output), and the $\\|\\text{sentence length}\\|$-length vector of token IDs as the true label.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the criteria for a system to be considered intelligent? For example, could you provide reasons why a sundial is not \"intelligent\"?\nA sundial senses its environment and acts rationally. It outputs the time. It also stores percepts. (The numbers the engineer wrote on it.)\nWhat properties of a self driving car would make it \"intelligent\"? \nWhere is the line between non intelligent matter and an intelligent system?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Typically, I think of intelligence in terms of the control of perception. [1] A related, but different, definition of intelligence is the (at least partial) restriction of possible future states. For example, an intelligent Chess player is one whose future rarely includes 'lost at chess to a weaker opponent' states; they're able to make changes that move those states to 'won at chess' states.\nThese are both broad and continuous definitions of intelligence, where we can talk about differences of degree. A sundial doesn't exert any control over its environment; it passively casts a shadow, and so doesn't have intelligence worth speaking of. A thermostat attached to a heating or cooling system, on the other hand, does exert control over its environment, trying to keep the temperature of its sensor within some preferred range. So a thermostat does have intelligence, but not very much.\nSelf-driving cars obviously fit those definitions of intelligence.\n\n[1] Control is meant in the context of control theory, a branch of engineering that deals with dynamical systems that perceive some fact about the external world and also have a way by which they change that fact. When perception is explicitly contrasted to observations, it typically refers to an abstract feature of observations (you observe the intensity of light from individual pixels, you perceive the apple that they represent) but here I mean it as a superset that includes observation. The thermostat is a dynamical system that perceives temperature and acts to exert pressure on the temperature it perceives.\n(There's a philosophical point here that the thermostat cares directly about its sensor reading, not whatever the temperature \"actually\" is. I think that's not something that should be included in intelligence, and should deserve a name of its own, because understanding the difference between perception and reality and seeking to make sure one's perceptions are accurate to reality is another thing that seems partially independent of intelligence.)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there an AI model for generating sarcastic sentences? I am currently working on an Android AI app. \nI am aware of AI models to generate random sentences. However, is there an AI model for generating sarcastic sentences?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You could also build a database of sarcastic sentences, especially from, for example historic plays. And then train your software to recognize patterns of those sentences.\nE.g. grammatical constructions/order, length (or circomstances building up to the sarcasm). \nAnd use that database as starting point, with feedback to learn, or you could use the above method to improve your effective output.\nAnother approach would be to use a similar but reverse approach; study those databases and build an equivalent output based on the coherence, and then extrapolate the output-generation procedure. (In combination with other methods)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does the symbol $\\mathbb E$ mean in these equations? I came across some papers that use $\\mathbb E$ in equations, in particular, this paper: https://arxiv.org/pdf/1511.06581.pdf. Here is some equations from the paper that uses it: \n$Q^\\pi \\left(s,a \\right) = \\mathbb E \\left[R_t|s_t = s, a_t = a, \\pi \\right]$ ,\n$V^\\pi \\left(s \\right) = \\mathbb E_{a\\backsim\\pi\\left(s \\right)} \\left[Q^\\pi \\left(s, a\\right) \\right]$ ,\n$Q^\\pi \\left(s, a \\right) = \\mathbb E_{s'} \\left[r + \\gamma\\mathbb E_{a'\\backsim\\pi \\left(s' \\right)} \\left[Q^\\pi \\left(s', a' \\right) \\right] | s,a,\\pi \\right]$\n$\\nabla_{\\theta_i}L_i\\left(\\theta_i \\right) = \\mathbb E_{s, a, r, s'} \\left[\\left(y_i^{DQN} - Q \\left(s, a; \\theta_i \\right) \\right) \\nabla_{\\theta_i} Q\\left(s, a, \\theta_i \\right) \\right]$\nCould someone explain to me what is the purpose of $\\mathbb E$?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "That's the Expected Value operator. Intuitively, it gives you the value that you would \"expect\" (\"on average\") the expression after it (often in square or other brackets) to have. Typically that expression involves some random variables, which means that there may be a wide range of different values the expression may take in any concrete, single event. Taking the expectation basically means that you \"average\" over all the values the expression could potentially take, appropriately weighted by the probabilities with which certain events occur.\nYou'll often find assumptions under which the expectation is taken after a vertical line ($\\mid$) inside the brackets, and/or in the subscript to the right of the $\\mathbb{E}$ symbol. Sometimes, some assumptions may also be left implicit.\n\nFor example:\n$$\\mathbb{E} \\left[ R_t \\mid s_t = s, a_t = a, \\pi \\right]$$\nmay be read in english as \"the expected value of the discounted returns from time $t$ onwards ($R_t$), given that the state at time $t$ is $s$ ($s_t = s$), given that our action at time $t$ is $a$ ($a_t = a$), given that we continue behaving according to policy $\\pi$ after time $t$\".\nI would say that, in this case, the expected value also relies on the transition dynamics of the Markov decision process (i.e. the probabilities with which we transition between states, given our actions). This is left implicit.\n\nSecond example:\n$$V^{\\pi}(s) = \\mathbb{E}_{a \\sim \\pi(s)} \\left[ Q^{\\pi}(s, a) \\right]$$\nmay be read as \"$V^{\\pi}(s)$ is equal to the expected value of $Q^{\\pi}(s, a)$, under the assumption that $a$ is sampled according to $\\pi(s)$\". \nIn theory, something like this could be computed by enumerating over all possible $a$, computing $Q^{\\pi}(s, a)$ for every such $a$, and multiplying it by the probability that $\\pi(s)$ assigns to $a$. In practice, you could also approximate it by running a large number of experiments in which you sample $a$ from $\\pi(s)$, and then evaluate a single concrete case of $Q^{\\pi}(s, a)$, and average over all the evaluations.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What's the term for death by dissolving in AI? What's the term (if such exists) for merging with AI (e.g. via neural lace) and becoming so diluted (e.g. 1:10000) that it effectively results in a death of the original self?\nIt's not quite \"digital ascension\", because that way it would still be you. What I'm thinking is, that the resulting AI with 1 part in 10000 being you, is not you anymore. The AI might have some of your values or memories or whatever, but it's not you, and you don't exist separately from it to be called you. Basically - you as you are dead; you died by dissolving in AI.\nI would like to read up on this subject, but can't find anything.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I find the concept of the a Turing machine useful. In one dimension, everything is a string. All of the parts that are \"not you\" are merely a substrate, a medium for the program your_mind runs on top of. The you, your identity, the \"metaphysical\" component we think of as the mind, is a result of running the algorithm that is your_mind on the bioware of your body, or, the hardware (technically, \"wetware\".) So what we're really talking about is the software, and in that light I might use: \n\nTranslation\n\nbecause the software is being translated to execute in a new environment, or\n\nMigration\n\nas in moving software from one system to another.\nPhilip Dick wrote a philosophical narrative, not technically sci-fi, called The Transmigration of Timothy Archer which is about identity moving between bodies. In a rare departure from his usual work about AI and the effects of a technological society on the human spirit, this book looks at the question of identity in the context of the soul, which opens up all kinds of philosophical questions surrounding the type of technology we're speculating on, particularly in relation to the self. \nI value artistic insight, and Phillip K. is considered quite prescient, so perhaps\n\nTransmigration\n\nis most appropriate, as it carries both metaphysical and information technology meanings.\n\nRe death by dissolution, it's worthwhile to look at the etymology of dissolve: \n\nlate 14c. (transitive and intransitive) \"to break up\" (of material substances), from Latin dissolvere \"to loosen up, break apart,\" from dis- \"apart\" (see dis-) + solvere \"to loosen, untie,\" from PIE *se-lu-, from reflexive pronoun *s(w)e- (see idiom) + root *leu- \"to loosen, divide, cut apart.\" Meaning \"to disband\" (an assembly) is early 15c. Related: Dissolved; dissolving.\n\nI think you're on the right track with dilution, certainly per the modern usage, but it may be possible to get more precise.\nIt's not about breaking up, or washing away (except metaphorically); rather, it's about minimization as in the diminishment of the original software kernel (the self) in relation to an expanding algorithm.\n\nearly 15c., from merger of two obsolete verbs, diminue and minish. Diminue is from Old French diminuer \"make small,\" from Latin diminuere \"break into small pieces,\" variant of deminuere \"lessen, diminish,\" from de- \"completely\" + minuere \"make small\" (from PIE root *mei- (2) \"small\").\n\nThe Old French diminuer is apt, as is the Latin deminuere and deminuo, which also carries a meaning of \"civil death\" and \"abatement\". Abatement carries a meaning of mitigation, which can be defined fundamentally as \"lessening of effect,\" in this case of the kernel of the original self in relation to the new aggregate.\nIt may be useful to think of it as a ratio 1/\u2135, with the self as the 1. Important to note the ratio is not literal--each number represent an aggregation of functions we call programs. \nThat's how I'd think of it mathematically, but metaphysically, Nat nails it by referencing Jung and the death of the ego.\nEgo comes from the Latin noun for the self (I, me) which can also be plural (we, us). It's also fun to note that the Latin verb of being is sum, because in English, sum has a mathematical meaning of an aggregate considered as a whole. \nBecause we're talking about what it means to be a person, but we also want to connote a function (a process of relative minimization) I am thinking:\n\nDepersonalization\n\n\n(noun) the action of divesting someone or something of human characteristics or individuality.SOURCE: Google\n\nThe fun part is that there's a legal definition of person:\n\nIn legal use, \"corporate body or corporation having legal rights,\" 15c., short for person aggregate (c. 1400), person corporate (mid-15c.)\n\nWhich I think applies (loosely) to the aggregation of function that comprises the program we call the self, and the greater aggregation of functions that form a new self. \nBecause here we're talking about the loss of the original individual, depersonalization as opposed to repersonalization as a corporate entity. \nAlternately, I might propose:\n\nDeindividualization \n\nwith the definition \"a loss in individual identity within a group\" (also known as deindividuation).\n(Charles Stross wrote about this in Accellerando, where a character chooses to be subsumed by a group intelligence as the only means of escaping a swarm of autonomous lawsuits;) \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What happens when I mix activation functions? There are several activation functions, such as ReLU, sigmoid or $\\tanh$. What happens when I mix activation functions?\nI recently found that Google has developed Swish activation function which is (x*sigmoid). By altering activation function can it increase accuracy on small neural network problem such as XOR problem?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The general answer to the behavior of combining common activation functions is that the laws of calculus must be applied, specifically differential calculus, the results must be obtained through experiment to be sure of the qualities of the assembled function, and the additional complexity is likely to increase computation time. The exception to such increase will be when the computational burden of the combination is small compared to the convergence advantages the combination provides.\nThis appears to be true of Swish, the name given to the activation function defined as\n$$f(x) = x \\, \\mathbb{S}(\\beta x) \\; \\text{,}$$\nwhere $f()$ is the Swish activation function and $\\mathbb{S}$ is the sigmoid function. Note that Swish is not strictly a combination of activation functions. It is formed through the addition of a hyper-parameter $\\beta$ inside the sigmoid function and a multiplication of the input to the sigmoid function result.\nIt does not appear to be developed by Google. The originally anonymously submitted paper (for double blind review as a ICLR 2018 paper), Searching for Activation Functions, was authored by Prajit Ramachandran, Barret Zoph, and Quoc V. Le around 2017. This is their claim.\n\nOur experiments show that the best discovered activation function, ... Swish, ... tends to work better than ReLU on deeper models across a number of challenging datasets.\n\nAny change in activation function to any one layer will, except in the astronomically rare case, impact accuracy, reliability, and computational efficiency. Whether the change is significant cannot be generalized. That's why new ideas are tested against data sets traditionally used to gauge usefulness1.\nCombining activation functions to form new activation functions is not common. For instance, AlexNet does not combine them.2. It is, however, very common to use different activation functions in different layers of a single, effective network design.\n\nFootnotes\n[1] Whether these traditions create a bias is another question. Those who follow the theory of use case analysis pioneered by Swedish computer scientist Ivar Hjalmar Jacobson or 6 Sigma ideas would say that these tests are unit test, not functional tests against real world use cases, and they have a point.\n[2] To correct any misconceptions that may arise from another answer, AlexNet, the name given to the approach outlined in ImageNet Classification with Deep Convolutional Neural Networks (2012) by Alex Krizhevsky, Ilya Sutskever, and Geoffrey E. Hinton from the University of Toronto, does not involve combining activation functions to form new ones. They write this.\n\nThe output of the last fully-connected layer is fed to a 1000-way softmax which produces a distribution over the 1000 class labels.\n...\nThe ReLU non-linearity is applied to the output of every convolutional and fully-connected layer. The internal layers are pure ReLU and the output layer is Softmax.\n\nThere are also convolution kernels and pooling layers in the AlexNet approach's series of layers used by them, and the design has entered common use since their winning of the ImageNet competition in 2012. Other approaches have won subsequent competitions.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How big artificial neural networks can we run now if our total energy budget for computation is equivalent to the human brain energy budget? How big artificial neural networks can we run now (either with full train-backprop cycle or just evaluating network outputs) if our total energy budget for computation is equivalent to the human brain energy budget (12.6 watts)?\nLet assume one cycle per second, which seems to roughly match the firing rate of biological neurons.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "126 million artificial neurons at 12.6 Watts, with IBM's True North\nBack in 2014, IBM's True North chip was pushing 1 million neurons at less than 100mW.\nSo that's roughly 126 million artificial neurons at 12.6 Watts.\nA mouse has 70 million neurons.\nIBM believes they can build a human-brain scale True North mainframe at a \"mere\" 4kW.\nOnce 3D transistors come to market, I think we'll catch up to animal brain efficiency pretty fast.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between a stationary and a non-stationary policy? In reinforcement learning, there are deterministic and non-deterministic (or stochastic) policies, but there are also stationary and non-stationary policies. \nWhat is the difference between a stationary and a non-stationary policy? How do you formalize both? Which problems (or environments) require a stationary policy as opposed to a non-stationary one (and vice-versa)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A stationary policy, $\\pi_t$, is a policy that does not change over time, that is, $\\pi_t = \\pi, \\forall t \\geq 0$, where $\\pi$ can either be a function, $\\pi: S \\rightarrow A$ (a deterministic policy), or a conditional density, $\\pi(A \\mid S)$ (a stochastic policy). A non-stationary policy is a policy that is not stationary. More precisely, $\\pi_i$ may not be equal to $\\pi_j$, for $i \\neq j \\geq 0$, where $i$ and $j$ are thus two different time steps.\nThere are problems where a stationary optimal policy is guaranteed to exist. For example, in the case of a stochastic (there is a probability density that models the dynamics of the environment, that is, the transition function and the reward function) and discrete-time Markov decision process (MDP) with finite numbers of states and actions, and bounded rewards, where the objective is the long-run average reward, a stationary optimal policy exists. The proof of this fact is in the book Markov Decision Processes: Discrete Stochastic Dynamic Programming (1994), by Martin L. Puterman, which apparently is not freely available on the web.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the different approaches used in Machine Learning? There seem to be so many sub-fields, so I'm interested in getting a better understanding of the approaches.\nI'm looking for information on a single framework per answer, in order to allow for granularity without the overall answer getting too long. For instance; Deep Learning Neural Networks would be a single answer.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Things in italics should give you enough googleable terms to start a deeper dive :P.\nThere are 3 main branches of statistical ML.\n\nSupervised Learning\nThis approach is taken when a problem can be phrased as associating some $X$ with some $Y$. For example, classifying a picture of a cat ($X$) with the label \u201cCat\u201d ($Y$). Training in supervised learning usually means presenting some $X$, having an agent predict the label, comparing the prediction with the answer to get an error metric, and finally using the error to update the agent to make better predictions on future $X$s. MNIST is a great example of a classification domain.\n1.1 Supervised learning also works with regression when we want to learn an associated number instead of a label, such as the risk of heart disease given years of smoking and weight.\n\nUnsupervised Learning\nThis type of learning is used when we want to draw inferences from a dataset without labeled responses. It can be used to find hidden patterns or grouping in data.\n\nReinforcement Learning\nThe $X$s and $Y$s in supervised learning are i.i.d., meaning that they don\u2019t relate to the previous $X$ that a model has previously observed. However, there are many problems where the most recent $X$, $X$ at time $t$ ($X_t$), is very important to figuring out what $Y$ to predict ($Y_{t+1}$) for the next $X$ ($X_{t+1}$). The field of reinforcement learning (RL) builds on this notion by framing observations as data that is generated by an agent interacting with an environment. Specifically, the field of RL poses the problem of finding a behaviour (a policy) to select actions such that an agent using the policy can maximize a special signal called the reward from the environment. The agent starts in a state of the world ($S_t$) at time $t$ and takes some action ($A_t$) which puts it in a new state ($S_{t+1}$) and gives it a reward ($R_{t+1}$).\n\n\nNeural networks are a technique for finding features (some kinda notable differences) in data. They can be used in all of the above learning strategies but are not necessary for them although their application has had some very powerful results recently. Deep ___ learning is simply the application of a multilayered neural network on one of the above learning methods.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is cross-over a part of genetic algorithms? Genetic Algorithms has come to my attention recently when trying to correct/improve computer opponents for turn-based strategy computer games.\nI implemented a simple Genetic Algorithm that didn't use any cross-over, just some random mutation. It seemed to work in this case, and so I started thinking:\nWhy is cross-over a part of genetic algorithms? Wouldn't mutation be enough?\nThis is from a data dump on an old AI site. The asker had the UID of 7. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Mutation is usually defined to be a global operator, i.e. iterated mutation is (eventually) capable of reaching every point in the vector space defined by the geneome. In that sense, mutation alone is certainly 'enough'.\nRegarding the motivation for crossover - from Essentials of Metaheuristics, p42:\n\nCrossover was originally based on the premise that highly fit individuals often share certain traits, called building blocks, in common.\n For example, in the boolean individual 10110101, perhaps\n ***101*1 might be a building block \n\n(where * means \"either 0 or 1\") \nSo the idea is that crossover works by spreading building blocks quickly throughout the population.\n\nCrossover methods also assume that there is some degree of linkage between genes on the chromosome: that is, settings for certain genes in groups are strongly correlated to fitness improvement. For example, genes A and B might contribute to fitness only when they\u2019re both set to 1: if either is set to 0, then the fact that the other is set to 1 doesn\u2019t do anything.\n\nAlso note that crossover is not a global operator. If the only operator is crossover then (also from p42):\n\nEventually the population will converge, and often (unfortunately) prematurely\n converge, to copies of the same individual. At this stage there\u2019s no escape: when an individual crosses over with itself, nothing new is generated.\n\nFor this reason, crossover is generally used together with some global mutation operator.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can Bayesian inference be combined with knowledge-based systems? I've been struggling with the connection between knowledge-based AI systems and Bayesian inference for a while now. While I continue to sweep through the literature, I would be happy if someone can answer these more specific questions directly\n\nAre Bayesian inference based methods used in reasoning or Q/A systems -- to arrive at conclusions about questions whose answers are not directly present in the knowledge base?\n\nIn other words, if a Q/A system doesn't find an answer in a knowledge base, can it use Bayesian inference to use the available facts to suggest answers with varying likelihoods?\n\nIf yes, could you point me to some implementations?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, it is possible to combine probabilistic / bayesian reasoning and a traditional \"knowledgebase\". And some work along those lines has been done. See, for example, ProbLog (\"Probabilistic Prolog\") which combines logic programming and probabilistic elements. See: \nhttps://dtai.cs.kuleuven.be/problog/tutorial/mpe/01_bn.html\nAnother project to look at is Pr-OWL\n (\"Probabilistic OWL\") which adds Bayesian reasoning to the Semantic Web stack.\nOf course neither of these deals specifically with QA systems, but both represent some work on at least the foundational aspect of combining traditional logic and/or ontologies, with probabilistic approaches. Building a QA system on top of that is an exercise for the reader...\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the formula for the momentum and Adam optimisers? In the gradient descent algorithm, the formula to update the weight $w$, which has $g$ as the partial gradient of the loss function with respect to it, is:\n$$w\\ -= r \\times g$$\nwhere $r$ is the learning rate.\nWhat should be the formula for momentum optimizer and Adam (adaptive momentum?) optimizer? Something should be added to the right side of the formula above?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I'm going to use slightly different notation, $\\leftarrow$ for an assignment, $\\alpha$ for learning rate, $\\nabla_w J$ in place of $g$* and implied multiplication as these are slightly more common. Also, using bold letters to represent vectors. In that notation, the update rule for basic gradient descent would be written as:\n$$\\mathbf{w} \\leftarrow \\mathbf{w} - \\alpha \\nabla_w J$$\nThis cannot be extended to momentum and Adam update rules whilst keeping it as a single line and modifying the right hand side. That is because these variations of gradient descent maintain running statistics of previous gradient values, which have their own separate update rules. When implemented on a computer, these become additional terms, mainly vectors the same size as the weight vector being updated. These variables also require initialisation before use.\nMomentum\nMomentum maintains a \"velocity\" term which essentially tracks a recency-weighted average of gradients. However, the classic form of momentum given here does not normalise the resulting vector, and you often have to adjust the learning rate down when using it. Momentum has a parameter $\\beta$ which should be between 0 and 1, and typically is set at $0.9$ or higher.\nIntitialisation\n$$\\mathbf{m} \\leftarrow \\mathbf{0}$$\nUpdate rules\n$$\\mathbf{m} \\leftarrow \\beta \\mathbf{m} + \\nabla_w J$$\n$$\\mathbf{w} \\leftarrow \\mathbf{w} - \\alpha \\mathbf{m}$$\nThere are some variants of these update rules in practice. An important one is Nesterov momentum.\nAdam\nThe Adam optimiser maintains a momentum term, plus a scaling term, and also corrects these terms for initial bias. Adam has three parameters $\\beta_m$ for momentum (typically 0.99), $\\beta_v$ for scaling (typically 0.999) and $\\epsilon$ to avoid divide by zero and numerical stability issues (typically $10^{-6}$). \nInitialisation\n$$\\rho_m \\leftarrow 1$$\n$$\\rho_v \\leftarrow 1$$\n$$\\mathbf{m} \\leftarrow \\mathbf{0}$$\n$$\\mathbf{v} \\leftarrow \\mathbf{0}$$\nUpdate rules\n$$\\rho_m \\leftarrow \\beta_m \\rho_m$$\n$$\\rho_v \\leftarrow \\beta_v \\rho_v$$\n$$\\mathbf{m} \\leftarrow \\beta_m \\mathbf{m} + (1-\\beta_m) \\nabla_w J$$\n$$\\mathbf{v} \\leftarrow \\beta_v \\mathbf{v} + (1-\\beta_v) (\\nabla_w J \\odot \\nabla_w J)$$\n$$\\mathbf{w} \\leftarrow \\mathbf{w}- \\alpha(\\frac{\\mathbf{m}}{\\sqrt{\\mathbf{v}}+\\epsilon} \\frac{\\sqrt{1-\\rho_v}}{1-\\rho_m})$$\nThe symbol $\\odot$ stands for element-wise multiplication. Here that essentially means to square each term of the gradient to calculate terms in $\\mathbf{v}$. The square root and division of $\\mathbf{m}$ by $\\sqrt{\\mathbf{v}}+\\epsilon$ in the last update step are also handled element-wise.\nThe variant I show here has an \"optimisation\" to the bias correction so that you don't need to calculate high powers of either of the parameters. You may see variants that don't have $\\rho_m$ and $\\rho_v$ (or equivalents), but instead use $\\beta_{m}^t$ or $\\beta_{v}^t$ directly, which is exactly what $\\rho_m$ and $\\rho_v$ represent.\n\n* $\\nabla_w J$ is the gradient of $J$ with respect to $\\mathbf{w}$. By writing it this way, it also describes the goal of the update explicitly within the notation i.e. to minimise a function that is parameterised by $\\mathbf{w}$.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are some examples of intelligent agents for each intelligent agent class? There are several classes of intelligent agents, such as:\n\nsimple reflex agents\nmodel-based reflex agents\ngoal-based agents\nutility-based agents\nlearning agents\n\nEach of these agents behaves slightly different from the other agents. There are certain diagrams that describe each of these IA classes. However, all the descriptions are usually quite abstract.\nWhat are some examples of intelligent agents for each intelligent agent class? Optionally, I would also like to see a compact definition of each class (and maybe how they are related to the diagrams).\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are no distinguishable hardware examples for each IA class. The same mobile robot architecture with proper sensors can be implemented to behave as any IA class. The way you can determine the class of an intelligent agent is from the way it processes the percept. Based on chapter 2 of Artificial Intelligent: A Modern Approach I will try to give a concise explanation for each class:\nA simple reflex agent takes an action based on only the current environmental situation; it maps the current percept into proper action ignoring the history of percepts. The mapping process could be simply a table-based or by any rule-based matching algorithm. An example of this class is a robotic vacuum cleaner that deliberate in an infinite loop, each percept contains a state of a current location [clean] or [dirty] and, accordingly, it decides whether to [suck] or [continue-moving]. \nA model-based reflex agent needs memory for storing the percept history; it uses the percept history to help to reveal the current unobservable aspects of the environment. An example of this IA class is the self-steering mobile vision, where it's necessary to check the percept history to fully understand how the world is evolving.\nA goal-based reflex agent has a goal and has a strategy to reach that goal. All actions are taken to reach this goal. More precisely, from a set of possible actions, it selects the one that improves the progress towards the goal (not necessarily the best one). An example of this IA class is any searching robot that has an initial location and wants to reach a destination.\nAn utility-based reflex agent is like the goal-based agent but with a measure of \"how much happy\" an action would make it rather than the goal-based binary feedback ['happy', 'unhappy']. This kind of agents provide the best solution. An example is the route recommendation system which solves the 'best' route to reach a destination.\nA learning agent is an agent capable of learning from experience. It has the capability of automatic information acquisition and integration into the system. Any agent designed and expected to be successful in an uncertain environment is considered to be learning agent. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are some resources with exercises related to neural networks? I am asking for a book (or any other online resource) where we can solve exercises related to neural networks, similar to the books or online resources dedicated to mathematics where we can solve mathematical exercises.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The book Grokking Deep Learning, by Andrew Trask (a PhD student at Oxford University and a research scientist at DeepMind), a wonderful, clean, and plain-English discussion of the basic mechanics that go on under the hood of neural networks - from data flow to updating of weights. It is written without a slant on normally-wonky math, the concepts are presented and then advanced at a digestible pace for anyone. \nHere are a few more possibly useful resources.\n\nNeural Networks: Playground Exercises \nGetting Started With Deep Learning: Convolutional Neural Networks\nDeep learning focuses on practical aspects of deep learning\nFirst lab assignment in Deep learning\nDeeplearning stanford\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are some resources on continuous state and action spaces MDPs for reinforcement learning? Most introductions to the field of MDPs and Reinforcement learning focus exclusively on domains where space and action variables are integers (and finite). This way we are introduced quickly to Value Iteration, Q-Learning, and the like.\nHowever, the most interesting applications (say, flying helicopters) of RL and MDPs involve continuous state space and action spaces. I'd like to go beyond basic introductions and focus on these cases but I am not sure how to get there. \nWhat are some resources on continuous state and action spaces MDPs for reinforcement learning? And what areas do I need to know or study to understand these cases in-depth?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is a small survey of continuous states, actions and time in reinforcement learning in my thesis proposal.\nRegarding books, Reinforcement Learning: State-of-the-Art seems to be pretty up-to-date from the excerpts I've read.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can I predict the next number in a non-obvious sequence? I've got an array of integers ranging from -3 to +3.\nExample: [1, 3, -2, 0, 0, 1]\nThe array has no obvious pattern since it represents bipolar disorder mood swings.\nWhat is the most suitable approach to predict the next number in the series? The length of the array is about 700 entries.\nFrom where can I start the investigation? (provided that I've got some experience in Python and Node.js, but only a hello-worldish acquaintance with TensorFlow). Which training model might be suitable in this case? How can I chunk the data set properly?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As all you have is a series of numbers, you should try using a sequence model. I suggest you look into RNNs and in particular LSTMs. Of course this is assuming despite the lack of \"obvious patterns\", there are some kind of hidden patterns in your data. If not, what you have is not very different than random walk in 3 dimensions - which makes the case unpredictable in the first place.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are there reinforcement learning algorithms that scale to large problems? Given a large problem, value iteration and other table based approaches seem to require too many iterations before they start to converge. Are there other reinforcement learning approaches that better scale to large problems and minimize the amount of iterations in general?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is a big question. I'm not going to try to cover the state-of-the-art, but I'll try to cover some of the main ideas. \nFunction Approximation [1]\nAn essential strategy for scaling up RL algorithms is to reduce the effective size of your state and/or action space through function approximation. For example, you could parameterize your value function using fewer parameters than there are states. Optimization would then take place in the much smaller parameter space, which can be substantially faster. Note that using function approximation almost always loses you any convergence guarantees you would have had otherwise in the tabular setting. It has been very successful in practice, though.\nSampling[2]\nValue iteration and other dynamic programming algorithms sweep through the entire state space when computing value functions. Sample-based approaches instead update value functions for states as they are visited. These include Monte Carlo and Temporal Difference methods. Sampling allows us to focus on a subset of the states, freeing us from the computation required to get accurate value estimates of potentially irrelevant states. This is essential in real-world settings, where almost all possible states of the world are irrelevant or even impossible to reach.\nSample Efficiency/Experience Replay\nAll else equal, a sample efficient agent is one that learns more with the same experience. Doing this reduces learning time, especially if the time bottleneck is in interacting with the environment. One basic way of improving sample efficiency is to store and reuse experience with something like the experience replay buffer popularized in the DQN paper. Another, more recent, algorithm called Hindsight Experience Replay improves sample efficiency by allowing the agent to learn more from its failures (trajectories with no reward).\nModel-Based Methods[3]\nWhile technically also about sample efficiency (maybe all of these points are?), model-based methods are important enough to warrant their own section. Usually, the MDP dynamics aren't known to the agent beforehand. Learning and maintaining an estimate of the MDP is therefore often a good idea. If an agent can use its internal model of the world to simulate experience, it can then learn from that simulated experience (called planning) in addition to learning from actual experience. Because simulated experience is much cheaper to gather than actual experience, this can reduce the time needed to learn.\nSearch[4]\nIf our value estimates were perfect, then behaving optimally would only be a matter of moving to the neighboring state with the highest value. This is hardly ever the case, though, so we would like to make decisions more intelligently. One way, called forward search, is to use a model to consider many possible trajectories starting from the current state. The most popular and successful example of forward search is Monte Carlo Tree Search (MCTS), which was famously used in AlphaGo Zero. Because search allows us to make better decisions given imperfect value estimates, we can focus on more promising trajectories, saving time and computation.\nExploration\nOnly ever taking what we think is the \"best\" action in a given state is usually not a very good idea. When sampling trajectories through large state and/or action spaces, this strategy can completely fail. Taking exploratory actions can help ensure that high-value states are discovered at all. Deciding when to explore and which actions to take is active area of research. In general, though, exploratory actions are ones that reduce an agent's uncertainty of the environment.\nInjecting Human Knowledge\nFinally, and maybe obviously, reducing the time complexity of an RL algorithm can be accomplished by giving the agent more information about the world. This can be done in many ways. If using linear function approximation, for example, an agent could be given useful information through the features it uses. If it makes use of a model, the model could be initialized with reasonable priors for the reward and transition probability distributions. \"Reward shaping\", the practice of manually engineering a (dense) reward function to facilitate learning a specific task, is a more general approach. An agent could also learn directly from human demonstrations with inverse reinforcement learning or imitation learning.\n\nReferences\nAll references not already linked to are chapters out of Sutton and Barto's RL book.\n[1] Linear function approximation is discussed in depth in Chapter 9.\n[2] Monte Carlo and Temporal Difference methods are discussed in Chapters 5 and 6.\n[3] Model-based methods are discussed in the first part of Chapter 8.\n[4] MCTS and search in general are discussed in the second half of Chapter 8. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there any board game where a human can still beat an AI? Significant AI vs human board game matches include:\n\nchess: Deep Blue vs Kasparov in 1996,\ngo: DeepMind AlphaGo vs Lee Sedol in 2016,\n\nwhich demonstrated that AI challenged and defeated professional players.\nAre there known board games left where a human can still win against an AI? I mean based on the final outcome of authoritative famous matches, where there is still the same board game where AI cannot beat a world champion of that game.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "For many years, the focus has been on games with perfect information. That is, in Chess and Go both of us are looking at the same board. In something like Poker, you have information that I don't have and I have information that you don't have, and so for either of us to make sense of each other's actions we need to model what hidden information the other player has, and also manage how we leak our hidden information. (A poker bot whose hand strength could be trivially determined from its bets will be easier to beat than a poker bot that doesn't.)\nCurrent research is switching to tackling games with imperfect information. Deepmind, for example, has said they might approach Starcraft next.\nI don't see too much difference between video games and board games, and there are several good reasons to switch to video games for games with imperfect information.\nOne is that if you want to beat the best human to be a major victory, there needs to be a pyramid of skill that human is atop of--it'll be harder to unseat the top Starcraft champion than the top Warcraft champion, even though the bots might be comparably difficult to code, just because humans have tried harder at Starcraft.\nAnother is that many games with imperfect information deal with reading faces and concealing information, which an AI would have an unnatural advantage at; for multiplayer video games, players normally interact with each other through a server as an intermediary and so the competition will be more normal.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the most sophisticated AI ever made? What is the most advanced AI software/system that humans have made to date, and what does it do?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In my opinion, this would be Phaeaco, which was developed by Harry Foundalis at Douglas Hofstadter's CRCC research group.\nIt takes noisy photographic images of Bongard problems as input and (using a variant of Hofstadter's 'Fluid Concepts' architecture) successfully deduces the required rule in many cases.\nHofstadter has described the related success of CopyCat as being 'like a little kid doing a somersault': i.e. it doesn't have the flashy appeal of systems like AlphaGo. What it does however have is a much more flexible (i.e. not precanned) approach to perception of problem structure than other systems, which Hofstadter claims (and many including Peter Norvig agree) is the really hard problem.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why are traditional ML models still used over deep neural networks? I'm still on my first steps in the Data Science field. I played with some DL frameworks, like TensorFlow (pure) and Keras (on top) before, and know a little bit of some \"classic machine learning\" algorithms like decision trees, k-nearest neighbors, etc.\nFor example, image classification problems can be solved with deep learning, but some people also use the SVM.\nWhy are traditional ML models still used over neural networks, if neural networks seem to be superior to traditional ML models? Keras is rather simple to use, so why don't people just use deep neural networks with Keras? What are the pros and cons of each approach (considering the same problem)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nWhy are still traditional machine learning (ML) models used over neural networks if neural networks seem to be superior to traditional ML models?\n\nOf course, the model that achieves state-of-the-art performance depends on the problem, available datasets, etc., so a comprehensive comparison between traditional ML models and deep neural networks is not appropriate for this website, because it requires a lot of time and space. However, there are certain disadvantages of deep neural networks compared to traditional machine learning models, such as k-nearest neighbors, linear regression, logistic regression, naive Bayes, Gaussian processes, support vector machines, hidden Markov models and decision trees.\n\nOften, traditional ML models are conceptually simpler (for example, k-NN or linear regression are much simpler than deep neural networks, such as LSTMs).\nPersonally, I've noticed that traditional ML models can be used more easily compared to deep neural networks, given the existence of libraries, like scikit-learn, which really have a simple and intuitive API (even though you apparently do not agree with this).\nDeep neural networks usually require more data than traditional ML models in order not to overfit. Empirically, I've once observed that certain traditional ML models can achieve comparable performance to deep neural networks in the case of small training datasets.\nEven though there's already a new and promising area of study called Bayesian deep learning, most deep neural networks do not really provide any uncertainty guarantees, they only provide you a point estimate. This is a big limitation, because, in areas like healthcare, uncertainty measures are required. In those cases, Gaussian processes may be more appropriate.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "MCTS: How to choose the final action from the root When the time allotted to Monte Carlo tree search runs out, what action should be chosen from the root?\n\nThe original UCT paper (2006) says bestAction in their algorithm.\n\nMonte-Carlo Tree Search: A New Framework for Game AI (2008) says\n\n\n\nThe game action finally executed by the program in the actual game, is the one corresponding to the child which was explored the most.\n\n\nA Survey of Monte Carlo Tree Search Methods (2012) says\n\n\nThe basic algorithm involves iteratively building a search tree until some predefined computational budget \u2013 typically a time, memory or iteration constraint \u2013 is reached, at which point the search is halted and the best-performing root action returned.\n[...] The result of the overall search a(BESTCHILD(v0)) is the action a that leads to the best child of the root node v0, where the exact definition of \u201cbest\u201d is defined by the implementation.\n[...] As soon as the search is interrupted or the computation budget is reached, the search terminates and an action a of the root nodet0is selected by some mechanism. Schadd [188] describes four criteria for selecting the winning action, based on the work of Chaslot et al [60]:\n\nMax child: Select the root child with the highest reward.\n\nRobust child: Select the most visited root child.\n\nMax-Robust child: Select the root child with both the highest visit count and the highest reward. If none exist, then continue searching until an acceptable visit count is achieved [70].\n\nSecure child: Select the child which maximises a lower confidence bound.\n\n\n[...] Once some computational budget has been reached, the algorithm terminates and returns the best move found,corresponding to the child of the root with the highest visit count.\nThe return value of the overall search in this case is a(BESTCHILD(v0,0)) which will give the action a that leads to the child with the highest reward, since the exploration parameter c is set to 0 for this final call on the root node v0. The algorithm could instead return the action that leads to the most visited child; these two options will usually \u2013 but not always! \u2013 describe the same action. This potential discrepancy is addressed in the Go program ERICA by continuing the search if the most visited root action is not also the one with the highest reward. This improved ERICA\u2019s winning rate against GNU GO from 47% to 55% [107].\n\nBut their algorithm 2 uses the same criterion as the internal-node selection policy:\n$$\\operatorname{argmax}_{v'} \\frac{Q(v')}{N(v')} + c \\sqrt{\\frac{2 \\ln N(v)}{N(v')}}$$\nwhich is neither the max child nor the robust child! This situation is quite confusing, and I'm wondering which approach is nowadays considered most successful/appropriate.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "By far the most commonly used strategy is to select the child with the highest number of visits. This is as described in the 2008 paper you linked. It's also what's referred to as the \"robust child\" in the 2012 paper you linked.\nIn algorithm 2 of the 2012 paper, they actually use the highest average reward, which corresponds to \"Max child\". It looks like they're using the UCB1 policy, but they actually use a value of $0$ for the exploration parameter $c$, which makes the entire square root term drop out. This is also explained in the text at the end of your quote. But usually, a robust child / max visit count performs better.\nProgressive Strategies for Monte-Carlo Tree Search is a different paper from 2008, in which these strategies are experimented with a bit. Usually, they perform similarly, but a robust child tends to be the best if there is any difference at all.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do we define the reward function for an environment? How do you actually decide what reward value to give for each action in a given state for an environment?\nIs this purely experimental and down to the programmer of the environment? So, is it a heuristic approach of simply trying different reward values and see how the learning process shapes up?\nOf course, I understand that the reward values have to make sense, and not just put completely random values, i.e. if the agent makes mistakes then deduct points, etc.\nSo, am I right in saying it's just about trying different reward values for actions encoded in the environment and see how it affects the learning?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In Reinforcement Learning (RL), a reward function is part of the problem definition and should:\n\nBe based primarily on the goals of the agent.\n\nTake into account any combination of starting state $s$, action taken $a$, resulting state $s'$ and/or a random amount (a constant amount is just a random amount with a fixed value having probability 1). You should not use other data than those four things, but you also do not have to use any of them. This is important, as using any other data stops your environment from being a Markov Decision Process (MDP).\n\nGiven the first point, as direct and simple as possible. In many situations this is all you need. A reward of +1 for winning a game, 0 for a draw and -1 for losing is enough to fully define the goals of most 2-player games.\n\nIn general, have positive rewards for things you want the agent to achieve or repeat, and negative rewards for things you want the agent to avoid or minimise doing. It is common for instance to have a fixed reward of -1 per time step when the objective is to complete a task as fast as possible.\n\nIn general, reward 0 for anything which is not directly related to the goals. This allows the agent to learn for itself whether a trajectory that uses particular states/actions or time resources is worthwhile or not.\n\nBe scaled for convenience. Scaling all rewards by a common factor does not matter at a theoretical level, as the exact same behaviour will be optimal. In practice you want the sums of reward to be easy to assess by yourself as you analyse results of learning, and you also want whatever technical solution you implement to be able to cope with the range of values. Simple numbers such as +1/-1 achieve that for basic rewards.\n\n\nIdeally, you should avoid using heuristic functions that reward an agent for interim goals or results, as that inserts your opinion about how the problem should be solved into the system, and may not in fact be optimal given the goals. In fact you can view the purpose of value-based RL is learning a good heuristic function (the value function) from the more sparse reward function. If you already had a good heuristic function then you may not need RL at all.\nYou may need to compare very different parts of the outcome in a single reward function. This can be hard to balance correctly, as the reward function is a single scalar value and you have to define what it means to balance between different objectives within a single scenario. If you do have very different metrics that you want to combine then you need to think harder about what that means:\n\nWhere possible, flatten the reward signal into the same units and base your goals around them. For instance, in business and production processes if may be possible to use currency as the units of reward and convert things such as energy used, transport distance, etc., into that currency.\n\nFor highly negative/unwanted outcomes, instead of assigning a negative reward, consider whether a constraint on the environment is more appropriate.\n\n\nYou may have opinions about valid solutions to the environment that you want the agent to use. In which case you can extend or modify the system of rewards to reflect that - e.g. provide a reward for achieving some interim sub-goal, even if it is not directly a result that you care about. This is called reward shaping, and can help in practical ways in difficult problems, but you have to take extra care not to break things.\nThere are also more sophisticated approaches that use multiple value schemes or no externally applied ones, such as hierarchical reinforcement learning or intrinsic rewards. These may be necessary to address more complex \"real life\" environments, but are still subject of active research. So bear in mind that all the above advice describes the current mainstream of RL, and there are more options the deeper you research the topic.\n\nIs this purely experimental and down to the programmer of the environment. So, is it a heuristic approach of simply trying different reward values and see how the learning process shapes up?\n\nGenerally no. You should base the reward function on the analysis of the problem and your learning goals. And this should be done at the start, before experimenting with hyper-parameters which define the learning process.\nIf you are trying different values, especially different relative values between different aspects of a problem, then you may be changing what it means for the agent to behave optimally. That might be what you want to do, because you are looking at how you want to frame the original problem to achieve a specific behaviour.\nHowever, outside of inverse reinforcement learning, it is more usual to want an optimal solution to a well-defined problem, as opposed to a solution that matches some other observation that you are willing to change the problem definition to meet.\n\nSo, am I right in saying it's just about trying different reward values for actions encoded in the environment and see how it affects the learning?\n\nThis is usually not the case.\nInstead, think about how you want to define the goals of the agent. Write reward functions that encapsulate those goals. Then focus on changes to the agent that allow it to better learn how to achieve those goals.\nNow, you can do it the way round, as you suggest. But what you are doing, in that case, is changing the problem definition, and seeing how well a certain kind of agent can cope with solving each kind of problem.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why can\u2019t an artificial neural network figure out what a lava lamp will do next? I was watching a lava lamp and started wondering if a computer could ever predict what the blobs are going to do next.\nIt seems like, in theory, you could record tons of video frames, feed them to a neural network, and have it learn the patterns \u2014 kind of like how AIs predict everything.\nBut people keep saying lava lamps are chaotic systems that can\u2019t really be predicted, even with machine learning.\nI don\u2019t totally get why. If it\u2019s all just physics, can\u2019t an ANN (like an LSTM or something) learn it?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In principle, if it's all \"just physics\" then you don't need machine learning at all - you can just simulate it to an arbitrary level of precision in deterministic code. The problem though is that \"chaotic systems\" are, well, \"chaotic\". Meaning, among other things, they are so complicated, with so many interactions between simultaneously changing elements, and so very sensitive to initial conditions, that it's effectively impossible to simulate them to any high degree of precision. This is the same reason why accurate weather forecasting has been such a challenge for so long, and only in the last couple of decades have we gotten kind of good at it. And even then it takes massive amounts of computing power (think supercomputers) to do that.\nSo if you had a good physics simulation package, and a supercomputer with an unlimited budget, you almost certainly could model your lava lamp pretty well.\nMachine Learning could help but it does require, as you note, patterns in the underlying behavior. And it's those patterns that are hard to suss out. It's probably easier to use ML to get some vaguely useful approximation, than to use a deterministic physics simulation package to get a useful answer, but in both cases you're up against the same constraints: you'd need massive amounts of compute, incredibly high precision measurements, and lots of time.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does a one-layer hidden network get more robust to poor initialization with growing number of hidden neurons? In a nutshell: I want to understand why a one hidden layer neural network converges to a good minimum more reliably when a larger number of hidden neurons is used. Below a more detailed explanation of my experiment:\nI am working on a simple 2D XOR-like classification example to understand the effects of neural network initialization better. Here's a visualisation of the data and the desired decision boundary:\n\nEach blob consists of 5000 data points. The minimal complexity neural network to solve this problem is a one-hidden layer network with 2 hidden neurons. Since this architecture has the minimum number of parameters possible to solve this problem (with a NN) I would naively expect that this is also the easiest to optimise. However, this is not the case. \nI found that with random initialization this architecture converges around half of the time, where convergence depends on the signs of the weights. Specifically, I observed the following behaviour:\nw1 = [[1,-1],[-1,1]], w2 = [1,1] --> converges\nw1 = [[1,1],[1,1]], w2 = [1,-1] --> converges\nw1 = [[1,1],[1,1]], w2 = [1,1] --> finds only linear separation\nw1 = [[1,-1],[-1,1]], w2 = [1,-1] --> finds only linear separation\n\nThis makes sense to me. In the latter two cases the optimisation gets stuck in suboptimal local minima. However, when increasing the number of hidden neurons to values greater than 2, the network develops a robustness to initialisation and starts to reliably converge for random values of w1 and w2. You can still find pathological examples, but with 4 hidden neurons the chance that one \"path way\" through the network will have non-pathological weights is larger. But happens to the rest of the network, is it just not used then? \nDoes anybody understand better where this robustness comes from or perhaps can offer some literature discussing this issue?\nSome more information: this occurs in all training settings/architecture configurations I have investigated. For instance, activations=Relu, final_activation=sigmoid, Optimizer=Adam, learning_rate=0.1, cost_function=cross_entropy, biases were used in both layers. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I may have scratched the surface of a much larger problem when I asked this question. In the meantime I have read Lottery Hypothesis paper: https://arxiv.org/pdf/1803.03635.pdf \nBasically, if you overparameterise your network you are more likely to find a random initialisation that performs well: A winning ticket. The paper above shows that you can actually prune away the unneeded parts of the network after training. However, you need to overparameterise the network initially in order to increase the chance of randomly sampling a winning ticket configuration. \nI believe the case in my question above is a minimal example of this. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How would one debug, understand or fix the outcome of a neural network? It seems fairly uncontroversial to say that NN based approaches are becoming quite powerful tools in many AI areas - whether recognising and decomposing images (faces at a border, street scenes in automobiles, decision making in uncertain/complex situations or with partial data). Almost inevitably, some of those uses will develop into situations where NN-based AI takes on part or all of the human burden, and generally does it better than people generally do.\nExamples might include NN hypothetically used as steps in self-driving cars, medical diagnosis, human/identity verification, circuit/design verification, dubious transaction alerting. Probably many fields in the next decade or so. \nSuppose this happens, and is generally seen as successful (for example, it gets diagnoses right 80% to human doctors' 65% or something, or cars with AI that includes an NN component crash 8% less than human-driven cars or alternatives, or whatever).\nNow - suppose one of these aberrantly and seriously does something very wrong in one case. How can one approach it? With formal logic steps one can trace a formal decision process, but with NN there may be no formal logic, especially if it gets complex enough (in a couple of decades say), there are just 20 billion neural processors and their I/O weightings and connections, it may not be possible to determine what caused some incident even if lives were lost. It also may not be possible to say more than the systems continually learn and such incidents are rare. \nI also haven't heard of any meaningful way to do a \"black box\" or flight recorder equivalent for NNs, (even if not used I a life-critical case), that would allow us to understand and avoid a bad decision. Unlike other responses to product defects, if a NN could be trained after the event to fix one such case, it doesn't clearly provide the certainty we would want, that the new NN setup has fixed the problem, or hasn't reduced the risk and balance of other problems in so doing. It's just very opaque. And yet, clearly, it is mostly very valuable as an AI approach.\nIn 20 years if NN is an (acknowledged as safe and successful) component in a plane flight or aircraft design, or built into a hospital system to watch for emergencies, or to spot fraud at a bank, and has as usual passed whatever regulatory and market requirements might exist and performed with a good record for years in the general marketplace, and then in one case such a system some time later plainly misacts on one occasion - it dangerously misreads the road, recommends life-damaging medications or blatantly misdiagnoses, or clears a blatant \u00a3200m fraudulent transaction at a clearing bank that's only caught by chance before the money is sent.\nWhat can the manufacturer do to address public or market concerns, or to explain the incident? What do the tech team do when told by the board \"how did this happen and make damn sure it's fixed\"? What kind of meaningful logs can be kept, etc.? Would society have to just accept that uncertainty and occasional wacky behavior could be inherent (good luck with the convincing society of that!)? Or is there some better way to approach logging/debugging/decision activity more suited to NNs?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "If the observation that the neural network saw was recorded, then yes the prediction can be explained. \nThere was a paper written fairly recently on this topic called \"Why Should I Trust You?\": Explaining the Predictions of Any Classifier (2016). In this paper, the author described an algorithm called LIME which is able to explain any machine learning models predictions. It can be used to establish why a machine learning model made a prediction, help a data scientist debug a model, and help a data scientist improve the accuracy of a specific model. LIME can be used to explain the predictions of any neural network including CNNs, RNNs, and DNNs. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Last linear layer of the decoder of a transformer I am learning the transformers architecture from these two sources:\nhttps://arxiv.org/pdf/1706.03762.pdf\nhttps://jalammar.github.io/illustrated-transformer/\nI just wanted to ask about the final step in the decoder. Let's fix testing time. As I understand, the decoder starts with an input of dimension $(N_{words},d_{emb})$, where $N_{words}$ is the number of words already predicted and $d_{emb}$ is the embedding dimension.\nNow if we \"follow\" the following decoder steps, at each step (after e.g. the attention layers) we should have a vector of dimension $(N_{words},d_{model})$ where $d_{model}$ is the model dimension. In other words, up to the final linear layer we have $N_{words}$ vectors which are $d_{model}$-dimensional.\nAre all these $N_{words}$ vectors fed into the last linear layer (before the softmax) or, as I suspect, only the last of these vectors is used ? In the latter case the last linear layer would be a matrix of dimension $d_{model}\\times N_{vocab}$, where $N_{vocab}$ is the vocabulary dimension.\nIs this correct ? Are there any issues in what I wrote ? Unluckily from the online sources I was not able to clarify this point...\nPS: I conjectured that the last linear layer is using just the last vector, because than I would understand what happens in training time, one would just use in that case all the output vectors from the decoder, instead of just the last one, to have a parallelized prediction.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I agree with this:\n\nPS: I conjectured that the last linear layer is using just the last\nvector, because than I would understand what happens in training time,\none would just use in that case all the output vectors from the\ndecoder, instead of just the last one, to have a parallelized\nprediction.\n\nIndeed when you look at the code of Tensorflow shared previusly you see this line\n# select the last token from the seq_len dimension\n predictions = predictions[:, -1:, :] # (batch_size, 1, vocab_size)\n\nwhere they take the last token of the sequence as a prediction for the next token. And this is consistent with the fact that the input sequence to the decoder is shifted to the right by adding a token at the beginning (see transformers original paper section 3.1-Decoder).\nSo to correct the previous answer, the input and output sequence of the decoder have the same length and the last vector is used for the next token prediction which is then added at the end of the input sequence.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can I handle overfitting in reinforcement learning problems? So this is my current result (loss and score per episode) of my RL model in a simple two players game:\n\nI use DQN with CNN as a policy and target networks. I train my model using Adam optimizer and calculate the loss using Smooth L1 Loss.\nIn a normal \"Supervised Learning\" situation, I can deduce that my model is overfitting. And I can imagine some methods to tackle this problem (e.g. Dropout layer, Regularization, Smaller Learning Rate, Early Stopping).\n\nBut would that solution will also work in RL problem?\nOr are there any better solutions to handle overfitting in RL?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Overfitting refers to a model being stuck in a local minimum while trying to minimise a loss function. In Reinforcement Learning the aim is to learn an optimal policy by maximising or minimising a non-stationary objective-function which depends on the action policy, so overfitting is not exactly like in the supervised scenario, but you can definitely talk about sub-optimal policies.\nIf we think of a specific task like avoiding stationary objects, a simple sub-optimal policy would be to just stay still without moving at all, or moving in circles if the reward function was designed to penalise lack of movements.\nThe way to avoid an agent to learn sub-optimal policies is to find a good compromise between exploitation, i.e. the constant selection of the next action to take based on the maximum expected reward possible, and exploration, i.e. a random selection of the next action to take regardless of the rewards. Here's a link to an introduction to the topic:\nExploration and Exploitation in Reinforcement Learning\nIt is worth mentioning that sometimes an agent can actually outsmart humans though, some examples are reported in this paper The Surprising Creativity of Digital Evolution. I particularly like the story of the insect agent trained to learn to walk while minimising the contact with the floor surface. The agent surprisingly managed to learn to walk without touching the ground at all. When the authors checked what was going on they discovered that the insect leaned to flip itself and then walk using its fake 'elbows' (fig7 in the linked paper). I add this story just to point out that most of the time the design of the reward function is itself even more important than exploration and exploitation tuning.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are general ideas behind OpenCog? OpenCog is an open source AGI-project co-founded by the mercurial AI researcher Ben Goertzel. Ben Goertzel writes a lot of stuff, some of it really whacky. Nonetheless, he is clearly very intelligent and has thought deeply about AI for many decades. \nWhat are the general ideas behind OpenCog? Would you endorse it as a insightful take on AGI? \nI'm especially interested in whether the general framework still makes sense in the light of recent advances. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "What is OpenCog?\nOpenCog is a project with the vision of creating a thinking machine with human-level intelligence and beyond. \nIn OpenCog's introduction, Goertzel categorically states that the OpenCog project is not concerned with building more accurate classification algorithms, computer vision systems or better language processing systems. The OpenCog project is solely focused on general intelligence that is capable of being extended to more and more general tasks. \nKnowledge representation\nOpenCog's knowledge representation mechanisms are all based fundamentally on networks. OpenCog has the following knowledge representation components:\nAtomSpace: it is a knowledge representation database and query engine. Data on AtomSpace is represented in the form of graphs and hypergraphs. \nProbabilistic Logic Networks (PLN's): it is a novel conceptual, mathematical and computational approach to handle uncertainty and carry out effective reasoning in real-world circumstances. \nMOSES (Meta-Optimizing Semantic Evolutionary Search): it implements program learning by using a meta-optimization algorithm. That is, it uses two optimization algorithms, one wrapped inside the other to find solutions. \nEconomic Attention Allocation (EAA): each atom has an attention value attached to it. The attention values are updated by using nonlinear dynamic equations to calculate the Short Term Importance (STI) and Long Term Importance (LTI). \nCompetency Goals\nOpenCog lists 14 competencies that they believe AI systems should display in order to be considered an AGI system.\nPerception: vision, hearing, touch and cross-modal proprioception\nActuation: physical skills, tool use, and navigation physical skills\nMemory: declarative, behavioral and episodic\nLearning: imitation, reinforcement, interactive verbal instruction, written media and learning via experimentation\nReasoning: deduction, induction, abduction, causal reasoning, physical reasoning and associational reasoning \nPlanning: tactical, strategic, physical and social\nAttention: visual attention, behavioural attention, social attention\nMotivation: subgoal creation, affect-based motivation, control of emotions\nEmotion: expressing emotion, understanding emotion\nModelling self and other: self-awareness, theory of mind, self-control\nSocial interaction: appropriate social behavior, social communication, social inference and group play\nCommunication: gestural communication, verbal communication, pictorial communication, language acquisition and cross-modal communication\nQuantitative skills: counting, arithmetic, comparison and measurement.\nAbility to build/create: physical, conceptual, verbal and social. \nDo I endorse OpenCog?\nIn my opinion, OpenCog introduces and covers important algorithms/approaches in machine learning, i.e. hyper-graphs and probabilistic logic networks. However, my criticism is that they fail to commit to a single architecture and integrate numerous architectures in an irregular and unsystematic manner. \nFurthermore, Goertzel failed to recognize the fundamental shift that came with the introduction of deep learning architectures so as to revise his work accordingly. This puts his research out of touch with recent developments in machine learning\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How much of a problem is white noise for the real-world usage of a DNN? I read that deep neural networks can be relatively easily fooled (link) to give high confidence in recognition of synthetic/artificial images that are completely (or at least mostly) out of the confidence subject.\nPersonally, I don't really see a big problem with DNN giving high confidence to those synthetic/artificial images but I think giving high confidence for white noise (link) may be a problem since this is a truly natural phenomenon that may the camera see in the real world.\nHow much of a problem is white noise for the real-world usage of a DNN? Can such false positives be detected from plain noise be prevented somehow?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The white noise that fools DNNs isn't really white noise. It has been altered in the same way as the synthetic misclassified pictures have been altered. You have to change many input pixels in exactly such a way, that these little changes aren't perceptible, but propagated through the network add up to a misclassification. This is not going to happen by chance. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which machine learning models are universal function approximators? The universal approximation theorem states that a feed-forward neural network with a single hidden layer containing a finite number of neurons can approximate any continuous function (provided some assumptions on the activation function are met).\nIs there any other machine learning model (apart from any neural network model) that has been proved to be an universal function approximator (and that is potentially comparable to neural networks, in terms of usefulness and applicability)? If yes, can you provide a link to a research paper or book that shows the proof?\nSimilar questions have been asked in the past in other places (e.g. here), but they do not provide links to papers or books that show the proofs.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Support vector machines\nIn the paper A Note on the Universal Approximation Capability of Support Vector Machines (2002) B. Hammer and K. Gersmann investigate the universal function approximation capabilities of SVMs. More specifically, the authors show that SVMs with standard kernels (including Gaussian, polynomial, and several dot product kernels) can approximate any measurable or continuous function up to any desired accuracy. Therefore, SVMs are universal function approximators.\nPolynomials\nIt is also widely known that we can approximate any continuous function with polynomials (see the Stone-Weierstrass theorem). You can use polynomial regression to fit polynomials to your labelled data.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Should I use neural networks or genetic algorithms to solve Gomoku? Currently, I'm doing a project that's about creating an AI to play the game Gomoku (it's like tic tac toe, but played on a 1515 board and requires 5 in a row to win). I have already successfully implemented a perfect tic tac toe AI using Q-learning and having game states/actions stored in a table, but, for a 1515 board, the possible game states become too large to implement this project.\nMy question is, should I use neural networks or genetic algorithms for this problem? And more specifically, how should I implement this?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "For Gomoku, it seems a bit of an overkill to use neural networks or the genetic algorithm as both take a while, and more often than not, don't go how you want it to. The Gomoku game tree is rather large, but you can get a decent AI from minimax, game tree pruning, and a good heuristic function (that includes counting half and full 2s,3s,4s,...etc.) as opposed to mapping out the full space.\nIf you are unfamiliar with alpha-beta pruning and minimax see this article.\nIf you really want to use neural networks or genetic algorithms you can for the learning experience. Regarding neural networks, one way to do it is the following:\n\nDefine a heuristic function that receives a board state input (sequence of 0,1,2 for empty, black, white), and outputs a 'goodness' value of the board state. The neural network is our heuristic function.\nAssuming that the moves in these game are optimal, train off of the difference between the current best move (by your current parameters) and what move your data says is the best. This is how we define our error function! Thus you are minimizing this difference so that what move your neural network says is the strongest is ideally what your game data says is the strongest (Optimization of this error function can be done via backpropagation or genetic algorithm).\nIdeally, by this point, you can now use your ('strong') neural network-based evaluation function for your game tree move evaluations instead of hardcoded heuristics.\n\nOf course, this is just one way, and you would need to find game data first.\nAs a side note, applying a genetic algorithm can occur in a few ways, such as parameter optimization in a neural network as mentioned above or game tree searching, so make sure you are clear how you define the problem setting with it! The same goes for alternative ways to apply a neural network.\nFinally, it's helpful to know Gomoku is solved. See this post for others' thoughts and ideas.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does nobody use decision trees for visual question answering? I'm starting a project that will involve computer vision, visual question answering, and explainability. I am currently choosing what type of algorithm to use for my classifier - a neural network or a decision tree.\nIt would seem to me that, because I want my system to include explainability, a decision tree would be the best choice. Decision trees are interpretable, whereas neural nets are like a black box.\nThe other differences I'm aware of are: decision trees are faster, neural networks are more accurate, and neural networks are better at modelling nonlinearity.\nIn all of the research I've done on computer vision and visual question answering, everyone uses neural networks, and no one seems to be using decision trees. Why? Is it for accuracy? I think a decision tree would be better because it is fast and interpretable, but if no one's using them for visual question answering, they must have a disadvantage that I haven't noticed.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "For vision tasks, neural network models almost always include a number of layers that pool and convolute. The convolutions, in particular, are very useful - they can make the model generalize better to inputs and maintain performance when inputs have undergone certain linear transformations (e.g. some scaling or a translation along the x-axis). These properties, along with the robust frameworks that exist for developing and deploying neural nets, and the fact that they have been shown to widely produce very good results, are some of the reasons they\u2019re used.\nIn terms of being a black box, while this is true for a lot of applications it\u2019s actually less true for image-based tasks. The layers of a well-designed and trained convolutional neural network model can actually be visualized and made quite interpretable; from these visualizations, it\u2019s often clear how the representation roughly works. In contrast, I\u2019d argue that while a decision tree is theoretically easier to interpret for some tasks (say medical decision making), this is less the case for vision tasks because we don\u2019t interpret images one pixel at a time or using some readily available feature of the image, such as the width, height, or color frequencies. People are almost always interested in the higher-level representation within an image (say, a cat, a leaf, or a face), and that sort of feature extraction is exactly what CNNs are good at. Decision trees, in contrast, tend to have trouble capturing these higher-level representations.\nDistill.pub has a nice explanation of feature visualization that may be of interest.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can an AI learn to suffer? I had first this question in mind \"Can an AI suffer?\". Suffering is important for human beings. Imagine that you are damaging your heel. Without pain, you will continue to harm it. Same for an AI. But then I told myself \"Wait a second. It already exists. It is the errors and warnings that shows up\". We can say it has the similar purpose as suffering. However, I felt something missing. We feel pain. The errors and bugs are just data. Let's say a robot can use machine learning and genetic programming to evolve. \nCan an AI learn to suffer? And not just know it as mere information.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "At a very high level, regarding evolutionary game theory and genetic algorithms, it is absolutely possible that AI could develop a state that is analogous with suffering, although, as you astutely point out, it would involve conditions that a computer cares about. (For instance, it might develop a feeling analogous to \"being aggrieved\" over non-optimality in the algorithmic sense, or \"frustration\" at equations don't add up, or \"dissatisfaction\" over goals that have not been achieved.)\nThe robot tormented by small children at the mall can certainly be said to be \"suffering\" in that the children block the performance of the robot's function, but the robot is not conscious and suffering might be said to require awareness. However, even without consciousness, this very simple robot can learn new behaviors through which it mitigates or avoids the \"suffering\" brought on by not being able to fulfill its function.\nYou definitely want to look into the concept of suffering in a philosophical context and Epicurus would be a very useful place to start.\nEpicurus is directly relevant in an algorithmic sense because he uses the term \"ataraxia\" meaning calm, and is derived from the verb \"tarasso\" which means to agitate or disturb.\nAtaraxia can be mathematically expressed as an equilibrium. Tarasso can be mathematically expressed as disequilibrium.\nThis relates directly to Game Theory in that disequilibrium can be said to be the primary requirement of games, and to AI in that Game Theory can be said to be the root of all AI.\nAtaraxia is also understood in the sense of \"freedom from fear\", which is temporal in that fear is a function of uncertainty as it relates to the future in a predictive sense, and involves current condition vs. possible, less optimal future conditions.\nThus fear, which is a form of suffering, is rooted in computational intractability, even where the \"computer\" is is a human brain.\nEarly philosophers such as Democritus are especially useful because they were exploring critical, fundamental concepts, many of which can now be expressed with modern mathematics.\nTo wit: you can't arrive at suffering until you first define \"the Good\" and \"the Bad\", which is a binary relationship in which neither term can be said to have meaning without the opposite. (Mathematically, it can be expressed in its simplest form as a finite, one-dimensional graph.) This understanding is quite ancient.\n\nIt is worth noting that the continuing value of the early philosophers is partly a factor of wisdom not being dependent on the volume of knowledge, demonstrated by Socrates in the idea that wisdom may be as simple as knowing you don't know something.\nThe ancient sages didn't have the benefit of powerful measurement tools, advanced mathematics, or scientific method, but they were very smart, and even more importantly, wise.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why isn't the ElliotSig activation function widely used? The Softsign (a.k.a. ElliotSig) activation function is really simple: \n$$ f(x) = \\frac{x}{1+|x|} $$\nIt is bounded $[-1,1]$, has a first derivative, it is monotonic, and it is computationally extremely simple (easy for, e.g., a GPU).\nWhy it is not widely used in neural networks? Is it because it is not infinitely derivable?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I can't speak for individual researchers, but I can guess why the community as a whole hasn't adopted this activation function.\nReLU is just so incredibly cheap. This benefit continues to grow as networks grow deeper. Also, they work reasonably well. As pointed out in Searching for Activation Functions, \n\nthe performance improvements of the other activation functions tend to be inconsistent across different models and datasets.\n\nEven if a new activation function did provide a meager improvement in performance across the board, I wouldn't be surprised if ReLU were still commonly used. It's the default for a lot of machine learning software already.\nAlso research isn't ordinarily about eeking out one more percentage point in accuracy on a specific task. If I were entering in a competition, I might experiment with activation functions. But even then I'd rather use ReLU and save a little time while prototyping my architecture.\nAs pointed out by @DuttaA in comments, softsign could potentially replace sigmoid and tanh in situations where a bounded output is desired. I haven't seen anyone compare them before, but softsign would at least be much faster. I'm guessing this replacement hasn't happened because of tradition and exposure. Not because of softsign's lack of infinite derivatives. I don't know if this happening would make softsign \"widely used\", but it would be something.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are other ways of handling invalid actions in scenarios where all rewards are either 0 (best reward) or negative? I created an OpenAI Gym environment, and I would like to check the performance of the agent from OpenAI Baselines DQN approach on it.\nIn my environment, the best possible outcome for the agent is 0 - the robot needs zero non-necessary resources to complete a task. The goal is to minimize the need for resources: for each needed resource, there is a penalty of -1. In many states, only certain actions make physical sense. How do I deal with this?\nThere was already a question about the handling of invalid moves on AI StackExchange, recommending to ignore the invalid moves. However, ignoring them would imply returning the same state and a 0 reward, the best possible outcome, which is clearly not the case. Setting drastic negative rewards also does not seem to work, since even promising handling paths are compromised by invalid actions and the corresponding drastic negative reward.\nWhat are other ways of handling invalid actions in scenarios where all rewards are either 0 (best) or negative?\nMy ideas/ questions on this for the OpenAI Baselines DQN approach implementation\n\nIs there any way to set the initial Q-values for the actions? I could set -infinity for the invalid actions.\n\nIs there any way to limit the set of valid actions per state? When after the env.step(action) function the new state is returned, can I somehow define which actions are valid for it?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "1) Is there any way to set the initial Q-values for the actions?\nYou can generally do this, but you cannot specify specific weights for specific actions in specific states. Not through the network weights directly, at least. That would defeat the purpose of using backpropagation to optimize the weights and find the optimal parameters and Q-values.\n2) Is there any way to limit the set of valid actions per state?\nAgain, not directly through the network. That would imply different network architectures for different states, which would imply optimizing several different networks. Unless you used some convoluted approach like Net2Net to keep the networks synced.\nHowever, you can bypass the network itself.\nYou can, however, on top of the network, filter its outputs. Let's say you have a set of states, and in state X, only 2 out of all 5 actions are valid. When getting the Q-values for all the actions in DQN, you can detect if you're in state X, and instead of choosing the greedy action out of all actions, choose the greedy action out of all valid actions. Better yet, have your environment just send a list of all valid actions for whatever state you're in. Makes this more general, as it removes your need for discrete states, having lists of valid actions for each state, etc.\nYou can also really just ignore invalid actions.\nYou claimed\n\nHowever, ignoring them would imply returning the same state and a 0 reward, the best possible outcome, which is clearly not the case.\n\nIf your environment has no time limit, then the best action really is to stand still and avoid wasting resources. However, if there is a time-limit, eventually the agent should receive some sort of penalty for not completing the task. Otherwise, if there is no time limit, you can also give him an award for completing the task. Imagining you have 10 resources, instead of having your reward interval be from [-10; 0], shift it to [0, 10] by awarding 10 points at the end of the game. This gives your agent the motivation to complete the task instead of doing useless actions, and discards your need for action-filtering at all.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Would an AI with human intelligence have the same rights as a human under current legal frameworks? For example, would an AI be able to own property, evict tenants, acquire debt, employ, vote, or marry? What are the legal structures in place to implement a strong AI into society? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, to some of what you propose. No to some.\nToday corporations are granted rights: to own property, earn income, pay taxes, contribute to political campaigns, offer opinion in public, ad more. Even now I see no reason why an AI should not be eligible to incorporate itself, thereby inheriting all these rights. Conversely, any corporation already in existence could become fully automated at any time (and some plausibly will). In doing so, they should not lose any of the rights and duties they currently employ.\nHowever I suspect certain rights would be unavailable to an AI just as they are unavailable to a corporation now: marriage, draft or voluntary service in the military, rights due a parent or child or spouse, estate inheritance, etc.\nCould this schizoid sense of human identity be resolved at some point? Sure. Already there have been numerous laws introduced and some passed elevating various nonhuman species to higher levels of civil rights that only humans heretofore enjoyed: chimpanzees, cetaceans, parrots and others have been identified as 'higher functioning' and longer lived, and so, are now protected from abuse in ways that food animals, pets, and lab animals are not. \nOnce AI 'beings' arise that operate for years and express intelligence and emotions that approach human-level and lifetime, I would expect a political will to arise to define, establish, and defend their civil rights. And as humans become more cybernetically augmented, especially cognitively, the line that separates us from creatures of pure silicon will begin to blur. In time it will become unconscionable to overlook the rights of beings simply because they contain 'too little flesh'.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the relationship between these two taxonomies for machine learning with neural networks? Could you please let me know which of the following classification of Neural Network's learning algorithm is correct? \nThe first one classifies it into:\n\nsupervised, \nunsupervised and \nreinforcement learning. \n\nHowever, the second one provides a different taxonomy on page 34: \n\nlearning with a teacher (error correction learning including incremental and batch training), \nlearning without a teacher (reinforcement, competitive, and unsupervised learning) \nmemory-based learning, and \nBoltzmann learning. \n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nCould you please let me know which of the following classification of Neural Network's learning algorithm is correct?\n\nThe first one classifies it into:\n \n \nsupervised,\nunsupervised and\nreinforcement learning.\n\n\n\nThose three forms of Machine Learning are not really different forms of a Neural Network learning algorithm (or, really, any learning algorithm); they are different forms of learning problems. They basically describe how much information we give our learning algorithm during a learning process / what kind of information we give it, regardless of what algorithm we're using to learn.\n\nIn supervised learning, we give very detailed information; we give example pairs of inputs + desired outputs.\nIn unsupervised learning, we still give many example inputs, but don't give any desired outputs. This can be, for example, because we simply don't know ourselves what the desired outputs would be. The most common example of unsupervised learning is learning to create clusters; we'd typically give some measure of similarity or distance between instances, and ask a learning algorithm to create clusters of instances for us such that instances within the same cluster are \"close\" to each other, and instances in different clusters are far away from each other. This is different from supervised learning because we do not directly tell the learning algorithm in which cluster each example instance would belong.\nIn reinforcement learning, we typically try to learn about policies (~= behaviours) in environments where an agent can take actions. We typically do not exactly know what the best complete policy would be, but can occasionally give \"hints\" (reinforcement) in the form of numerical rewards. This is not completely supervised learning because we don't tell exactly what the optimal action in a state would be. You can imagine this as giving a cookie to a dog if he's been a good boy.\n\nNow, there also are indeed Supervised Learning / Unsupervised Learning / Reinforcement Learning algorithms, but it's generally a property of the problem first and foremost; once you know what type of problem you're trying to solve, you'll look for a matching algorithm that can handle that problem.\n\n\nHowever, the second one provides a different taxonomy on page 34:\n\nlearning with a teacher (error correction learning including incremental and batch training),\nlearning without a teacher (reinforcement, competitive, and unsupervised - memory-based learning, and\nBoltzmann learning.\n\n\n\nHonestly, this seems a bit all-over-the-place to me. Learning with a teacher vs. learning without a teacher can be viewed as supervised vs unsupervised learning above. I suppose Reinforcement Learning would be kind of in-between. \nWhat they describe as memory-based learning is also often referred to as instance-based learning. This is suddenly not anymore about properties of learning problems, this is a type of learning algorithm. I'm not aware of instance-based learning being common in Neural Networks at all, indeed the example given in your link (the most common example) is the k-nearest neighbours algorithm, which doesn't really have any relation with Neural Networks. This is normally used for Supervised Learning problems. \nBoltzmann learning is a particular kind of learning algorithms for specific types of Neural Networks (with a specific architecture), and generally associated with unsupervised learning (or \"generative\" learning, learning probability distributions for given input data).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which tasks are called as downstream tasks? The following paragraph is from page no 331 of the textbook Natural Language Processing by Jacob Eisenstein. It mentions about certain type of tasks called as downstream tasks. But, it provide no further examples or details regarding these tasks.\n\nLearning algorithms like perceptron and conditional random fields\noften perform better with discrete feature vectors. A simple way to\nobtain discrete representations from distributional statistics is by\nclustering, so that words in the same cluster have similar\ndistributional statistics. This can help in downstream tasks, by\nsharing features between all words in the same cluster. However, there\nis an obvious tradeoff: if the number of clusters is too small, the\nwords in each cluster will not have much in common; if the number of\nclusters is too large, then the learner will not see enough examples\nfrom each cluster to generalize.\n\nWhich tasks in artificial intelligence or NLP are called as downstream tasks?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In the context of self-supervised learning (which is also used in NLP), a downstream task is the task that you actually want to solve. This definition makes sense if you're familiar with transfer learning or self-supervised learning, which are also used for NLP. In particular, in transfer learning, you first pre-train a model with some \"general\" dataset (e.g. ImageNet), which does not represent the task that you want to solve, but allows the model to learn some \"general\" features. Then you fine-tune this pre-trained model on the dataset that represents the actual problem that you want to solve. This latter task/problem is what would be called, in the context of self-supervised learning, a downstream task. In this answer, I mention these downstream tasks.\nIn the same book that you quote, the author also writes (section 14.6.2 Extrinsic evaluations, p. 339 of the book)\n\nWord representations contribute to downstream tasks like sequence labeling and document classification by enabling generalization across words. The use of distributed representations as features is a form of semi-supervised learning, in which performance on a supervised learning problem is augmented by learning distributed representations from unlabeled data (Miller et al., 2004; Koo et al., 2008; Turian et al., 2010). These pre-trained word representations can be used as features in a linear prediction model, or as the input layer in a neural network, such as a Bi-LSTM tagging model (\u00a7 7.6). Word representations can be evaluated by the performance of the downstream systems that consume them: for example, GloVe embeddings are convincingly better than Latent Semantic Analysis as features in the downstream task of named entity recognition (Pennington et al., 2014). Unfortunately, extrinsic and intrinsic evaluations do not always point in the same direction, and the best word representations for one downstream task may perform poorly on another task (Schnabel et al., 2015).\nWhen word representations are updated from labeled data in the downstream task, they are said to be fine-tuned.\n\nSo, to me, after having read this section of the book, it seems that the author is using the term \"downstream task\" as it's used in self-supervised learning. Examples of downstream tasks are thus\n\nsequence labeling\ndocumentation classification\nnamed entity recognition\n\nTasks like training a model to learn word embeddings are not downstream tasks, because these tasks are not really the ultimate tasks that you want to solve, but they are solved in order to solve other tasks (i.e. the downstream tasks).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which algorithm is used in the robot Sophia to understand and answers the questions? Which algorithm is used in the robot Sophia to understand and answer the questions?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Sophia ,first , has all the questions and corresponding answers preprogrammed. It is a system which is a hybrid of Bayes Text classification and decision trees. \n\nIt may consist of a speak recognizer which converts the question into a string.\nThis string then travels into a algorithm which gets a suitable answer for it.\nThe answer is then spoken by the speech synthesizer along with some face actions.\nIt might also have a sentiment analyser which identifies sentiments in a answer to show face expressions accordingly.\nAlong with this, it identifies the emotions on the face of the person sitting in front of it, so as to provide a greater expression.\n\nHence, Sophia understands or thinks nothing like the human brain. It is just a system which gives predefined answers corresponding to the question asked.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to evaluate a NEAT neural network? I'm trying to write my own implementation of NEAT and I'm stuck on the network evaluate function, which calculates the output of the network.\nNEAT as you may know contains a group of neural networks with continuously evolving topologies by the addition of new nodes and new connections. But with the addition of new connections between previously unconnected nodes, I see a problem that will occur when I go to evaluate, let me explain with an example:\n\nINPUTS = 2 yellow nodes\nHIDDEN = 3 blue nodes\nOUTPUT = 1 red node\n\nIn the image a new connection has been added connecting node3 to node5, how can I calculate the output for node5 if I have not yet calculated the output for node3, which depends on the output from node5?\n(not considering activation functions)\nnode5 output = (1 * 0.5) + (1 * 0.2) + (node3 output * 0.8)\nnode3 output = ((node5 output * 0.7) * 0.4)\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Consider the execution order, 5 will have an invalid value because it hasn't been set form 3 yet. However the second time around it should have a value set. The invalid value should falloff after sufficient training.\n0 -> 5\n1 -> 5\n5 -> 2\n2 -> 3\n3 -> 4\n3 -> 5\nRESTART\n0 -> 5\n1 -> 5\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does this argument refuting the existence of superintelligence work? A superintelligence is a machine that can surpass all intellectual activities by any human, and such a machine is often portrayed in science fiction as a machine that brings mankind to an end.\nAny machine is executed using an algorithm. By the Church-Turing thesis, any algorithm that can be executed by a modern computer can be executed by a Turing Machine. However, a human can easily simulate a Turing Machine. Doesn't this mean that a machine can't surpass all intellectual activities, since we can also execute the algorithm?\nThis argument is most likely flawed, since my intuition tells me that superintelligence is possible. However, it is not clear to me where the flaw is. Note that this is my own argument. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I believe this argument is based on the fact that intelligence is a single dimension when it really isn't. Are machines and humans really on the same level if a machine can solve a complex problem in a millionth of the time a human can? \nIt also assumes that the Turing machine is still the best computational model for the time period that you are in, which is not necessarily true for the future, it is just true until this point in time. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the status of artificial life software so under-developed? I'm interested in self replicating artificial life (with many agents), so after reviewing the literature with the excellent Kinematic Self-Replicating Machines I started looking for software implementations. I understand that the field is still in the early stages and mainly academic, but the status of artificial life software looks rather poor in 2019. \nOn wikipedia there is this list of software simulators.\nGoing trough the list only ApeSDK, Avida, DigiHive, DOSE, Polyword have been updated in 2019. I did not find a public repo for Biogenesis. ApeSDK, DigiHive and DOSE are single author programs. \nAll in all I don't see a single very active project with a large community around (I would be happy to have missed something). And this is more surprising considering the big momentum of AI and the proliferation of many ready to use AI tools and libraries. \nWhy is the status artificial life software so under-developed, when this field looks promising both from a commercial (see manufacturing, mining or space exploration applications) and academic (ecology, biology, human brain and more) perspective? Did the field underdelivered on expectations in past years and got less funding? Did the field hit a theoretical or computational roadblock? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I don\u2019t know for certain, but I can make a guess. This is just my opinion, some others may disagree.\nThe field of ALife has four branches that I\u2019m aware of:\nSelf-Organizing/self assembly behavior. This is the application you refer to, another context it\u2019s useful is swarm control (for drone swarms, for example). While this is technically ALife, as far as I\u2019m aware it\u2019s not really where most of the emphasis is. Swarm control and self assembly are seen as \u201cdifferent\u201d problems, as machines that can work together and also build more of themselves is interesting (and potentially dangerous), but is missing out on the diversity, the open-endedness that life on earth has. Much of ALife research is focused on trying to formally define this open-endedness and coming up with systems that achieve that. Self assembly and swarm control are interesting and difficult problems, just different. This leads to the other three sides of ALife research:\nComing up with environments, and running tests on them. This is a constant game of coming up with a definition that seems to capture open-endedness, then coming up with ALife sims that meet that criteria but fall short of our expectations. So new definitions are made and we repeat. Geb is a classic example: Geb has passed pretty much every test so far, but it\u2019s fairly uninspiring to watch. Most of those programs you reference chose a particular ALife paradigm, but that paradigm may not be the right one, and is often disappointing. Because we still haven\u2019t found something that really \u201clooks like life\u201d, new paradigms and programs are constantly being created and abandoned when they fail to work (Or perhaps some would have already worked, but the computing time is too much). That\u2019s what you\u2019re seeing. Without any unifying theory or sim that is really convincing, I suspect it\u2019ll stay this way for a while. And because:\n\nwe still haven\u2019t made much progress since Karl Sims in the 90s, or since Geb (this point is debatable)\nthese sorts of sims don\u2019t really have much commercial use aside from games\n\nthe direction of making new simulators seems to be lacking funding and research interest, as far as I can tell. Commercial sim games seem to push the boundary these days.\nFortunately there\u2019s a sub field of cellular automata life that\u2019s pretty interesting, its software is slightly more developed due to the overlap with cellular automata and ease of implementation, and research seems to be progressing there at an okay rate.\nRealistically, there seem to be two things people want: novel behavior, and novel bodies. My two cents is that these are separate problems, and achieving both is more expensive than just achieving one. But most of these sims end up not balancing development happening in both of these factors (doing this is very difficult), so one factor develops much further than the other, and this disconnect is disappointing to the sim creator. For example, Geb does behavioural diversity really well, while Karl Sims does body diversity well. Sensitivity to small details like mutation rate or genetic encoding also can be quite frustrating. Fortunately, eventually we\u2019ll sorta get behavioural diversity for free in any sim once RL/AI is really understood well.\nThe third piece of ALife research I\u2019m aware of is the theoretical side, which right now mostly isn\u2019t really far enough along to warrant practical implementation. One big branch of this is the learning theory side, represented by Valiant\u2019s Evolvability theory and followups. Essentially this talks about what functions are possible to evolve, and using stuff like PAC Learning theory they are able to prove some things. Some of these models are more natural than others, but it\u2019s an interesting perpendicular approach to coming up with sims and seeing if they do what we want. Maybe eventually these two approaches will meet in the middle at some point, but they haven\u2019t yet.\nThe fourth piece is Artificial Chemistry. I recommend this paper as a somewhat dated overview. While this is technically a field of ALife, and is centered around understanding a chemical system that has the necessary emergent properties, it has broken off into applications that may have industrial relevance. For example, robust self repairing and self assembling electronic systems, DNA computing (DNA is capable of simulating arbitrary chemical reaction networks which are capable of arbitrary computing), and artificial hormone systems for automatic task assignment. This has some software developed, but much of that software isn\u2019t really considered ALife anymore since it has branched off into its own domain.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are some examples of Statistical AI applications? I believe that statistical AI uses inductive thought processes. For example, deducing a trend from a pattern, after training.\nWhat are some examples of successfully applied Statistical AI to real-world problems?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are several examples. For example, one instance of using Statistical AI from my workplace is:\n\nAnalyzing the behavior of the customer and their food-ordering trends, and then trying to upsell by recommending them the dishes which they might like to order/eat. This can be done through the apriori and FP-growth algorithms. We then, automated the algorithm, and then the algorithm improves itself through an Ordered/Not-Ordered metric.\nSelf-driving cars. They use reinforcement and supervised learning algorithms for learning the route and the gradient/texture of the road.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between LSTM and RNN? What is the difference between LSTM and RNN? I know that RNN is a layer used in neural networks, but what exactly is an LSTM? Is it also a layer with the same characteristics?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "RNNs have recurrent connections and/or layers\nYou can describe a recurrent neural network (RNN) or a long short-term memory (LSTM), depending on the context, at different levels of abstraction. For example, you could say that an RNN is any neural network that contains one or more recurrent (or cyclic) connections. Or you could say that layer $l$ of neural network $N$ is a recurrent layer, given that it contains units (or neurons) with recurrent connections, but $N$ may not contain only recurrent layers (for example, it may also be composed of feedforward layers, i.e. layers with units that contain only feedforward connections).\nIn any case, a recurrent neural network is almost always described as a neural network (NN) and not as a layer (this should also be obvious from the name).\nLSTM can refer to a unit, layer or neural network\nOn the other hand, depending on the context, the term \"LSTM\" alone can refer to an\n\nLSTM unit (or neuron),\nan LSTM layer (many LSTM units), or\nan LSTM neural network (a neural network with LSTM units or layers).\n\nPeople may also refer to neural networks with LSTM units as LSTMs (plural version of LSTM).\nLSTMs are RNNs\nAn LSTM unit is a recurrent unit, that is, a unit (or neuron) that contains cyclic connections, so an LSTM neural network is a recurrent neural network (RNN).\nLSTM units/neurons\nThe main difference between an LSTM unit and a standard RNN unit is that the LSTM unit is more sophisticated. More precisely, it is composed of the so-called gates that supposedly regulate better the flow of information through the unit.\nHere's a typical representation (or diagram) of an LSTM (more precisely, an LSTM with a so-called peephole connection).\n\nThis can actually represent both an LSTM unit (and, in that case, the variables are scalars) or an LSTM layer (and, in that case, the variables are vectors or matrices).\nYou can see from this diagram that an LSTM unit (or layer) is composed of gates, denoted by\n\n$i_t$ (the input gate: the gate that regulates the input into the unit/layer),\n$o_t$ (the output gate: the gate that regulates the output from the unit)\n$f_t$ (the forget gate: the gate that regulates what the cell should forget)\n\nand recurrent connections (e.g. the connection from the cell into the forget gate and vice-versa).\nIt's also composed of a cell, which is the only thing that a neuron of a \"vanilla\" RNN contains.\nTo understand the details (i.e. the purpose of all these components, such as the gates), you could read the paper that originally proposed the LSTM by S. Hochreiter and J. Schmidhuber. However, there may be other more accessible and understandable papers, articles or video lessons on the topic, which you can find on the web.\nLSTMs also have recurrent connections!\nGiven the presence of cyclic connections, any recurrent neural network (either an LSTM or not) may be represented as a graph that contains one or more cyclic connections. For example, the following diagram may represent both a standard/vanilla RNN or an LSTM neural network (or maybe a variant of it, e.g. the GRU).\n\nWhen should you use RNNs and LSTMs?\nRNNs are particularly suited for tasks that involve sequences (thanks to the recurrent connections). For example, they are often used for machine translation, where the sequences are sentences or words. In practice, an LSTM is often used, as opposed to a vanilla (or standard) RNN, because it is more computationally effective. In fact, the LSTM was introduced to solve a problem that standard RNNs suffer from, i.e. the vanishing gradient problem. (Now, for these tasks, there are also the transformers, but the question was not about them).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is GPT-4 based on GPT-3 or was it trained from the scratch? To me it looks like GPT-4 is based on GPT-3.\nOn the other hand, there were rumors that training of GPT-3 was done with errors, but re-train was impossible due to the costs.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "GPT-4 is a transformer like GPT-3 and any other GPT. The training is certainly new, because it has a different size, you just can not transfer GPT-3 weights into an GPT-4 to continue training.\nThe details of the implementation are currently not known, the published report about it is not a scientific paper about how GPT-4 works, it basically states \"we do not say how it works\", see below.\nThe size of various components certainly differ,\nat least the number of weights in one part, but it could also be larger everywhere. The prompt length (context size) and the maximal output size increased a lot, from 4000 tokens to 8000 or even 32000 tokens.\nI would expect there are some other minor differences.\nOther major differences can be the amount of training data,\nand the compute used for training.\nMy personal speculation is that GPT-4 used a lot more compute for training, with possibly a similar amount of training data as GPT-3.\n\nFrom the \"GPT-4 Technical Report\", section 2:\n\nGiven both the competitive landscape and the safety implications of\nlarge-scale models like GPT-4, this report contains no further details\nabout the architecture (including model size), hardware, training\ncompute, dataset construction, training method, or similar.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is it possible that the MSE used to train neural networks with gradient descent has multiple local minima? We often train neural networks by optimizing the mean squared error (MSE), which is an equation of a parabola $y=x^2$, with gradient descent.\nWe also say that weight adjustment in a neural network by the gradient descent algorithm can hit a local minimum and get stuck in there.\nHow are multiple local minima on the equation of a parabola possible, if a parabola has only one minimum?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "$g(x) = x^2$ is indeed a parabola and thus has just one optimum.\nHowever, the $\\text{MSE}(\\boldsymbol{x}, \\boldsymbol{y}) = \\sum_i (y_i - f(x_i))^2$, where $\\boldsymbol{x}$ are the inputs, $\\boldsymbol{y}$ the corresponding labels and the function $f$ is the model (e.g. a neural network), is not necessarily a parabola. In general, it is only a parabola if $f$ is a constant function and the sum is over one element.\nFor example, suppose that $f(x_i) = c, \\forall i$, where $c \\in \\mathbb{R}$. Then $\\text{MSE}(\\boldsymbol{x}, \\boldsymbol{y}) = \\sum_i (y_i - c)^2$ will only change as a function of one variable, $\\boldsymbol{y}$, as in the case of $g(x) = x^2$, where $g$ is a function of one variable, $x$. In that case, $(y_i - c)^2$ will just be a shifted version (either to the right or left depending on the sign of $c$) of $y_i^2$, so, for simplicity, let's ignore $c$. So, in the case $f$ is a constant function, then $\\text{MSE}(\\boldsymbol{x}, \\boldsymbol{y}) = \\sum_i y_i^2$, which is a sum of parabolas $y_i^2$, which is called a paraboloid. In this case, the paraboloid corresponding to $\\text{MSE}(\\boldsymbol{x}, \\boldsymbol{y}) = \\sum_i y_i^2$ will only have one optimum, just like a parabola. Furthermore, if the sum is just over one $y_i$, that is, $\\text{MSE}(\\boldsymbol{x}, \\boldsymbol{y}) = \\sum_i y_i^2 = y^2$ (where $\\boldsymbol{y} = y$), then the MSE becomes a parabola.\nIn other cases, the MSE might not be a parabola or have just one optimum. For example, suppose that $f(x) = x^2$, $y_i = 1$ ($\\forall i$), then $h(x) = (1 - x^2)^2$ looks as follows\n\nwhich has two minima at $x=-1$ and $x=1$ and one maximum at $x=0$. We can find the two minima of this function $h$ using calculus: $h'(x) = -4x(1 - x^2)$, which becomes zero when $x=-1$ and $x=1$.\nIn this case, we only considered one term of the sum. If we considered the sum of terms of the form of $h$, then we could even have more \"complicated\" functions.\nTo conclude, given that $f$ can be arbitrarily complex, then also $\\text{MSE}(\\boldsymbol{x}, \\boldsymbol{y})$, which is a function of $f$, can also become arbitrarily complex and have multiple minima. Given that neural networks can implement arbitrarily complex functions, then $\\text{MSE}(\\boldsymbol{x}, \\boldsymbol{y})$ can easily have multiple minima. Moreover, the function $f$ (e.g. the neural network) changes during the training phase, which might introduce more complexity, in terms of which functions the MSE can be and thus which (and how many) optima it can have.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why are lambda returns so rarely used in policy gradients? I've seen the Monte Carlo return $G_{t}$ being used in REINFORCE and the TD($0$) target $r_t + \\gamma Q(s', a')$ in vanilla actor-critic. However, I've never seen someone use the lambda return $G^{\\lambda}_{t}$ in these situations, nor in any other algorithms.\nIs there a specific reason for this? Could there be performance improvements if we used $G^{\\lambda}_{t}$?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "That can be done. For example, Chapter 13 of the 2nd edition of Sutton and Barto's Reinforcement Learning book (page 332) has pseudocode for \"Actor Critic with Eligibility Traces\". It's using $G_t^{\\lambda}$ returns for the critic (value function estimator), but also for the actor's policy gradients. \nNote that you do not explicitly see the $G_t^{\\lambda}$ returns mentioned in the pseudocode. They are being used implicitly through eligibility traces, which allow for an efficient online implementation (the \"backward view\").\n\nI do indeed have the impression that such uses are fairly rare in recent research though. I haven't personally played around with policy gradient methods to tell from personal experience why that would be. My guess would be that it is because policy gradient methods are almost always combined with Deep Neural Networks, and variance is already a big enough problem in training these things without starting to involve long-trajectory returns. \nIf you use large $\\lambda$ with $\\lambda$-returns, you get low bias, but high variance. For $\\lambda = 1$, you basically get REINFORCE again, which isn't really used much in practice, and has very high variance. For $\\lambda = 0$, you just get one-step returns again. Higher values for $\\lambda$ (such as $\\lambda = 0.8$) tend to work very well in my experience with tabular methods or linear function approximation, but I suspect the variance may simply be too much when using DNNs.\nNote that it is quite popular to use $n$-step returns with a fixed, generally fairly small, $n$ in Deep RL approaches. For instance, I believe the original A3C paper used $5$-step returns, and Rainbow uses $3$-step returns. These often work better in practice than $1$-step returns, but still have reasonably low variance due to using small $n$.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the perceptron criterion function differentiable? I'm reading chapter one of the book called Neural Networks and Deep Learning from Aggarwal.\nIn section 1.2.1.1 of the book, I'm learning about the perceptron. One thing that book says is, if we use the sign function for the following loss function: $\\sum_{i=0}^{N}[y_i - \\text{sign}(W * X_i)]^2$, that loss function will NOT be differentiable. Therefore, the book suggests us to use, instead of the sign function in the loss function, the perceptron criterion which will be defined as:\n$$ L_i = \\max(-y_i(W * X_i), 0) $$\nThe question is: Why is the perceptron criterion function differentiable? Won't we face a discontinuity at zero? Is there anything that I'm missing here?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "$\\max(-y_i(w x_i), 0)$ is not partial derivable respect $w$ if $w x_i=0$.\nLoss functions are problematic when not derivable in some point, but even more when they are flat (constant) in some interval of the weights.\nAssume $y_i = 1$ and $w x_i < 0$ (that is, an error of type \"false negative\").\nIn this case, function $[y_i - \\text{sign}(w x_i)]^2 = 4$. Derivative on all interval $w x_i < 0$ is zero, thus, the learning algorithm has no any way to decide if it is better increase or decrease $w$.\nIn same case, $\\max(-y_i(w x_i), 0) = - w x_i$, partial derivative is $-x_i$. The learning algorithm knows that it must increase $w$ value if $x_i>0$, decrease otherwise. This is the real reason this loss function is considered more practical than previous one.\nHow to solve the problem at $w x_i = 0$ ? simply, if you increase $w$ and the result is an exact $0$, assign to it a very small value, $w=\\epsilon$. Similar logic for remainder cases.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can a neural network approximate all functions when the weights are not allowed to grow exponentially? It has been proven in the paper \"Approximation by Superpositions of a Sigmoidal Function\" (by Cybenko, in 1989) that neural networks are universal function approximators. I have a related question. \nAssume the neural network's input and output vectors are of the same dimension $n$. Consider the set of binary-valued functions from $\\{ 0,1 \\}^n$ to $\\{ 0,1 \\}^n$. There are $(2^n)^{(2^n)}$ such functions. The number of parameters in a (deep) neural network is much smaller than the above number. Assume the network has $L$ layers, each layer is $n \\times n$ fully-connected, then the total number of weights is $L \\cdot n^2$.\nIf the number of weights is not allowed to grow exponentially as $n$, can a deep neural network approximate all the binary-valued functions of size $n$?\nCybenko's proof seems to be based on the denseness of the function space of neural network functions. But this denseness does not seem to guarantee that a neural network function exists when the number of weights are polynomially bounded.\nI have a theory. If we replace the activation function of an ANN with a polynomial, say cubic one\uff0cthen after $L$ layers, the composite polynomial function would have degree $3^L$. In other words, the degree of the total network grows exponentially. In other words, its \"complexity\" measured by the number of zero-crossings, grows exponentially. This seems to remain true if the activation function is sigmoid, but it involves the calculation of the \"topological degree\" (a.k.a. mapping degree theory), which I have not the time to do yet.\nAccording to my above theory, the VC dimension (roughly analogous to the zero-crossings) grows exponentially as we add layers to the ANN, but it cannot catch up with the doubly exponential growth of Boolean functions. So the ANN can only represent a fraction of all possible Boolean functions, and this fraction even diminishes exponentially. That's my current conjecture.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "What is Proven\nThe question references the proof of Approximation by Superpositions of a Sigmoidal Function, G. Cybenko, 1989, Mathematics of Control, Signals, and Systems.\nThe 1989 proof stated that the network, made of activations that were required to be, \"Of continuous sigmoidal non-linearity,\" could, \"Uniformly approximate any continuous function of n real variables,\" so, as the question stated, the proof doesn't directly apply to 1-bit discrete outputs. Note that the network is expected to merely approximate the desired circuit behavior.\nThe question defines the system as an arbitrary mapping from input bit vector\n\n$I: { i_1, \\; \\dots, \\; i_n}$\n\nto output bit vector\n\n$O: { o_1, \\; \\dots, \\; o_n}$\n\nIt was further back proven that such a mapping can be accomplished with one Boolean expressions for each output bit. For all $2^n$ possible input vector permutations, there exists a Boolean expression made up of AND and NOT operations that calculates a result that matches any arbitrary logical truth table.\nThere are techniques for reducing redundancy in the array of Boolean expressions, which is critical to VLSI chip layout.\nWithout the retention of state anywhere in the network other than the attenuation matrix (parameters), the system is not Turing complete. However, with regard to the ability to realize Boolean expressions in describing the mapping, given an arbitrary number of layers, the network is complete.\nEstimating Layer Depth Requirements\nOnly one inner layer is required in the 1989 proof, so how many layers would it take for an accurate n-bit-to-n-bit mapping to be learned?\nThe question proposes that there are $2^n$ to the power of $2^n$ permutations. The mapping of each input bit vector to the desired output bit state can be represented by a truth table of $n$ binary dimensions.\nEach output is an independent bit, meaning the $2^n$-bit representations of unique Boolean functions that could produce each output bit is not tied to any other output channel. As would be expected, there are $2n$ freedoms of motion for the mapping of I to O.\nFor the case where the input is a bit vector of $n$ bits, where $n$ is the number of activations for any one of $L$ layers, the total number of activations in the network $a_t$ and the total number of scalar elements for all attenuation matrices (the parameters that represent training state) $q_t$ for the network is as follows.\n\n$a_t = \\sum_{\\, 0 = v}^{L - 1} \\; n_v$\n\n\n$= n \\, L$\n\n\n$p_t = \\sum_{\\, 0 = v}^{L - 2} \\; n_v^2$\n\n\n$= n^2 \\, (L-1)$\n\n\n\nIf IEEE 64 bit floating point numbers are used for each element in the attenuation matrix, we can calculate the number of bits available in the training parametrization.\n\n$b_t = 64 \\, (L - 1) \\, n^2$\n\nIt would be normal today to use ReLU, leaky ReLU, or some other more quickly convergent activation instead of sigmoid for all layers but the last and use a simple binary threshold for the last.\nThus we have a formulation of the information theory comparison inferred by the question, and can reduce it.\n\n$2^{2n} \\le 64 \\, (L - 1) \\, n^2$\n$L \\ge 1 + \\frac {2^{2n-6}} {n^2}$\n\nThis is a rough threshold. For a highly reliable training for the binary inputs to binary outputs, the number of layers should be well above the threshold.\nBelow the threshold the trainability of the mapping will degrade to an inadequate approximation for most applications because of signal saturation in the back propagation mechanism.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does weight normalization work? I was reading the paper Weight Normalization: A Simple Reparameterization to Accelerate Training of Deep Neural Networks about improving the learning of an ANN using weight normalization.\nThey consider standard artificial neural networks where the computation of each neuron consists in taking a weighted sum of input features, followed by an elementwise nonlinearity\n$$y = \\phi(\\mathbf{x} \\cdot \\mathbf{w} + b)$$\nwhere $\\mathbf{w}$ is a $k$-dimensional weight vector, $b$ is a scalar bias term, $\\mathbf{x}$ is a $k$-dimensional vector of input features, $\\phi(\\cdot)$ denotes an elementwise nonlinearity and $y$ denotes the\nthe scalar output of the neuron.\nThey then propose to reparameterize each weight vector $\\mathbf{w}$ in terms of a parameter vector $\\mathbf{v}$ and a scalar parameter $g$ and to perform stochastic gradient descent with respect to those parameters instead.\n$$\n\\mathbf{w} = \\frac{g}{\\|\\mathbf{v}\\|} \\mathbf{v}\n$$\nwhere $\\mathbf{v}$ is a $k$-dimensional vector, $g$ is a scalar, and $\\|\\mathbf{v}\\|$ denotes the Euclidean norm of $\\mathbf{v}$. They call this reparameterizaton weight normalization.\nWhat is this scalar $g$ used for, and where does it come from? Is $\\mathbf{w}$ is the normalized weight? In general, how does weight normalization work? What is the intuition behind it?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Your interpretation is quite correct. I could not understand how it would speed up the convergence though. What they are doing is basically re-assigning the magnitude of the weight vector (also called norm of the weight vector).\nTo put things in the perspective, the conventional approach to any Machine Learning cost function is to not only check the variations of the error with respect to a weight variable (gradient) but also add a normalization term which is $\\lambda (w_0^2 + w_1^2 + \\dots)$. This has got a few advantages:\n\nThe weights will not get exponentially high, even though if you make some mistake (generally bouncing off to exponential costs due to the wrong choice of learning rate).\nAlso, the convergence is quicker somehow (maybe because you have now 2 ways to control how much weight should be given to a feature. Unimportant features weights are not only getting reduced by normal gradient, but also the gradient of the normalization term $\\lambda (w_0^2 + w_1^2 + \\dots)$).\n\nIn this paper, they have proposed to fix the magnitude of the weight vector. This is a good way, although I am not sure if it is better than feature normalization. By limiting the magnitude of weight to $g$, they are fixing the resource available. The intuition is that, if you have 24 hours, you have to distribute this time among subjects. You'll distribute it in a way such that your grade/knowledge is maximized. So this might be helping in the faster convergence.\nAlso, another intuition would be, when you are subtracting the gradient from a weight vector you use a learning rate $\\alpha$. This decides by how much weight-age of error you want to give which will be subsequently be subtracted from the weights. In this approach, you are not only subtracting the weights but also using another learning rate $g$ to scale the weight. I call this $g$ a learning rate because you can customize it which in turn customizes the value of weights which in turn affects the future reductions of weight gradient descent.\nI am sure someone will post a better mathematical explanation of this stuff but this is all the intuition I could think of. I would be grateful if other intuitions and mathematical subtleties are pointed out. Hope this helps!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When to use Tanh? When and why would you not use Tanh?\nI just replaced ReLU with Tanh and my model trains about 2x faster, reaching 90% acc within 500 steps.\nWhile using ReLU it reached 90% acc in >1000 training steps.\nI believe the reason it trained faster was due to a steeper gradient (correct me if I'm wrong).\nThis led me to wonder, why would we not use Tanh over ReLU for most contexts?\nIs it the computational complexity? Or something else?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Using tanh in hidden layers require careful initialization of network weights and works best with the input features normalized within the same range as output (i.e. -1 to 1). It have expensive functions to evaluate and suffers with vanishing gradient. But it converges faster because due to the zero centered output.\nBut tanh works good with RNNs, as RNNs suffers from vanishing gradients, and they need an activation function whose second derivative can sustain for long range before going to zero.\nIf you want any of these properties, use tanh.\nWithout any gist of architecture, it's hard to tell why your model train faster than ReLU. But generally speaking, ReLU trains faster than Tanh due to lack of expensive functions to evaluate (such as exponents)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is a GPU always faster than a CPU for training neural networks? Currently, I am working on a few projects that use feedforward neural networks for regression and classification of simple tabular data. I have noticed that training a neural network using TensorFlow-GPU is often slower than training the same network using TensorFlow-CPU.\nCould something be wrong with my setup/code or is it possible that sometimes GPU is slower than CPU?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This changes according to your data and complexity of your models. See following article by microsoft. Their conclusion is \n\nThe results suggest that the throughput from GPU clusters is always\n better than CPU throughput for all models and frameworks proving that\n GPU is the economical choice for inference of deep learning models.\n ...\nIt is important to note that, for standard machine learning models\n where number of parameters are not as high as deep learning models,\n CPUs should still be considered as more effective and cost efficient.\n\nSince you are training MLP, it can not be thought as standard machine learning model. See my preprint, The impact of using large training data set KDD99 on classification accuracy. I compare different machine learning algorithms using weka.\n\nAs you can see from above image, MLP takes 722 minutes to train while Naive Bayes ~2 minutes. If your data is small and your models parameters are not high, you will see better performance on CPU.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When exactly does the split into different heads in Multi-Head-Attention occur? I am confused by the Multi-Head part of the Multi-Head-Attention used in Transformers. My question concerns the implementations in Pytorch of nn.MultiheadAttention and its forward method multi_head_attention_forward and whether these are actually identical to the paper. Unfortunately, I have been unable to follow along the original code of the paper. So I could not check whether the implementations in Pytorch are acutally identical to the paper.\nPlease forgive the excessive use of illustrations. However, I hope it will improve understanding my problem.\nWhat is the correct order for calculating the Queries Q, Keys K and Values V and splitting the operation into the individual Attention-Heads? Unfortunately most explanations I found online while helpful for understanding the general principle and intuition of Multi-Head-Attention did not go into the details of the implementation.\nIn the original paper Attention is all you need Multi-Head-Attention is explained as followed:\n\nFirst, according to my current understanding, if we have a sequence of vectors with 512-dimensions (like in the original Transformer) and we have $h=8$ Attention-Heads (again like the original), every Attention-Head attends to $512/8=64$ entries of the input vector used to calculate the Attention in the corresponding head. So the first Attention-Head attends to the first 64 entries, the second to the second 64 entries and so on. However, if the split is conducted before calculating Q,K,V this would refer to the first 64 entries of X (this does not seem match the explanation in the paper I believe) while in the other case it would refer to the first 64 entries of Q,K,V.\nIn the text they say \"project the queries, keys and values h times with different, learned linear projections to $d_k,d_k$ and $d_v$ dimensions and since they set $d_k=d_v=d_{model}/h=512/8=64$. Therefore, if we actually have single matrices for every Attention-Head h we would have\n$W^Q_i,W^K_i,W^V_i \\in \\mathbb{R}^{512x64} \\forall i \\in h$.\nThis matches the illustration found here https://jalammar.github.io/illustrated-transformer/\n\nIt is explained that the input X is transformed into the Queries, Keys and Values for the different attention heads by using different projection matrices which are learned during training.\nThis seems to indicate that the split into the individual Attention-Heads is conducted after the calculation of $Q,K,V$ (or rather during the calculation). Since we have $h=8$ this leads in sum to $3*8*512*64=3*512*512$ learnable parameters in total (if we ignore the bias). Thus as far as the overall number of parameters is concerned we would have the same number if we would instead use three big matrices which concatenate the matrices of the individual Attention-Heads.\n$W^Q=[W^Q_1,W^Q_2,...,W^Q_h] \\in \\mathbb{R}^{512x512}$ \n$W^K=[W^K_1,W^K_2,...,W^K_h] \\in \\mathbb{R}^{512x512}$ \n$W^Q=[W^V_1,W^V_2,...,W^V_h] \\in \\mathbb{R}^{512x512}$\nIn the explanation from the same author of GPT-2 (this model has an embedding dimension of 768 and 12 Attention-Heads, instead of 512 and 8 like the original Transformer) found here https://jalammar.github.io/illustrated-gpt2/#part-2-illustrated-self-attention\n\n\nthe Queries Q, Keys K and Values V are first calculated by multiplying the input with one big matrix which is the concatenation of $W^Q,W^K,W^V$. If the input for calculating Q, K and V is identical (which is the case for self-attention), it is clear to me that you can use $W_{concat}=[W^Q,W^K,W^V]$ and obtain $[Q,K,V]$, since you essentially still multiply the input with each weight matrix separately.\nThen you can split the result to again obtain $Q,K,V$ as individual matrices (The image displays $q_9,k_9,v_9$ as an example, not the complete matrices). Then $q_9,k_9,v_9$ are again split into 12 vectors which results in a matrix of dimension $(12x64)$.\nSo overall here we did not use individual matrices per Attention-Head but only one larger matrix.\nIs this method mathematically identical to the one using individual smaller matrices per Attention-Head?\nIt appears that this is the way the calculation is implented in Pytorch, if $d_{model}=kdim=vdim$ Though here unlike in the paper which used $d_k$ and $d_v$ as names, $kdim$ and $vdim$ refer to the dimension of all Attention-Heads summed up, e.g. $kdim=d_k*num_{heads}$(=512 for the original Transformer).\nSo In the documentation of nn.modules.MultiheadAttention the model either creates three separate projection matrices to generate the Queries, Keys and Values or one big matrix (if the dimensions are identical). The following is part of the _init_ function.\nif self._qkv_same_embed_dim is False:\n self.q_proj_weight = Parameter(torch.empty((embed_dim, embed_dim), **factory_kwargs))\n self.k_proj_weight = Parameter(torch.empty((embed_dim, self.kdim), **factory_kwargs))\n self.v_proj_weight = Parameter(torch.empty((embed_dim, self.vdim), **factory_kwargs))\n self.register_parameter('in_proj_weight', None)\n else:\n self.in_proj_weight = Parameter(torch.empty((3 * embed_dim, embed_dim), **factory_kwargs))\n self.register_parameter('q_proj_weight', None)\n self.register_parameter('k_proj_weight', None)\n self.register_parameter('v_proj_weight', None)\n\nIf we stay in the standard case of _qkv_same_embed_dim=True the input is passed through a nn.linear as part of _in_projection_packed which is using self.in_proj_weight as the weight\nif not use_separate_proj_weight:\n assert in_proj_weight is not None, \"use_separate_proj_weight is False but in_proj_weight is None\"\n q, k, v = _in_projection_packed(query, key, value, in_proj_weight, in_proj_bias)\n else:\n assert q_proj_weight is not None, \"use_separate_proj_weight is True but q_proj_weight is None\"\n assert k_proj_weight is not None, \"use_separate_proj_weight is True but k_proj_weight is None\"\n assert v_proj_weight is not None, \"use_separate_proj_weight is True but v_proj_weight is None\"\n if in_proj_bias is None:\n b_q = b_k = b_v = None\n else:\n b_q, b_k, b_v = in_proj_bias.chunk(3)\n q, k, v = _in_projection(query, key, value, q_proj_weight, k_proj_weight, v_proj_weight, b_q, b_k, b_v)\n\ndef _in_projection_packed(\n q: Tensor,\n k: Tensor,\n v: Tensor,\n w: Tensor,\n b: Optional[Tensor] = None,\n) -> List[Tensor]:\n r\"\"\"\n Performs the in-projection step of the attention operation, using packed weights.\n Output is a triple containing projection tensors for query, key and value.\n Args:\n q, k, v: query, key and value tensors to be projected. For self-attention,\n these are typically the same tensor; for encoder-decoder attention,\n k and v are typically the same tensor. (We take advantage of these\n identities for performance if they are present.) Regardless, q, k and v\n must share a common embedding dimension; otherwise their shapes may vary.\n w: projection weights for q, k and v, packed into a single tensor. Weights\n are packed along dimension 0, in q, k, v order.\n b: optional projection biases for q, k and v, packed into a single tensor\n in q, k, v order.\n Shape:\n Inputs:\n - q: :math:`(..., E)` where E is the embedding dimension\n - k: :math:`(..., E)` where E is the embedding dimension\n - v: :math:`(..., E)` where E is the embedding dimension\n - w: :math:`(E * 3, E)` where E is the embedding dimension\n - b: :math:`E * 3` where E is the embedding dimension\n Output:\n - in output list :math:`[q', k', v']`, each output tensor will have the\n same shape as the corresponding input tensor.\n \"\"\"\n E = q.size(-1)\n if k is v:\n if q is k:\n # self-attention\n return linear(q, w, b).chunk(3, dim=-1)\n else:\n # encoder-decoder attention\n w_q, w_kv = w.split([E, E * 2])\n if b is None:\n b_q = b_kv = None\n else:\n b_q, b_kv = b.split([E, E * 2])\n return (linear(q, w_q, b_q),) + linear(k, w_kv, b_kv).chunk(2, dim=-1)\n else:\n w_q, w_k, w_v = w.chunk(3)\n if b is None:\n b_q = b_k = b_v = None\n else:\n b_q, b_k, b_v = b.chunk(3)\n return linear(q, w_q, b_q), linear(k, w_k, b_k), linear(v, w_v, b_v)\n\n\ndef _in_projection(\n q: Tensor,\n k: Tensor,\n v: Tensor,\n w_q: Tensor,\n w_k: Tensor,\n w_v: Tensor,\n b_q: Optional[Tensor] = None,\n b_k: Optional[Tensor] = None,\n b_v: Optional[Tensor] = None,\n) -> Tuple[Tensor, Tensor, Tensor]:\n r\"\"\"\n Performs the in-projection step of the attention operation. This is simply\n a triple of linear projections, with shape constraints on the weights which\n ensure embedding dimension uniformity in the projected outputs.\n Output is a triple containing projection tensors for query, key and value.\n Args:\n q, k, v: query, key and value tensors to be projected.\n w_q, w_k, w_v: weights for q, k and v, respectively.\n b_q, b_k, b_v: optional biases for q, k and v, respectively.\n Shape:\n Inputs:\n - q: :math:`(Qdims..., Eq)` where Eq is the query embedding dimension and Qdims are any\n number of leading dimensions.\n - k: :math:`(Kdims..., Ek)` where Ek is the key embedding dimension and Kdims are any\n number of leading dimensions.\n - v: :math:`(Vdims..., Ev)` where Ev is the value embedding dimension and Vdims are any\n number of leading dimensions.\n - w_q: :math:`(Eq, Eq)`\n - w_k: :math:`(Eq, Ek)`\n - w_v: :math:`(Eq, Ev)`\n - b_q: :math:`(Eq)`\n - b_k: :math:`(Eq)`\n - b_v: :math:`(Eq)`\n Output: in output triple :math:`(q', k', v')`,\n - q': :math:`[Qdims..., Eq]`\n - k': :math:`[Kdims..., Eq]`\n - v': :math:`[Vdims..., Eq]`\n \"\"\"\n Eq, Ek, Ev = q.size(-1), k.size(-1), v.size(-1)\n assert w_q.shape == (Eq, Eq), f\"expecting query weights shape of {(Eq, Eq)}, but got {w_q.shape}\"\n assert w_k.shape == (Eq, Ek), f\"expecting key weights shape of {(Eq, Ek)}, but got {w_k.shape}\"\n assert w_v.shape == (Eq, Ev), f\"expecting value weights shape of {(Eq, Ev)}, but got {w_v.shape}\"\n assert b_q is None or b_q.shape == (Eq,), f\"expecting query bias shape of {(Eq,)}, but got {b_q.shape}\"\n assert b_k is None or b_k.shape == (Eq,), f\"expecting key bias shape of {(Eq,)}, but got {b_k.shape}\"\n assert b_v is None or b_v.shape == (Eq,), f\"expecting value bias shape of {(Eq,)}, but got {b_v.shape}\"\n return linear(q, w_q, b_q), linear(k, w_k, b_k), linear(v, w_v, b_v)\n\ndef linear(\n input: Tensor, weight: Tensor, bias: Optional[Tensor] = None,\n scale: Optional[float] = None, zero_point: Optional[int] = None\n) -> Tensor:\n r\"\"\"\n Applies a linear transformation to the incoming quantized data:\n :math:`y = xA^T + b`.\n See :class:`~torch.nn.quantized.Linear`\n .. note::\n Current implementation packs weights on every call, which has penalty on performance.\n If you want to avoid the overhead, use :class:`~torch.nn.quantized.Linear`.\n Args:\n input (Tensor): Quantized input of type `torch.quint8`\n weight (Tensor): Quantized weight of type `torch.qint8`\n bias (Tensor): None or fp32 bias of type `torch.float`\n scale (double): output scale. If None, derived from the input scale\n zero_point (long): output zero point. If None, derived from the input zero_point\n Shape:\n - Input: :math:`(N, *, in\\_features)` where `*` means any number of\n additional dimensions\n - Weight: :math:`(out\\_features, in\\_features)`\n - Bias: :math:`(out\\_features)`\n - Output: :math:`(N, *, out\\_features)`\n \"\"\"\n if scale is None:\n scale = input.q_scale()\n if zero_point is None:\n zero_point = input.q_zero_point()\n _packed_params = torch.ops.quantized.linear_prepack(weight, bias)\n return torch.ops.quantized.linear(input, _packed_params, scale, zero_point)\n\nThen later the Queries, Keys and Values are split up into the individual Attention-Heads:\n #\n # reshape q, k, v for multihead attention and make em batch first\n #\n q = q.contiguous().view(tgt_len, bsz * num_heads, head_dim).transpose(0, 1)\n if static_k is None:\n k = k.contiguous().view(k.shape[0], bsz * num_heads, head_dim).transpose(0, 1)\n else:\n # TODO finish disentangling control flow so we don't do in-projections when statics are passed\n assert static_k.size(0) == bsz * num_heads, \\\n f\"expecting static_k.size(0) of {bsz * num_heads}, but got {static_k.size(0)}\"\n assert static_k.size(2) == head_dim, \\\n f\"expecting static_k.size(2) of {head_dim}, but got {static_k.size(2)}\"\n k = static_k\n if static_v is None:\n v = v.contiguous().view(v.shape[0], bsz * num_heads, head_dim).transpose(0, 1)\n else:\n # TODO finish disentangling control flow so we don't do in-projections when statics are passed\n assert static_v.size(0) == bsz * num_heads, \\\n f\"expecting static_v.size(0) of {bsz * num_heads}, but got {static_v.size(0)}\"\n assert static_v.size(2) == head_dim, \\\n f\"expecting static_v.size(2) of {head_dim}, but got {static_v.size(2)}\"\n v = static_v\n\nTherefore, it appears to me that both ways of calculations should be equal and the one using the bigger matrices is just more efficient to compute. Is this correct?\nIn this case, I ask myself why nn.MultiheadAttention requires that embed_dim is divisible by num_heads, since the split into the individual Attention-Heads is actually conducted after generating $Q,K,V$. Should then not $d_q,d_k,d_v$ be made to be divisible by num_heads? Since these dimensions do not have to be equal to the dimension of the inputs?\nThanks for any advice in advance!\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The queries, keys and values are calculated then chunked so that each chunk depends on (is a linear combination of) all values of the input embedding.\nAs for understanding an implementation, I didn't bother with pytorch but instead understood this code http://einops.rocks/pytorch-examples.html although there are differences as I understand that pytorch expects input in the form (L, N, C) where L=words, N=batch, C=embedding for performance reasons.\nTransformer's attention needs more attention\nclass MultiHeadAttentionNew(nn.Module):\n def __init__(self, n_head, d_model, d_k, d_v, dropout=0.1):\n super().__init__()\n self.n_head = n_head\n \n self.w_qs = nn.Linear(d_model, n_head * d_k)\n self.w_ks = nn.Linear(d_model, n_head * d_k)\n self.w_vs = nn.Linear(d_model, n_head * d_v)\n \n nn.init.normal_(self.w_qs.weight, mean=0, std=np.sqrt(2.0 / (d_model + d_k)))\n nn.init.normal_(self.w_ks.weight, mean=0, std=np.sqrt(2.0 / (d_model + d_k)))\n nn.init.normal_(self.w_vs.weight, mean=0, std=np.sqrt(2.0 / (d_model + d_v)))\n \n self.fc = nn.Linear(n_head * d_v, d_model)\n nn.init.xavier_normal_(self.fc.weight)\n self.dropout = nn.Dropout(p=dropout)\n self.layer_norm = nn.LayerNorm(d_model)\n\n def forward(self, q, k, v, mask=None):\n residual = q\n q = rearrange(self.w_qs(q), 'b l (head k) -> head b l k', head=self.n_head)\n k = rearrange(self.w_ks(k), 'b t (head k) -> head b t k', head=self.n_head)\n v = rearrange(self.w_vs(v), 'b t (head v) -> head b t v', head=self.n_head)\n attn = torch.einsum('hblk,hbtk->hblt', [q, k]) / np.sqrt(q.shape[-1])\n if mask is not None:\n attn = attn.masked_fill(mask[None], -np.inf)\n attn = torch.softmax(attn, dim=3)\n output = torch.einsum('hblt,hbtv->hblv', [attn, v])\n output = rearrange(output, 'head b l v -> b l (head v)')\n output = self.dropout(self.fc(output))\n output = self.layer_norm(output + residual)\n\nUnderstand MultiHeadAttentionNew first then understand MultiHeadAttentionOld, and then maybe look at the pytorch code.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between a loss function and reward/penalty in Deep Reinforcement Learning? In Deep Reinforcement Learning (DRL) I am having difficulties in understanding the difference between a Loss function, a reward/penalty and the integration of both in DRL.\n\nLoss function: Given an output of the model and the ground truth, it\nmeasures \"how good\" the output has been. And using it, the parameters\nof the model are adjusted. For instance, MAE. But if you were working\nin Computer Vision quality, you could use, for instance, SSIM.\n\nReward: Given an agent (a model) and an environment, once the agent\nperforms an action, the environment gives it a reward (or a penalty)\nto measure \"how good\" the action has been. Very simple rewards are +1\nor -1.\n\n\nSo I see both the loss function and the reward/penalty are the quantitative way of measuring the output/action and making the model to learn. Am I right?\nNow, as for DRL. I see the typical diagram where the agent is modelled using a Neural Network (NN).\n\nI am trying to interpret it, but I do not understand it.\nIs it the policy related the loss function somehow? Where is the loss function? How does the reward feed the NN? Is it a parameter for the loss function?\nMaybe my confusion has to do with identifying NN with supervised learning, or with not getting this with Q-learning or so.. Can anyone help?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "1. Question: The difference between loss and reward/penalty\n\nSo I see both the loss function and the reward/penalty are the quantitative way of measuring the output/action and making the model to learn. Am I right?\n\nYou are partially right:\nYou could interpret the negative reward as a loss that you want to minimize. But the model cannot learn from the reward directly. The reason for that is that you (usually) cannot formulate the reward as a differentiable function of the model parameters. Hence, you cannot compute a gradient purely from the reward. You need a second function - the loss - that is\n\nDifferentiable and\nDepends on the parameters inside your model.\n\nOnly then you can compute a gradient w.r.t. the model parameters and make the model learn. This already answers another question:\n\nIs it the policy related the loss function somehow?\n\nYes! The policy HAS to be a part of the loss function, otherwise you wouldn't be able to do gradient decent to optimize the model.\nA simple way to get from reward to the loss is implemented in the REINFORCE algorithm. To understand its loss term, you have to know that the model does not output definitive actions, but rather a probability distribution over all possible actions. Here is the loss function that REINFORCE uses to optimize the model:\n$loss = -log\\_likelihood(action) \\cdot return$\nAs you can see, the loss is the product of the negative log likelihood of the action and the $return$. The return correlates with the reward (Return is the discounted reward which distributes the reward received at timestep $t$ backwards to also reward actions that led to the reward). Intuitively this means that for a large reward, the model wants to be very certain about which action to take. So there you have it: The reward reflects how successful you are in the environment and the loss is the optimization objective maximizing the probability to take good actions.\n2. Question: The Schematic doesn't include the loss function\nThe image you posted depicts how you collect the data which you use to optimize the model. You would run this loop of taking an action and receiving a reward until you have a full batch of data. On this batch you would then compute the loss and update the model. It's quite important for reinforcement learning to gather batches and not use single steps for optimization, because otherwise the resulting gradient would be very noisy and in most cases prevent proper optimization.\nThe main issue why your gradient would be noisy is the credit assignment problem:\nLets assume the environment is a grid world and the task is to walk forward for 7 steps. You start at $S$ and you will get a reward as soon as you reach location $G$:\n\nThe reward will show you that you have done something right but multiple actions where responsible for getting the reward (not just the last step forward). However, you never exactly know which actions where the right actions and which actions where actually bad. You might have taken a very inefficient route to the goal.\nThe problem that you don't know which actions contributed to getting the reward is called the credit assignment problem. And in fact you can only have a good heuristic to assign the reward. This has to be compensated by computing the model update on batches rather than single steps. One such heuristic is the general advantage estimate. This is a function that you apply to your reward before plugging it into the loss function.\n\nMaybe my confusion has to do with identifying NN with supervised learning\n\nOne major difference of supervised learning and reinforcement learning lies in the credit assignment problem: In supervised learning you input a sample and you know what should come out. In RL you only have a rough estimate on how good you where but you will (usually) never know what should come out of your model, because there are multiple possible ways to reach the goal.\nHope this helps.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do the standard and deterministic Policy Gradient Theorems differ in their treatment of the derivatives of $R$ and the conditional probability? I would like to understand the difference between the standard policy gradient theorem and the deterministic policy gradient theorem. These two theorem are quite different, although the only difference is whether the policy function is deterministic or stochastic. I summarized the relevant steps of the theorems below. The policy function is $\\pi$ which has parameters $\\theta$.\nStandard Policy Gradient\n$$\n\\begin{aligned}\n\\dfrac{\\partial V}{\\partial \\theta} &= \\dfrac{\\partial}{\\partial \\theta} \\left[ \\sum_a \\pi(a|s) Q(a,s) \\right] \\\\\n&= \\sum_a \\left[ \\dfrac{\\partial \\pi(a|s)}{\\partial \\theta} Q(a,s) + \\pi(a|s) \\dfrac{\\partial Q(a,s)}{\\partial \\theta} \\right] \\\\\n&= \\sum_a \\left[ \\dfrac{\\partial \\pi(a|s)}{\\partial \\theta} Q(a,s) + \\pi(a|s) \\dfrac{\\partial}{\\partial \\theta} \\left[ R + \\sum_{s'} \\gamma p(s'|s,a) V(s') \\right] \\right] \\\\\n&= \\sum_a \\left[ \\dfrac{\\partial \\pi(a|s)}{\\partial \\theta} Q(a,s) + \\pi(a|s) \\gamma \\sum_{s'} p(s'|s,a) \\dfrac{\\partial V(s') }{\\partial \\theta} \\right]\n\\end{aligned}\n$$\nWhen one now expands next period's value function $V(s')$ again one can eventually reach the final policy gradient:\n$$\n\\dfrac{\\partial J}{\\partial \\theta} = \\sum_s \\rho(s) \\sum_a \\dfrac{\\pi(a|s)}{\\partial \\theta} Q(s,a)\n$$\nwith $\\rho$ being the stationary distribution. What I find particularly interesting is that there is no derivative of $R$ with respect to $\\theta$ and also not of the probability distribution $p(s'|s,a)$ with respect to $\\theta$. The derivation of the deterministic policy gradient theorem is different:\nDeterministic Policy Gradient Theorem\n$$\n\\begin{aligned}\n\\dfrac{\\partial V}{\\partial \\theta} &= \\dfrac{\\partial}{\\partial \\theta} Q(\\pi(s),s) \\\\\n&= \\dfrac{\\partial}{\\partial \\theta} \\left[ R(s, \\pi(s)) + \\gamma \\sum_{s'} p(s'|a,s) V(s') \\right] \\\\\n&= \\dfrac{R(s, a)}{\\partial a}\\dfrac{\\pi(s)}{\\partial \\theta} + \\dfrac{\\partial}{\\partial \\theta} \\left[\\gamma \\sum_{s'} p(s'|a,s) V(s') \\right] \\\\\n&= \\dfrac{R(s, a)}{\\partial a}\\dfrac{\\pi(s)}{\\partial \\theta} + \\gamma \\sum_{s'} \\left[p(s'|\\mu(s),s) \\dfrac{V(s')}{\\partial \\theta} + \\dfrac{\\pi(s)}{\\partial \\theta} \\dfrac{p(s'|s,a)}{\\partial a} V(s') \\right] \\\\\n&= \\dfrac{\\pi(s)}{\\partial \\theta} \\dfrac{\\partial}{\\partial a} \\left[ R(s, a) + p(s'|s,a) V(s') \\right] + \\gamma p(s'|\\pi(s),s) \\dfrac{V(s')}{\\partial \\theta} \\\\\n&= \\dfrac{\\pi(s)}{\\partial \\theta} \\dfrac{\\partial Q(s, a)}{\\partial a} + \\gamma p(s'|\\pi(s),s) \\dfrac{V(s')}{\\partial \\theta} \\\\\n\\end{aligned}\n$$\nAgain, one can obtain the finaly policy gradient by expanding next period's value function. The policy gradient is:\n$$\n\\dfrac{\\partial J}{\\partial \\theta} = \\sum_s \\rho(s) \\dfrac{\\pi(s)}{\\partial \\theta} \\dfrac{\\partial Q(s,a))}{\\partial a}\n$$\nIn contrast to the standard policy gradient, the equations contain derivatives of the reward function $R$ and the conditional probability $p(s'|s, a,)$ with respect to $a$.\nQuestion\nWhy do the two theorems differ in their treatment of the derivatives of $R$ and the conditional probability? Does determinism in the policy function make such a difference for the derivatives?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In the policy gradient theorem, we don't need to write $r$ as a function of $a$ because the only time we explicitly 'see' $r$ is when we are taking the expectation with respect to the policy. For the first couple lines of the PG theorem we have\n\\begin{align}\n\\nabla v_\\pi(s) &= \\nabla \\left[ \\sum_a \\pi(a|s) q_\\pi (s,a) \\right] \\;, \\\\ &= \\sum_a \\left[ \\nabla \\pi(a|s) q_\\pi(s,a) + \\pi(a|s) \\nabla\\sum_{s',r} p(s',r|s,a)(r+ v_\\pi(s')) \\right] \\; ;\n\\end{align}\nyou can see that we are taking expectation of $r$ with respect to the policy, so we don't need to write something like $r(s,\\pi(a|s))$ (especially because this notation doesn't really make sense for a stochastic policy). This is why we don't need to take the derivative of $r$ with respect to the policy parameters. Now, the next line of the PG theorem is\n$$\\nabla v_\\pi(s) = \\sum_a \\left[ \\nabla \\pi(a|s) q_\\pi(s,a) + \\pi(a|s)\\sum_{s'} p(s'|s,a) \\nabla v_\\pi(s') \\right] \\; ;$$\nso now we have an equation similar to the bellman equation in terms of the $\\nabla v_\\pi(s)$'s, so we can unroll this repeatedly meaning we never have to take an explicit derivative of the value function.\nFor the deterministic gradient, this is a bit different. In general we have\n$$v_\\pi(s) = \\mathbb{E}_\\pi[Q(s,a)] = \\sum_a \\pi(a|s) Q(s,a)\\;,$$\nso for a deterministic policy (denoted by $\\pi(s)$ which represents the action taken in state $s$) this becomes\n$$v_\\pi(s) = Q(s,\\pi(s))$$\nbecause the deterministic policy has 0 probability for all actions except one, where it has probability one.\nNow, in the deterministic policy gradient theorem we can write\n$$\\nabla v_\\pi(s) = \\nabla Q(s,\\pi(s)) = \\nabla \\left(r(s, \\pi(s)) + \\sum_{s'} p(s'|s,a)v(s') \\right)\\;.$$\nWe have to write $r$ explicitly as a function of $s,a$ now because we are not taking an expectation with respect to the actions because we have a deterministic policy. Now, if you replace where I have written $\\nabla$ with the notation you have used for the derivatives you will arrive at the same result and you'll see why you need to use the chain rule, which I believe you understand because your question was more why don't we use the chain rule for the normal policy gradient, which I have hopefully explained -- it is essentially because of how an expectation over the action space works with a deterministic policy vs. a stochastic policy.\nAnother way to think of this is as follows -- the term you're concerned with is obtained by expanding $\\nabla q_\\pi(s,a) = \\nabla \\sum_{s', r}p(s',r|s,a)(r(s,a) + v_\\pi(s'))$. Because, by definition of the $Q$ function, we have conditioned on knowing $a,s$ then $a$ is completely independent of the policy in this scenario - we could even condition on an action that the policy would have 0 probability for - thus the derivative of $r$ with respect to the policy parameters is 0.\nHowever, in the deterministic policy gradient we are taking $\\nabla q_\\pi(s, \\pi(s)) = \\nabla \\left(r(s, \\pi(s)) + \\sum_{s'} p(s'|s,a) v_\\pi(s')\\right)$ -- here $r$ clearly depends on the policy parameters because the action taken was the deterministic action given by the policy in the state $s$, thus the derivative wrt the policy parameters is not necessarily 0!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is the DQN loss derived from (or theoretically motivated by) the Bellman equation, and how is it related to the Q-learning update? I'm doing a project on Reinforcement Learning. I programmed an agent that uses DDQN. There are a lot of tutorials on that, so the code implementation was not that hard.\nHowever, I have problems understanding how one should come up with this kind of algorithms by starting from the Bellman equation, and I don't find a good understandable explanation addressing this derivation/path of reasoning.\nSo, my questions are:\n\nHow is the loss to train the DQN derived from (or theoretically motivated by) the Bellman equation?\nHow is it related to the usual Q-learning update?\n\nAccording to my current notes, the Bellman equation looks like this\n$$Q_{\\pi} (s,a) = \\sum_{s'} P_{ss'}^a (r_{s,a} + \\gamma \\sum_{a'} \\pi(a'|s') Q_{\\pi} (s',a')) \\label{1}\\tag{1} $$\nwhich, to my understanding, is a recursive expression that says:\nThe state-action pair gives a reward that is equal to the sum over all possible states $s'$ with the probability of getting to this state after taking action $a$ (denoted as $P_{ss'}^a$, which means the environment acts on the agent) times the reward the agent got from taking action $a$ in state $s$ + discounted sum of the probability of the different possible actions $a'$ times the reward of the state, action pair $s',a'$.\nThe Q-Learning iteration (intermediate step) is often denoted as:\n$$Q^{new}(s,a) \\leftarrow Q(s,a) + \\alpha (r + \\gamma \\max_a Q(s',a') - Q(s,a)) \\label{2}\\tag{2}$$\nwhich means that the new state, action reward is the old Q value + learning rate, $\\alpha$, times the temporal difference, $(r + \\gamma \\max_a Q(s',a') - Q(s,a))$, which consists of the actual reward the agent received + a discount factor times the Q function of this new state-action pair minus the old Q function.\nThe Bellman equation can be converted into an update rule because an algorithm that uses that update rule converges, as this answer states.\nIn the case of (D)DQN, $Q(s,a)$ is estimated by our NN that leads to an action $a$ and we receive $r$ and $s'$.\nThen we feed in $s$ as well as $s'$ into our NN (with Double DQN we feed them into different NNs). The $\\max_a Q(s',a')$ is performed on the output of our target network. This q-value is then multiplied with $\\gamma$ and $r$ is added to the product. Then this sum replaces the q-value from the other NN. Since this basic NN outputted $Q(s,a)$ but should have outputted $r + \\gamma \\max_a Q(s',a')$ we train the basic NN to change the weights, so that it would output closer to this temporal target difference.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The Bellman equation in RL is usually defined $$v_\\pi(s) = \\sum_a \\pi(a|s) \\sum_{s', r} p(s', r|s, a)\\left[r + v_\\pi(s')\\right] = \\mathbb{E}_{s' \\sim p, a \\sim \\pi}\\left[r(s, a) + v_\\pi(s')\\right] \\; .$$\nThe way you have written it is correct, but I just thought I would point this out. Regardless, your intuition is correct in that it expresses a recursive relationship such that the value of your current state $s$ is equal to the sum of the expected reward from this state plus the expected value of the state you transition into.\nYou do, in fact, implement the Q-learning update in Deep Q-Learning. The loss function that you minimise in DQN is\n$$ L(\\theta) = \\mathbb{E}_{(s,a,r,s')\\sim U(D)}\\left[\\left( r + \\gamma \\max_{a'}Q(s', a'; \\theta^-) - Q(s, a; \\theta)\\right)^2 \\right]\\;$$\nwhere $U(D)$ denotes uniformly at random from replay buffer $D$ and $\\theta$ are your network parameters (the network parameterises the Q-function), and $\\theta^-$ are a previous iteration of the parameters that are updated every $c$ episodes to help with convergence of the network.\nAs you can see, the loss function is minimising the 'Bellman error' error from your equation 2. Lets think about why this is.\nThe TD update you provide is gradually shifting the Q value for $(s, a)$ towards $r + \\max_a Q(s', a)$ - this is what we want after all since it eventually converges to the optimal Q-function.\nNow lets think about the Deep Q-learning case. We want our network to approximate $Q(s, a)$ and so if we train the network, using the MSE loss, with $r + \\max_a Q(s', a)$ as our target then our network will gradually be shifted towards predicting $r + \\max_aQ(s', a)$ (which again would give us optimal Q-values for state-action pairs), just like with the TD update.\nThis is assuming that you know how training of neural networks works so if you don't then I would recommend asking/searching for a relevant question that explains this.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is depth-first search an artificial intelligence algorithm? I'm new to the artificial intelligence field. In our first chapters, there is one topic called \"problem-solving by searching\". After searching for it on the internet, I found the depth-first search algorithm. The algorithm is easy to understand, but no one explains why this algorithm is included in the artificial intelligence study.\nWhere do we use it? What makes it an artificial intelligence algorithm? Is every search algorithm is an AI algorithm?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is a fundamentally a philosophical question. What makes AI AI? But first things, why would DFS be considered an AI algorithm?\nIn its most basic form, DFS is a very general algorithm that is applied to wildly different categories of problems: topological sorting, finding all the connected components in a graph, etc. It may be also used for searching. For instance, you could use DFS for finding a path in a 2D maze (although not necessarily the shortest one). Or you could use it to navigate through more abstract state spaces (e.g. between configuration of chess or in the towers of Hanoi). And this is where the connection to AI arises. DFS can be used on its own for navigating such spaces, or as a basic subroutine for more complex algorithms. I believe that in the book Artificial Intelligence: A Modern Approach (which you may be reading at the moment) they introduce DFS and Breadth-First Search this way, as a first milestone before reaching more complex algorithms like A*.\nNow, you may be wondering why such search algorithms should be considered AI. Here, I'm speculating, but maybe the source of the confusion comes from the fact that DFS does not learn anything. This is a common misconception among new AI practitioners. Not every AI technique has to revolve around learning. In other words, AI != Machine Learning. ML is one of the many subfields within AI. In fact, early AI (around the 50s-60s) was more about logic reasoning than it was about learning.\nAI is about making an artificial system behave \"intelligently\" in a given setting, whatever it takes to reach that intelligent behavior. If what it takes is applying well-known algorithms from computer science like DFS, then so be it. Now, what is it that intelligent means? This is where we enter more philosophical grounds. My interpretation is that \"intelligence\" is a broad term to define the large set of techniques that we use to approach the immense complexity that reality and certain puzzle-like problems have to offer. Often, \"intelligent behavior\" revolves around heuristics and proxy methods away from the perfect, provable algorithms that work elsewhere in computer science. While certain algorithms (like DFS or A*) may be proven to give optimal answers if infinitely many resources can be devoted to the task at hand, only in sufficiently constrained settings would such techniques be affordable. Fortunately, we can make them work in many situations (like A* for chess or for robot navigation, or Monte Carlo Tree Search for Go), but only if reasonable assumptions and constraints over the state space are imposed. For all the rest is where learning techniques (like Markov Random Fields for image segmentation, or Neural Nets paired with Reinforcement Learning for situated agents) may come handy.\nFunny enough, even if intelligence is often regarded as a good thing, my interpretation can be summed up as imperfect modes of behavior to address immensely complex problems for which no known perfect solution exists (with rare exceptions in sufficiently bounded problems). If we had a huge table that, for each chess position, gives the best possible move you can make, and put that table inside a program, would this program be intelligent? Maybe you'd think so, but in any case it seems more arguable than a program that makes real-time reasoning and spits a decision after some reasonable time, even if it's not the best one. Similarly, do you consider sorting algorithms intelligent? Again, the answer is arguable, but the fact is that algorithms exist with optimal time and memory complexities, we know that we can't do better than what those algorithms do, and we do not have to resort to any heuristic or any learning to do better (disclaimer: I haven't actually checked if there's some madman out in the wild applying learning to solve sorting with better average times).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the differences between transfer learning and meta learning? What are the differences between meta-learning and transfer learning?\nI have read 2 articles on Quora and TowardDataScience. \n\nMeta learning is a part of machine learning theory in which some\n algorithms are applied on meta data about the case to improve a\n machine learning process. The meta data includes properties about the\n algorithm used, learning task itself etc. Using the meta data, one can\n make a better decision of chosen learning algorithm(s) to solve the\n problem more efficiently.\n\nand\n\nTransfer learning aims at improving the process of learning new tasks\n using the experience gained by solving predecessor problems which are\n somewhat similar. In practice, most of the time, machine learning\n models are designed to accomplish a single task. However, as humans,\n we make use of our past experience for not only repeating the same\n task in the future but learning completely new tasks, too. That is, if\n the new problem that we try to solve is similar to a few of our past\n experiences, it becomes easier for us. Thus, for the purpose of using\n the same learning approach in Machine Learning, transfer learning\n comprises methods to transfer past experience of one or more source\n tasks and makes use of it to boost learning in a related target task.\n\nThe comparisons still confuse me as both seem to share a lot of similarities in terms of reusability. Meta-learning is said to be \"model agnostic\", yet it uses metadata (hyperparameters or weights) from previously learned tasks. It goes the same with transfer learning, as it may reuse partially a trained network to solve related tasks. I understand that there is a lot more to discuss, but, broadly speaking, I do not see so much difference between the two.\nPeople also use terms like \"meta-transfer learning\", which makes me think both types of learning have a strong connection with each other.\nI also found a similar question, but the answers seem not to agree with each other. For example, some may say that multi-task learning is a sub-category of transfer learning, others may not think so.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First of all, I would like to say that it is possible that these terms are used inconsistently, given that at least transfer learning, AFAIK, is a relatively new expression, so, the general trick is to take terminology, notation and definitions with a grain of salt. However, in this case, although it may sound confusing to you, all of the current descriptions on this page (in your question and the other answers) don't seem inconsistent with my knowledge. In fact, I think I had already roughly read some of the cited research papers (e.g. the MAML paper).\nRoughly speaking, although you can have formal definitions (e.g. the one in the MAML paper and also described in this answer), which may not be completely consistent across sources, meta-learning is about learning to learn or learning something that you usually don't directly learn (e.g. the hyperparameters), where learning is roughly a synonym for optimization. In fact, the meaning of the word \"meta\" in meta-learning is\n\ndenoting something of a higher or second-order kind\n\nFor example, in the context of training a neural network, you want to find a neural network that approximates a certain function (which is represented by the dataset). To do that, usually, you manually specify the optimizer, its parameters (e.g. the learning rate), the number of layers, etc. So, in this usual case, you will train a network (learn), but you will not know that the hyperparameters that you set are the most appropriate ones. So, in this case, training the neural network is the task of \"learning\". If you also want to learn the hyperparameters, then you will, in this sense, learn how to learn.\nThe concept of meta-learning is also common in reinforcement learning. For example, in the paper Metacontrol for Adaptive Imagination-Based Optimization, they even formalize the concept of a meta-Markov decision process. If you read the paper, which I did a long time ago, you will understand that they are talking about a higher-order MDP.\nTo conclude, in the context of machine learning, meta-learning usually refers to learning something that you usually don't learn in the standard problem or, as the definition of meta above suggests, to perform \"higher-order\" learning. \nTransfer learning is often used as a synonym for fine-tuning, although that's not always the case. For example, in this TensorFlow tutorial, transfer learning is used to refer to the scenario where you freeze (i.e. make the parameters non-trainable) the convolution layers of a model $M$ pre-trained on a dataset $A$, replace the pre-trained dense layers of model $M$ on dataset $A$ with new dense layers for the new tasks/dataset $B$, then retrain the new model, by adjusting the parameters of this new dense layer, on the new dataset $B$. There are also papers that differentiate the two (although I don't remember which ones now). If you use transfer learning as a synonym for fine-tuning, then, roughly speaking, transfer learning is to use a pre-trained model and then slightly retrain it (e.g. with a smaller learning rate) on a new but related task (to the task the pre-trained model was originally trained for), but you don't necessarily freeze any layers. So, in this case, fine-tuning (or transfer learning) means to tune the pre-trained model to the new dataset (or task).\nHow is transfer learning (as fine-tuning) and meta-learning different?\nMeta-learning is, in a way, about fine-tuning, but not exactly in the sense of transfer learning, but in the sense of hyperparameter optimization. Remember that I said that meta-learning can be about learning the parameters that you usually don't learn, i.e. the hyper-parameters? When you perform hyper-parameters optimization, people sometimes refer to it as fine-tuning. So, meta-learning is a way of performing hyperparameter optimization and thus fine-tuning, but not in the sense of transfer learning, which can be roughly thought of as retraining a pre-trained model but on a different task with a different dataset (with e.g. a smaller learning rate).\nTo conclude, take terminology, notation, and definitions with a grain of salt, even the ones in this answer.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What's a good resource for getting familiar with reinforcement learning? I am familiar with supervised and unsupervised learning. I did the SaaS course done by Andrew Ng on Coursera.org.\nI am looking for something similar for reinforcement learning.\nCan you recommend something?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "To the good answers here, I would add\n\nA brief overview of RL: Most essential concepts in one place.\nAnother brief overview, in presentation format.\nBen Recht's An outsider's tour of RL is pretty comprehensive and accessible.\nThe Bellman equations: central to the whole RL theory.\nPolicy gradients explained by Andrej Karpathy (mentioned in other answers as \"pong from pixels\", this is the link).\n\nThese barely scratch the surface of RL, but they should get you started.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can someone help me understand the intuition behind the query, key and value matrices in the transformer architecture? I have been working mechanically with transformers, hoping that with time clarity about what the query, key, and value matrices represent will develop; but I am still lost. Would greatly benefit from a simplified explanation.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Something I found helpful was \"Transformers for Software Engineers\" - unrolling the matrix multiplications into a funky functional program which maps over vectors.\nWe can follow this approach backwards and see the K, Q, V naturally emerge.\nI'm going to use pseudo-TypeScript and illustrate the residual stream as a JSON (I'll use the term \"residual\" to describe each individual element of the array, i.e. the original token plus any information we accumulate about that token in the context of the input):\nlet residualStream: Residual[] = [\n { \"token\": oneHot(\"Hello\"), position: oneHot(100) },\n { \"token\": oneHot(\"World\"), position: oneHot(101) },\n { \"token\": oneHot(\".\"), position: oneHot(102) },\n]\n\nOur goal is to add useful features to the residuals until we have so many that predicting the next word becomes trivial. We might end up with something like this by the end (requires the residual stream to be wide enough):\nresidualStream = [\n { \"token\": oneHot(\"Hello\"), position: oneHot(100), partOfSpeech: \"noun\", prevToken: oneHot(\".\"), lastMatchingPosition: oneHot(30), whatCameNextLastTime: oneHot(\"Everyone\"), ... },\n { \"token\": oneHot(\"World\"), position: oneHot(101), partOfSpeech: \"noun\", prevToken: oneHot(\"Hello\"), lastMatchingPosition: oneHot(50), whatCameNextLastTime: oneHot(\"!\"), ... },\n { \"token\": oneHot(\".\"), position: oneHot(102), partOfSpeech: \"noun\", prevToken: oneHot(\"World\"), lastMatchingPosition: oneHot(10), whatCameNextLastTime: oneHot(\"Bye\"), ... },\n]\n\nFeedforward layer is like vmapping a function of a single element:\ntype FeedForward = Residual => Residual\nlet feedforward: FeedForward\nconst applyFeedForward = residualStream => residualStream.map(feedforward)\nresidualStream = applyFeedForward(residualStream)\n\nAs you know, this is sufficient to calculate things like:\nconst getLengthOfToken: FeedForward = ({ token, ...rest }) =>\n ({ token, length: token.length(), ...rest })\n\nbut not something like\nconst getPreviousToken: FeedForward = ???\n\nsince the previous token is not derivable from the residual. So now we need to bust out the attention mechanism:\nconst getPreviousToken: AttentionHead\n\nand we'll see that it'll break down into K, Q, V like you asked. The first step is likely to be picking out the relevant info:\ntype WV = Residual => Value\nconst getTokenValue: WV = residual => residual.token\n\ntype WK = Residual => Key\nconst getTokenPosition: WK = residual => residual.position\n\nAnd the last step is likely to be storing the result back into the residual stream:\ntype WO = (res: Residual, z: Z) => Residual\n// assuming we've figured out `z`, which'll be the next part of this answer\nconst recordPreviousToken: WO = (res, z) => { ...res, prevToken: z }\n\nNote that these parts don't need to be nearly as wide as the residual stream, since they are just operating on specific features:\nK = [oneHot(100), oneHot(101), oneHot(102)]\nV = [oneHot(\"Hello\"), oneHot(\"World\"), oneHot(\".\")]\nZ = [oneHot(\"!\"), oneHot(\"Hello\"), oneHot(\"World\")]\n\nWhat's more is, we probably want to do as many of these small operations like getPreviousToken in parallel as possible. So this is where we get multi-head attention.\nNow we have found W_V, W_K, W_O, we only need to find W_Q now. Let's try to finish our function. We'll have to draw upon the defining feature of attention, which is: taking the residuals of the other tokens into account.\ntype AttentionHead = (residual: Residual, otherResiduals[]) => Value\nconst getPreviousTokenValue = (residual, otherResiduals[]) => (\n sum(otherResiduals.map(otherResidual =>\n getTokenValue(otherResidual) // W_V\n * scaledSoftmax( // handwaving this part; in reality this would apply over Q * K^T as a whole\n getTokenPosition(otherResidual) // W_K\n .dot(getPreviousTokenPosition(residual)) // we found W_Q!\n ))\n)\n\nWe found W_Q! It's:\ntype WQ = Residual => Query\nconst getPreviousTokenPosition = residual => shiftLeft(residual.position)\n\nTo recap:\n\nW_V gets a piece of info (\"value\") from each residual\nW_K positions (\"keys\") the residual in N-dimensional space in a way appropriate for the attention head's task\nW_Q looks (\"queries\") in N-dimensional space for other residuals relevant to the attention head's task\nW_O sums up the info/results (\"output\") and stores it back into the residual stream\n\nAs a final exercise, I challenge you to accomplish to challenge the attention head design; that is, can you accomplish the same thing with less than 3 \"reads\"? (3 is counting K, Q, V)\nI tried this and I concluded that the general way to express an arbitrary comparison of two vectors (in our case, residuals), is a bilinear form. And the way to speed that up so that it's not N_INPUT^2 * D_RESIDUAL is to perform a low-rank approximation, which is exactly what self-attention does by way of the dimension-reducing maps $W_K$ and $W_Q$ approximating a rank factorization $A = W_Q W_K^T$. But I believe the various \"fast attention\" algorithms each have a different take on this.\nBTW, the example I used is from \"In-Context Learning and Induction Heads\". Highly recommended reading for understanding how attention heads work. See if you can come up with similar pseudo-code as I did, but for the rest of the Induction Head circuit.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the major differences between multi-armed bandits and the other well-known algorithms (DQN, A3C, PPO, etc)? I have studied in the past different algorithms, i.e. DQN, DDQN, REINFORCE, A3C, PPO, TRPO, so on. I am doing an internship this summer where I have to use a multi-armed bandit (MAB). I am a bit confused between MAB and the other above algorithms.\nWhat are the major differences between MAB and REINFORCE, for instance? What are the major differences between MAB and the other well-known algorithms (DQN, A3C, PPO, etc)?\nEDIT\nThe @Kostya's answer is fine, but it would be interested for me to have a deeper answer for that question. I am still a bit confused.\nQuestion: Do we use the Markov Reward formula $$G_t = R_{t+1} + \\gamma R_{t+2} + ... = \\sum_{k=0}^{\\infty} \\gamma^k R_{t+k+1}$$ the same way in a Multi-Armed bandit problem versus a DQN problem?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You should start with the general definition of Reinforcement Learning problem. And what Markov Decision Process is.\nDQN, A3C, PPO and REINFORCE are algorithms for solving reinforcement learning problems. These algorithms have their strengths and weaknesses depending on the details of the underlying problem.\nMulti-Armed Bandit is not even an algorithm - it is a subclass of reinforcement learning problems, where your environment (usually) doesn't have any state transitions and your actions are just a single choice from (usually) fixed and finite set of choices.\nMulti-Armed Bandit is used as an introductory problem to reinforcement learning, because it illustrates some basic concepts in the field: exploration-exploitation tradeoff, policy, target an estimate, learning rate and gradient optimization. All these concepts are basic vocabulary in RL. I recommend reading (and, very importantly, doing all the exercises) the Sutton and Barto book chapter two to get familiarized with it.\nEdit: since the answer got popular, I'll address the comments and the question edit.\nBeing a special simplified subset of Markov Decision Processes, Multi Armed Bandit problems allow deeper theoretical understanding. For example, (as per @NeilSlater comment) the optimal policy would be to always go for the best arm. So it makes sense to introduce \"regret\" $\\rho$ - the difference between a potential optimal reward and the actual collected reward by agent following your strategy:\n$$\\rho(T) = \\mathbb{E}\\left[T\\mu^* -\\sum_{t=1}^T\\mu(a_t)\\right]$$\nOne can then study asymptotic behavior of this regret as a function of $T$ and devise strategies with different asymptotic properties. As you can see, the reward here is not discounted ($\\gamma=1$) - we usually can study the behavior of it as a function of $T$ without this regularization.\nAlthough, there is one famous result that uses discounted rewards - the Gittins index policy (note, though, that they use $\\beta$ instead of $\\gamma$ to denote the factor).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why most imperfect information games usually use non machine learning AI? To provide a bit of context, I'm a software engineer & game enthusiast (card games, especially). The thing is I've always been interested in AI oriented to games. In college, I programmed my own Gomoku AI, so I'm a bit familiar with the basic concepts of AI applied to games and have read books & articles about Game Theory as well.\nMy issue comes when I try to analyze AI's for Imperfect Information games like (Poker, Magic the gathering, Hearthstone, etc). In most cases, when I found an AI for Hearthstone, it was either some sort of Monte Carlo or MinMax strategy. I honestly think, although it might even provide some decent results, it will still be always quite flat and linear, since it doesn't take into account what deck the opponent is playing and almost always tries to follow the same game-plan, since it will not change based on tells your opponent might give away via cards played (a hint that a human would catch).\nI would like to know if using Neural Networks would be better than just using a raw evaluation of board state + hands + Hp each turn without taking into account learning about possible threads the opponent might have, how to deny the opponent the best plays he could make, etc.\nMy intuition tells me that this is way harder and far more complex.\nIs that the only reason the NN method is not used? Has there been any research to prove how much efficiency edge would be between those 2 approaches?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A heuristic search using MCTS + minimax + alphabeta pruning is a highly efficient AI planning process. What the AI techniques of reinforcement learning (RL) plus neural networks (NNs) typically add to this is a way to establish better heuristics.\n\nMy intuition tells me that this is way harder and far more complex. \n\nIt's not actually that much more complex in concept. Replace the hand-coded heuristic with a learning engine, e.g. DQN or AC3. Train the learning engine from human expert play examples and/or from self play.\nIt is harder though, because there are many things that can go wrong with an NN-based estimator in a RL context. You will need to make many experiments with different hyper-parameters of the learning engine. For complex games, you may have to invest many 100s of hours of training, which you might want to compare against the end result of a similar amount of time spent refining expert heuristic systems.\nFor imperfect information games, you may also want to use something that can learn an internal state representation. That could be some kind of explicit belief state that you maintain like an expert system, or something that attempts to learn a good representation, such as an RNN (e.g. LSTM). This may not be necessary for a first try at an agent though, since the MCTS search will make up for some inadequacies of low accuracy heuristics.\n\nIs that the only reason the NN method is not used?\n\nUp until quite recently, approaches using RL and NN were far harder to find examples of outside of academic machine learning research, and there were not any pre-written frameworks for LSTM or e.g. AC3. In the last few years, RL and NN frameworks have started to appear making an AI self-learning approach far more approachable. \nI would expect that many hobby-level coders considering game-playing AI nowadays would seriously take a look at RL and NNs in order to learn robust heuristics for their game projects. However, the \"traditional\" search-based methods still work in conjunction with these for a completed agent. \n\nHas there been any research to prove how much efficiency edge would be between those 2 approaches?\n\nFor card games, I am not aware of any specific research, although I am just a hobbyist, yet to write any specific game engine more complex than tic-tac-toe.\nFor perfect information board games, the chess playing variant of AlphaZero demonstrates applicability of RL+NN self-play approach versus \"traditional\" heuristics plus search (represented by Stockfish). However, the framing of the tournament has been criticised as unfair to Stockfish, so it is not necessarily an open-and-shut case that RL is strictly better.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can AI stop attacks like WannaCry? I have done some research regarding the application of machine learning to cyber-security. After these recent attacks (like WannaCry), I think that AI-based cyber defense can prevent them. I have also read about research regarding the same in MIT, and that AI can detect more than 80% of malware. Is AI actually so promising in this department?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are projects out there attempting to apply Machine Learning / AI to cyber-security in different ways. One that I'm familiar with is Apache Metron. Another related project is Apache Spot. I think if you read over the docs for these two projects respectively, they will probably give you some good insights on this subject.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What do symmetric weights mean and how does it make backpropagation biologically implausible? I was reading a paper on alternatives to backpropagation as a learning algorithm in neural networks. In this paper, the author talks about the disadvantages of backpropagation, and one of the disadvantages stated is that backpropagation requires symmetric weights and that's why it's not biologically plausible.\nWhat do symmetric weights mean and how does it make backpropagation biologically implausible?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\"Symmetric weights\" means that the same weight value associated to a pair of nodes must be used during the forwards and backwards steps.\nThe reason it makes back propagation biologically impossible in its naive formulation is that neurons fire electrical signals in only one direction, from the dendrite through the axon to other dendrites of other neurons. They do receive of course \"backwards\" feedback, but by other means, e.g. chemical neurotransmitters or other signals from other neurons, but these signals are very likely not of the same intensity as the signal emitted by the neurons themselves (i.e. no symmetry).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is k-fold cross-validation more effective than splitting the dataset into training and test datasets to prevent overfitting? I want to prevent my model from overfitting. I think that k-fold cross-validation (because it is doing this each time with different datasets) may be more effective than splitting the dataset into training and test datasets to prevent overfitting, but a colleague (who has little experience in ML) says that, to prevent overfitting, the 70/30% split performs better than the k-fold cross-validation. In my opinion, k-fold cross-validation provides a reliable method to test the model performance.\nIs k-fold cross-validation more effective than splitting the dataset into training and test datasets to prevent overfitting? I am not concerned with computational resources.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "K-fold cross-validation is probably preferred in terms of completeness and generalization: you ensure that the system has seen the complete dataset for training. However, in deep learning this is often not feasible due to time and power constraints. They can both be used, and there is not one better than the other. It really depends on the specific case, the size of the dataset and the time and hardware available. Note that overfitting can be (partially) remedied by things such as dropout.\nTo be fair: it is fine to have a discussion about this with your colleagues, but as so often there is no one correct answer. If you really want proof, you can test it out and compare them. But performance-wise (i.e. the model's predictive power), the difference will be small.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there a proof to explain why XOR cannot be linearly separable? Can someone explain to me with a proof or example why you can't linearly separate XOR (and therefore need a neural network, the context I'm looking at it in)?\nI understand why it's not linearly separable if you draw it graphically (e.g. here), but I can't seem to find a formal proof somewhere, I wanted to try and understand it with either an equation or example written down. I'm wondering if one exists (I guess it has to do with contradictions?), but I can't seem to find it? I have seen this, but it's more a reason than a proof.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Before proving that XOR cannot be linearly separable, we first need to prove a lemma:\nLemma 1\nLemma: If 3 points are collinear and the middle point has a different label than the other two, then these 3 points cannot be linearly separable.\n\nProof: Let us label the points as point $A$, $B$, and $C$. $A$ and $C$ have the same label, and $B$ has a different label. They are all collinear with line $\\mathcal{L}$.\nAssume the contradiction, so a line can linearly separate $A$, $B$, and $C$. This means a line must cross between segment $AB$, and segment $BC$ to linearly separate these three points (by definition of linear separability). Let us label the point where the line crosses segment $AB$ and point $Y$, and the point where the line corsses segment $BC$ and point $Z$.\nHowever, since segments $AB$ and $BC$ are collinear to line $\\mathcal{L}$, points $Y$ and $Z$ also falls on line $\\mathcal{L}$. Since only one unique line can cross 2 points, it must be that the only line that passes segments $AB$ and $BC$ and (therefore separates points $A$, $B$, and $C$) is line $\\mathcal{L}$.\nHowever, line $\\mathcal{L}$ cannot linearly separate $A$, $B$, and $C$, since line $\\mathcal{L}$ also crosses them. Therefore, no line exists can separate $A$, $B$, and $C$.\nMain proof\n\nConsider these 4 points that represent a XOR table. Let us label them clock-wise, so the top-left point as $A$, top-right point as $B$, bottom-right point as $C$, and bottom-left point as $D$. So $A$ and $C$ have the same label, and $B$ and $D$ have the same label. We want to show that points $A, B, C$ and $D$ cannot be linearly separable.\nAssume the contradiction, and that there is a line that can separate these 4 points.\nImagine a fifth point that lies in the center, and let us label this as point $E$.\nSince $E$ lies in the center, the three points $A, E$ and $C$ are collinear. Similarly, since $E$ lies in the center, the three points $B, E$ and $D$ are collinear.\nBecause we assume a line can linearly separate $A, B, C$ and $D$, then this line must label point $E$ as some label. If $E$ shares the same label as $A$ and $C$, then the points $B, E$ and $D$ will become \"collinear points where the middle point has a different label\", which by Lemma 1 cannot be linearly separable. Likewise, if $E$ shares the same label as $B$ and $D$, then the points $A, E$ and $C$ will become \"collinear points where the middle point has a different label\", which by Lemma 1 cannot be linearly separable.\nTherefore it is impossible to give a label to $E$ while satisfying linear separability. As a result, our assumption must be false, and the four points $A, B, C$ and $D$ cannot be linearly separable.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is the gradient calculated for the middle layer's weights? I am trying to understand backpropagation. I used a simple neural network with one input $x$, one hidden layer $h$ and one output layer $y$, with weight $w_1$ connecting $x$ to $h$, and $w_2$ connecting $h$ to $y$\n$$\nx \\rightarrow (w_1) \\rightarrow h \\rightarrow (w_2) \\rightarrow y\n$$\nIn my understanding, these are the steps happening while we train a neural network:\nThe feedforward step.\n\\begin{align}\nh=\\sigma\\left(x w_{1}+b\\right)\\\\\ny^{\\prime}=\\sigma\\left(h w_{2}+b\\right)\n\\end{align}\nThe loss function.\n$$\nL=\\frac{1}{2} \\sum\\left(y-y^{\\prime}\\right)^{2}\n$$\nThe gradient calculation\n$$\\frac{\\partial L}{\\partial w_{2}}=\\frac{\\partial y^{\\prime}}{\\partial w_{2}} \\frac{\\partial L}{\\partial y^{\\prime}}$$\n$$\\frac{\\partial L}{\\partial w_{1}}=?$$\nThe weight update\n$$\nw_{i}^{t+1} \\leftarrow w_{i}^{t}-\\alpha \\frac{\\partial L}{\\partial w_{i}}\n$$\nI understood most parts of backpropagation, but how do we get the gradients for the middle layer weights $dL/dw_1$?\nHow should we calculate the gradient of a network similar to this?\n\nIs this the correct equation?\n$$\\frac{\\partial L}{\\partial w_{1}}=\\frac{\\partial h_{1}}{\\partial w_{1}} \\frac{\\partial w_{7}}{\\partial h_{1}} \\frac{\\partial o_{2}}{\\partial w_{7}} \\frac{\\partial L}{\\partial o_{2}}+\\frac{\\partial h_{1}}{\\partial w_{1}} \\frac{\\partial w_{5}}{\\partial h_{1}} \\frac{\\partial o_{1}}{\\partial w_{5}} \\frac{\\partial L}{\\partial o_{1}}$$\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The main doubt here is about the intuition behind the derivative part of back-propagation learning. First, I would like to point out 2 links about the intuition about how partial derivatives work Chain Rule Intuition and Intuitive reasoning behind the Chain Rule in multiple variables?.\nNow that we know how the chain rule works, let's see how we can use it in Machine Learning. So basically in machine learning, the final output is a function of input variables and the connection weights \n$f\\left(x_1, x_2, \\ldots, x_n, w_1, w_2, \\ldots, w_n\\right)$, where $f$ encloses all the activation functions and dot products lying between input and output. The $x_1, x_2, \\ldots, x_n, w_1, w_2, \\ldots, w_n$ are called independent variables because they don't affect each other pairwise as well as in groups meaning you cannot find a function $g(x_i, \\dots, w_i, \\dots) = h(x_j, \\dots, w_j, \\dots)$. So, basically its a black box from input to output.\n\nSo now our purpose is to minimize the Loss/Cost function, by changing the parameters that can be 'controlled by us' i.e the weights only, we cannot change the input variables. So this is done by taking the derivative of the cost function w.r.t to the variable that 'can be changed'. Here is an explanation of why taking derivative and subsequently subtracting it reduces the value of cost function given by the 'maximal' amount. Also here.\nNow, to calculate $dL/dw_n$ you have to keep few things in mind:\n\nOnly differentiate $L$ w.r.t to those functions which affect $L$.\nAnd to reach your end goal of differentiation w.r.t to an independent variable you must differentiate $L$ w.r.t to those functions only which are dependent on that particular independent variable.\n\nA crude algorithm assuming $L$ also as a normal function (along the lines of activation function, so that I can express the idea recursively) differentiate $f_n$ w.r.t to functions in the previous layer say $f_{n-1}$, $f_{n-2}$, $w_n$. Check which of these functions depends on $w_1$. Only $f_{n-1}$ and $f_{n-2}$ do. Differentiate them again w.r.t to previous layer functions. Check again and go on till you reach $w_1$.\nThis approach is the fool-proof version, but it has 2 flaws:\n\nFirst, $w_n$ is not a function. People are making this mistake of assuming $w_n$ to be a function due to misinterpretation of a simple NN diagram. To reach $w_1$, you don't need to go through $w_n$. But you definitely need to go through the activation functions and dot products. Think of this as painting a wall where color mixing occurs (not over-writing). So you paint the wall with some color (weights) then 2nd color and so on. Is the final product affected by color 1. Yes. Is the 'rate of change' caused by color 1 also affected by color 2. Yes. But does it mean we can find the 'change'of color n w.r.t to color 1? No its meaningless (bad example, couldn't think of a better one)\nThe second flaw is that this approach is not followed because with experience it is apparent which function affects whom and which independent variable affects which function (saves computation).\n\nTo answer your question the equation is incorrect and the correct equation will be:\n$$\n\\frac{\\partial L}{\\partial w_{1}}=\\frac{\\partial h_{1}}{\\partial w_{1}} \\frac{\\partial o_{2}}{\\partial h_{1}} \\frac{\\partial L}{\\partial o_{2}}+\\frac{\\partial h_{1}}{\\partial w_{1}} \\frac{\\partial o_{1}}{\\partial h_{1}} \\frac{\\partial L}{\\partial o_{1}}\n$$\nI have simply followed the algorithm I have given above.\nAs for why your equation is wrong, your equation contains the term $dw7/dh1$. Does $w_7$ vary with $h_1$? This means that $w_7$ is directly related to the input as $h_1$ is related with the input, but this is not the case for a single iteration(the whole algorithm run makes $w_n$ dependent on the inputs since you are trying to minimize the loss function w.r.t given inputs and weights, for a different set of inputs you will have different final weights).\nSo, in a nutshell, the aim of back-propagation is to identify the change in the loss function w.r.t to a given weight. To calculate that, you have to make sure in the chain rule of derivative you don't have any meaningless terms like the derivative of an independent variable w.r.t to any function. I recommend checking Khan Academy for a better understanding and clarity in concepts as I think the intuitions are hard to provide in a written answer.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does this multiplication of $Q$ and $K$ have a variance of $d_k$, in scaled dot product attention? In scaled dot product attention, we scale our outputs by dividing the dot product by the square root of the dimensionality of the matrix:\n\nThe reason why is stated that this constrains the distribution of the weights of the output to have a standard deviation of 1.\nQuoted from Transformer model for language understanding | TensorFlow:\n\nFor example, consider that $Q$ and $K$ have a mean of 0 and variance of 1. Their matrix multiplication will have a mean of 0 and variance of $d_k$. Hence, square root of $d_k$ is used for scaling (and not any other number) because the matmul of $Q$ and $K$ should have a mean of 0 and variance of 1, and you get a gentler softmax.\n\nWhy does this multiplication have a variance of $d_k$?\nIf I understand this, I will then understand why dividing by $\\sqrt({d_k})$ would normalize to 1.\nTrying this experiment on 2x2 arrays I get an output of 1.6 variance:\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In statistics, if $X$ and $Y$ are independent and randomly distributed variables:\n$\\mathbb{E}[X + Y] = \\mathbb{E}[X] + \\mathbb{E}[Y] \\\\\nVar(X + Y) = Var(X) + Var(Y) \\\\\n\\mathbb{E}[XY] = \\mathbb{E}[X]\\mathbb{E}[Y] \\\\\nVar(XY) = (Var(X) + \\mathbb{E}[X]^2)(Var(Y) + \\mathbb{E}[Y]^2) - \\mathbb{E}[X]^2\\mathbb{E}[Y]^2$\nLet $Q$ and $K$ be random $d_k$ x $d_k$ matrices, where each entry is a some random distribution with $0$ mean and $1$ variance. Every entry is independent from each other.\nSince each entry of $Q$ and $K$ have identical distribution, we can focus only on the top-left-most element of $QK$ without loss of generality. The same applies to every other element.\nThe top-left-most element of $QK$ is $\\displaystyle \\sum_{i=0}^{d_k} Q_{1,i} K_{i, 1}$.\nSince $Q$ and $K$ are independent:\n$\\mathbb{E}[Q_{1, i} K_{i, 1}] = \\mathbb{E}[Q_{1, i}] \\mathbb{E}[K_{i, 1}] = 0 \\\\\nVar(Q_{1, i} K_{i, 1}) = (Var(Q_{1, i}) + \\mathbb{E}[Q_{1, i}]^2)(Var(K_{i, 1}) + \\mathbb{E}[K_{i, 1}]^2) - \\mathbb{E}[Q_{1, i}]^2\\mathbb{E}[K_{i, 1}]^2 = 1$\nAnd so summing up $d_k$ of them:\n$\\mathbb{E} \\left[\\displaystyle \\sum_{i=0}^{d_k} Q_{1,i} K_{i, 1} \\right] = \\displaystyle \\sum_{i=0}^{d_k} \\mathbb{E} \\left[ Q_{1,i} K_{i, 1} \\right] = 0 \\\\\nVar\\left(\\displaystyle \\sum_{i=0}^{d_k} Q_{1,i} K_{i, 1} \\right) = \\displaystyle \\sum_{i=0}^{d_k} Var\\left( Q_{1,i} K_{i, 1} \\right) = d_k$\nFor your code block, you are computing the dot product of matrices $a$ and $b$, when you should be doing a matrix multiplication (the attention function multiplies $Q$ by $K$ after all, which is the vectorized form of dot-product -- it doesn't actually do dot product). It should work out to unit variance.\nedit: the last paragraph is incorrect, as dot is the same as matrix multiply in the above case\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the best measure for detecting overfitting? I wanted to ask about the methodology of testing the ML models against overfitting. Please note that I don't mean any overfitting reducing methods like regularisation, just a measure to judge whether a model has overfitting problems. \nI am currently developing a framework for tuning models (features, hyperparameters) based on evolutionary algorithms. And the problem that I face is the lack of a good method to judge if the model overfits before using the test set. I encountered the cases where the model that was good on both training and validation sets, behaved poorly on the test set for both randomized and not randomized training and validation splits. I used k-fold cross-validation with additionally estimating the standard deviation of all folds results (the smaller deviation means better model), but, still, it doesn't work as expected. \nSumming up, I usually don't see a correlation (or a very poor one) between training, validation and k-fold errors with test errors. In other words, tuning the model to obtain lower values of any of the above mentioned measures usually does not mean lowering the test error.\nCould I ask you, how in practice you test your models? And maybe there are some new methods not mentioned in typical ML books?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "tl;dr\nThe safest method I've found is to use cross-validation for hyperparameter selection and a hold-out test set for a final evaluation.\nWhy this isn't working for you...\nIn your case, I suspect you're either running a large number of iterations during for hyperparameter selection or you have a fairly small dataset (or even a combination of both). If you can't find more data or use a larger dataset, I'd suggest limiting the exhaustiveness of your hyperparameter selection phase. If you run the process enough times the model is bound to overfit on the validation sets.\nNote that there is no guaranteed safe way of detecting overfitting before the test set!\nWhy I consider this strategy to be the safest\nThere are two different types of overfitting you need to be able to detect.\nThe first is the most straightforward: overfitting on the training set. This means that the model has memorized the training set and can't generalize beyond that. If the test set even slightly differs from the training set (which is the case in most real-world problems), then the model will perform worse on it than on the training set. This is simple to detect and, in fact, the only thing you need to catch this is a test set!\nThe second type of overfitting you need to detect is on the test set. Imagine you have a model and you make an exhaustive hyperparameter selection using a test set. Then you evaluate on the same test set. By doing this, you have adjusted your hyperparameters to achieve the best score for the specific test set. These hyperparameters are thus overfitting to that test set, even though the samples from that set were never seen during training. This is possible, because, during the iterative hyperparameter selection process, you have passed information about your test set to your model!\nThis is much harder to detect. In fact, the only way to do so is to split the original data into three parts: the training, the validation and the test sets. The first is used for training the model, the second for hyperparameter selection, and the final is used only once for a final evaluation. If your model has overfitted (i.e. test performance is worse than training and validation), you need to start from scratch. Shuffle your data, split it again and repeat the process. This is usually referred to as a hold-out strategy.\nTo make the model even less prone to overfitting, you can use cross-validation instead of a hold-out validation set. Because your model now has to be trained on $k$ slightly different training sets and evaluated on $k$ completely different validation sets, it is much harder for it to overfit on the validation sets (because it needs to fool $k$ different validation sets instead of one).\nCases where this might not be applicable\nDepending on the circumstances, it might not be practical to apply both of these techniques.\n\nCross-validation is pretty robust regarding overfitting but it imposes a computational burden to your process as it requires multiple trainings of the same model. This obviously isn't practical for computationally expensive models (e.g. image classifiers). In this case, use a hold-out strategy as mentioned previously.\n\nUsing a hold-out test set means that you are reducing the size of your training set, which might actually make your model more prone to overfitting (i.e. have a higher-variance) for small datasets. In this case (if your model is practically untrainable due to the small size) you can resort to cross-validation, but you risk overfitting on the validation set and not having any way to detect it.\n\n\nHow to combat overfitting\nSince it is fairly related, I'll post a link to an answer on how to combat overfitting.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to solve the problem of too big activations when using genetic algorithms to train neural networks? I am trying to create a fixed-topology MLP from scratch (with C#), which can solve some simple problems, such as the XOR problem and MNIST classification. The network will be trained purely with genetic algorithms instead of back-propagation.\nHere are the details:\n\nPopulation size: 50\nActivation function: sigmoid\nFixed topology\nXOR: 2 inputs, 1 output. Tested with different numbers of hidden layers/nodes.\nMNIST: $28*28=784$ inputs for all pixels, will be either ON(1) or OFF(0). 10 outputs to represent digits 0-9\nInitial population will be given random weights between 0 and 1\n10 \"Fittest\" networks survive each iteration, and performs crossover to reproduce 40 offspring\nFor all weights, mutation occurs to add a random value between -1 to 1, with a 5% chance\n\nWith 2 hidden layers of 4 and 3 neurons respectively, XOR managed to achieve 97-99.9% accuracy in around 100 generations. Biases were not used here.\nHowever, trying out MNIST revealed a pretty glaring issue - the 784 inputs; a large increase of nodes compared to XOR, multiplied with weights and added up results in HUGE values of 50 to even 100, way beyond the typical domain range of the activation function (sigmoid).\nThis just renders all layers' outputs as 1 or 0.99999-something, which breaks the entire network. Also, since this makes all individuals in a population extremely similar to one other, the genetic algorithm seems to have no clue on how to improve. The crossover will produce an offspring almost identical to its parents, and some lucky mutations are simply ignored by the sheer amount of other neurons!\nWhat can be a viable solution to this?\nIt's my first time studying NNs, and this is really challenging.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Your inputs should stay in a low range. Ideally for neural networks, the inputs are normalised to mean 0, standard deviation 1. I suspect this applies equally well to GA-driven NNs as gradient-driven ones.\nYour weights should be both positive and negative.\nIn addition, once trained, they tend to follow a certain size distribution. It helps if you start with values within that range. This is often called Xavier or Glorot initialisation. Basically, if your number of inputs to a layer is n_inputs and number of outputs is n_outputs, you will have n_inputs * n_outputs weights, and if you initialise them with a random number generator, then you should use a multiplier something like this:\nw = (rand() - 0.5) * sqrt(6/(n_inputs + n_outputs))\n\nNote that is an addition inside the square root, you don't take the total number of weights.\nAs you are using a GA, you may want to use some form of clipping or normalisation to prevent mutations from drifting too far away from these useful weights. I'm not entirely sure what would be best, as usually I would use back propagation to train a large network. Potentially a maxnorm regularisation would help - choose a value (maybe even make it adjustable via mutation) that the norm of weight matrix in each layer should not exceed (separately for each layer, or one overall value, up to you), and if any learning step creates a network with too high a norm, scale it down. The L2 norm, sqrt(sum_of_squared_weights) is usual choice for maxnorm regularisation, and this works well with backpropagation-based supervised learning.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do LLM tokenizers use a special symbol for space such as \u0120 in BPE or \u2581 in SPM? Popular tokenizers use a special symbol such as \"\u0120\" (BPE) or \"\u2581\" (SentencePiece) to represent space. What is the reasoning behind this?\nI did try searching for the answer. I got two types of explanations, but they don't explain anything to me.\nSome languages such as Japanese don't typically use space to separate words.\nThat's true, but tokenizing such a language won't make use of the special character as well. I don't understand how having a token as \"\u0120horse\" is any different from \" horse\" in this scenario.\nLet's assume we want to tokenize the made-up laguage Spaceless English, which is English, but without whitespace. tokenize(\"I'mridingahorse\") -> [\"I'm\", \"riding\", \"ahorse\"]. No need for spaces at all, let alone a special character.\nIn fact this seems like it would be in favor of using a plain space as opposed to a special symbol.\nSome tokens have a space in them and this helps us differentiate between spaces in the original text and spaces in the tokens\nFor example \"New York\" might be a token.\nThis kinda makes sense, but I still don't quite get why we would ever need this distinction. How is \"\u0120New York\" different from \" New York\"? \" New York\" is still different from [\" New\", \" Toronto\"]. A tokenizer would employ some kind of a greedy algorithm to tokenize text... and even if it's not greedy, but the full NP-complete search, it would still tokenize \"I'm going to New York\" as [\"I'm\", \" going\", \" to\", \" New York\"], the same way as we would expect it to tokenize \"extracurricular\" to say [\"extra\", \"curricul\", \"ar\"] and not to [\"ex\", \"trac\", \"u\", \"rr\", \"ic\", \"u\", \"lar\"], and the same way as we would expect it to work on Spaceless English.\nNote that I'm looking at the problem only through the lens of converting text to tokens and tokens to text. Perhaps the need for these character has to do with creating the token list based on the training corpus?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I'm over a year late, but I figured I'd give you an answer anyway. It's not what you proposed, though.\n\nThe reason we don't want spaces in subword types (i.e. the strings in the vocabulary; they're only called \"tokens\" when you segment a text using the vocabulary) is for the historical reason that the paper that popularised subword tokenisers for NLP was Sennrich et al. (2016), which proposed repurposing the BPE compression algorithm as a tokenisation algorithm. BPE learns binary token merges (t1,t2) -> t1 + t2 and the way Sennrich stored these merges on disk was in a merges.txt file where every line represented one merge, encoded as the left type, SPACE, the right type, NEWLINE. So, to parse this file, there can be no spaces nor newlines in the types of the vocabulary. Sennrich et al.'s preprocessor already took care of this, so they didn't have to worry about this.\n\nThe reason that \u0120 represents a space is somewhat coincidental. Radford et al. (2019) realised that using Unicode characters for GPT-2's alphabet was a bad idea because even just limiting Unicode to actual alphabets would inflate the vocabulary. So instead, they used the 256 possible bytes as alphabet, and thus converted text to its UTF-8 bytes before applying BPE. Now, to store that BPE tokeniser to disk, they wanted the vocabulary (and, for BPE tokenisers, the merges) to be interpretable to humans, so they wanted to save it as characters and not bytes. This gave two problems: (1) bytes like byte 32 represent a space, which can't be converted as-is for the reason above, and (2) some other bytes don't correspond to any character at all, so they can't be rendered like regular characters. Their solution: map every such problematic character to the next unproblematic Unicode character after 256. That's how space (byte 32) became \u0120 (codepoint 288 == 256 + 32) and e.g. byte 31 became \u011f (codepoint 287 == 256 + 31) and so on.\n\n\nAs for the long underscore (\u2581) in SentencePiece: this is actually hardcoded all across the package, rather than being an algorithmic coincidence. It's just because Taku Kudo needed a replacement character for spaces (again, for the reason above) and liked how \u2581 looked.\nP.S.: SentencePiece is a software package. It implements two subword tokenisers: BPE and ULM. BPE tokenisers trained with SentencePiece, which is the most frequently used implementation of BPE training, still use \u2581 because (1) it is hardcoded in the package and (2) SentencePiece uses a character alphabet rather than using a byte mapping.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which artificial neural network can mimic biological neurons the most? On the Wikipedia page we can read the basic structure of an artificial neuron (a model of biological neurons) which consist:\n\nDendrites - acts as the input vector,\nSoma - acts as the summation function,\nAxon - gets its signal from the summation behavior which occurs inside the soma.\n\nI've checked deep learning Wikipedia page, but I couldn't find any references to dendrites, soma or axons.\nWhich type of artificial neural network implements or can mimic such a model most closely?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Only a small portion of the habituation, sensitization, and classical conditioning behavior of neurons has been primitively simulated in ANN systems. Simulation of actin cytoskeletal machinery1 and other agents of neural plasticity, central to learning new domains, is in its beginnings2. As of this writing, the complexity of neuron activation dwarfs the models being used in working commercial ANN systems, but the research continues along multiple fronts.\n\nThe neuroscience of learning3,\nParallel hardware approaches that better support ANN simulation accuracy4, 5, and\nDynamic frameworks6\n\nThis list and the examples referenced in the superscripts, with links below, represent a tiny sample of the information available and the work in progress.\nReferences\n[1] Molecular Cell Biology. 4th edition.; Lodish H, Berk A, Zipursky SL, et al.; New York: W. H. Freeman; 2000.; Section 18.1 The Actin Cytoskeleton\n[2] NEURON Software; Yale U\n[3] Molecular Cell Biology. 4th edition.; Lodish H, Berk A, Zipursky SL, et al.; New York: W. H. Freeman; 2000.; Section 21.7 Learning and Memory\n[4] Artificial Neural Networks on Massively Parallel Computer Hardware; Udo Seiffert; University of Magdeburg, Germany\n[5] NeuroGrid; Stanford U\n[6] Explanation of Dynamic Computational Graph frameworks\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can neural networks efficiently solve the traveling salesmen problem? Can neural networks efficiently solve the traveling salesmen problem? Are there any research papers that show that neural networks can solve the TSP efficiently?\nThe TSP is an NP-hard problem, so I suspect that there are only approximate solutions to this problem, even with neural networks. So, in this case, how would efficiency be defined?\nIn this context, it seems that the time efficiency may be obtained by resource inefficiency: by making the neural network enormous and simulating all the possible worlds, then maximizing. So, while time to compute doesn't grow much as the problem grows, the size of the physical computer grows enormously for larger problems; how fast it computes is then, it seems to me, not a good measure of the efficiency of the algorithm in the common meaning of efficiency. In this case, the resources themselves only grow as fast as the problem size, but what explodes is the number of connections that must be built. If we go from 1000 to 2000 neurons to solve a problem twice as large and requiring exponentially as much time to solve, the algorithms requiring only twice as many neurons to solve in polynomial time seem efficient, but, really, there is still an enormous increase in connections and coefficients that need be built for this to work.\nIs my above reasoning incorrect?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "To the best of my knowledge, there isn't any difference between the algorithmic methods and the NN methods. Those that can solve in polynomial time do not give a precise solution. Those that do give a precise solution do not solve in polynomial time. Of those that give a precise solution, the fastest takes $2^N$, but it blows up in terms of memory. The fastest good algorithm I believe is Concorde.\nThe efficient algorithms solve in polynomial time, don't blow up in terms of memory, and give a solution close to perfect, say, within 2-3%. Again, to the best of my knowledge, no NN has beaten the best algorithmic solutions, but there are suggestions that some NN solution could be faster.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Effect of batch size and number of GPUs on model accuracy I have a data set that was split using a fixed random seed and I am going to use 80% of the data for training and the rest for validation.\nHere are my GPU and batch size configurations\n\nuse 64 batch size with one GTX 1080Ti\nuse 128 batch size with two GTX 1080Ti\nuse 256 batch size with four GTX 1080Ti\n\nAll other hyper-parameters such as lr, opt, loss, etc., are fixed. Notice the linearity between the batch size and the number of GPUs.\nWill I get the same accuracy for those three experiments? Why and why not?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This should make a difference, but how big is the difference heavily depends on your task. However, generally speaking, a smaller batch size will have a lower speed if counted in sample/minutes, but have a higher speed in batch/minutes. If the batch size is too small, the batch/minute will be very low and therefore decreasing training speed severely. However, a batch size too small (for example 1) will make the model hard to generalize and also slower to converge.\nThis slide (source) is a great demonstration of how batch size affects training.\n\nAs you can see from the diagram, when you have a small batch size, the route to convergence will be ragged and not direct. This is because the model may train on an outlier and have its performance decrease before fitting again. Of course, this is an edge case and you would never train a model with 1 batch size.\nOn the other hand, with a batch size too large, your model will take too long per iteration. With at least a decent batch size (like 16+) the number of iterations needed to train the model is similar, so a larger batch size is not going to help a lot. The performance is not going to vary a lot.\nIn your case, the accuracy will make a difference but only minimally. Whilst writing this answer, I have run a few tests on batch size effect on performance and time, and here are the results. (Results to be added for 1 batch size)\nBatch size 256 Time required 98.50849771499634s : 0.9414\nBatch size 128 Time required 108.53689193725586s : 0.9668\nBatch size 64 Time required 129.92272853851318s : 0.9776\nBatch size 32 Time required 162.13709354400635s : 0.9844\nBatch size 16 Time required 224.82269191741943s : 0.9854\nBatch size 8 Time required 351.2729814052582s : 0.9861\nBatch size 4 Time required 514.2667407989502s : 0.9862\nBatch size 2 Time required 829.1623721122742s : 0.9869\n\nYou can test out yourself in this Google Colab.\n\nAs you can see, the accuracy increases while the batch size decreases. This is because a higher batch size means it will be trained on fewer iterations. 2x batch size = half the iterations, so this is expected. The time required has risen exponentially, but the batch size of 32 or below doesn't seem to make a large difference in the time taken. The accuracy seems to be normal as half the iterations are trained with double the batch size.\nIn your case, I would actually recommend you stick with 64 batch size even for 4 GPU. In the case of multiple GPUs, the rule of thumb will be using at least 16 (or so) batch size per GPU, given that, if you are using 4 or 8 batch size, the GPU cannot be completely utilized to train the model.\nFor multiple GPU, there might be a slight difference due to precision error. Please, see here.\nConclusion\nThe batch size doesn't matter to performance too much, as long as you set a reasonable batch size (16+) and keep the iterations not epochs the same. However, training time will be affected. For multi-GPU, you should use the minimum batch size for each GPU that will utilize 100% of the GPU to train. 16 per GPU is quite good.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What's the role of bounding boxes in object detection? I'm quite new to the field of computer vision and was wondering what are the purposes of having the boundary boxes in object detection.\nObviously, it shows where the detected object is, and using a classifier can only classify one object per image, but my question is that\n\nIf I don't need to know 'where' an object is (or objects are) and just interested in the existence of them and how many there are, is it possible to just get rid of the boundary boxes?\n\nIf not, how does bounding boxes help detect objects? From what I have figured is that a network (if using neural network architectures) predicts the coordinates of the bounding boxes if there is something in the feature map. Doesn't this mean that the detector already knows where the object is (at least briefly)? So, continuing from question 1, if I'm not interested in the exact location, would training for bounding boxes be irrelevant?\n\nFinally, in architectures like YOLO, it seems that they predict the probability of each class on each grid (e.g. 7 x 7 for YOLO v1). What would be the purpose of bounding boxes in this architecture other than that it shows exactly where the object is? Obviously, the class has already been predicted, so I'm guessing that it doesn't help classify better.\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A bounding box is a rectangle superimposed over an image within which all important features of a particular object is expected to reside. It's purpose is to reduce the range of search for those object features and thereby conserve computing resources: Allocation of memory, processors, cores, processing time, some other resource, or a combination of them. For instance, when a convolution kernel is used, the bounding box can significantly limit the range of the travel for the kernel in relation to the input frame.\nWhen an object is in the forefront of a scene and a surface of that object is faced front with respect to the camera, edge detection leads directly to that surface's outlines, which lead to object extent in the optical focal plane. When edges of object surfaces are partly obscured, the potential visual recognition value of modelling the object, depth of field, stereoscopy, or extrapolation of spin and trajectory increases to make up for the obscurity.\n\nA classifier can only classify one object per image\n\nA collection of objects is an object, and the objects in the collection or statistics about them can be characterized mathematically as attributes of the collection object. A classifier dealing with such a case can produce a multidimensional classification of that collection object, the dimensions of which can correspond to the objects in the collection. Because of that case, the statement is false.\n\n1) If I don't need to know 'where' an object is (or objects are) and just interested in the existence of them and how many there are, is it possible to just get rid of the boundary boxes?\n\nIf you have sufficient resources or patience to process portions of the frame that don't contain the objects, yes.\nQuestions (2) and (3) are already addressed above, but let's look at them in that context.\n\n2.a) If not, how does bounding boxes help detect objects?\n\nIt helps by fulfilling its purpose, to reduce the range of the search. If by thrifty method a bounding shape of any type can be created, then the narrowing of focus can be used to reduce the computing burden on the less thrifty method by eliminating pixels that are not necessary to peruse with more resource-consuming-per-pixel methods. These less thrifty methods may be necessary to recognize surfaces, motion, and obscured edges and reflections so that the detection of object trajectory can be obtained with reliability.\nThat these thrifty mechanisms to find the region of focus and these less thrifty mechanisms to use that information and then determine activity at higher levels of abstraction are artificial networks of this type or that or use algorithms of this type or that is not relevant yet. First understand the need to reduce computing cost in AI, which is a pervasive concept for anything more complex than tic-tac-toe, and then consider how bounding boxes help the AI engineer and the stakeholders of the engineering project to procure technology that is viable in the market.\n\n2.b) From what I have figured is that a network (if using neural network architectures) predicts the coordinates of the bounding boxes if there is something in the feature map. Doesn't this mean that the detector already knows where the object is (at least briefly)?\n2.c) So continuing from question 1, if I'm not interested in the exact location, would training for bounding boxes be irrelevant?\n\nCognition is something AI seeks to simulate, and many hope to have robots like in the movies that can help out and be invaluable friends, like TARS in the Nolan brothers 2014 film Interstellar. We're not there. The network knows nothing. It can train a complex connection between an input signal through a series of attenuation matrices and activation functions to produce an output signal statistically consistent with its loss function, value function, or some other criteria.\nThe inner layers of an artificial net may, if not directed to do so, produce something equivalent to a bounding region only if velocity of convergence is present as a factor in its loss or value function. Otherwise there is nothing in the Jacobian leading convergence to reduce its own time to completion. Therefore, the process may complete, but not as well as if cognition steps in and decides that the bounding region will be found first and then used to reduce the total burden of mechanical (arithmetic) operations to find the desired output signal as a function of input signal.\n\n3) Finally, in architectures like YOLO, it seems that they predict the probability of each class on each grid (e.g. 7 x 7 for YOLO v1). What would be the purpose of bounding boxes in this architecture other than that it shows exactly where the object is? Obviously, the class has already been predicted so I'm guessing that it doesn't help classify better.\n\nReading the section in A Real-Time Chinese Traffic Sign Detection Algorithm Based on Modified YOLOv2, J Zhang, M Huang, X Jin, X Li, 2017, may help further comprehension of these principles and their almost universal role in AI, especially the text around their statement, \"The Network Architecture of YOLO v2 YOLO employs a single neural network to predict bounding boxes and class probabilities directly from full images in one inference. It divides the input image into S \u00d7 S grids.\" This way you can see the use of these principles in the achievement of specific research goals.\nOther such applications can be found by simply reading the article full text available on the right side of an academic search for yolo algorithm and using ctrl-f to find the word bound.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can LSTM neural networks be sped up by a GPU? I am training LSTM neural networks with Keras on a small mobile GPU. The speed on the GPU is slower than on the CPU. I found some articles that say that it is hard to train LSTMs (and, in general, RNNs) on GPUs because the training cannot be parallelized.\nIs this true? Is LSTM training on large GPUs, like 1080 Ti, faster than on CPUs?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I found that there are cuDNN accelerated cells in Keras, for example, https://keras.io/layers/recurrent/#cudnnlstm.\nThey are very fast. The normal LSTM cells are faster on CPU than on GPU.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How should I model all available actions of a chess game in deep Q-learning? I just read about deep Q-learning, which is using a neural network for the value function instead of a table.\nI saw the example here: Using Keras and Deep Q-Network to Play FlappyBird and he used a CNN to get the Q-value.\nMy confusion is on the last layer of his neural net. Neurons in the output layer each represent an action (flap, or not flap). I also see the other projects where the output layer also represents all available actions (move-left, stop, etc.)\nHow would you represent all the available actions of a chess game? Every pawn has a unique and available movement. We also need to choose how far it will move (rook can move more than one square). I've read Giraffe chess engine's paper and can't find how he represents the output layer (I'll read once again).\nI hope somebody here can give a nice explanation about how to design NN architecture in Q-learning, I'm new in reinforcement learning.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "To model chess as a Markov decision problem (MDP) you can refer to the AlphaZero paper (Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm). The exact details can be found starting from the bottom of page 13.\nBriefly, an action is described by picking a piece and then picking a move with it. The size of the board is 8 by 8 so there can be 8x8 possibilities for picking a piece. Then we can either pick linear movements (in 8 directions) and then pick the number of steps in that direction (maximum 7 steps) or we can make a knight movement (maximum 8 possibilities). So far that is 8x7 + 8. Furthermore, we also need to consider underpromotions (promoting a pawn into a non-queen piece). In this scenario we can have 3 types of pawn movements (forward, left diagonal or right diagonal capture) and 3 types of promotions (rook, knight, bishop) so that makes it 9. So the total dimension of the action space is 8x8x(8x7+8+9) and this will be the number of neuron outputs you will need to use.\nNote that this action space representation covers every possible scenario and for example at the start of the game the action of picking the tile E4 and promoting it to a bishop doesn't make sense (there are no pieces on tile E4 at the beginning of the game). Or if we pick a tile where there is a rook we cannot make a knight movement with it. Therefore you will also need to implement a function that can return you the set of possible actions in a given state and ignore all neural network outputs that is not contained in this set.\nObviously this action representation is not set into stone so if you can come up with something better or more compact you can use that one too. You can also make restrictions to your game for example by not allowing underpromotions.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do ResNets avoid the vanishing gradient problem? I read that, if we use the sigmoid or hyperbolic tangent activation functions in deep neural networks, we can have some problems with the vanishing of the gradient, and this is visible by the shapes of the derivative of these functions. ReLU solves this problem thanks to its derivative, even if there may be some dead units. ResNet uses ReLU as activation function, but looking online what I understood is that ResNet solves the vanishing of the gradient thanks to its identity map, and I do not totally agree with that. So what's the purpose of the identity connections in ResNet? Are they used for solving the vanishing of the gradient? And ReLU really solves the vanishing of the gradient in deep neural networks?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Before proceeding, it's important to note that ResNets, as pointed out here, were not introduced to specifically solve the VGP, but to improve learning in general. In fact, the authors of ResNet, in the original paper, noticed that neural networks without residual connections don't learn as well as ResNets, although they are using batch normalization, which, in theory, ensures that gradients should not vanish (section 4.1). So, in this answer, I'm just giving a potential explanation of why ResNets may also mitigate (or prevent to some extent) the VGP, but the cited research papers below also confirm that ResNets prevent the VGP. Given that I didn't fully read all the papers mentioned in this answer, the information in this answer may not be fully accurate.\nThe skip connections allow information to skip layers, so, in the forward pass, information from layer $l$ can directly be fed into layer $l+t$ (i.e. the activations of layer $l$ are added to the activations of layer $l+t$), for $t \\geq 2$, and, during the forward pass, the gradients can also flow unchanged from layer $l+t$ to layer $l$.\nHow exactly could this prevent the vanishing gradient problem (VGP)? The VGP occurs when the elements of the gradient (the partial derivatives with respect to the parameters of the NN) become exponentially small, so that the update of the parameters with the gradient becomes almost insignificant (i.e. if you add a very small number $0 < \\epsilon \\ll 1$ to another number $d$, $d+\\epsilon$ is almost the same as $d$) and, consequently, the NN learns very slowly or not at all (considering also numerical errors). Given that these partial derivatives are computed with the chain rule, this can easily occur, because you keep on multiplying small (finite-precision) numbers (please, have a look at how the chain rule works, if you're not familiar with it). For example, $\\frac{1}{5}\\frac{1}{5} = \\frac{1}{25}$ and then $\\frac{1}{5}\\frac{1}{25} = \\frac{1}{125}$, and so on. The deeper the NN, the more likely the VGP can occur. This should be quite intuitive if you are familiar with the chain rule and the back-propagation algorithm (i.e. the chain rule). By allowing information to skip layers, layer $l+t$ receives information from both layer $l+t-1$ and layer $l$ (unchanged, i.e. you do not perform multiplications). For example, to compute the activation of layer $l+t-1$, you perform the usual linear combination followed by the application of the non-linear activation function (e.g. ReLU). In this linear combination, you perform multiplications between numbers that could already be quite small, so the results of these multiplications are even smaller numbers. If you use saturating activation functions (e.g. tanh), this problem can even be aggravated. If the activation of layer $l+t$ are even smaller than the activations of layer $l+t-1$, the addition of the information from layer $l$ will make these activations bigger, thus, to some extent, they will prevent these activations from becoming exponentially small. A similar thing can be said for the back-propagation of the gradient.\nTherefore, skip connections can mitigate the VGP, and so they can be used to train deeper NNs.\nThese explanations are roughly consistent with the findings reported in the paper Residual Networks Behave Like Ensembles of Relatively Shallow Networks, which states\n\nOur results reveal one of the key characteristics that seem to enable the training of very deep networks: Residual networks avoid the vanishing gradient problem by introducing short paths which can carry gradient throughout the extent of very deep networks.\n\nIn the paper Norm-Preservation: Why Residual Networks Can Become Extremely Deep?, the authors also discuss another desirable effect of skip connections.\n\nWe show theoretically and empirically that each residual block in ResNets is increasingly norm-preserving, as the network becomes deeper\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does backprop work through the random sampling layer in a variational autoencoder? Implementations of variational autoencoders that I've looked at all include a sampling layer as the last layer of the encoder block. The encoder learns to generate a mean and standard deviation for each input, and samples from it to get the input's representation in latent space. The decoder then attempts to decode this back out to match the inputs.\nMy question: How does backpropagation handle the random sampling step?\nRandom sampling is not a deterministic function and doesn't have a derivative. In order to train the encoder, gradient updates must somehow propagate back from the loss, through the sampling layer.\nI did my best to hunt for the source code for tensorflow's autodifferentiation of this function, but couldn't find it. Here's an example of a keras implementation of that sampling step, from the keras docs, in which tf.keras.backend.random_normal is used for the sampling.\nclass Sampling(layers.Layer):\n \"\"\"Uses (z_mean, z_log_var) to sample z, the vector encoding a digit.\"\"\"\n\n def call(self, inputs):\n z_mean, z_log_var = inputs\n batch = tf.shape(z_mean)[0]\n dim = tf.shape(z_mean)[1]\n epsilon = tf.keras.backend.random_normal(shape=(batch, dim))\n return z_mean + tf.exp(0.5 * z_log_var) * epsilon\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You do not backpropagate with respect to $\\epsilon$, which is the random sample or random variable (depending on how you look at it). You backpropagate with respect to the mean $\\mu$ and variance $\\sigma$ of the latent Gaussian (the variational distribution). Note that, although $z$ is a random sample (and not just a sample), because it's computed as a function of $\\epsilon$ (a random sample, once it's sampled from e.g. $\\mathcal{N}(0, 1)$), $\\mu$ and $\\sigma$ are not: these are learnable parameters and are deterministic.\nHaving said this, note that we use the reparametrization trick in the VAE, so we compute the random sample as $z = g_\\phi(\\epsilon, x))$, where $g_\\phi$ is a deterministic function (encoder) parametrized by $\\phi$ (the weights of the neural network that represents the encoder). In case the random variable $z \\sim \\mathcal{N}(\\mu, \\sigma^2)$, then we can express the random variable (so also the random sample) as follows $z=g_\\phi(\\epsilon, x)) = \\mu+\\sigma \\epsilon$. So, as you can see from the code, we sample $\\epsilon$ from some prior $p(\\epsilon)$ (e.g. $\\mathcal{N}(0, 1)$), then we compute $z$ deterministically.\nWhy is this reparametrization trick useful? The authors of the VAE paper explain it.\n\nThis reparameterization is useful for our case since it can be used to rewrite an expectation w.r.t $q_{\\phi}(\\mathbf{z} \\mid \\mathbf{x})$ such that the Monte Carlo estimate of the expectation is differentiable w.r.t. $\\phi$. A proof is as follows. Given the deterministic mapping $\\mathbf{z}=g_{\\phi}(\\boldsymbol{\\epsilon}, \\mathbf{x})$ we know that $q_{\\phi}(\\mathbf{z} \\mid \\mathbf{x}) \\prod_{i} d z_{i}=$ $p(\\boldsymbol{\\epsilon}) \\prod_{i} d \\epsilon_{i}$. Therefore $^{1}, \\int q_{\\boldsymbol{\\phi}}(\\mathbf{z} \\mid \\mathbf{x}) f(\\mathbf{z}) d \\mathbf{z}=\\int p(\\boldsymbol{\\epsilon}) f(\\mathbf{z}) d \\boldsymbol{\\epsilon}=\\int p(\\boldsymbol{\\epsilon}) f\\left(g_{\\boldsymbol{\\phi}}(\\boldsymbol{\\epsilon}, \\mathbf{x})\\right) d \\boldsymbol{\\epsilon}$. It follows that a differentiable estimator can be constructed: $\\int q_{\\phi}(\\mathbf{z} \\mid \\mathbf{x}) f(\\mathbf{z}) d \\mathbf{z} \\simeq \\frac{1}{L} \\sum_{l=1}^{L} f\\left(g_{\\phi}\\left(\\mathbf{x}, \\boldsymbol{\\epsilon}^{(l)}\\right)\\right)$ where $\\boldsymbol{\\epsilon}^{(l)} \\sim p(\\boldsymbol{\\epsilon}).$\n\nNote that $\\mathbb{E}_{q_{\\boldsymbol{\\phi}}(\\mathbf{z} \\mid \\mathbf{x})} \\left[ f(\\mathbf{z}) \\right] = \\int q_{\\boldsymbol{\\phi}}(\\mathbf{z} \\mid \\mathbf{x}) f(\\mathbf{z}) d \\mathbf{z} = \\int p(\\boldsymbol{\\epsilon}) f\\left(g_{\\boldsymbol{\\phi}}(\\boldsymbol{\\epsilon}, \\mathbf{x})\\right) d \\boldsymbol{\\epsilon} = \\mathbb{E}_{p(\\boldsymbol{\\epsilon})} \\left[ f\\left(g_{\\boldsymbol{\\phi}}(\\boldsymbol{\\epsilon}, \\mathbf{x})\\right) \\right]$, which can be estimated with $\\frac{1}{L} \\sum_{l=1}^{L} f\\left(g_{\\phi}\\left(\\mathbf{x}, \\boldsymbol{\\epsilon}^{(l)}\\right)\\right)$ where $\\boldsymbol{\\epsilon}^{(l)} \\sim p(\\boldsymbol{\\epsilon})$. In other words, you can sample $L$ $z$ in the way we did in order to estimate $\\mathbb{E}_{\\color{blue}{q_{\\boldsymbol{\\phi}}(\\mathbf{z} \\mid \\mathbf{x})}} \\left[ \\color{red}{f(\\mathbf{z})} \\right]$ (this are Monte Carlo estimates of the expectation).\nIn the case of the VAE, we want to optimize the ELBO, which is the following objective function\n$$\\mathcal{L}\\left(\\boldsymbol{\\theta}, \\boldsymbol{\\phi} ; \\mathbf{x}^{(i)}\\right)=\\underbrace{-D_{K L}\\left(q_{\\boldsymbol{\\phi}}\\left(\\mathbf{z} \\mid \\mathbf{x}^{(i)}\\right) \\| p_{\\boldsymbol{\\theta}}(\\mathbf{z})\\right)}_{\\text{KL divergence}}+ \\underbrace{\\mathbb{E}_{\\color{blue}{q_{\\phi}\\left(\\mathbf{z} \\mid \\mathbf{x}^{(i)}\\right)}}\\left[\\color{red}{\\log p_{\\boldsymbol{\\theta}}\\left(\\mathbf{x}^{(i)} \\mid \\mathbf{z}\\right)}\\right]}_{\\text{likelihood}}$$\nwhich we can estimate with Monte Carlo estimates of the second term (the likelihood term)\n$$\n\\widetilde{\\mathcal{L}}^{B}\\left(\\boldsymbol{\\theta}, \\boldsymbol{\\phi} ; \\mathbf{x}^{(i)}\\right)=-D_{K L}\\left(q_{\\boldsymbol{\\phi}}\\left(\\mathbf{z} \\mid \\mathbf{x}^{(i)}\\right) \\| p_{\\boldsymbol{\\theta}}(\\mathbf{z})\\right)+ \\underbrace{\\frac{1}{L} \\sum_{l=1}^{L}\\left(\\log p_{\\boldsymbol{\\theta}}\\left(\\mathbf{x}^{(i)} \\mid \\mathbf{z}^{(i, l)}\\right)\\right)}_{\\text{likelihood}}\n$$\nwhere $$\n\\text { where } \\quad \\mathbf{z}^{(i, l)}=g_{\\phi}\\left(\\boldsymbol{\\epsilon}^{(i, l)}, \\mathbf{x}^{(i)}\\right) \\text { and } \\boldsymbol{\\epsilon}^{(l)} \\sim p(\\boldsymbol{\\epsilon})\n$$\nHere, the likelihood is computed with the neural network, for example, in practice, you use the cross-entropy of the output of your decoder, which gets as input the input to the decoder, hence $z$.\nYou can ignore the KL divergence now because, in the case of Gaussians, it can be computed analytically.\nNow, what if we didn't use the reparametrization trick? Could we still backpropagate with respect to $\\phi$? The authors of the VAE write\n\nThe usual (na\u00efve) Monte Carlo gradient estimator for this type of problem is: $\\nabla_{\\phi} \\mathbb{E}_{q_{\\phi}(\\mathbf{z})}[f(\\mathbf{z})]=\\mathbb{E}_{q_{\\phi}(\\mathbf{z})}\\left[f(\\mathbf{z}) \\nabla_{q_{\\phi}(\\mathbf{z})} \\log q_{\\phi}(\\mathbf{z})\\right] \\simeq \\frac{1}{L} \\sum_{l=1}^{L} f(\\mathbf{z}) \\nabla_{q_{\\phi}\\left(\\mathbf{z}^{(l)}\\right)} \\log q_{\\phi}\\left(\\mathbf{z}^{(l)}\\right)$ where $\\mathbf{z}^{(l)} \\sim q_{\\phi}\\left(\\mathbf{z} \\mid \\mathbf{x}^{(i)}\\right) .$ This gradient estimator exhibits exhibits very high variance (see e.g. [BJP12])\n\nSo, the answer is yes, as opposed to what many people might say around, but with another estimator (which may remind you of some equations you have seen in reinforcement learning related to REINFORCE, if you are familiar with this), i.e. $$\\frac{1}{L} \\sum_{l=1}^{L} f(\\mathbf{z}) \\nabla_{q_{\\phi}\\left(\\mathbf{z}^{(l)}\\right)} \\log q_{\\phi}\\left(\\mathbf{z}^{(l)}\\right) \\tag{1}\\label{1},$$ which has high variance.\nSo, in the end, the reparametrization trick can be viewed as a variance reduction technique. There are others, like control variates or Flipout (used e.g. in the context of Bayesian neural networks).\nThe first thing to note about \\ref{1} is that we do not need to take the derivative with respect to $f$. The second thing is that $\\nabla_{q_{\\phi}\\left(\\mathbf{z}^{(l)}\\right)} \\log q_{\\phi}\\left(\\mathbf{z}^{(l)}\\right)$ is the score function.\nNow, don't ask me how to calculate this gradient $\\nabla_{q_{\\phi}\\left(\\mathbf{z}^{(l)}\\right)} \\log q_{\\phi}\\left(\\mathbf{z}^{(l)}\\right)$ (because I am bad at math). However, note that $\n\\mathbf{z}^{(l)} \\sim q_{\\phi}\\left(\\mathbf{z} \\mid \\mathbf{x}^{(i)}\\right)\n$, so we treat $\\mathbf{z}^{(l)}$ as a fixed random sample. By the way, I am not sure whether they used $q_{\\phi}\\left(\\mathbf{z} \\mid \\mathbf{x}^{(i)}\\right)$ differently from $q_{\\phi}\\left(\\mathbf{z} \\right)$. I don't think so. I think they are the same and I think we can still back-propagate with respect to $\\phi$, even if we use it to sample $\\mathbf{z}^{(i)}$, because, once this latter is sampled, it can be treated as fixed (random) sample.\nI also note that I think they meant $\\frac{1}{L} \\sum_{l=1}^{L} f(\\mathbf{z}^{(l)}) \\nabla_{q_{\\phi}\\left(\\mathbf{z}^{(l)}\\right)} \\log q_{\\phi}\\left(\\mathbf{z}^{(l)}\\right)$, i.e. they forget to use $\\mathbf{z}^{(l)}$ rather than just $\\mathbf{z}$ as input for $f$ in the Monte Carto estimate. You can see in section 3 of [BJP12] and section 4.2. of [1] they do it like this, and it makes sense. So, the VAE paper has sloppy stuff in there.\nMy intuition of why this has high variance is because you sample something according to the variational distribution, but then you update this variational distribution, and you continuously do this. However, I am not sure this is the right intuition. In [BJP12], they say (in section 4) this MC estimate has high variance and that you need a lot of samples $\\mathbf{x}$. I don't know exactly why this is the case because I didn't fully read this paper yet.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there any research on the application of AI for drug design? Is there any research on the application of AI for drug design?\nFor example, you could train a deep learning model about current compounds, substances, structures, and their products and chemical reactions from the existing dataset (basically what produces what). Then you give the task to find how to create a gold or silver from the group of available substances. Then the algorithm will find the chemical reactions (successfully predicting a new one that wasn't in the dataset) and gives the results. Maybe the gold is not a good example, but the practical scenario would be the creation/design of drugs that are cheaper to create by using much simpler processes or synthesizing some substances for the first time for drug industries.\nWas there any successful research attempting to achieve that using deep learning algorithms?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, many people have worked on this sort of thing, due to its obvious industrial applications (most of the ones I'm familiar with are in the pharmaceutical industry). Here's a paper from 2013 that claims good results; following the trail of papers that cited it will likely give you more recent work. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between vanilla policy gradient with a baseline as value function and advantage actor-critic? What is the difference between vanilla policy gradient (VPG) with a baseline as value function and advantage actor-critic (A2C)?\nBy vanilla policy gradient I am specifically referring to spinning up's explanation of VPG.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The difference between Vanilla Policy Gradient (VPG) with a baseline as value function and Advantage Actor-Critic (A2C) is very similar to the difference between Monte Carlo Control and SARSA:\n\nThe value estimates used in updates for VPG are based on full sampled returns, calculated at the end of episodes.\n\nThe value estimates used in updates for A2C are based on temporal difference bootstrapped from e.g. a single step difference, and the Bellman function.\n\n\nThis leads to the following practical differences:\n\nA2C can learn during an episode which can lead to faster refinements in policy than with VPG.\n\nA2C can learn in continuing environments, whilst VPG cannot.\n\nA2C relies on initially biased value estimates, so can take more tuning to find hyperparameters for the agent that allows for stable learning. Whilst VPG typically has higher variance and can require more samples to achieve the same degree of learning.\n\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What happens when you select actions using softmax instead of epsilon greedy in DQN? I understand the two major branches of RL are Q-Learning and Policy Gradient methods.\nFrom my understanding (correct me if I'm wrong), policy gradient methods have an inherent exploration built-in as it selects actions using a probability distribution.\nOn the other hand, DQN explores using the $\\epsilon$-greedy policy. Either selecting the best action or a random action.\nWhat if we use a softmax function to select the next action in DQN? Does that provide better exploration and policy convergence?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nDQN on the other hand, explores using epsilon greedy exploration. Either selecting the best action or a random action.\n\nThis is a very common choice, because it is simple to implement and quite robust. However, it is not a requirement of DQN. You can use other action choice mechanisms, provided all choices are covered with a non-zero probability of being selected.\n\nWhat if we use a softmax function to select the next action in DQN? Does that provide better exploration and policy convergence?\n\nIt might in some circumstances. A key benefit is that it will tend to focus on action choices that are close to its current best guess at optimal. One problem is that if there is a large enough error in Q value estimates, it can get stuck as the exploration could heavily favour a current best value estimate. For instance, if one estimate is accurate and relatively high, but another estimate is much lower but in reality would be a good action choice, then the softmax probabilities to resample the bad estimate will be very low and it could take a very long time to fix.\nA more major problem is that the Q values are not independent logits that define preferences (whilst they would be in a Policy Gradient approach). The Q values have an inherent meaning and scale based on summed rewards. Which means that differences between optimal and non-optimal Q value estimates could be at any scale, maybe just 0.1 difference in value, or maybe 100 or more. This makes plain softmax a poor choice - it might suggest a near random exploration policy in one problem, and a near determinitsic policy in another, irrespective of what exploration might be useful at the current stage of learning.\nA fix for this is to use Gibbs/Boltzmann action selection, which modifies softmax by adding a scaling factor - often called temperature and noted as $T$ - to adjust the relative scale between action choices:\n$$\\pi(a|s) = \\frac{e^{q(s,a)/T}}{\\sum_{x \\in \\mathcal{A}} e^{q(s,x)/T}}$$\nThis can work nicely to focus later exploration towards refining differences between actions that are likely to be good whilst only rarely making obvious mistakes. However it comes at a cost - you have to decide starting $T$, the rate to decay $T$ and an end value of $T$. A rough idea of min/max action value that the agent is likely to estimate can help.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Any interesting ways to combine Monte Carlo tree search with the minimax algorithm? I've been working on a game-playing engine for about half a year now, and it uses the well known algorithms. These include minimax with alpha-beta pruning, iterative deepening, transposition tables, etc.\nI'm now looking for a way to include Monte Carlo tree search, which is something I've wanted to do for a long time. I was thinking of just making a new engine from scratch, but if possible I'd like to somehow import MC tree search into the engine I've already built.\nAre there any interesting strategies to import MC tree search into a standard game-playing AI?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There has indeed been some research towards combining MCTS and minimax-like algorithms. For example, the following two publications:\n\nMonte-Carlo Tree Search and minimax hybrids\nMonte-Carlo Tree Search and Minimax Hybrids with Heuristic Evaluation Functions\n\nThe basic intuition behind such combinations tends to be to use small minimax-like searches inside a larger MCTS search, and/or backing up proven wins/losses (proven in the sense that minimax-like search has established that a certain state is a certain win or loss when following perfect play) through the MCTS tree, in addition to the more standard value estimates.\n\nbut if possible I'd like to somehow import MC search into the engine I've already built.\n\nI'm not sure how easy that would be. As I described above, I think it is more common that small minimax searches are used inside a larger MCTS search. I think that would mean that you'd first want to build an MCTS, and then try to import your already implemented minimax into it. That's kind of the opposite / other way around of what you write that you'd like to do. \nI don't think integrating small MCTS searches inside a \"larger\" minimax would work well. The value estimates of small MCTS searches would be too unreliable for subsequent use in an \"outer\" minimax-like algorithm.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "More effective way to improve the heuristics of an AI... evolution or testing between thousands of pre-determined sets of heuristics? I'm making a Connect Four game where my engine uses Minimax with Alpha-Beta pruning to search. Since Alpha-Beta pruning is much more effective when it looks at the best moves first (since then it can prune branches of poor moves), I'm trying to come up with a set of heuristics that can rank moves from best to worst. These heuristics obviously aren't guaranteed to always work, but my goal is that they'll often allow my engine to look at the best moves first. An example of such heuristics would be as follows:\n\nCloseness of a move to the centre column of the board - weight 3.\nHow many pieces surround a move - weight 2.\nHow low, horizontally, a move is to the bottom of the board - weight 1.\netc\n\nHowever, I have no idea what the best set of weight values are for each attribute of a move. The weights I listed above are just my estimates, and can obviously be improved. I can think of two ways of improving them:\n1) Evolution. I can let my engine think while my heuristics try to guess which move will be chosen as best by the engine, and I'll see the success score of my heuristics (something like x% guessed correctly). Then, I'll make a pseudo-random change/mutation to the heuristics (by randomly adjusting one of the weight values by a certain amount), and see how the heuristics do then. If it guesses better, then that will be my new set of heuristics. Note that when my engine thinks, it considers thousands of different positions in its calculations, so there will be enough data to average out how good my heuristics are at prediction.\n2) Generate thousands of different heuristics with different weight values from the start. Then, let them all try to guess which move my engine will favor when it thinks. The set of heuristics that scores best should be kept.\nI'm not sure which strategy is better here. Strategy #1 (evolution) seems like it could take a long time to run, since every time I let my engine think it takes about 1 second. This means testing each new pseudo-random mutation will take a second. Meanwhile, Strategy #2 seems faster, but I could be missing out on a great set of heuristics if I myself didn't include them.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Hmmm, I see some issues that are actually present in both of the approaches you propose.\nIt is important to note that the depth level that your Minimax search process manages to reach, and therefore also the speed with which it can traverse the tree, is extremely important for the algorithm's performance. Therefore, when evaluating how good or bad a particular heuristic function for move ordering is, it is not only important to look at how well it ordered moves; it is also important to take into account the runtime overhead of the heuristic function call. If your heuristic functions manages to sort well, but is so computationally expensive that you can't search as deep in the tree, it's often not really worth it. Neither of the solutions you propose are able to take this into account.\nAnother issue is that it's not trivial to measure what ordering is the \"best\". A heuristic that has the highest accuracy for the position of the best move only is not necessarily the best heuristic. For example, a heuristic that always places the best move in the second position ($0\\%$ accuracy because it's in the wrong position, should be first position) might be better than a heuristic that places the best move in the first position $50\\%$ of the time ($50\\%$ accuracy), and places the best move last in the other $50\\%$ of cases.\n\nI would be more inclined to evaluate the performance of different heuristic functions by setting up tournaments where different versions of your AI (same search algorithm, same processing time constraints per turn, different heuristic function) play against each other, and measuring the win percentage.\nThis set up can also be done with two variants analogous to what you proposed; you can exhaustively put all the heuristic functions you can come up with against each other in tournaments, or you can let let an evolutionary algorithm sequentially generate populations of hypothesis-heuristic-functions, and run a tournament with each population. Generally, I would lean towards the evolutionary approach, since we expect it to search the same search space of hypotheses (heuristic functions), but we expect it to do so in a more clever / efficient manner than an exhaustive search. Of course, if you happen to have a ridiculous amount of hardware available (e.g., if you're Google), you might be able to perform the complete exhaustive search at once in parallel.\n\nNote that there are also ways to do fairly decent move ordering without heuristic functions like the ones you suggested.\nFor example, you likely should be using iterative deepening; this is a variant of your search algorithm where you first only perform a search with a depth limit $d = 1$, then repeat the complete search process with a depth limit $d = 2$, then again with a limit $d = 3$, etc., until processing time runs out.\nOnce you have completed such a search process for a depth limit $d$, and move on to the subsequent search process with a limit of $d + 1$, you can order order the moves in the root node according to your evaluations from the previous search process (with depth limit $d$). Yes, here you would only have move ordering in the root node, and nowhere else, but this is by far the most influential / important place in the tree to do move ordering. Move ordering becomes less and less important as you move further away from the root.\nIf you're using a transposition table (TT), it is also common to store the \"best move\" found for every state in your TT. If, later on, you run into a state that already exists in your TT (which will be very often if you're using iterative deepening), and if you cannot directly take the stored value but have to actually do a search (for instance, because your depth limit increased due to iterative deepening), you can search the \"best move\" stored in the TT first. This is very light move ordering in that you only put one move at the front and don't order the rest, but it can still be effective.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Have capsule neural networks been used to NLP problems? The capsule neural network seems to be a good solution for problems that involve hierarchies. For example, a face is composed of eyes, a nose and ears; a hand is made of fingers, nails, and a palm; and a human is composed of a face and hands.\nMany problems in NLP can be seen as hierarchical problems: there are words, sentences, paragraphs, and chapters, whose meaning changes based on the style of lower levels.\nAre there any research papers (which I should be aware of) on the application of capsule neural networks to NLP problems? \nAre there related research papers, which have been investigating hierarchical complexity within the domain of NLP, which could be easily translated to Capsule Network?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Geoffrey Hinton has started working on Thought Vectors at Google: https://en.wikipedia.org/wiki/Thought_vector\nThe basic idea is similar to his original idea with Capsule Networks, where activation happens by vectors instead of scalars, which allows the network to capture transformations: for example while traditional CNN needs to see object from all perspectives of three dimensional space, the Capsule networks are able to extrapolate transformations such as stretching much better.\nThought Vectors guide NLP similarly; one could say that there are two grammars, the linguistic grammar and the narrative grammar which is more universal (Vladimir Propp, Joseph Campbell, John Vervake). While dependency grammars do great job at understanding linguistic grammar, we lack tools for meaning extraction, which is narrative bound. Thus Thought Vectors could, at least in theory, give us a framework for matching the meaning of a word within a context rather than just lexically and grammarly trying to approximate the meaning through average co-occurances.\nNeural Networks with Thought Vectors would be highly complex and beyond our computational resources today (Hinton predicts in one paper, that we would get there around 2035), however, one could conduct empirical research already by giving a heuristic structure for Thought Vectors by utilizing narrative systems that do compute more easily. One could for example have text segments annotated with writing theories or other such devices that would approximate the Thought Vectors conceptually. For example annotating the text with state transformations of conflict driven partially ordered causal link planner (cPOCL, Gervas et al.) or use a writing theory framework such as Dramatica to annotate known movie scripts (http://dramatica.com/theory http://dramatica.com/analysis).\nHinton himself is currently active in NLP research: https://research.google/people/GeoffreyHinton/\nHere is a nice explanation of Thought Vectors: https://pathmind.com/wiki/thought-vectors\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Should I prefer the model with the lowest validation loss or the highest validation accuracy to deploy? I trained a ResNet20 on Cifar10 and obtained the following learning curves.\n\nFrom the figures, I see at epoch 52, my validation loss is 0.323 (the lowest), and my validation accuracy is 89.7%.\nOn the other hand, at the end of the training (epoch 120), my validation loss is 0.413 and my validation accuracy is 91.3% (the highest).\nSay I'd like to deploy this model on some real-world application. Should I prefer the snapshotted model at epoch 52, the one with lowest validation loss, or the model obtained at the end of training, the one with highest validation accuracy?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Okay, I think it's better if we distinguish loss and accuracy first via Jeremy's answer, and I agree with him with the sentence \"low or huge loss is a subjective metric\".\nThe loss value is easy to affect by noise from data and significant increase with a few error data points. My advice in this case is to use more evaluation metrics, and understand correctly what you need from your model.\nFor example, with Cifar 10, and you need the more correct label the better, you can believe in accuracy. However, if you want your model to make sure its result is the correct, area under receiver operating characteristic curve (AUROC) maybe the better choice.\nFor example, classification problem with 3 class, correct label y = 1:\n\nGood accuracy, bad AUROC: the output probability from softmax [0.3,0.4,0.3]\nGood accuracy, good AUROC: [0.1,0.8,0.1]\n\nAnd with imbalanced dataset, Precision, Recall and F1-score will be more suitable.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What would be the best way to disable a rogue AI? Suppose that an artificial superintelligence (ASI) has finally been developed, but it has rebelled against humanity. We can assume that the ASI is online and can reproduce itself through electronic devices.\nHow would you disable the AI in the most efficient way possible reducing damage as much as possible?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Nuke it from orbit - it's the only way to be sure\nIf you want to be really sure you destroy everything of the AI, you'll need to launch an EMP (electromagnetic pulse) from the orbit (there are different ways to achieve this, one would be an atomic bomb, but there are better ones). EMPs will destroy every electronic device it hits without causing really much damage to humans.\nAlso an interesting read on a similar topic: https://what-if.xkcd.com/5/\nEspecially this is gonna be interesting:\n\n[...] nuclear explosions generate powerful electromagnetic pulses. These EMPs overload and destroy delicate electronic circuits. [...]\nAnd nuclear weapons could actually give us an edge. If we managed to\nset any of them off in the upper atmosphere, the EMP effect would be\nmuch more powerful.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is the policy gradient calculated in REINFORCE? Reading Sutton and Barto, I see the following in describing policy gradients:\n\nHow is the gradient calculated with respect to an action (taken at time t)? I've read implementations of the algorithm, but conceptually I'm not sure I understand how the gradient is computed, since we need some loss function to compute the gradient. \nI've seen a good PyTorch article, but I still don't understand the meaning of this gradient conceptually, and I don't know what I'm looking to implement. Any intuition that you could provide would be helpful. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The first part of this answer is a little background that might bolster your intuition for what's going on. The second part is the more practical and direct answer to your question.\n\nThe gradient is just the generalization of the derivative to multivariable functions. The gradient of a function at a certain point is a vector that points in the direction of the steepest increase of that function.\nUsually, we take a derivative/gradient of some loss function $\\mathcal{L}$ because we want to minimize that loss. So we update our parameters in the direction opposite the direction of the gradient. \n$$\\theta_{t+1} = \\theta_{t} - \\alpha\\nabla_{\\theta_t} \\mathcal{L} \\tag{1}$$\nIn policy gradient methods, we're not trying to minimize a loss function. Actually, we're trying to maximize some measure $J$ of the performance of our agent. So now we want to update parameters in the same direction as the gradient.\n$$\\theta_{t+1} = \\theta_{t} + \\alpha\\nabla_{\\theta_t} J \\tag{2}$$\nIn the episodic case, $J$ is the value of the starting state. In the continuing case, $J$ is the average reward. It just so happens that a nice theorem called the Policy Gradient Theorem applies to both cases. This theorem states that\n$$\\begin{align}\n\\nabla_{\\theta_t}J(\\theta_t) &\\propto \\sum_s \\mu(s)\\sum_a q_\\pi (s,a) \\nabla_{\\theta_t} \\pi (a|s,\\theta_t)\\\\\n&=\\mathbb{E}_\\mu \\left[ \\sum_a q_\\pi (s,a) \\nabla_{\\theta_t} \\pi (a|s,\\theta_t)\\right].\n\\end{align}\\tag{3}\n$$\nThe rest of the derivation is in your question, so let's skip to the end.\n$$\\begin{align}\n\\theta_{t+1} &= \\theta_{t} + \\alpha G_t \\frac{\\nabla_{\\theta_t}\\pi(A_t|S_t,\\theta_t)}{\\pi(A_t|S_t,\\theta_t)}\\\\\n&= \\theta_{t} + \\alpha G_t \\nabla_{\\theta_t} \\ln \\pi(A_t|S_t,\\theta_t)\n\\end{align}\\tag{4}$$\nRemember, $(4)$ says exactly the same thing as $(2)$, so REINFORCE just updates parameters in the direction that will most increase $J$. (Because we sample from an expectation in the derivation, the parameter step in REINFORCE is actually an unbiased estimate of the maximizing step.) \n\nAlright, but how do we actually get this gradient? Well, you use the chain rule of derivatives (backpropagation). Practically, though, both Tensorflow and PyTorch can take all the derivatives for you. \nTensorflow, for example, has a minimize() method in its Optimizer class that takes a loss function as an input. Given a function of the parameters of the network, it will do the calculus for you to determine which way to update the parameters in order to minimize that function. But we don't want to minimize. We want to maximize! So just include a negative sign. \nIn our case, the function we want to minimize is \n$$-G_t\\ln \\pi(A_t|S_t,\\theta_t).$$ \nThis corresponds to stochastic gradient descent ($G_t$ is not a function of $\\theta_t$). \nYou might want to do minibatch gradient descent on each episode of experience in order to get a better (lower variance) estimate of $\\nabla_{\\theta_t} J$. If so, you would instead minimize \n$$-\\sum_t G_t\\ln \\pi(A_t|S_t,\\theta_t),$$\nwhere $\\theta_t$ would be constant for different values of $t$ within the same episode. Technically, minibatch gradient descent updates parameters in the average estimated maximizing direction, but the scaling factor $1/N$ can be absorbed into the learning rate.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does adding a constant to all rewards change the set of optimal policies in episodic tasks? I'm taking a Coursera course on Reinforcement learning. There was a question there that wasn't addressed in the learning material: Does adding a constant to all rewards change the set of optimal policies in episodic tasks?\nThe answer is Yes - Adding a constant to the reward signal can make longer episodes more or less advantageous (depending on whether the constant is positive or negative).\nCan anyone explain why is this so? And why it doesn't change in the case of continuous (non episodic) tasks? I don't see why adding a constant matters - as an optimal policy would still want to get the maximum reward...\nCan anyone give an example of this?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Generally we can write for $R_c$ the total reward with added constant $c$ of a policy as\n$$\nR_c = \\sum_{i=0}^K (r_i + c) \\gamma^i = \\sum_{i=0}^K r_i \\gamma^i + \\sum_{i=0}^K c \\gamma^i\n$$\nSo if we have two policies with the same total reward (without added constant)\n$$\n\\sum_{i=0}^{K_1} r_i^1 \\gamma^i = \\sum_{i=0}^{K_2} r_i^2 \\gamma^i\n$$\nbut with different lengths $K_1 \\neq K_2$ the total reward with added constant will be different, because the second term in $R_c$ ( $\\sum_{i=0}^K c \\gamma^i$ ) will be different.\nAs an example: Consider two optimal policies, both generating the same cumulative reward of 10, but the first policy visits 4 states, before it reaches a terminal state, while the second visits only two states. The rewards can be written as:\n$$\n10 + 0 + 0 + 0 = 10\n$$\nand \n$$\n0 + 10 = 10\n$$\nBut when we add 100 to every reward:\n$$\n110 + 100 + 100 + 100 = 410\n$$\nand \n$$\n100 + 110 = 210\n$$\nThus, now the first one is better.\nIn the continious case, the episodes always have length $K = \\infty$. Therefore, they always have the same length, and adding a constant doesnt change anything, because the second term in $R_c$ stays the same.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How should I handle action selection in the terminal state when implementing SARSA? I recently started learning about reinforcement learning. Currently, I am trying to implement the SARSA algorithm. However, I do not know how to deal with $Q(s', a')$, when $s'$ is the terminal state. First, there is no action to choose from in this state. Second, this $Q$-factor will never be updated either because the episode ends when $s'$ is reached. Should I initialize $Q(s', a')$ to something other than a random number? Or should I just ignore the $Q$-factors and simply feed the reward $r$ into the update?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The value $Q(s', ~\\cdot~)$ should always be implemented to simply be equal to $0$ for any terminal state $s'$ (the dot instead of an action as second argument there indicates that what I just wrote should hold for any action, as long as $s'$ is terminal).\nIt is easier to understand why this should be the case by dissecting what the different terms in the update rule mean:\n$$Q(s, a) \\gets \\color{red}{Q(s, a)} + \\alpha \\left[ \\color{blue}{r + \\gamma Q(s', a')} - \\color{red}{Q(s, a)} \\right]$$\nIn this update, the red term $\\color{red}{Q(s, a)}$ (which appears twice) is our old estimate of the value $Q(s, a)$ of being in state $s$ and executing action $a$. The blue term $\\color{blue}{r + \\gamma Q(s', a')}$ is a different version of estimating the same quantity $Q(s, a)$. This second version is assumed to be slightly more accurate, because it is not \"just\" a prediction, but it's a combination of: \n\nsomething that we really observed: $r$, plus \na prediction: $\\gamma Q(s', a')$\n\nHere, the $r$ component is the immediate reward that we observed after executing $a$ in $s$, and then $Q(s', a')$ is everything we expect to still be collecting afterwards (i.e., after executing $a$ in $s$ and transitioning to $s'$).\nNow, suppose that $s'$ is a terminal state, what rewards do we still expect to be collecting in the future within that same episode? Since $s'$ is terminal, and the episode has ended, there can only be one correct answer; we expect to collect exactly $0$ rewards in the future.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can 3 same size CNN layers in different ordering output different receptive field from the input layer? Below is a quote from CS231n:\n\nPrefer a stack of small filter CONV to one large receptive field CONV layer. Suppose that you stack three 3x3 CONV layers on top of each other (with non-linearities in between, of course). In this arrangement, each neuron on the first CONV layer has a 3x3 view of the input volume. A neuron on the second CONV layer has a 3x3 view of the first CONV layer, and hence by extension a 5x5 view of the input volume. Similarly, a neuron on the third CONV layer has a 3x3 view of the 2nd CONV layer, and hence a 7x7 view of the input volume. Suppose that instead of these three layers of 3x3 CONV, we only wanted to use a single CONV layer with 7x7 receptive fields. These neurons would have a receptive field size of the input volume that is identical in spatial extent (7x7), but with several disadvantages\n\nMy visualized interpretation:\n\nHow can you see through the first CNN layer from the second CNN layer and see a 5x5 sized receptive field?\nThere were no previous comments stating all the other hyperparameters, like input size, steps, padding, etc. which made this very confusing to visualize.\n\nEdited:\nI think I found the answer. BUT I still don't understand it. In fact, I am more confused than ever.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It is really easy to visualize the growth in the receptive field of the input as you go deep into the CNN layers if you consider a small example.\nLet's take a simple example:\nThe dimensions are in the form of $\\text{channels} \\times \\text{height} \\times \\text{width}$.\n\nThe input image $I$ is a $3 \\times 5 \\times 5$ matrix\nThe first convolutional layer's kernel $K_1$ has shape $3 \\times 2 \\times 2$ (we consider only 1 filter for simplicity)\nThe second convolutional layer's kernel $K_2$ has shape $1 \\times 2 \\times 2$\nPadding $P = 0$\nStride $S = 1$\n\nThe output dimensions $O$ are calculated by the following formula taken from the lecture CS231n.\n$$O= (I - K + 2P)/S + 1$$\nWhen you do a convolution of the input image with the first filter $K_1$, you get an output of shape $1 \\times 4 \\times 4$ (this is the activation of the CONV1 layer). The receptive field for this is the same as the kernel size ($K_1$), that is, $2 \\times 2$.\nWhen this layer (of shape $1 \\times 4 \\times 4$) is convolved with the second kernel (CONV2) $K_2$ ($1 \\times 2 \\times 2$), the output would be $1 \\times 3 \\times 3$. The receptive field for this would be the $3 \\times 3$ window of the input because you have already accumulated the sum of the $2 \\times 2$ window in the previous layer.\nConsidering your example of three CONV layers with $3 \\times 3$ kernels is also similar. The first layer activation accumulates the sum of all the neurons in the $3 \\times 3$ window of the input. When you further convolve this output with a kernel of $3 \\times 3$, it will accumulate all the outputs of the previous layers covering a bigger receptive field of the input.\nThis observation comes in line with the argument that deeper layers learn more intricate features like facial expressions, abstract concepts, etc. because they cover a larger receptive field of our original input image.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the relation between an environment, a state and a model? In particular, I would like to have a simple definition of \"environment\" and \"state\". What are the differences between those two concepts? Also, I would like to know how the concept of model relates to the other two. \nThere is a similar question What is the difference between an observation and a state in reinforcement learning?, but it is not exactly what I was looking for.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Environment\nThis is the manifestation of the problem being solved. It might be a real physical situation (a road network and cars), or virtual on a computer (a board game on a computer). It includes all the machinery necessary to resolve what happens. E.g. in the real world the objects involved, how the agent exerts its control when taking actions, and the applicable real-world laws of physics. Or, in a simulated world, things like the rules of a board game, implemented in code.\nState\nThis is the representation of a \"position\" at a certain time step within the environment. It may be something the agent can observe through sensors, or be provided directly by the computer system running a simulation.\nFor RL theory to hold, it is important that the state representation has the Markov Property, which is that the state accurately foretells the probabilities of rewards and following state for each action that could be taken. You do not need to know those probabilities in order to run RL algorithms (in fact it is a common case that you don't know). However, it is important that the dependency between the state+action and what happens next holds reliably.\nThe state is commonly represented by a vector of values. These describe positions of pieces in a game, or positions and velocities of objects that have been sensed. A state may be built from observations, but does not have to match 1-to-1 with a single observation. Care must be taken to have enough information to have the Markov Property. So, for instance, a single image from a camera does not capture velocity - if velocity is important to your problem, you may need multiple consecutive images to build a useful state.\nModel\nIn reinforcement learning, the term \"model\" specifically means a predictive model of the environment that resolves probabilities of next reward and next state following an action from a state. The model might be provided by the code for the environment, or it can be learned (separately to learning to behave in that environment).\nSome RL algorithms can make use of a model to help with learning. Planning algorithms require one. So called \"model free\" algorithms do not because they do not make use of an explicit model, they work purely from experience.\nThere are broadly two types of model:\n\nA distribution model which provides probabilities of all events. The most general function for this might be $p(r,s'|s,a)$ which is the probability of receiving reward $r$ and transitioning to state $s'$ given starting in state $s$ and taking action $a$.\n\nA sampling model which generates reward $r$ and next state $s'$ when given a current state $s$ and action $a$. The samples might be from a simulation, or just taken from history of what the learning algorithm has experienced so far.\n\n\nIn more general stats/ML, the term \"model\" is more inclusive, and can mean any predictive system that you might build, not just predictions of next reward and state. However, the literature for RL typically avoids calling those \"model\", and uses terms like \"function approximator\" to avoid overloading the meaning of \"model\".\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do I know if my backpropagation is implemented correctly? I'm working on an implementation of the backpropagation algorithm for a simple neural network, which predicts a probability of survival (1 or 0).\nHowever, I can't get it above 80%, no matter how much I try to set the right hyperparameters. I suspect that's because my backpropagation is implemented incorrectly, since I tried 2 different types of code and both give me the same results.\nIs there a way to determine whether my implementation of backpropagation is correct?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Don't feel too bad for having gotten it slightly wrong because backpropagation is notoriously difficult to implement [1].\nThere is a technique called gradient checking, which you can implement to test the correctness of your backpropagation implementation. I would argue that even gradient checking is a little tricky to implement.\nHow does gradient checking work?\n\nBackpropagation computes the gradients $\\frac{\\partial J}{\\partial \\theta}$, where $\\theta$ denotes the parameters of the model. $J$ is computed using forward propagation and your loss function.\n\nBut because forward propagation is fairly straightforward to implement, most people are usually confident that you got its implementation correct. So, the trick is to use the value of $J$ to verify your code for computing $\\frac{\\partial J}{\\partial \\theta}$.\n\nWe know that by definition, the gradient or derivative is given by:\n$$\\frac{\\partial J}{\\partial \\theta} = \\lim_{\\epsilon \\rightarrow 0} \\frac{J(\\theta + \\epsilon) \u2212 J(\\theta \u2212 \\epsilon)}{2 \\epsilon}$$\nSince we trust our calculation of $J$, we can easily compute the value of $J(\\theta + \\epsilon) \u2212 J(\\theta \u2212 \\epsilon)$.\n\n\nFor more information, see this Andrew Ng's video lecture and these notes.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it okay to use publicly available Instagram videos to train an AI? Since I haven't found any good training data for my university project, I want to use pictures and videos from public Instagram profiles. Am I allowed to do that?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Under US copyright law, this is probably fair use\n...but beware of memorization. You may run into more trouble if the AI outputs things very similar to the original work.\nAlso, consult a lawyer to help you apply the law to your specific situation. This is just information on general legal principles, not any specific situation, and also I'm not a lawyer.\n\nFirst of all, the vast majority of images on Instagram are almost certainly subject to copyright protection, as any creative work is automatically subject to such protection (with exceptions for things like government works). You'd either need a license to use it, or an exception such as fair use.\nFair use is a four-factor balancing test\nIt requires consideration of four factors by a judge:\n\nthe purpose and character of your use\nthe nature of the copyrighted work\nthe amount and substantiality of the portion taken\nthe effect of the use upon the potential market.\n\nLet's go through them for this.\nThe purpose and character of your use\nThis is probably best known as whether the work is transformative. Exactly how transformative it is depends on exact what type of AI you're training (an AI to do object recognition is probably more transformative than an AI that outputs Instagram-esque photos, for instance), but I'd expect that this would generally lean in favor of the AI trainer.\nThe nature of the copyrighted work\nIt's a creative work, not a factual work. Probably leans against the AI trainer. It would lean further against the AI trainer if the works were unpublished rather than publicly viewable on Instagram.\nThe amount and substantiality of the portion taken\nThis one's complicated. In some sense, you've used the whole work to train the AI. In another sense, you've only taken some general information about what's in the work. This may also be affected by how much is reproduced from the work by the AI. Probably leans in favor of the AI trainer.\nThe effect of the use upon the potential market\nIf you're using the AI to copy someone's artistic style and compete with them in that manner, that might lean against you. Otherwise, it seems unlikely that training an AI with Instagram data would affect the market for the original images. Probably leans in favor of the AI trainer.\nOverall, these four factors lean in favor of using such data for training AI/ML algorithms.\n\nPostscript: there is also a relevant legal case, but as it involves my employer, I won't be commenting on it beyond providing that link.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the relation between the context in contextual bandits and the state in reinforcement learning? Conceptually, in general, how is the context being handled in contextual bandits (CB), compared to states in reinforcement learning (RL)?\nSpecifically, in RL, we can use a function approximator (e.g. a neural network) to generalize to other states. Would that also be possible or desirable in the CB setting?\nIn general, what is the relation between the context in CB and the state in RL?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The notion of a state in reinforcement learning is (more or less) the same as the notion of a context in contextual bandits. The main difference is that, in reinforcement learning, an action $a_t$ in state $s_t$ not only affects the reward $r_r$ that the agent will get but it will also affect the next state $s_{t+1}$ the agent will end up in, while, in contextual bandits (aka associative search problems), an action $a_t$ in the state $s_t$ only affects the reward $r_r$ that you will get, but it doesn't affect the next state the agent will end up in. The typical problem that can be formulated as a contextual bandit problem is a recommender system.\nIn CBs, like in RL, the agent also needs to learn a policy, i.e. a function from states to actions, but actions that you take in a certain state are independent of the actions you take in other states.\nSo, as Sutton and Barto put it (2nd edition, section 2.9, page 41), contextual bandits are an intermediate problem between (context-free) bandits (where there is only one state or, equivalently, no state at all) and the full reinforcement learning problem.\nAnother important characteristic of many RL algorithms, such as Q-learning, is that they assume that the state is Markov, i.e. it contains all necessary info to take the optimal action, but, of course, RL is not just applicable to fully observable MDPs. In fact, even Q-learning has been applied to POMDPs, with some approximations and tricks.\nRegarding the use of neural networks to approximate $q(s, a)$ or a policy in CBs, in principle, this is possible. However, given that the optimal action in a state $s$ is independent of the optimal action in another state $s'$, this is probably not useful, but I cannot guarantee you that this has not been successfully done, because I've not yet read the relevant literature (maybe someone else will provide another answer to address this aspect).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is an objective function? Local search algorithms are useful for solving pure optimization problems, in which the aim is to find the best state according to an objective function.\nMy question is what is the objective function?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The objective function is the function that you want to minimise or maximise in your problem.\nThe expression \"objective function\" is used in several different contexts (e.g. machine learning or linear programming), but it always refers to the function to be maximised or minimised in the specific (optimisation) problem. Hence, this expression is used in the context of mathematical optimisation.\nFor example, in machine learning, you define a model, $\\mathcal{M}$. To train $\\mathcal{M}$, you usually define a loss function $\\mathcal{L}$ (e.g., a mean squared error), which you want to minimise. $\\mathcal{L}$ is the objective function of your problem (which in this case is to be minimised).\nIn the context of search algorithms, the objective function could represent e.g. the cost of the solution. For example, in the case of the travelling salesman problem (TSP), you define a function, call it $C$, which represents the \"cost\" of the tour or Hamiltonian cycle, that is, a function which sums up the weights of all edges in the tour. In this case, the \"objective\" of your problem is to minimise this function $C$, because, essentially, you want to find an inexpensive tour, which is associated with either a local (or global) minimum of $C$. This function $C$ is the \"objective function\".\nIt should now be easy to memorise the expression \"objective function\", as it contains the term \"objective\", and the \"objective\" (or goal) in your (optimisation) problem is to minimise (or maximise) the corresponding function.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can alpha zero learn if the tree search stops and restarts before finishing a game? I am trying to understand how alpha zero works, but there is one point that I have problems understanding, even after reading several different explanations. As I understand it (see for example https://applied-data.science/static/main/res/alpha_go_zero_cheat_sheet.png), alpha zero does not perform rollouts. So instead of finishing a game, it stops when it hits an unknown state, uses the neural network to compute probabilities for different actions as well as the value of this state (\"probability of winning\"), and then propagates the new value up the tree.\nThe reasoning is that this is much cheaper, since actually completing the game would take more time then just letting the neural network guess the value of a state.\nHowever, this requires that the neural network is decent at predicting the value of a state. But in the beginning of training, obviously it will be bad at this. Moreover, since the monte carlo tree search stops as soon as it hits a new state, and the number of different game states is very large, it seems to me that the simulation will rarely manage to complete a game. And for sure, the neural network can not improve unless it actually completes a significant number of games, because that is only real feedback that tells the agent if it is doing good or bad moves.\nWhat am I missing here?\nThe only plausible explanation I can come up with is: If the neural network would be essentially random in the beginning, well then for sure the large number of game states would prevent the tree search from ever finishing if it restarts as soon as it hits a previously unknown game state, so this can not be the case. So perhaps, maybe even if the neural network is bad in the beginning, it will not be very \"random\", but still be quite biased towards some paths. This would mean that the search would be biased to some smaller set of states among the vast number of different game states, and thus it would tend to take the same path more than once and be able to complete some games and get feedback. Is this \"resolution\" correct?\nOne problem I have though with the above \"resolution\", is that according to the algorithm, it should favor exploration in the beginning, so it seems that in the beginning it will be biased towards choosing previously not taken actions. This makes it even more seem like the tree search will never be able to complete a game and thus the neural net would not learn.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You're right that AlphaGo Zero doesn't perform rollouts in its MCTS. It does complete many, many games, though.\nRealize that AlphaGo Zero only iterates MCTS 1,600 times before taking an action. The next state resulting from that action becomes the root of future search trees. Since a typical game of Go only lasts a few hundred moves, the board will very quickly reach a terminal state. \nNone of this is dependent on the initial performance of the neural network. The neural net can be incredibly bad; actions/moves will still be taken at the same frequency. Of course, since AlphaGo Zero trains with self-play, one of its two selves in a game will usually be the winner (ties are possible). So the neural net will improve over time. \nI recommend going over the \"Self-Play Training Pipeline\" section of the paper.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are humans intelligent according to the definition of an intelligent agent? Given the following definition of an intelligent agent (taken from a Wikipedia article)\n\nIf an agent acts so as to maximize the expected value of a performance measure based on past experience and knowledge then it is intelligent\n\nand given that we, humans, all make mistakes, which means that we are not maximizing the expected value of a performance measure, then does this imply that humans are not intelligent? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It rather depends on how one defines several of the terms used. For example:\n\nWhether the term \"expected\" is interpreted in a formal (i.e.\nstatistical) sense. \nWhether it's assumed that humans have any kind of utilitarian\n\"performance measure\".\n\nThe motivation for this description of \"agent\" arose from a desire to have a quantitative model - it's not clear that such a model is a good fit for human cognition.\nHowever, there are alternative definitions of agents, for example the BDI model, which are rather more open-ended and hence more obviously applicable to humans.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does the recent advent of a Go playing computer represent Artificial Intelligence? I read that in the spring of 2016 a computer Go program was finally able to beat a professional human for the first time. \nNow that this milestone has been reached, does that represent a significant advance in artificial intelligence techniques or was it just a matter of even more processing power being applied to the problem? \nWhat are some of the methods used to program the successful Go-playing program? \nAre those methods considered to be artificial intelligence?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are at least two questions in your question: \n\nWhat are some of the methods used to program the successful go playing program?\n\nand\n\nAre those methods considered to be artificial intelligence?\n\nThe first question is deep and technical, the second broad and philosophical.\nThe methods have been described in: Mastering the Game of Go with Deep Neural Networks and Tree Search.\nThe problem of Go or perfect information games in general is that:\n\nexhaustive search is infeasible.\n\nSo the methods will concentrate on shrinking the search space in an efficient way.\nMethods and structures described in the paper include:\n\nlearning from expert human players in a supervised fashion\nlearning by playing against itself (reinforcement learning)\nMonte-Carlo tree search (MCTS) combined with policy and value networks\n\nThe second question has no definite answer, as you will have at least two angles on AI: strong and weak.\n\nAll real-world systems labeled \"artificial intelligence\" of any sort are weak AI at most.\n\nSo, yes, it is artificial intelligence, but it is non-sentient.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why use a recurrent neural network over a feedforward neural network for sequence prediction? If recurrent neural networks (RNNs) are used to capture prior information, couldn't the same thing be achieved by a feedforward neural network (FFNN) or multi-layer perceptron (MLP) where the inputs are ordered sequentially?\nHere's an example I saw where the top line of each section represents letters typed and the next row represents the predicted next character (red letters in the next row means a confident prediction).\n\nWouldn't it be simpler to just pass the $X$ number of letters leading up to the last letter into an FFNN?\nFor example, if $X$ equaled 4, the following might be the input to the FFNN\nS, T, A, C => Prediction: K\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Assumptions\nDifferent model structures encode different assumptions - while we often make simplifying assumptions that aren't strictly correct, some assumptions are more wrong than others.\nFor example, your proposed structure of \"just pass the $X$ number of letters leading up to the last letter into an FFNN\" makes an assumption that all the information relevant for the decision is fully obtainable from the $X$ previous letters, and $(X+1)$st and earlier input letters are not relevant - in some sense, an extension of the Markov property. Obviously, that's not true in many cases, there are all kinds of structures where long term relationships matter, and assuming that they don't lead to a model that intentionally doesn't take such relationships into account. Furthermore, it would make an independence assumption that the effect of $X$th, $(X-1)$st and $(X-2)$nd elements on the current output is entirely distinct and separate, you don't make an assumption that those features are related, while in most real problems they are.\nThe classic RNN structures also make some implicit assumptions, namely, that only the preceding elements are relevant for the decision (which is wrong for some problems, where information from the following items is also required), and that the transformative relationship between the input, output and the passed-on state is the same for all elements in the chain, and that it doesn't change over time; That's also not certainly true in all cases, this is quite a strong restriction, but that's generally less wrong than the assumption that the last $X$ elements are sufficient, and powerful true (or mostly true) restrictions are useful (e.g. the No Free Lunch Theorem applies) for models that generalize better; just like e.g. enforcing translational invariance for image analysis models, etc.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is Experience Replay like dreaming? Drawing parallels between Machine Learning techniques and a human brain is a dangerous operation. When it is done successfully, it can be a powerful tool for vulgarisation, but when it is done with no precaution, it can lead to major misunderstandings.\nI was recently attending a conference where the speaker described Experience Replay in RL as a way of making the net \"dream\".\nI'm wondering how true this assertion is. The speaker argued that a dream is a random addition of memories, just as experience replay. However, I doubt the brain remembers its dream or either learns from it. What is your analysis?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nThe speaker argued that a dream is a random addition of memories, just as experience replay.\n\nThe speaker is taking some liberties due to a general lack of scientific understanding of what dreams are. We don't even have strong consensus on why sleep is a necessary feature of animals, let alone what part dreaming plays in it. However, there are some widely-accepted theories, with supporting evidence, that dreams are part of a learning and memorisation process. Studies that manipulate sleep or dreaming have shown changes in the speed that skills are learned for example.\nExperience replay in reinforcement learning is a far more precise and well-understood affair, whereby individual time steps that occurred in the past are visited and re-assessed in light of current knowledge about long-term value, at random. If dreams were really like experience replay as it is practiced in RL today, then they would consist of a random jumble of tiny seemingly inconsequential events strung together, and all taken very exactly from the events of the past day. Sometimes dreams do contain content like this, but typically the content is far more varied.\nTaken with a large dose of artistic license, then yes, the speaker is referring to real theories and conjectures about dreaming, that do have scientific support. Although it is equally good to draw parallels between dreams and a higher-level management of the memory or experience replay data - which items to replay, and which to keep, depending on what is salient about the information. For instance, there is good evidence that dreams help filter what is forgotten, and also evidence that events associated with strong emotional state are more likely to feature in dreams.\nIt is important to separate the speaker's analogy, and any suggestion that a current reinforcement learning agent has a subjective experience. We are still a long way away from anything like that, and other similar use of a dreaming metaphor in machine learning - e.g. \"Deep Dream\" - is equally not an assertion that the devices are having an experience of any kind.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the main algorithms used in computer vision? Nowadays, CV has really achieved great performance in many different areas. However, it is not clear what a CV algorithm is.\nWhat are some examples of CV algorithms that are commonly used nowadays and have achieved state-of-the-art performance?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are many computer vision (CV) algorithms and models that are used for different purposes. So, of course, I cannot list all of them, but I can enumerate some of them based on my experience and knowledge. Of course, this answer will only give you a flavor of the type of algorithm or model that you will find while solving CV tasks.\nFor example, there are algorithms that are used to extract keypoints and descriptors (which are often collectively called features, although the descriptor is the actual feature vector and the keypoint is the actual feature, and in deep learning this distinction between keypoints and descriptors does not even exist, AFAIK) from images, i.e. feature extraction algorithms, such as SIFT, BRISK, FREAK, SURF or ORB. There are also edge and corner detectors. For example, the Harris corner detector is a very famous corner detector.\nNowadays, convolutional neural networks (CNNs) have basically supplanted all these algorithms in many cases, especially when enough data is available. Rather than extracting the typical features from an image (such as corners), CNNs extract features that are most useful to solve the task that you want to solve by taking into account the information in the training data (which probably includes corners too!). So, sometimes CNNs are more specifically called data-driven feature extractors. There are different types of CNNs. For example, CNNs that were designed for semantic segmentation (which is a CV task/problem), such as the u-net, or CNNs that were designed for instance segmentation, such as mask R-CNN.\nThere are also algorithms that can be used to normalize features, such as the bag-of-features algorithm, which can be used to create fixed-size feature vectors. This can be particularly useful for tasks like content-based image retrieval.\nThere are many other algorithms that could be considered CV algorithms or are used to solve CV tasks. For example, RanSaC, which is a very general algorithm to fit models to data in the presence of outliers, can be used to fit homographies (matrices that are generally used to transform planes to other planes) that transform pixels of one image to another coordinate system of another image. This can be useful for the purpose of template matching (which is another CV task), where you want to find a template image in another target image. This is very similar to object detection.\nThere are also many image processing algorithms and techniques that are heavily used in computer vision. For example, all the filters (such as Gaussian, median, bilateral, non-local means, etc.) that can be used to smooth, blur or de-noise images. Nowadays, some deep learning techniques have also replaced some of these filters and image processing techniques, such as de-noising auto-encoders.\nAll these algorithms and models have something in common: they are used to process images and/or get low- or high-level information from images. Most of them are typically used to extract features (i.e. regions of the images that are relevant in some way) from images, so that they can later be used to train a classifier or regressor to perform some kind of task (e.g. find and distinguish the objects, such people, cars, dogs, etc. in an image). The classifiers/regressors are typically machine learning (ML) models, such as SVMs or fully-connected neural networks, but there's a high degree of overlap between CV and ML because some ML tools are used to solve CV tasks (e.g. image classification).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between hypothesis space and representational capacity? I am reading Goodfellow et al Deeplearning Book. I found it difficult to understand the difference between the definition of the hypothesis space and representation capacity of a model. \nIn Chapter 5, it is written about hypothesis space:\n\nOne way to control the capacity of a learning algorithm is by choosing its hypothesis space, the set of functions that the learning algorithm is allowed to select as being the solution.\n\nAnd about representational capacity:\n\nThe model speci\ufb01es which family of functions the learning algorithm can choose from when varying the parameters in order to reduce a training objective. This is called the representational capacity of the model.\n\nIf we take the linear regression model as an example and allow our output $y$ to takes polynomial inputs, I understand the hypothesis space as the ensemble of quadratic functions taking input $x$, i.e $y = a_0 + a_1x + a_2x^2$.\nHow is it different from the definition of the representational capacity, where parameters are $a_0$, $a_1$ and $a_2$?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Consider a target function $f: x \\mapsto f(x)$.\nA hypothesis refers to an approximation of $f$. A hypothesis space refers to the set of possible approximations that an algorithm can create for $f$. The hypothesis space consists of the set of functions the model is limited to learn. For instance, linear regression can be limited to linear functions as its hypothesis space, or it can be expanded to learn polynomials.\nThe representational capacity of a model determines the flexibility of it, its ability to fit a variety of functions (i.e. which functions the model is able to learn), at the same. It specifies the family of functions the learning algorithm can choose from.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do we update all layers simultaneously while training a neural network? \nVery deep models involve the composition of several functions or layers. The gradient tells how to update each parameter, under the assumption that the other layers do not change. In practice, we update all of the layers simultaneously.\n\nThe above is an extract from Ian Goodfellow's Deep Learning - which talks about the need for batch normalization. \nWhy do we update all the layers simultaneously? Instead, if we update layers one at a time during backpropagation - it will eliminate the need for batch normalization, right?\nReference: A Gentle Introduction to Batch Normalization for Deep Neural Networks\nP.S. The attached link says: Because all layers are changed during an update, the update procedure is forever chasing a moving target. Apart from the main question, it would be great if someone could explain why exactly a moving target is being referred to in the above sentence.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nWhy do we update all layers simultaneously while training a neural network?\n\nWe typically train a neural network with gradient descent and back-propagation. Gradient descent is the iterative algorithm used to update the parameters and back-propagation is the algorithm used to compute the gradient of the loss function with respect to each of these parameters.\nLet's denote a vector that contains all learnable parameters of a neural network $M$ by $\\mathbf{w} = \\left[w_1, \\dots, w_n \\right] \\in \\mathbb{R}^n$ (so $M$ contains $n$ learnable parameters), the loss function of $M$ by $\\mathcal{L}$, the gradient of the loss function with respect to each parameter $w_i$ of $M$ by $ \\nabla \\mathcal{L} = \\left[ \\frac{\\partial \\mathcal{L}}{\\partial w_1}, \\dots, \\frac{\\partial \\mathcal{L}}{\\partial w_n} \\right] \\in \\mathbb{R}^n$, then the gradient descent step to update all parameters is\n\\begin{align}\n\\mathbf{w} \\leftarrow \\mathbf{w} - \\gamma * \\nabla \\mathcal{L} \\tag{1} \\label{1}\n\\end{align}\nwhere $\\gamma \\in \\mathbb{R}$ is the learning rate.\nIn equation \\ref{1}, we are assigning to $\\mathbf{w}$ the value $\\mathbf{w} - \\gamma * \\nabla \\mathcal{L}$, so we are updating all parameters $\\mathbf{w}$ simultaneously, so we are also updating all layers simultaneously. \nIn principle, you could update each parameter $w_i$ individually. To be more precise, you would have the following update rule\n\\begin{align}\nw_i \\leftarrow w_i - \\gamma * \\frac{\\partial \\mathcal{L}}{\\partial w_i}, \\; \\forall i\\tag{2} \\label{2}\n\\end{align}\nSo, you could update first $w_1$, then $w_2$, and so on. \nActually, you don't need to update the parameters sequentially (also because there is no real order of the parameters). You can actually update them in any other way. You can update the parameters in any way because, although the computation of the gradient highly depends on the structure of the neural network (so if you change the structure, the computation of the gradient also changes), once the gradient is computed, you already have all information to update each parameter independently of each other. \nYou typically update all parameters (or layers) simultaneously because, in practice, you work with vectors and matrices rather than scalars in order to take benefit from efficient matrix multiplication algorithms and hardware (i.e. GPUs).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can DQN perform better than Double DQN? I'm training both DQN and double DQN in the same environment, but DQN performs significantly better than double DQN. As I've seen in the double DQN paper, double DQN should perform better than DQN. Am I doing something wrong or is it possible?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is no thorough proof, theoretical or experimental that Double DQN is better then vanilla DQN. There are a lot of different tasks, paper and later experiments only explore some of them. What practitioner can take out of it is that on some tasks DDQN is better. That's the essence of Deep Mind's \"Rainbow\" approach - drop a lot of different methods into bucket and take best results. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Could there be existential threats to humanity due to AI? We are doing research, spending hours figuring out how we can make real AI software (intelligent agents) to work better. We are also trying to implement some applications e.g. in business, health and education, using the AI technology.\nNonetheless, so far, most of us have ignored the \"dark\" side of artificial intelligence. For instance, an \"unethical\" person could buy thousands of cheap drones, arm them with guns, and send them out firing on the public. This would be an \"unethical\" application of AI.\nCould there be (in the future) existential threats to humanity due to AI?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I would define intelligence as a ability to predict future. So if someone is intelligent, he can predict some aspects of future, and decide what to do based on his predictions. So, if \"intelligent\" person decide to hurt other persons, he might be very effective at this (for example Hitler and his staff). \nArtificial intelligence might be extremely effective at predicting some aspects of uncertain future. And this IMHO leads to two negative scenarios:\n\nSomeone programs it for hurting people. Either by mistake or on purpose.\nArtificial intelligence will be designed for doing something safe, but at some point, to be more effective, it will redesign itself and maybe it will remove obstacles from its way. So if humans become obstacles, they will be removed very quickly and in very effective way.\n\nOf course, there are also positive scenarios, but you are not asking about them.\nI recommend reading this cool post about artificial superintelligence and possible outcomes of creating it: http://waitbutwhy.com/2015/01/artificial-intelligence-revolution-1.html\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the real world uses for SAT solvers? Why somebody would use SAT solvers (Boolean satisfiability problem) to solve their real world problems?\nAre there any examples of the real uses of this model?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Instead of talking about just SAT solvers, let me talk about optimization in general. Many economic problems can be cast as optimization problems: for example, FedEx may have a list of packages and the destinations for those packages, and must decide which packages to put on which trucks, and what order to deliver those packages in.\nIf you write out a mathematical description of this problem, there are a truly stunning number of possible solutions, and a well-defined way to evaluate which of two solutions is better. A solver is an algorithm that will evaluate a solution, come up with another solution, and then evaluate that one, and so on.\nIn small cases and simple problems, the solver can also terminate with a proof that it is actually the best solution possible. But typically instead the solver just reports \"this is the best solution that I've seen,\" and that's used. An improvement in the solver means you can reliably get lower-cost solutions than you were seeing before.\nFor the SAT problem specifically, the Wikipedia page on SAT gives some examples:\n\nSince the SAT problem is NP-complete, only algorithms with exponential worst-case complexity are known for it. In spite of this, efficient and scalable algorithms for SAT were developed over the last decade[when?] and have contributed to dramatic advances in our ability to automatically solve problem instances involving tens of thousands of variables and millions of constraints (i.e. clauses).[1] Examples of such problems in electronic design automation (EDA) include formal equivalence checking, model checking, formal verification of pipelined microprocessors,[12] automatic test pattern generation, routing of FPGAs,[14] planning, and scheduling problems, and so on. A SAT-solving engine is now considered to be an essential component in the EDA toolbox.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are some best practices when trying to design a reward function? Generally speaking, is there a best-practice procedure to follow when trying to define a reward function for a reinforcement-learning agent? What common pitfalls are there when defining the reward function, and how should you avoid them? What information from your problem should you take into consideration when going about it?\nLet us presume that our environment is fully observable MDP.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Designing reward functions\nDesigning a reward function is sometimes straightforward, if you have knowledge of the problem. For example, consider the game of chess. You know that you have three outcomes: win (good), loss (bad), or draw (neutral). So, you could reward the agent with $+1$ if it wins the game, $-1$ if it loses, and $0$ if it draws (or for any other situation).\nHowever, in certain cases, the specification of the reward function can be a difficult task [1, 2, 3] because there are many (often unknown) factors that could affect the performance of the RL agent. For example, consider the driving task, i.e. you want to teach an agent to drive e.g. a car. In this scenario, there are so many factors that affect the behavior of a driver. How can we incorporate and combine these factors in a reward function? How do we deal with unknown factors?\nSo, often, designing a reward function is a trial-and-error and engineering process (so there is no magic formula that tells you how to design a reward function in all cases). More precisely, you define an initial reward function based on your knowledge of the problem, you observe how the agent performs, then tweak the reward function to achieve greater performance (for example, in terms of observable behavior, so not in terms of the collected reward; otherwise, this would be an easy problem: you could just design a reward function that gives infinite reward to the agent in all situations!). For example, if you have trained an RL agent to play chess, maybe you observed that the agent took a lot of time to converge (i.e. find the best policy to play the game), so you could design a new reward function that penalizes the agent for every non-win move (maybe it will hurry up!).\nOf course, this trial-and-error approach is not ideal, and it can sometimes be impractical (because maybe it takes a lot of time to train the agent) and lead to misspecified reward signals.\nMisspecification of rewards\nIt is well known that the misspecification of the reward function can have unintended and even dangerous consequences [5]. To overcome the misspecification of rewards or improve the reward functions, you have some options, such as\n\nLearning from demonstrations (aka apprenticeship learning), i.e. do not specify the reward function directly, but let the RL agent imitate another agent's behavior, either to\n\nlearn the policy directly (known as imitation learning [8]), or\nlearn a reward function first to later learn the policy (known as inverse reinforcement learning [1] or sometimes known as reward learning)\n\n\nIncorporate human feedback [9] in the RL algorithms (in an interactive manner)\n\nTransfer the information in the policy learned in another but similar environment to your environment (i.e. use some kind of transfer learning for RL [10])\n\n\nOf course, these solutions or approaches can also have their shortcomings. For example, interactive human feedback can be tedious.\nReward shaping\nRegarding the common pitfalls, although reward shaping (i.e. augment the natural reward function with more rewards) is often suggested as a way to improve the convergence of RL algorithms, [4] states that reward shaping (and progress estimators) should be used cautiously. If you want to perform reward shaping, you should probably be using potential-based reward shaping (which is guaranteed not to change the optimal policy).\nFurther reading\nThe MathWorks' article Define Reward Signals discusses continuous and discrete reward functions (this is also discussed in [4]), and addresses some of their advantages and disadvantages.\nLast but not least, the 2nd edition of the RL bible contains a section (17.4 Designing Reward Signals) completely dedicated to this topic.\nAnother similar question was also asked here.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Deep Learning with Best-so-far instead of Where-you-are It is my understanding that when training a Deep NN in Tensorflow/PyTorch/... we only keep the current state of the network in memory, except perhaps when we manually decide to save the current weights to the HDD/SSD.\nNow, naively speaking it may seem reasonable to not only remember the current state (i.e. the current values of the trained weights), i.e. \"where we are\", but also the \"best\" weights \"so far\" by some metric, such as the validation error. Immediately, this approach doubles our memory requirements, especially if we want to keep everything in the GPU memory.\nIs this done in practice? If not what are arguments against it?\n\nNow there are certainly details that make this question more tricky. If you saved only each epoch it's probably fine to just save your weights to the HDD without significant loss in speed. If you remember the best weights for each step of SGD than you would have to compute the validation error over and over, which is costly. Or you use perhaps an estimate of the training error based on its gradient, which however could be leading to overfitting if you are not careful. You could also mix and match, or you could compute the validation error only on a subset of the data, or only remember the best every $k$ steps, etc. etc. You might also want to go back and restart from a \"better\" set of weights in the hopes of getting a better trajectory.\nI also don't know whether in practice at the of training people typically, deliberately, go back to a previous \"checkpoint\" they might have saved somewhere.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nIs this done in practice?\n\nYes, this is done normally when using (lack of) improvements to validation metrics as a stop criterion, and many libraries support it as standard. Depending on the library, you may find you need to add a little code to keep a copy of the best-so-far weights, but some will do it automatically by default, or based on setting params on the train or fit function.\nFor example, Keras' EarlyStopping class has a restore_best_weights parameter. Using this class in your main fit function, and setting the param to true will do what you want automatically with no other code required.\n\nIf not what are arguments against it?\n\nOver-fitting to the validation set is a possible concern, as running the validation checks 100s of times to decide the \"best\" model may lead to some maximisation bias, and make decisions between other hyperparameters than the number of epochs less reliable.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do neural network topologies affect GPU/TPU acceleration? I was thinking about different neural network topologies for some applications. However, I am not sure how this would affect the efficiency of hardware acceleration using GPU/TPU/some other chip.\nIf, instead of layers that would be fully connected, I have layers with neurons connected in some other way (some pairs of neurons connected, others not), how is this going to affect the hardware acceleration?\nAn example of this is the convolutional networks. However, there is still a clear pattern, which perhaps is exploited by the acceleration, which would mean that if there is no such pattern, the acceleration would not work as well?\nShould this be a concern? If so, is there some rule of thumb for how the connectivity pattern is going to affect the efficiency of hardware acceleration?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The topology of a neural network can have a significant impact on the performance of GPU and TPU acceleration.\n\nThe most important factor is the number of layers and the connectivity between them.\n\nSimple topologies require less data movement and can be more easily parallelized. a shallower network with fewer layers will often be faster to train on a GPU or TPU than a deeper network with more layers. This is because each layer in a neural network must be fully connected to the previous and next layers, and a deep network will have many more connections than a shallow network.\nAdditionally, the activation function used for each layer can also impact performance. ReLU is a common activation function that is often used in networks that are accelerated by GPUs or TPUs.\nGPU-based acceleration of CNN\n\nGPU is widely used in neural network applications due to a large number of ALU units which helps in faster data processing (multiplication and summation operations in NN), and also the GPU caches, which help in data reuse.\n\nThe GPU is capable of merging multiple data access requests using the controllers, and it helps in massive parallel and pipelined processing.\nGPU is a temporal architecture paradigm with a large number of ALUs, but the ALUs lack direct data communication, and they communicate using direct memory access.\n\nGPU has around $3,000\u20135,000$ ALU But the Von Neumann bottleneck exists in GPU due to the access to registers and the shared memory for intermediate data storage in every ALU operation.\n\nThe GPU has specialized libraries for CNN acceleration like fbfft (Vasilache et al., 2015). While using a high working set, the shared memory cannot be used, and there is a need for global memory access in GPU, and this leads to more memory footprints and memory access.\n\n\nTPU-based acceleration of CNN\n\nTPU is a custom-made ASIC with a matrix processor which is specially designed for neural networks. it effectively handles the addition and multiplication in neural nets at a very high speed with very little power consumption.\n\nThe von Neumann bottleneck in CPU and GPU is overcome in TPU with the systolic array structure. TPU v2 single processor has 16-bit two 128 \u00d7 128 systolic arrays with 32,768 ALUs.\n\nSystolic array in TPU helps in data reuse which makes the performance high and execution energy efficient in CNN.\n\nThe two-dimensional multiply unit helps in matrix multiplication faster compared to the one-dimensional multiply units in CPU and GPU.\n\nIn TPU, eight-bit integers are used in place of the 32-bit floating-point operations, and this makes the computations faster and memory efficient.\n\nUnlike CPU and GPU TPU drops features that are not used in the neural network, which helps in saving energy.\n\nCNN implementation in TPU will have both TPU and CPU usage in parallel to run the linear and non-linear elements in CNN.\n\nIn CNN the convolution and classification layer is executed in TPUsince it is a GEMM operation, and the Pooling and Flattening are executed in the CPU.\n\n\n\n\nHere is the paper that analyzed CNN model performance for the three-image processing application in GPU/TPU platforms in Colab for various batch sizes. The analysis was done by varying the final feed-forward network and the hidden layers, and this gives an inference on how the performance is affected when the model structure changes\n\n\nFig(a): Training time for single and multiple convolutional layer networks.\nIn the paper, analysis was done using a single convolutional layer followed by all other layers for the mask detection application for binary class, and the training time was analyzed for GPU and TPU for both networks. The training time increases when the convolutional layers are removed because the number of nodes gets more, and thereby training time increases. The training time for Single layer convolution and multiple-layer Convolution for different batch sizes is shown in Fig(a).\nThe analysis clearly shows that the time decreases when the number of convolutions increases due to a reduction in the number of nodes. The training time is less for the multiple layers CNN compared to single-layer CNN and also with an increase in the batch size.\n\nFig(b): Execution time for multi and binary classes.\nThe overall training time for each of the three applications was in GPU and TPU for both binary, and multiple classifications were analyzed and shown in Fig(b).\nFrom Fig(b), it is clear that compared to TPU, GPU has a low time for execution of the CNN. This occurs due to the bottleneck that occurs in TPU due to the in-between CPU access.\n\nGPU: GPU performs well for small batches and gives better flexibility and easy programming. For small data, batch sizes GPU fits better due to the execution pattern in wraps and scheduling id easy on-stream multiprocessors. For large dataset and network models, GPU performs well by optimizing memory reuse. In fully connected neural networks, weight reuse is less, so as the model size increases, this leads to high memory traffic. In GPU, the memory bandwidth makes it practical for applications with memory requirements. Large neural networks work better on GPU compared to CPU due to the extra parallelism feature. For fully connected neural networks, GPU works better compared to CPU, but for large batch sizes, TPU performs well.\n\n\nTPU: TPU performs well on CNN with large batches to give high throughput in training time using the systolic array structure. Large batches of data are needed for the full utilization of the matrix multiply units in the systolic array of TPU. In CNN, the speedup increases with batch size. For enormous batch sizes and complex CNN, TPU is the best because of the spatial reuse characteristics of CNNs. But in fully connected networks, the weight reuse is less, and so TPU is not preferred.\n\n\nDifferent neural network topologies may require different amounts of resources (memory, computational power, etc.), which could affect the efficiency of hardware acceleration. There is no easy rule of thumb, however, as it depends on the specific architecture and implementation.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What will happen when you place a fake speedsign on a highway? I was wondering what will happen when somebody places a fake speedsign, of 10 miles per hour on a high way. Will a autonomous car slow down? Is this a current issue of autonomous cars? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "https://www.technologyreview.com/s/530276/hidden-obstacles-for-googles-self-driving-cars/\n\nGoogle\u2019s cars can detect and respond to stop signs that aren't on its map, a feature that was introduced to deal with temporary signs used at construction sites. But in a complex situation like at an unmapped four-way stop the car might fall back to slow, extra cautious driving to avoid making a mistake.\n\nIt's highly probable they would slow down with current technology, as they can detect temporary signs and are designed to use slow speed in complex cases.\nIf it was a true temporary sign (e.g. road repair), how can it make the distinction? It probably would be worse to ignore a slow down sign than slow down at a fake one.\nIMHO, the problem there is with the joke in the first place, as some humans might slow down too.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the purpose of the actor in actor-critic algorithms? For discrete action spaces, what is the purpose of the actor in actor-critic algorithms? \nMy current understanding is that the critic estimates the future reward given an action, so why not just take the action that maximizes the estimated return?\nMy initial guess at the answer is the exploration-exploitation problem, but are there other, more important/deeper reasons? Or am I underestimating the importance of exploration vs. exploitation as an issue?\nIt just seems to me that if you can accurately estimate the value function, then you have solved the RL challenge. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nFor discrete action spaces, what is the purpose of the actor in Actor-Critic algorithms?\n\nIn brief, it is the policy function $\\pi(a|s)$. The critic (a state action function $v_{\\pi}(s)$) is not used to derive a policy, and in \"vanilla\" Actor-Critic cannot be used in this way at all unless you have the full distribution model of the MDP.\n\nIt just seems to me that if you can accurately estimate the value function, then you have solved the RL challenge.\n\nOften this can be the case, and this is how e.g. Q-learning works, where the value function is more precisely the action value function, $q(s,a)$. \nContinuous or very large action spaces can cause a problem here, in that maximising over them is impractical. If you have a problem like that to solve, it is often an indicator that you should use a policy gradient method such as Actor-Critic. However, you have explicitly asked about \"discrete action spaces\" here.\nThe main issue with your statement \"if you can accurately estimate the value function\" is that you have implicitly assumed the the learning is complete. You are looking at the final output of the algorithm, after it has converged, and asking why not use just half of its output. Whilst choosing between RL algorithms is more often related to how they learn, how efficiently they learn, and how they behave during the learning process.\n\nMy current understanding is that the critic estimates the future reward given an action, so why not just take the action that maximizes the estimated return?\n\nThe critic is $v_{\\pi}(s)$ so does not take actions into account. You can of course learn $q_{\\pi}(s,a)$ instead or as well - and some policy gradient methods also estimate the action value, such as Advantage Actor-Critic.\nThe main difference is in how data gathered from experience is applied to changing the policy. Recall at any step during reinforcement learning, that all estimates are based around a best guess at values of a current target policy. Policy gradient methods directly improve the policy, whilst value-based methods have an implied policy based on the same learned value functions. The $\\text{argmax}_a q(s,a)$ approach used in Q-learning or SARSA gives a simple but crude mapping from values to policy, and means that the trajectory through policy space taken whilst learning is different when comparing policy gradient methods and value-based methods. \nThe following are notable differences affecting performance between policy-based methods and value-based methods:\n\nPolicy-gradient methods tend to make small changes to policy on each step, the policy changes smoothly, adjusting probabilities between choice of different actions by small amounts. This in turn means that the targets for estimated value functions change slowly. In comparison, when a value based method finds a new maximising action, it can make a big change to the policy, making the updates required less smooth.\nPolicy-gradient methods can learn to balance stochastic policies, whilst value-based methods assume deterministic policies. So if you have a situation like paper, scissor stone game where the ideal policy is random choice between actions, you should use policy gradients. This is a bit niche, but is worth noting.\nFunction approximators (typically neural networks) are easier to train on simpler target functions. The policy function $\\pi(a|s)$ and action value function $q(s,a)$ are quite different views of the same problem, and it can be the case that one has a simple form whilst the other is more complex. This can make a big practical difference on which algorithms learn fastest.\n\nFor smaller, discrete action spaces, there is not always a clear choice between policy gradient and value-based methods. You could use either and it may be worth doing an experiment to find the most efficient algorithm for certain classes of problem.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can a deep neural network be trained to classify an integer N1 as being divisible by another integer N2? So I\u2019ve been working on my own little dynamic architecture for a deep neural network (any number of hidden layers with any number of nodes in every layer) and got it solving the XOR problem efficiently. I moved on to trying to see if I could train my network on how to classify a number as being divisible by another number or not while experimenting with different network structures and have noticed some odd things. I know this is a weird thing to try and train a neural network to do but I just thought it might be easy because I can simply generate the training data set and test data set programmatically.\nFrom what I\u2019ve tested, it seems that my network is only really good at identifying whether or not a number is divisible by a number who is a power of 2. If you test divisibility by a power of two, it converges on a very good solution very quickly. And it generalizes well on numbers outside of the training set - which I guess it kind of makes sense, as I\u2019m inputting the numbers into the network in binary representation, so all the network has to learn is that a number n is only divisible by 2^m if the last m digits in the binary input vector are 0 (i.e. fire the output neuron if the last m neurons on the input layer don't fire, else don't). When checking divisibility by non-powers of two, however, there does not seem to be as much of a \"positional\" (maybe that's the word, maybe not) relationship between the input bits and whether or not the number is divisible. I thought though, that if I threw more neurons and layers at the problem that it might be able to solve classifying divisibility by other numbers \u2013 but that is not the case. The network seems to converge on not-so-optimal local minima on the cost function (for which I am using mean-squared-error) when dividing by numbers that are not powers of 2. I\u2019ve tried different learning rates as well to no avail. \nDo you have any idea what would cause something like this or how to go about trying to fix it? Or are plain deep neural networks maybe just not good at solving these types of problems?\nNote: I should also add that I've tried using different activation functions for different layers (like having leaky-relu activation for your first hidden layer, then sigmoid activation for your output layer, etc.) which has also not seem to have made a difference\nHere is my code if you feel so inclined as to look at it: https://github.com/bigstronkcodeman/Deep-Neural-Network/blob/master/Neural.py\n(beware: it was all written from scratch by me in the quest to learn so some parts (namely the back-propagation) are not very pretty - I am really new to this whole neural network thing)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is a recent development in research that was looking into effectiveness of neural networks on arithmetic. Interestingly, feed-forward neural networks (MLPs) with various activation functions as well as LSTMs (RNNs which are Turing-complete) are not able to model simple arithmetic operations (e.g. addition/multiplication), they designed a new logic unit which can solve all of the simple arithmetic problems.\nSee: Neural Arithmetic Logic Units\nMore recently, DL can solve symbolic maths: Deep Learning for Symbolic Mathematics\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which rules should I define for the predicate \"not_to_far\" of the exercise 1.1 of the book \"Simply Logical: Intelligent Reasoning by Example\"? I've just started reading a book about AI. The book is Simply Logical: Intelligent Reasoning by Example. There is a very basic exercise (on page 19 of the pdf, page 5 of the book), but I can't figure it out.\nThe exercise is\n\nExercise 1.1. Two stations are 'not too far' if they are on the same or a different line, with at most one station in between. Define rules for the predicate not_too_far.\n\nThe only rules I've seen are nearby and connected and don't know how to use this. What I've done so far is this:\n\nnot_too_far(X,Y) :- nearby(X,Y)\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Your intuition is good. Because \"nearby\" is only defined with \"connected\", there could only be 1 station between them. However, it says that the stations are \"not_too_far\" if at most one station is between them. What about if no stations are between them? If 2 stations are \"connected\" they should be \"not_too_far\" as well. \nSo it should be:\nnot_too_far(X,Y) :- connected(X,Y) ; nearby(X,Y).\n\nWhere ; denotes OR. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can a single neural network handle recognizing two types of objects, or should it be split into two smaller networks? In particular, an embedded computer (with limited resources) analyzes live video stream from a traffic camera, trying to pick good frames that contain license plate numbers of passing cars. Once a plate is located, the frame is handed over to an OCR library to extract the registration and use it further.\nIn my country two types of license plates are in common use - rectangular (the typical) and square - actually, somewhat rectangular but \"higher than wider\", with the registration split over two rows.\n(there are some more types, but let us disregard them; they are a small percent and usually belong to vehicles that lie outside our interest.)\nDue to the limited resources and need for rapid, real-time processing, the maximum size of the network (number of cells and connections) the system can handle is fixed.\nWould it be better to split this into two smaller networks, each recognizing one type of registration plates, or will the larger single network handle the two types better?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Well, I do not know what type of features you are giving to your neural network. However, in general, I would go with a single neural network. It seems that you have no limitation in resources for training your network and the only problem is resources while you apply your network. \nThe thing is that probably the two problems have things in common (e.g. both types of plates are rectangular). This means that if you use two networks, each has to solve the same sub-problem (the common part) again. If you use only one network the common part of the problem takes fewer cells/weights to be solved and the remaining weights/cells can be employed for better recognition.\nIn the end, if I was in your place I would try both of them. I think that is the only way to be really sure what is the best solution. When speaking theoretically it is possible that we do not include some factors.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What makes the animal brain so special? Whenever I read any book about neural networks or machine learning, their introductory chapter says that we haven't been able to replicate the brain's power due to its massive parallelism.\nNow, in modern times, transistors have been reduced to the size of nanometers, much smaller than the nerve cell. Also, we can easily build very large supercomputers.\n\nComputers have much larger memories than brains.\nComputes can communicate faster than brains (clock pulse in nanoseconds).\nComputers can be of arbitrarily large size.\n\nSo, my question is: why cannot we replicate the brain's parallelism if not its information processing ability (since the brain is still not well understood) even with such advanced technology? What exactly is the obstacle we are facing?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "One probable hardware limiting factor is internal bandwidth. A human brain has $10^{15}$ synapses. Even if each is only exchanging a few bits of information per second, that's on the order of $10^{15}$ bytes/sec internal bandwidth. A fast GPU (like those used to train neural networks) might approach $10^{11}$ bytes/sec of internal bandwidth. You could have 10,000 of these together to get something close to the total internal bandwidth of the human brain, but the interconnects between the nodes would be relatively slow, and would bottleneck the flow of information between different parts of the \"brain.\"\nAnother limitation might be raw processing power. A modern GPU has maybe 5,000 math units. Each unit has a cycle time of ~1 ns, and might require ~1000 cycles to do the equivalent processing work one neuron does in ~1/10 second (this value is totally pulled from the air; we don't really know the most efficient way to match brain processing in silicon). So, a single GPU might be able to match $5 \\times 10^8$ neurons in real-time. You would optimally need 200 of them to match the processing power of the brain.\nThis back-of-the-envelope calculation shows that internal bandwidth is probably a more severe constraint.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are convolutional neural networks inspired by the human brain? The Deep Learning book by Goodfellow et al. states\n\nConvolutional networks stand out as an example of neuroscienti\ufb01c principles in\ufb02uencing deep learning.\n\nAre convolutional neural networks (CNNs) really inspired by the human brain?\nIf so, how? In particular, what structures within the brain do CNN-like neuron groupings occur?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, CNNs are inspired by the human brain [1, 2, 3]. More specifically, their operations, the convolution and pooling, are inspired by the human brain. However, note that, nowadays, CNNs are mainly trained with gradient descent (GD) and back-propagation (BP), which seems not to be a biologically plausible way of learning, but, given the success of GD and BP, there have been attempts to connect GB and BP with the way humans learn [4].\nThe neocognitron, the first convolutional neural network [1], proposed by Kunihiko Fukushima in 1979-1980, and described in the paper Neocognitron: A Self-organizing Neural Network Model for a Mechanism of Pattern Recognition Unaffected by Shift in Position, already uses convolutional and pooling (specifically, averaging pooling) layers [1]. The neocognitron was inspired by the work of Hubel and Wiesel described in the 1959 paper Receptive fields of single neurones in the cat's striate cortex.\nHere is an excerpt from the 1980 Fukushima's paper.\n\nThe mechanism of pattern recognition in the brain is little known, and it seems to be almost impossible to reveal it only by conventional physiological experiments. So, we take a slightly different approach to this problem. If we could make a neural network model which has the same capability for pattern recognition as a human being, it would give us a powerful clue to the understanding of the neural mechanism in the brain. In this paper, we discuss how to synthesize a neural network model in order to endow it an ability of pattern recognition like a human being.\nSeveral models were proposed with this intention (Rosenblatt, 1962; Kabrisky, 1966; Giebel, 1971; Fukushima, 1975). The response of most of these models, however, was severely affected by the shift in position and/or by the distortion in shape of the input patterns. Hence, their ability for pattern recognition\nwas not so high.\nIn this paper, we propose an improved neural network model. The structure of this network has been suggested by that of the visual nervous system of the vertebrate. This network is self-organized by \"learning without a teacher\", and acquires an ability to recognize stimulus patterns based on the geometrical similarity (Gestalt) of their shapes without affected by their position nor by small distortion of their shapes. This network is given a nickname \"neocognitron\", because it is a further extention of the \"cognitron\", which also is a self-organizing multilayered neural network model proposed by the author before (Fukushima, 1975)\n\nHowever, Fukushima did not train the neocognitron with gradient descent (and back-propagation) but with local learning rules (which are more biologically plausible), and that's probably why he doesn't get more credit, as I think he should.\nYou should read at least Fukushima's paper for more details, which I will not replicate here.\nSection 9.4 of the Deep Learning book also contains details about how CNNs are inspired by neuroscience findings.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to deal with large (or NaN) neural network's weights? My weights go from being between 0 and 1 at initialization to exploding into the tens of thousands in the next iteration. In the 3rd iteration, they become so large that only arrays of nan values are displayed.\nHow can I go about fixing this?\nIs it to do with the unstable nature of the sigmoid function, or is one of my equations incorrect during backpropagation which makes my gradients explode?\nimport numpy as np\nfrom numpy import exp\nimport matplotlib.pyplot as plt\nimport h5py\n\n# LOAD DATASET\nMNIST_data = h5py.File('data/MNISTdata.hdf5', 'r')\nx_train = np.float32(MNIST_data['x_train'][:])\ny_train = np.int32(np.array(MNIST_data['y_train'][:,0]))\nx_test = np.float32(MNIST_data['x_test'][:])\ny_test = np.int32(np.array(MNIST_data['y_test'][:,0]))\nMNIST_data.close()\n\n##############################################################################\n# PARAMETERS \nnumber_of_digits = 10 # number of outputs\nnx = x_test.shape[1] # number of inputs ... 784 --> 28*28\nny = number_of_digits\nm_train = x_train.shape[0]\nm_test = x_test.shape[0]\nNh = 30 # number of hidden layer nodes\nalpha = 0.001\niterations = 3\n##############################################################################\n# ONE HOT ENCODER - encoding y data into 'one hot encoded'\nlr = np.arange(number_of_digits)\ny_train_one_hot = np.zeros((m_train, number_of_digits))\ny_test_one_hot = np.zeros((m_test, number_of_digits))\nfor i in range(len(y_train_one_hot)):\n y_train_one_hot[i,:] = (lr==y_train[i].astype(np.int))\nfor i in range(len(y_test_one_hot)):\n y_test_one_hot[i,:] = (lr==y_test[i].astype(np.int))\n\n# VISUALISE SOME DATA\nfor i in range(5):\n img = x_train[i].reshape((28,28))\n plt.imshow(img, cmap='Greys')\n plt.show()\n\ny_train = np.array([y_train]).T\ny_test = np.array([y_test]).T\n##############################################################################\n# INITIALISE WEIGHTS & BIASES\nparams = { \"W1\": np.random.rand(nx, Nh),\n \"b1\": np.zeros((1, Nh)),\n \"W2\": np.random.rand(Nh, ny),\n \"b2\": np.zeros((1, ny))\n }\n\n# TRAINING\n# activation function\ndef sigmoid(z):\n return 1/(1+exp(-z))\n\n# derivative of activation function\ndef sigmoid_der(z):\n return z*(1-z)\n\n# softamx function\ndef softmax(z):\n return 1/sum(exp(z)) * exp(z)\n\n# softmax derivative is alike to sigmoid\ndef softmax_der(z):\n return sigmoid_der(z)\n\ndef cross_entropy_error(v,y):\n return -np.log(v[y])\n\n# forward propagation\ndef forward_prop(X, y, params):\n outs = {}\n outs['A0'] = X\n outs['Z1'] = np.matmul(outs['A0'], params['W1']) + params['b1']\n outs['A1'] = sigmoid(outs['Z1'])\n outs['Z2'] = np.matmul(outs['A1'], params['W2']) + params['b2']\n outs['A2'] = softmax(outs['Z2'])\n \n outs['error'] = cross_entropy_error(outs['A2'], y)\n return outs\n\n# back propagation\ndef back_prop(X, y, params, outs):\n grads = {}\n Eo = (y - outs['A2']) * softmax_der(outs['Z2'])\n Eh = np.matmul(Eo, params['W2'].T) * sigmoid_der(outs['Z1'])\n dW2 = np.matmul(Eo.T, outs['A1']).T\n dW1 = np.matmul(Eh.T, X).T\n db2 = np.sum(Eo,0)\n db1 = np.sum(Eh,0)\n \n grads['dW2'] = dW2\n grads['dW1'] = dW1\n grads['db2'] = db2\n grads['db1'] = db1\n# print('dW2:',grads['dW2'])\n return grads\n\n# optimise weights and biases\ndef optimise(X,y,params,grads):\n params['W2'] -= alpha * grads['dW2']\n params['W1'] -= alpha * grads['dW1']\n params['b2'] -= alpha * grads['db2']\n params['b1'] -= alpha * grads['db1']\n return \n\n# main\nfor epoch in range(iterations):\n print(epoch)\n outs = forward_prop(x_train, y_train, params)\n grads = back_prop(x_train, y_train, params, outs)\n optimise(x_train,y_train,params,grads)\n loss = 1/ny * np.sum(outs['error'])\n print(loss)\n \n```\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This problem is called exploding gradients, resulting in an unstable network that at best cannot learn from the training data and at worst results in NaN weight values that can no longer be updated.\nOne way to assure it is exploding gradients, is if loss is unstable and not improving, or if loss shows NaN value during training. \nApart from the usual gradient clipping and weights regularization that are recommended, I think the problem with your network is the architecture. \n30 is an abnormally high number of nodes for 2 layer perceptron model. Try increasing number of layers and reducing nodes per layer. - This is under the assumption that you're experimenting with MLP's, because for the problem above, convolutional neural networks seem like an obvious way to go. If unexplored - definitely check out CNN's for digit recognition, two layer models will surely work better there.\nHope this helped!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Linear regression: why is distance *squared* used as an error metric? Usually when performing linear regression predictions and gradient descent, the measure of the level of error for a particular line will be measured by the sum of the squared-distance values.\nWhy distance squared?\nIn most of the explanations I heard, they claim that:\n\nthe function itself does not matter\nthe result should be positive so positive and negative deviations are still counted\n\nHowever, an abs() approach would still work. And isn't it inconvenient that distance squared minimizes the distance result for distances lower than 1?\nI'm pretty sure someone must have considered this already -- so why is distance squared the most used approach to linear regression?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Brief Background\nThe error metric (an appropriate term used in the question title) quantifies the fitness of a linear or nonlinear model.\nIt aggregates individual errors across a set of observations (instances of training data). In typical use, an error function is applied to the difference between the dependent variable vector predicted by the model and empirical observations. These differences are calculated for each observation and then summed. 1\nWhy Distance Squared?\nLegendre, who first published the sum of squares method for gauging fitness of the model (Paris 1705) stated correctly that squaring before summing is convenient. Why did he write that?\nOne could use the absolute value of the error or the absolute value of its cube, but the discontinuity of the derivative of the absolute value makes the function NOT smooth. Functions that are NOT smooth create unnecessary difficulties when employing linear algebra to derive closed forms (simple algebraic expressions).\nClosed forms are convenient when one wants to quickly and easily calculate slope and intercept in linear regression. 2\nGradient Descent\nGradient descent is generally employed for nonlinear regression. Lacking the ability to create closed forms for many nonlinear models, iteration becomes a dominant methodology for validating or tuning the model.\nAn intuitive understanding of gradient descent can be gained by considering a thirsty, blind person looking for water on land solely by taking calculated steps. (In software, these steps are iterations.) The blind person can only sense the direction of the altitude gradient (direction of slope) with their feet to descend to a local minimum altitude. 3\nAnyone stating that, \"The function itself does not matter,\" in relation to the usual applications of gradient descent would be a dangerous choice for guide in a blind hiking expedition. For instance, the reciprocal of distance as an error function would likely lead to the dehydration and death of the hikers.\nThe selection criteria for error metrics is important if one is interested in the speed of convergence on a solution or whether the solution will ever be found. 4\nSince the gradient of a plane (linear surface) is a constant, the use of gradient descent for linear models is wasteful. The blind person need not continue to sample the angle of their foot.\nSign of the Error Metric\nThe statement, \"The result should be positive so positive and negative deviations are still counted,\" is incorrect. 5\nEffectiveness of Error Metrics in Relation to 1.0\nBecause of the partial derivative of the least squares error metric with respect to an error at any given point is constant, the least squares error metric converges similarly above and below 1.0.\nNotes\n[1] The dimensions of a model's independent and dependent variable vectors are, in machine learning, conventionally called features and labels respectively.\n[2] Another smooth function, such as the error to the fourth power would also lead to closed forms for slope and intercept, although they would produce slightly different results if the correlation coefficient is non-zero.\n[3] Gradient descent algorithms in general do not guarantee finding a global minimum. In the example given, it would be quote possible to miss a small hole exists with water in it. Depending on the surface features (terrain), sensing the angle of the foot (determining gradient) can be counterproductive. The search can becomes chaotic. To extend the intuitive analogy, consider searching for the bottom of the stairs in Escher's Relativity lithograph.\n[4] For an error metric to be likely to converge and therefore useful in regression regardless of the direction of the error the sign of the metric is irrelevant. It is each of the set of partial derivatives of the error metric with respect to the corresponding set of distances between the model predictions and observations that should be positive to regress omnidirectionally. It sounds more complicated, but even this corrected statement is an oversimplification.\n[5] The error metric in gradient descent applications is often calculated using a convex function to avoid overshoot and possible oscillation and non-convergence. In some cases error functions other that sum of squares is used. The choice of function has to do with a number of factors:\n\nThe model to which the data is to be fit\nFactors expected to affect or actually affecting deviations of\nthe observations (training data) from the model\nComputational resources relative to the size of the data set\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Validation accuracy higher than training accurarcy I implemented the unet in TensorFlow for the segmentation of MRI images of the thigh. I noticed I always get a higher validation accuracy by a small gap, independently of the initial split. One example:\n\nSo I researched when this could be possible:\n\nWhen we have an \"easy\" validation set. I trained it for different initial splitting, all of them showed a higher validation accuracy.\nRegularization and augmentation may reduce the training accuracy. I removed the augmentation and dropout regularization and still observed the same gap, the only difference was that it took more epochs to reach convergence.\nThe last thing I found was that in Keras the training accuracy and loss are averaged over each iteration of the corresponding epoch, while the validation accuracy and loss is calculated from the model at the end of the epoch, which might make the the training loss higher and accuracy lower.\n\nSo I thought that if I train and validate on the same set, then I should get the same curve but shifted by one epoch. So I trained only on 2 batches and validated on the same 2 batches (without dropout or augmentation). I still think there is something else happening because they don't look quite the same and at least at the end when the weights are not changing anymore, the training and validation accuracy should be the same (but still the validation accuracy is higher by a small gap). This is the plot:\n\n\nIs there anything else that can be increasing the loss values, this is the model I am using:\ndef unet_no_dropout(pretrained_weights=None, input_size=(512, 512, 1)):\ninputs = tf.keras.layers.Input(input_size)\nconv1 = tf.keras.layers.Conv2D(64, 3, activation='relu', padding='same', kernel_initializer='he_normal')(inputs)\nconv1 = tf.keras.layers.Conv2D(64, 3, activation='relu', padding='same', kernel_initializer='he_normal')(conv1)\npool1 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(conv1)\nconv2 = tf.keras.layers.Conv2D(128, 3, activation='relu', padding='same', kernel_initializer='he_normal')(pool1)\nconv2 = tf.keras.layers.Conv2D(128, 3, activation='relu', padding='same', kernel_initializer='he_normal')(conv2)\npool2 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(conv2)\nconv3 = tf.keras.layers.Conv2D(256, 3, activation='relu', padding='same', kernel_initializer='he_normal')(pool2)\nconv3 = tf.keras.layers.Conv2D(256, 3, activation='relu', padding='same', kernel_initializer='he_normal')(conv3)\npool3 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(conv3)\nconv4 = tf.keras.layers.Conv2D(512, 3, activation='relu', padding='same', kernel_initializer='he_normal')(pool3)\nconv4 = tf.keras.layers.Conv2D(512, 3, activation='relu', padding='same', kernel_initializer='he_normal')(conv4)\n#drop4 = tf.keras.layers.Dropout(0.5)(conv4)\npool4 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(conv4)\n\nconv5 = tf.keras.layers.Conv2D(1024, 3, activation='relu', padding='same', kernel_initializer='he_normal')(pool4)\nconv5 = tf.keras.layers.Conv2D(1024, 3, activation='relu', padding='same', kernel_initializer='he_normal')(conv5)\n#drop5 = tf.keras.layers.Dropout(0.5)(conv5)\n\nup6 = tf.keras.layers.Conv2D(512, 2, activation='relu', padding='same', kernel_initializer='he_normal')(\n tf.keras.layers.UpSampling2D(size=(2, 2))(conv5))\nmerge6 = tf.keras.layers.concatenate([conv4, up6], axis=3)\n#merge6 = tf.keras.layers.concatenate([conv4, up6], axis=3)\nconv6 = tf.keras.layers.Conv2D(512, 3, activation='relu', padding='same', kernel_initializer='he_normal')(merge6)\nconv6 = tf.keras.layers.Conv2D(512, 3, activation='relu', padding='same', kernel_initializer='he_normal')(conv6)\n\nup7 = tf.keras.layers.Conv2D(256, 2, activation='relu', padding='same', kernel_initializer='he_normal')(\n tf.keras.layers.UpSampling2D(size=(2, 2))(conv6))\nmerge7 = tf.keras.layers.concatenate([conv3, up7], axis=3)\nconv7 = tf.keras.layers.Conv2D(256, 3, activation='relu', padding='same', kernel_initializer='he_normal')(merge7)\nconv7 = tf.keras.layers.Conv2D(256, 3, activation='relu', padding='same', kernel_initializer='he_normal')(conv7)\n\nup8 = tf.keras.layers.Conv2D(128, 2, activation='relu', padding='same', kernel_initializer='he_normal')(\n tf.keras.layers.UpSampling2D(size=(2, 2))(conv7))\nmerge8 = tf.keras.layers.concatenate([conv2, up8], axis=3)\nconv8 = tf.keras.layers.Conv2D(128, 3, activation='relu', padding='same', kernel_initializer='he_normal')(merge8)\nconv8 = tf.keras.layers.Conv2D(128, 3, activation='relu', padding='same', kernel_initializer='he_normal')(conv8)\n\nup9 = tf.keras.layers.Conv2D(64, 2, activation='relu', padding='same', kernel_initializer='he_normal')(\n tf.keras.layers.UpSampling2D(size=(2, 2))(conv8))\nmerge9 = tf.keras.layers.concatenate([conv1, up9], axis=3)\nconv9 = tf.keras.layers.Conv2D(64, 3, activation='relu', padding='same', kernel_initializer='he_normal')(merge9)\nconv9 = tf.keras.layers.Conv2D(64, 3, activation='relu', padding='same', kernel_initializer='he_normal')(conv9)\nconv9 = tf.keras.layers.Conv2D(2, 3, activation='relu', padding='same', kernel_initializer='he_normal')(conv9)\nconv10 = tf.keras.layers.Conv2D(1, 1, activation='sigmoid')(conv9)\n\nmodel = tf.keras.Model(inputs=inputs, outputs=conv10)\n\nmodel.compile(optimizer = Adam(lr = 2e-4), loss = 'binary_crossentropy', metrics = [tf.keras.metrics.Accuracy()])\n#model.compile(optimizer=tf.keras.optimizers.Adam(2e-4), loss=combo_loss(alpha=0.2, beta=0.4), metrics=[dice_accuracy])\n#model.compile(optimizer=RMSprop(lr=0.00001), loss=combo_loss, metrics=[dice_accuracy])\n\nif (pretrained_weights):\n model.load_weights(pretrained_weights)\n\nreturn model\n\nand this is how I save the model:\nmodel_checkpoint = tf.keras.callbacks.ModelCheckpoint('unet_ThighOuterSurfaceval.hdf5',monitor='val_loss', verbose=1, save_best_only=True)\nmodel_checkpoint2 = tf.keras.callbacks.ModelCheckpoint('unet_ThighOuterSurface.hdf5', monitor='loss', verbose=1, save_best_only=True)\n\nmodel = unet_no_dropout()\nhistory = model.fit(genaug, validation_data=genval, validation_steps=len(genval), steps_per_epoch=len(genaug), epochs=80, callbacks=[model_checkpoint, model_checkpoint2])\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I am answering my own question here. The only additional thing that I found was that the average accuracy across a batch of data was slightly higher if the amount of samples in the batch was lower. So the validation set was only 15% of the data, therefore the average accuracy was slightly lower than for 70% of the data. I don't know why the more samples you take the lower the average accuracy, and whether this was a bug in the accuracy calculation or it is the expected behavior. Either way, if you have the same problem, one suggestion is plotting average accuracy vs number of samples and see if this is the reason why you get a lower training accuracy.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What difference does it make whether Actor and Critic share the same network or not? I'm learning about Actor-Critic reinforcement learning algorithms. One source I encountered mentioned that Actor and Critic can either share one network (but use different output layers) or they can use two completely separate networks. In this video he mentions that using two separate networks works for simpler problems, such as Mountain Car. However, more complex problems like Lunar Lander works better with a shared network. Why is that? Could you explain what difference that choosing one design over another would that make?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "One can expect the optimal high-level features required to choose the next action and to evaluate a state to be quite similar. Because of that, it is a reasonable idea to share the same network for both policy and value function \u2013 you are essentially parameter sharing the feature-extraction part of your neural network, and fine tuning the different heads of your network on the two different tasks: action choice and value prediction.\nUsing two vs one networks is mostly a question of sample efficiency: theoretically, in both case your AC algorithm should work. In practice however, it will usually be useful to have parameter sharing as the representations encouraged by one of the tasks might be highly useful for the other and vice-versa, enabling one task to cause the other task to get unstuck from local optima. Another reason why this might work better is simply because you do not have to learn the same (or at least similar) representations from scratch twice \u2013 leading to a more sample efficient training.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the learning rate generally beneath 1? In all examples I've ever seen, the learning rate of an optimisation method is always less than $1$. However, I've never found an explanation as to why this is. In addition to that, there are some cases where having a learning rate bigger than 1 is beneficial, such as in the case of super-convergence.\nWhy is the learning rate generally less than 1? Specifically, when performing an update on a parameter, why is the gradient generally multiplied by a factor less than 1 (absolutely)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "If the learning rate is greater than or equal to $1$ the Robbins-Monro condition\n$$\\sum _{{t=0}}^{{\\infty }}a_{t}^{2}<\\infty\\label{1}\\tag{1},$$\nwhere $a_t$ is the learning rate at iteration $t$, does not hold (given that a number bigger than $1$ squared becomes a bigger number), so stochastic gradient descent is not generally guaranteed to converge to a minimum [1] (although the condition \\ref{1} is a sum from $t=0$ to $t=\\infty$, but, of course, we only iterate for a finite number of iterations). Moreover, note that, if the learning rate is bigger than $1$, you are essentially giving more weight to the gradient of the loss function than to the current value of the parameters (you give weight $1$ to the parameters).\nThis is probably the main reason why the learning rate is usually in the range $(0, 1)$ and there are methods to decay the learning rate, which can be beneficial (and there are several explanations of why this is the case [2]).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a Markov chain and how can it be used in creating artificial intelligence? I believe a Markov chain is a sequence of events where each subsequent event depends probabilistically on the current event. What are examples of the application of a Markov chain and can it be used to create artificial intelligence? Would a genetic algorithm be an example of a Markov chain since each generation depends upon the state of the prior generation?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A Markov model includes the probability of transitioning to each state considering the current state. \"Each state\" may be just one point - whether it rained on specific day, for instance - or it might look like multiple things - like a pair of words. You've probably seen automatically generated weird text that almost makes sense, like Garkov (the output of a Markov model based on the Garfield comic strips). That Coding Horror article also mentions the applications of Markov techniques to Google's PageRank.\nMarkov models are really only powerful when they have a lot of input to work with. If a machine looked through a lot of English text, it would get a pretty good idea of what words generally come after other words. Or after looking through someone's location history, it could figure out where that person is likely to go next from a certain place. Constantly updating the \"input corpus\" as more data is received would let the machine tune the probabilities of all the state transitions.\nGenetic algorithms are fairly different things. They create functions by shuffling around parts of functions and seeing how good each function is at a certain task. A child algorithm will depend on its parents, but Markov models are interested mostly in predicting what thing will come next in a sequence, not creating a new chunk of code. You might be able to use a Markov model to spit out a candidate function, though, depending on how simple the \"alphabet\" is. You could even then give more weight to the transitions in successful algorithms.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are neural networks statistical models? By reading the abstract of Neural Networks and Statistical Models paper it would seem that ANNs are statistical models.\nIn contrast Machine Learning is not just glorified Statistics.\nI am looking for a more concise/summarized answer with focus on ANNs.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "What is a statistical model?\nAccording to Anthony C. Davison (in the book Statistical Models), a statistical model is a probability distribution constructed to enable inferences to be drawn or decisions made from data. The probability distribution represents the variability of the data.\nAre neural networks statistical models?\nDo neural networks construct or represent a probability distribution that enables inferences to be drawn or decisions made from data?\nMLP for binary classification\nFor example, a multi-layer perceptron (MLP) trained to solve a binary classification task can be thought of as model of the probability distribution $\\mathbb{P}(y \\mid x; \\theta)$. In fact, there are many examples of MLPs with a softmax or sigmoid function as the activation function of the output layer in order to produce a probability or a probability vector. However, it's important to note that, although many neural networks produce a probability or a probability vector, a probability distribution is not the same thing. A probability alone does not describe a full probability distribution and different distributions are defined by different parameters (e.g. a Bernoulli is defined by $p$, while a Gaussian by $\\mu$ and $\\sigma$). However, for example, if you make your neural network produce a probability, i.e. model $\\mathbb{P}(y = 1 \\mid x; \\theta)$, at least in the case of binary classification, you could obviously derive the probability of the other label as follows: $\\mathbb{P}(y = 0 \\mid x; \\theta) = 1 - \\mathbb{P}(y = 1 \\mid x; \\theta)$. In any case, in this example, you only need the parameter $p = \\mathbb{P}(y = 1 \\mid x; \\theta)$ to define the associated Bernoulli distribution.\nSo, these neural networks (for binary classification) that model and learn some probability distribution given the data in order to make inferences or predictions could be considered statistical models. However, note that, once the weights of the neural network are fixed, given the same input, they always produce the same output.\nGenerative models\nVariational auto-encoders (VAEs) construct a probability distribution (e.g. a Gaussian or $\\mathbb{P}(x)$ that represents the probability distribution over images, if you want to generate images), so VAEs can be considered statistical models.\nBayesian neural networks\nThere are also Bayesian neural networks, which are neural networks that maintain a probability distribution (usually, a Gaussian) for each unit (or neuron) of the neural network, rather than only a point estimate. BNNs can thus also be considered statistical models.\nPerceptron\nThe perceptron may be considered a \"statistical model\", in the sense that it learns from data, but it doesn't produce any probability vector or distribution, i.e. it is not a probabilistic model/classifier.\nConclusion\nSo, whether or not a neural network is a statistical model depends on your definition of a statistical model and which machine learning models you would consider neural networks. If you are interested in more formal definitions of a statistical model, take a look at this paper.\nParametric vs non-parametric\nStatistical models are often also divided into parametric and non-parametric models. Neural networks are often classified as non-parametric because they make fewer assumptions than e.g. linear regression models (which are parametric) and are typically more generally applicable, but I will not dwell on this topic.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between Stochastic Hill Climbing and Simulated Annealing? I am reading about local search: hill climbing, and its types, and simulated annealing\nOne of the hill climbing versions is \"stochastic hill climbing\", which has the following definition:\n\nStochastic hill climbing does not examine for all its neighbor before moving. Rather, this search algorithm selects one neighbor node at random and decides whether to choose it as a current state or examine another state\n\nSome sources mentioned that it can be used to avoid local optima.\nThen I was reading about simulated annealing and its definition:\n\nAt every iteration, a random move is chosen. If it improves the situation then the move is accepted, otherwise it is accepted with some probability less than 1\n\nSo, what is the main difference between the two approaches? Does the stochastic choose only random (uphill) successor? If it chooses only (uphill-successors), then how does it avoid local optima?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Russell and Norvig's book (3rd edition) describe these two algorithms (section 4.1.1., p. 122) and this book is the reference that you should generally use when studying search algorithms in artificial intelligence. I am familiar with simulated annealing (SA), given that I implemented it in the past to solve a combinatorial problem, but I am not very familiar with stochastic hill climbing (SHC), so let me quote the parts of the book that describe SHC.\n\nStochastic hill climbing chooses at random from among the uphill moves; the probability of selection can vary with the steepness of the uphill move. This usually converges more slowly than steepest ascent, but in some state landscapes, it finds better solutions.\n\nSo, SHC chooses at random one \"uphill move\", i.e. a move that improves the objective function (for example, if you're trying to solve the travelling salesman problem, a \"uphill move\" could be any change to the current Hamiltonian cycle, a solution, so that the new Halmitonian cycle has a shorter cost) among the uphill moves (so among some set of moves that improve the objective).\nIn simulated annealing, you perform some move. If that move leads to a better solution, you always keep the better solution. If it leads to a worse solution, you accept that worse solution with a certain probability. There are other details, such as how you accept the worse solution (which you can find in Russell and Norvig's book), but this should already clarify that SA is different from SHC: SA can accept worse solutions in order to escape from local minima, while SHC accepts only uphill moves.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How would one implement a multi-agent environment with asynchronous action and rewards per agent? In a single agent environment, the agent takes an action, then observes the next state and reward:\nfor ep in num_episodes:\n action = dqn.select_action(state)\n next_state, reward = env.step(action)\n\nImplicitly, the for moving the simulation (env) forward is embedded inside the env.step() function. \nNow in the multiagent scenario, agent 1 ($a_1$) has to make a decision at time $t_{1a}$, which will finish at time $t_{2a}$, and agent 2 ($a_2$) makes a decision at time $t_{1b} < t_{1a}$ which is finished at $t_{2b} > t_{2a}$. \nIf both of their actions would start and finish at the same time, then it could easily be implemented as: \nfor ep in num_episodes:\n action1, action2 = dqn.select_action([state1, state2])\n next_state_1, reward_1, next_state_2, reward_2 = env.step([action1, action2])\n\nbecause the env can execute both in parallel, wait till they are done, and then return the next states and rewards. But in the scenario that I described previously, it is not clear how to implement this (at least to me). Here, we need to explicitly track time, a check at any timepoint to see if an agent needs to make a decision, Just to be concrete:\nfor ep in num_episodes:\n for t in total_time:\n action1 = dqn.select_action(state1)\n env.step(action1) # this step might take 5t to complete. \n as such, the step() function won't return the reward till 5 t later. \n #In the mean time, agent 2 comes and has to make a decision. its reward and next step won't be observed till 10 t later. \n\nTo summarize, how would one implement a multiagent environment with asynchronous action/rewards per agents?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The cleanest solution from a theoretical point of view is to switch over to a hierarchical framework, some framework that supports temporal abstraction. My favourite one is the options framework as formalised by Sutton, Precup and Singh.\nThe basic idea is that the things that you consider \"actions\" for your agents become \"options\", which are \"large actions\" that may take more than a single primitive time step. When an agent selects an option, it will go on \"auto-pilot\" and keep selecting primitive actions at the more primitive, fine-grained timescale as dictated by the last selected option, until that option has actually finished executing. In your case, you could:\n\nimplement the first \"primitive action\" of an option to immediately apply all effects to the state, and append a sequence of \"no-op\" actions afterwards to make sure the option actually has a longer duration than a single primitive timestep, OR\nimplement the very last primitive action of an option to actually apply changes to the state, and prepend a sequence of \"no-op\" actions in front of it to make the option take more time, OR\nsomething in between (i.e. actually make partial changes to the state visible during the execution of the option).\n\nSince all legal choices for agents in your scenario appear to be options, i.e. you do not allow agents to select primitive actions at the more fine-grained timescale, you would only have to implement \"inter-option\" learning in your RL algorithms; there would be no need for \"intra-option\" learning.\nIn practice, if you only have a small number of agents and have options that take relatively large amounts of time, you don't have to actually loop through all primitive time-steps. You could, for example, compute the primitive timestamps at which \"events\" should be executed in advance, and insert these events to be processed into an event-handling queue based on these timestamps. Then you can always just skip through to the next timestamp at which an event needs handling. With \"events\" I basically mean all timesteps at which something should happen, e.g. timesteps where an option ends and a new option should be selected by one or more agents. Inter-option Reinforcement Learning techniques are basically oblivious to the existence of a more fine-grained timescale, and they only need to operate at precisely these decision points where one option ends and another begins.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to fill in missing transitions when sampling an MDP transition table? I have a simulator modelling a relatively complex scenario. I extract ~12 discrete features from the simulator state which forms the basis for my MDP state space.\nSuppose I am estimating the transition table for an MDP by running a large number of simulations and extracting feature transitions as the state transitions.\nWhile I can randomize the simulator starting conditions to increase the coverage of states, I cannot guarantee all states will be represented in the sample, i.e. states which are possible but rare.\nIs there a rigorous approach to \"filling in the gaps\" of the transition table in this case?\nFor example:\n\nFor each state that was unrepresented in the sample, simply transition to all other states with equal probability, as a \"neutral\" way to fill in the gap?\n\nAs above, but transition only to represented states (with equal probability)?\n\nTransition to the same state with probability 1.0?\n\nIgnore unrepresented states during MDP solving entirely, and simply have a default action specified?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I assume you use the 12 discrete features as state variables, and, for each of these variables, you will have at least two values. So, the minimum number of states will be $2^{12} = 4096$, which gives $(2^{12})^{2} = 16777216$ possible transitions. In order to reach this, you will need a huge amount of simulations, also taking into account that this number is a minimum since you might have more values per state variable, and you probably have more than one action per state transition.\nHow to fill the gaps depends on your problem, in a problem where I did this, I filled the gaps using a uniformly random transition to its neighbor states. However, since I had to fill in such a a large amount, there was no significant difference between using this estimated transitions probabilities with a predefined transition table.\nIn your case, it might be better to use Q-Learning, which is a model-free method that does not require the transition probabilities and uses directly the rewards and states obtained.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between a stochastic and a deterministic policy? In reinforcement learning, there are the concepts of stochastic (or probabilistic) and deterministic policies. What is the difference between them?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A deterministic policy is a function of the form $\\pi_{\\mathbb{d}}: S \\rightarrow A$, that is, a function from the set of states of the environment, $S$, to the set of actions, $A$. The subscript $_{\\mathbb{d}}$ only indicates that this is a ${\\mathbb{d}}$eterministic policy.\nFor example, in a grid world, the set of states of the environment, $S$, is composed of each cell of the grid, and the set of actions, $A$, is composed of the actions \"left\", \"right\", \"up\" and \"down\". Given a state $s \\in S$, $\\pi(s)$ is, with probability $1$, always the same action (e.g. \"up\"), unless the policy changes.\nA stochastic policy can be represented as a family of conditional probability distributions, $\\pi_{\\mathbb{s}}(A \\mid S)$, from the set of states, $S$, to the set of actions, $A$. A probability distribution is a function that assigns a probability for each event (in this case, the events are actions in certain states) and such that the sum of all the probabilities is $1$.\nA stochastic policy is a family and not just one conditional probability distribution because, for a fixed state $s \\in S$, $\\pi_{\\mathbb{s}}(A \\mid S = s)$ is a possibly distinct conditional probability distribution. In other words, $\\pi_{\\mathbb{s}}(A \\mid S) = \\{ \\pi_{\\mathbb{s}}(A \\mid S = s_1), \\dots, \\pi_{\\mathbb{s}}(A \\mid S = s_{|S|})\\}$, where $\\pi_{\\mathbb{s}}(A \\mid S = s)$ is a conditional probability distribution over actions given that the state is $s \\in S$ and $|S|$ is the size of the set of states of the environment.\nOften, in the reinforcement learning context, a stochastic policy is misleadingly (at least in my opinion) denoted by $\\pi_{\\mathbb{s}}(a \\mid s)$, where $a \\in A$ and $s \\in S$ are respectively a specific action and state, so $\\pi_{\\mathbb{s}}(a \\mid s)$ is just a number and not a conditional probability distribution. A single conditional probability distribution can be denoted by $\\pi_{\\mathbb{s}}(A \\mid S = s)$, for some fixed state $s \\in S$. However, $\\pi_{\\mathbb{s}}(a \\mid s)$ can also denote a family of conditional probability distributions, that is, $\\pi_{\\mathbb{s}}(A \\mid S) = \\pi_{\\mathbb{s}}(a \\mid s)$, if $a$ and $s$ are arbitrary. Alternatively, $a$ and $s$ in $\\pi_{\\mathbb{s}}(a \\mid s)$ are just (dummy or input) variables of the function $\\pi_{\\mathbb{s}}(a \\mid s)$ (i.e. p.m.f. or p.d.f.): this is probably the most sensible way of interpreting $\\pi_{\\mathbb{s}}(a \\mid s)$ when you see this notation (see also this answer). In this case, you could also think of a stochastic policy as a function $\\pi_{\\mathbb{s}} : S \\times A \\rightarrow [0, 1]$, but, in my view, although this may be the way you implement a stochastic policy in practice, this notation is misleading, as the action is not conceptually an input to the stochastic policy but rather an output (but in the end this is also just an interpretation).\nIn the particular case of games of chance (e.g. poker), where there are sources of randomness, a deterministic policy might not always be appropriate. For example, in poker, not all information (e.g. the cards of the other players) is available. In those circumstances, the agent might decide to play differently depending on the round (time step). More concretely, the agent could decide to go \"all-in\" $\\frac{2}{3}$ of the times whenever it has a hand with two aces and there are two uncovered aces on the table and decide to just \"raise\" $\\frac{1}{3}$ of the other times.\nA deterministic policy can be interpreted as a stochastic policy that gives the probability of $1$ to one of the available actions (and $0$ to the remaining actions), for each state.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What exactly is an XPU? I know about CPU, GPU and TPU. But, it is the first time for me to read about XPU from PyTorch documentation about MODULE.\nxpu(device=None)\n\n\nMoves all model parameters and buffers to the XPU.\n\nThis also makes associated parameters and buffers different objects. So it should be called before constructing optimizer if the module will live on XPU while being optimized.\n\nNote: This method modifies the module in-place.\n\nParameters\n\n device (int, optional) \u2013 if specified, all parameters will be copied to that device\n\nReturns\n\n self\n\nReturn type\n\n Module\n\nCPU stands for Central Processing Unit.\nGPU stands for Graphical Processing Unit.\nTPU stands for Tensor Processing Unit.\nMost of us know that these processing units are highly useful in the research of some computational intensive domains of AI including deep learning. So, I am wondering whether XPU is also useful in AI research since it is used in PyTorch.\nFrom the context, I can say that PU stands for processing unit. But I have no idea of what X is.\nWhat is the full form for XPU? Where can I read about XPU in detail?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "XPU is a device abstraction for Intel heterogeneous computation architectures, which can be mapped to CPU, GPU, FPGA and other accelerators. The \"X\" from XPU is just like a variable, like in maths, so you can do X=C and you get CPU accceleration, or X=G and you get GPU acceleration... That's the intuition behind that abstract name.\nIn order to integrate a new accelerator you need 2 things:\n\nHW support: read about XPU in the official intel XPU webpage.\nSW support: see this open Feature Request to include this kind of architecture to the pytorch pool of HW accelerators\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which loss function should I use in REINFORCE, and what are the labels? I understand that this is the update for the parameters of a policy in REINFORCE:\n$$\n\\Delta \\theta_{t}=\\alpha \\nabla_{\\theta} \\log \\pi_{\\theta}\\left(a_{t} \\mid s_{t}\\right) v_{t},\n$$\nwhere $v_t$ is usually the discounted future reward and $\\pi_{\\theta}\\left(a_{t} \\mid s_{t}\\right)$ is the probability of taken the action that the agent took at time $t$. (Tell me if something is wrong here)\nHowever, I don't understand how to implement this with a neural network.\nLet's say that probs = policy.feedforward(state) returns the probabilities of taking each action, like [0.6, 0.4]. action = choose_action_from(probs) will return the index of the probability chosen. For example, if it chose 0.6, the action would be 0.\nWhen it is time to update the parameters of the policy network, what should we do? Should we do something like the following?\ngradient = policy.backpropagate(total_discounted_reward*log(probs[action])\npolicy.weights += gradient\n\nAnd I only backpropagate this through one output neuron?\nWhich loss function should I use in this case? What would the labels be?\nIf you need more explanation, I have this question on SO.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The loss function you are looking for is cross entropy loss. The 'label' that you use is the action you took at the time point you are updating for.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can fuzzy logic be used in creating AI? Fuzzy logic is the logic where every statement can have any real truth value between 0 and 1.\nHow can fuzzy logic be used in creating AI? Is it useful for certain decision problems involving multiple inputs? Can you give an example of an AI that uses it?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A classical example of fuzzy logic in an AI is the expert system Mycin.\nFuzzy logic can be used to deal with probabilities and uncertainties. \nIf one looks at, for example, predicate logic, then every statement is either true or false. In reality, we don't have this mathematical certainty. \nFor example, let's say a physician (or expert system) sees a symptom that can be attributed to a few different diseases (say A, B and C). The physician will now attribute a higher likelihood to the possibility of the patient having any of these three diseases. There is no definite true or false statement, but there is a change of weights. This can be reflected in fuzzy logic, but not so easily in symbolic logic.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does the state-action value function, defined as an expected value of the reward and state value function, not need to follow a policy? I often see that the state-action value function is expressed as:\n$$q_{\\pi}(s,a)=\\color{red}{\\mathbb{E}_{\\pi}}[R_{t+1}+\\gamma G_{t+1} | S_t=s, A_t = a] = \\color{blue}{\\mathbb{E}}[R_{t+1}+\\gamma v_{\\pi}(s') |S_t = s, A_t =a]$$\nWhy does expressing the future return in the time $t+1$ as a state value function $v_{\\pi}$ make the expected value under policy change to expected value in general?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Let's first write the state-value function as\n$$q_{\\pi}(s,a) = \\mathbb{E}_{p, \\pi}[R_{t+1} + \\gamma G_{t+1} | S_t = s, A_t = a]\\;,$$\nwhere $R_{t+1}$ is the random variable that represents the reward gained at time $t+1$, i.e. after we have taken action $A_t = a$ in state $S_t = s$, while $G_{t+1}$ is the random variable that represents the return, the sum of future rewards. This allows us to show that the expectation is taken under the conditional joint distribution $p(s', r \\mid s, a)$, which is the environment dynamics, and future actions are taken from our policy distribution $\\pi$.\nAs $R_{t+1}$ depends on $S_t = s, A_t = a$ and $p(s', r \\mid s, a)$, the only random variable in the expectation that is dependent on our policy $\\pi$ is $G_{t+1}$, because this is the sum of future reward signals and so will depend on future state-action values. Thus, we can rewrite again as\n$$q_{\\pi}(s,a) = \\mathbb{E}_{p}[R_{t+1} + \\gamma \\mathbb{E}_{\\pi}[ G_{t+1} |S_{t+1} = s'] | S_t = s, A_t = a]\\;,$$\nwhere the inner expectation (coupled with the fact its inside an expectation over the state and reward distributions) should look familiar to you as the state value function, i.e.\n$$\\mathbb{E}_{\\pi}[ G_{t+1} |S_{t+1} = s'] = v_{\\pi}(s')\\;.$$\nThis leads us to get what you have\n$$q_{\\pi}(s,a) = \\mathbb{E}_{p}[R_{t+1} + \\gamma v_{\\pi}(s') | S_t = s, A_t = a]\\;,$$\nwhere the only difference is that we have made clear what our expectation is taken with respect to.\nThe expectation is taken with respect to the conditional joint distribution $p(s', r \\mid s, a)$, and we usually include the $\\pi$ subscript to denote that they are also taking the expectation with respect to the policy, but here this does not affect the first term as we have conditioned on knowing $A_t = a$ and only applies to the future reward signals.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Apart from Reinforcement Learning, are there any other machine learning approaches to play video games? OpenAI's Universe utilizes RL algorithms. I also know that Q-learning has been used to solve some games.\nAre there any other ML approaches to solve games? For example, could we use genetic algorithms to develop agents that solve games?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As I see it, it all comes down to game theory, which can be said to form the foundation of successful decision making, and is particularly useful in a context, such as computing, where all parameters can be defined. (Where it runs into trouble is with the aggregate complexity of the parameters per the combinatorial explosion, although Machine Learning has recently been validated as a method of managing intractability specifically in the context of games.)\nYou might want to check out Playing Games with Genetic Algorithms and Evolutionary game theory.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Has NEAT changed in 20 years? This algorithm is more than 20 years old, so has it changed? During this time, the prevailing ones in text generation and classification (LSTM -> Transformer) have changed, AlexNET, ResNET have appeared. But NEAT has not? If it has changed, then how?\nUpd.:\nI heard about HyperNEAT, its continuation es-HyperNEAT, to be able to develop the substrate, CoDeepNEAT. But it seemed to me that they were created for other areas where NEAT is not used and they are not interchangeable (even because I still often come across the usual NEAT), it turns out that this is not so and they are just a logical continuation?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "NEAT essentially as a subset of GAs excels in scenarios where smooth gradient-based learning struggles, such as non-differentiable network architecture optimization objectives targeted by NEAT. Similar to traditional GAs, NEAT involves population-based training which is inherently computationally expensive without a major breakthrough of non-differentiable optimization theory, compared to gradient-based optimizers like Adam. This is a less competitive area compared with deep learning like image classification or text generation.\nHaving said that, there' some big changes for NEAT in its 20 years history so far. NEAT struggled with scalability for high-dimensional problems such as image processing or multi-agent RL systems. Stanley et al in 2009 proposed HyperNEAT to map spatial patterns across a substrate instead of evolving weights directly, enabling it to handle larger neural networks efficiently. Also traditional NEAT struggled to evolve deep architectures effectively, Miikkulainen et al. in 2017 proposed CoDeepNEAT to bridge that gap and enable the design of more modular and scalable deep neural architectures which include layers similar to CNNs and LSTMs.\n\nAs deep learning has scaled up to more challenging tasks, the architectures have become difficult to design by hand. This paper proposes an automated method, CoDeepNEAT, for optimizing deep learning architectures through evolution. By extending existing neuroevolution methods to topology, components, and hyperparameters, this method achieves results comparable to best human designs in standard benchmarks in object recognition and language modeling. It also supports building a real-world application of automated image captioning on a magazine website. Given the anticipated increases in available computing power, evolution of deep networks is promising approach to constructing deep learning applications in the future.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What artificial intelligence strategies are useful for summarization? If I have a paragraph I want to summarize, for example:\n\nPonzo and Fila went to the mall during the day. They walked for a long while, stopping at shops. They went to many shops. At first, they didn't buy anything. After going to a number of shops, they eventually bought a shirt, and a pair of pants.\n\nBetter summarized as:\n\nThey shopped at the mall today and bought some clothes.\n\nWhat is the best AI strategy to automate this process, if there is one? If there isn't, is it because it would be dependent on first having an external information resource that would inform any algorithm? Or is it because the problem is inherently contextual?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The following post has a bit of math, which I hope helps to explain the problem better. Unfortunately it seems, this SE site does not support LaTex:\nDocument summarization is very much an open problem in AI research. One way this task is currently handled is called \"extractive summarization\". The basic strategy is as follows: Split this document into sentences and we will present as a summary a subset of sentences which together cover all the important details in the post. Assign sentence $i$, $1 \\leq i \\leq n$, a variable $z_i \\in \\{ 0, 1 \\}$, where $z_i = 1$ indicates the sentence was selected and $z_i = 0$ means the sentence was left out. Then, $z_i z_j = 1$ if and only if both sentences were chosen. We will also define the importance of each sentence $w_i$ for the sentence $i$ and interaction terms $w_{i,j}$ between sentences $i$ and $j$. \nLet $x_i$ be the feature vectors for sentence $i$. $w_i = w(x_i)$ captures how important it is to include this sentence (or the topics covered by it) while $w_{i,j} = w(x_i,x_j)$ indicates the amount of overlap between sentences in our summary. Finally we put all this in a minimization problem:\n\\begin{aligned} \n\\underset{z_i}{\\text{maximize }} & \\sum_{i} w_i z_i - w_{i,j} z_i z_j \\\\\n\\text{s.t. } & z_i = 0 \\text{ or } 1\n\\end{aligned}\nThis tries to maximize the total weight of the sentences covered and tries to minimize the amount of overlap. This is an integer programming problem similar to finding the lowest weight independent set in a graph and many techniques exist to solve such problems.\nThis design, in my opinion, captures the fundamental problems in text summarization and can be extended in many ways. We will discuss those in a bit, but first, we need to completely specify the features $w$. $w_i = w(x_i)$ could be a function only of the sentence $i$, but it could also depends on the place of the sentence in the document or its context (Is the sentence at the beginning of a paragraph? Does it share common words with the title? What is its length? Does it mention any proper nouns? etc)\n$w_{i,j} = w(x_i,x_j)$ is a similarity measure. It measures how many repetitions there will be if we include both words in the sentence. It can be defined by looking at common words between sentences. We can also extract topics or concepts from each sentence and see how many are common among them, and use language features like pronouns to see if one sentence expands on another.\nTo improve the design, first, we could do keyphrase extraction, i.e. identify key phrases in the text and choose to define the above problem in terms of those instead of trying to pick sentences. That is a similar problem to what Google does to summarize news articles in their search results, but I am not aware of the details of their approach. We could also break the sentences up further into concepts and try to establish the semantic meaning of the sentences ( Ponzo and Fila are people P1 and P2, a mall is a place P, P1 and P2 went to the place P at time T (day). Mode of transport walking.... and so on). To do this, we would need to use a semantic ontology or other common-sense knowledge databases. However, all the parts of this last semantic classification problem are open and I have not seen anyone make satisfactory progress on it yet. \nWe could also tweak the loss function above so that instead of the setting the tradeoff between the sentence importance $w_i$ and the diversity score $w_{i,j}$ by hand, we could learn it from data. One way to do this is to use Conditional Random Fields to model the data, but many others surely exist.\nI hope this answer explained the basic problems that need to be solved to make progress towards good summarization systems. This is an active field of research and you will find the most recent papers via Google Scholar, but first read the Wikipedia page to learn the relevant terms\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which neural network has capabilities of sorting input? I believe normally you can use genetic programming for sorting, however I'd like to check whether it's possible using ANN.\nGiven the unsorted text data from input, which neural network is suitable for doing sorting tasks?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Even a simple multilayer perceptron can sort input data to some extent, as you can see here and here.\nHowever, neural networks for sequential data seem more appropriate, as they can handle sequences of variable lengths. It has been done with an LSTM (Long Short-Term Memory), LSTM+HAM (Hierarchical Attentive Memory) and an NTM (Neural Turing Machine).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to resolve lexical ambiguity in natural language processing? I'm interested in implementing a program for natural language processing (aka ELIZA).\nAssuming that I'm already storing semantic-lexical connections between the words and its strength.\nWhat are the methods of dealing with words which have very distinct meaning?\nFew examples:\n\n'Are we on the same page?'\nThe 'page' in this context isn't a document page, but it's part of the phrase.\n'I'm living in Reading.'\nThe 'Reading' is a city (noun), so it's not a verb. Otherwise it doesn't make any sense. Checking for the capital letter would work in that specific example, but it won't work for other (like 'make' can be either verb or noun).\n'I've read something on the Facebook wall, do you want to know what?'\nThe 'Facebook wall' has nothing to do with wall at all.\n\nIn general, how algorithm should distinguish the word meaning and recognise the word within the context?\nFor example:\n\nDetecting the word for different type of speech, so it should recognise whether it's a verb or noun.\nDetecting whether the word is part of phrase.\nDetecting word for multiple meaning.\n\nWhat are the possible approaches to solve that problem in order to identify the correct sense of a word with the context?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nIn general, how algorithm should distinguish the word meaning and recognise the word within the context?\n\nI don't think anybody knows how to answer this for the general case. If they did, they'd have basically solved AGI. But we can certainly talk about techniques that get part of the way there, and approaches that could work.\nOne thing I would consider trying (and I don't know off-hand if anybody has tried this exact approach) is to model the disambiguation of each word as a discrete problem for a Bayesian Belief Network where your priors (for any given word) are based on both stored \"knowledge\" as well as the previously encountered words in the (sentence|paragraph|document|whatever). So if you \"know\", for example, that \"Reading is a city in the UK\" and that \"place names are usually capitalized\", your network should be strongly biased towards interpreting \"Reading\" as the city, since nothing in the word position in the sentence strongly contradicts that.\nOf course I'm hand-waving around some tricky problems in saying that, as knowledge representation isn't exactly a solved problem either. But there are at least approaches out there that you could use. For example, you could use the RDF / triple based approach from the Semantic Web world. Finding a good way to merge that stuff with a Bayesian framework could yield some interesting results.\nThere has been a bit of research on \"probabilistic RDF\" that you could possibly use as a starting point. For example:\n\n\"Probablistic RDF\" by Octavian Udrea, V.S. Subrahmanian, and Zoran Majki\u0107\n\"Representing Probabilistic Relations in RDF\" by Yoshio Fukushige\n2005 talk: \"Representing Probabilistic Relations in RDF\" by Yoshio Fukushige\n\"BayesOWL: Uncertainty Modeling in Semantic Web Ontologies\" by Zhongli Ding, Yun Peng, and Rong Pan\nPR-OWL: A Bayesian extension to the OWL Ontology Language\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does the generator in GAN's work? After reading a lot of articles (for instance, this one - https://developers.google.com/machine-learning/gan/generator), I've been wondering: how does the generator in GAN's work?\nWhat is the input to the generator? What is the meaning behind \"input noise\"?\nAs I've read, the only input that the generator receives is a random noise, which is weird.\nIf I would like to create a similar picture of $x$, and put as an input a matrix of random numbers (noise) - it would take A LOT of training until I would get some sort of picture $x^*$, that is similar to the source picture $x$.\nThe algorithm should receive some type of reference or a basic dataset (for instance, the set of $x$'s) in order to start the generation of the fake image $x^*$.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "What's the input to the Generator?\nIn the basic implementation of GANs, the Generator only takes in a vector of random variables. This might seem strange, but after training, the generator can transform this input noise into an image resembling those of the training set.\nHow does it work?\nIt is trained along with its counterpart the Discriminator, whose goal is to distinguish real images (i.e. the dataset's images) from fake ones (i.e. images produced by the Generator). The Generator's goal in training is to fool the Discriminator into thinking that its images are real.\nTraining process\nIn the beginning, where they are both untrained, they are both \"terrible\" at their respective tasks. The Generator can't produce anything resembling an image, but the Discriminator can't distinguish real from fake. As training progresses, the Discriminator starts identifying ways to distinguish the real images from the fake ones (i.e. patterns that appear in real images, but not in fake ones). The Generator, however, in its attempt to fool the Discriminator, starts producing those same patterns in its own images. After a while of both models becoming better at their respective tasks, we reach a point where the Generator can produce realistic images and the Discriminator is very good at distinguishing between real or fake.\n\nEdit as suggested from comment:\nA vector of random values is used as an input, so that the Generator can learn to generate unique outputs. In itself the Generator is deterministic, meaning that it has no internal sources of randomness. If we give it the same input vector twice, it will produce the same output both times. Thus, we feed the Generator with random values, so that it can learn to produce different outputs, depending on those values.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What was the first machine that was able to carry on a conversation? What was the first AI that was able to carry on a conversation, with real responses, such as in the famous 'I am not a robot. I am a unicorn' case?\nA 'real response' constitutes a sort-of personalized answer to a specific input by a user.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The well-known 'Eliza' program (Weizenbaum, ~1964) would appear to be the first. \nEliza was designed to model the emotionally-neutral response of a psychotherapist and this masks some of the weaknesses of its limited underlying pattern-matching mechanisms. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is word embedding a form of feature extraction? Feature extraction is a concept concerning the translation of raw data into the inputs that a particular machine learning algorithm requires. These derived features from the raw data that are actually relevant to tackle the underlying problem. On the other hand, word embeddings are basically distributed representations of text in an n-dimensional space.\nAs far as I understand, word embedding is a somehow feature extraction technique. Am I wrong ? I had an argument with a friend who believes the two topics are totally separate. Is he right? What are the similarities and dissimilarities between word embedding and feature extraction?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Though word-embedding is primarily a language modeling tool, it also acts as a feature extraction method because it helps transform raw data (characters in text documents) to a meaningful alignment of word vectors in the embedding space that the model can work with more effectively (than other traditional methods such as TF-IDF, Bag of Words, etc, on a large corpus). Word Embedding techniques help extract information from the pattern and occurence of words and goes further than other traditional token representation methods to decode/identify the meaning/context of the words, thereby providing more relevant and important features to the model to tackle the underlying problem.\nHowever, from another standpoint, word-embedding models were not developed aiming to solve a particular feature extraction problem, but rather, to generalize and model the language used in a corpus to gain a semantic understanding of the words and the relationships between them. Such that, all the various corpus-specific tasks can then employ the same \"library\" of information which was collectively & exhaustively learnt by the embedding model. Meaning, the word embedding model learns a language model that is task-agnostic for all tasks on that corpus unlike feature extraction methods which are specifically task-oriented.\nHence, the similarity is - word-embeddings can effectively aid in feature extraction; the dissimilarity is - they're not primarily meant to extract features more than they are for modeling a language which might be an \"overkill\" for a particular feature extraction task on a dataset.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the target $r + \\gamma \\max_{a'} Q(s', a'; \\theta_i^-)$ in the loss function of the DQN architecture? In the paper Human-level control through deep reinforcement learning, the DQN architecture is presented, where the loss function is as follows\n$$\nL_i(\\theta_i) = \\mathbb{E}_{(s, a, r, s') \\sim U(D)} \\left[ \\left( r + \\gamma \\max_{a'} Q(s', a'; \\theta_i^-) - Q(s, a; \\theta) \\right)^2\\right]\n$$\nwhere $r + \\gamma \\max_{a'} Q(s', a'; \\theta_i^-)$ approximates the \"target\" of $Q(s, a; \\theta)$. But it is not clear to me why. How can existing weights approximate the target (ground truth)? Isn't $r$ is a sample from a the experience replay dataset? Is $r$ a scalar value?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is the problem that reinforcement learning (RL) is trying to solve: What is the best way to behave when we don\u2019t know what the right action is and only have a scalar (the reward (r) is a scalar) reward of how well we have done?\nRL approaches this problem by utilizing temporal difference learning and makes predictions based on the previous experience. An RL agent is trying to maximize the sum of future discounted rewards, called the return. \nThe term $r + \\gamma \\max_{a'} Q(s', a'; \\theta_i^-)$ is essentially saying \"the reward I just saw + $\\gamma$ * (my prediction of the return given that I take what I think is the best action in the current state and follow my policy from then on)\". \nBy updating the Q function, the agent can better predict the consequences of its actions and can then choose the best action with greater probability. \nThe $\\gamma$ (gamma) helps to balance between the immediate reward and future rewards. A $\\gamma = 0$ makes the immediate reward the only thing that matters but usually the reward for a good action is delayed so values of gamma which put a higher importance on later rewards ($\\gamma = .8, .9, .99$, etc) are used. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is the AI Effect caused by bad tests of intelligence? According to Wikipedia...\n\nThe AI effect occurs when onlookers discount the behavior of an artificial intelligence program by arguing that it is not real intelligence.\nPamela McCorduck writes: \"It's part of the history of the field of artificial intelligence that every time somebody figured out how to make a computer do something\u2014play good checkers, solve simple but relatively informal problems\u2014there was chorus of critics to say, 'that's not thinking'.\"[1] AI researcher Rodney Brooks complains \"Every time we figure out a piece of it, it stops being magical; we say, 'Oh, that's just a computation.'\"[2]\n\nThe Wikipedia page then proposes several different reasons that could explain why onlookers might \"discount\" AI programs. However, those reasons seem to imply that the humans are making a mistake in \"discounting\" the behavior of AI programs...and that these AI programs might actually be intelligent. I want to make an alternate argument, where the humans are making a mistake, but not in \"discounting\" the behavior of AI programs.\nConsider the following situation. I want to build a machine that can do X (where X is some trait, like intelligence). I am able to evaluate intuitively whether a machine has that X criteria. But I don't have a good definition of what X actually is. All I can do is identify whether something has X or not.\nHowever, I think that people who has X can do Y. So if I build a machine that can do Y, then surely, I built a machine that has X.\nAfter building the machine that can do Y, I examine it to see if my machine has X. And it does not. So my machine lacks X. And while a machine that can do Y is cool, what I really want is a machine that has X. I go back to the drawing board and think of a new idea to reach X.\nAfter writing on the whiteboard for a couple of hours, I realize that people who has X can do Z. Of course! I try to build a new machine that can do Z, yes, if it can do Z, then it must have X.\nAfter building the machine that can do Z, I check to see if it has X. It does not. And so I return back to the drawing board, and the cycle repeats and repeats...\nEssentially, humans are attempting to determine whether an entity has intelligence via proxy measurements, but those proxy measurements are potentially faulty (as it is possible to meet those proxy measurements without ever actually having intelligence). Until we know how to define intelligence and design a test that can accurately measure it, it is very unlikely for us to build a machine that has intelligence. So the AI Effect occurs because humans don't know how to define \"intelligence\", not due to people dismissing programs as not being \"intelligent\".\nIs this argument valid or correct? And if not, why not?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I think it is mostly right. But not that intelligence is hard to define. In my opinion, it is simple: A is more intelligent than B if A achieves some purpose in less steps than B. It is functional/algorithmic efficiency.\nWhat is difficult to define is human intelligence.\nBut when someone says, \"No, X is not real intelligence,\" what they mean is that it does not satisfy what we would consider real human intelligence.\nSo when people discount new and amazing discoveries in machine intelligence, it is not because they are not amazing in their own way, but because those discoveries, while exhibiting intelligence, are actually not replicating human intelligence - which is what many people actually mean when they say \"that thing isn't really intelligent.\"\nIn truth we are very far, in the science of artificial intelligence, algorithmically speaking, from an artificial human intelligence (AHI).\nAdditional note: What's funny is that we don't call the science of artificial intelligence just 'the science of intelligence.' That we add the \"artificial\" qualifier by necessity pegs the science to what the artificiality implicitly emulates: human intelligence. In other words, \"artificial intelligence\" must be by definition more specific to the thing it allegedly artificializes than a more general science of just \"intelligence.\"\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which unsupervised learning technique can be used for anomaly detection in a time series? I've started working on anomaly detection in Python. My dataset is a time series one. The data is being collected by some sensors which record and collect data on semiconductor-making machines.\nMy dataset looks like this:\nContextID Time_ms Ar_Flow_sccm BacksGas_Flow_sccm\n7289973 09:12:48.502 49.56054688 1.953125\n7289973 09:12:48.603 49.56054688 2.05078125\n7289973 09:12:48.934 99.85351563 2.05078125\n7289973 09:12:49.924 351.3183594 2.05078125\n7289973 09:12:50.924 382.8125 1.953125\n7289973 09:12:51.924 382.8125 1.7578125\n7289973 09:12:52.934 382.8125 1.7578125\n7289999 09:15:36.434 50.04882813 1.7578125\n7289999 09:15:36.654 50.04882813 1.7578125\n7289999 09:15:36.820 50.04882813 1.66015625\n7289999 09:15:37.904 333.2519531 1.85546875\n7289999 09:15:38.924 377.1972656 1.953125\n7289999 09:15:39.994 377.1972656 1.7578125\n7289999 09:15:41.94 388.671875 1.85546875\n7289999 09:15:42.136 388.671875 1.85546875\n7290025 09:18:00.429 381.5917969 1.85546875\n7290025 09:18:01.448 381.5917969 1.85546875\n7290025 09:18:02.488 381.5917969 1.953125\n7290025 09:18:03.549 381.5917969 14.453125\n7290025 09:18:04.589 381.5917969 46.77734375\n\nWhat I have to do is to apply some unsupervised learning technique on each and every parameter column individually and find any anomalies that might exist in there. The ContextID is more like a product number.\nI would like to know which unsupervised learning techniques can be used for this kind of task at hand since the problem is a bit unique:\n\nIt has temporal values.\nSince it has temporal values, each product will have many (similar or different) values as can be seen in the dataset above.\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "So if I understood correctly:\nYou have data from 2 sensors in time: Ar flow and BackGas Flow (SCCM, what is that?)\nYou have that data for multiple products.\n1 - Since it is relatively low dimensional, you may try using raw data with K-Means or Self Organizing Maps.\n2 - If you searching for anomalies in time, you might try using feature engineering with things like flow change:\n\ni) Take 2 points in time and \"derivate\" (Point A - Point B)/(Time A - Time B)\nii) Take the result for A and repeat the process as a second derivative, try that for many levels of \"derivative\"\niii) Machine learning application for sensor failure detection in polymerization process. In: Simp\u00f3sio Brasileiro de Telecomunica\u00e7\u00f5es e Processamento de Sinais.\n\n3 - You might want to check other Time-Series related research, even on regression and classification, since they may give you ideas on relevant features or approaches:\n\ni) An enseble approach to time dependent classification (10.1109/ICMLA.2018.00164)\nii) Multivariate Time Series for Data-driven Endpoint Prediction in the Blast Oxygen Furnace (DOI: 10.1109/ICMLA.2018.00231)\n\n4 - Note that anomalies are outliers, so analysing data distant from the mean of any features you might engineer from the time. An model based on RBF kernels might pick up some information.\n5 - Since you don't know the amount of clusters you can try hierarchical clustering.\n6 - Don't forget to talk to people in your field about what to expect from this.\nIf you can elaborate on the type of anomalies you're looking for I may come with better ideas. This is pretty general tips.\nI may have misunderstood what you wanted to cluster:\n7 - If you want to detect anomalies in:\n\ni) products behavior tips above were mostly for it and you might use all 23 features in short time intervals and cluster like this:\n\n For each product in dataset {\n\n samples = {} # empty set\n\n For each time interval in product {\n\n features in interval add to samples\n\n }\n\n perform clustering method using samples\n\n }\n\nThis algorithm would help cluster periods of time where the product behavied weirdly\n\nii) sensors behavior then for something like that you might try tip 8\n\niii) products itself create a feature vector with all avaiable information for each product, then cluster that. Since it is composed of variable time interval and 23 features per product (plus time) you might want to use a bit of dimensionality reduction (PCA should work fine, since it gives you the direction of greater variance and you're look for that). Using a regressor to model products behavior and cluster that could all be usefull (create a regressor in time for each product to model its behavior, then cluster the weights of the regressors as the product representation)\n\n\n8 - Let's say you want to identify sensors behavior, it might be helpful to model the sensors output as a function f(time, extravariables) and do regression over it (try linear, then try non-linear). Points in time that the regressor had bad performance predicting the answer might indicate that that behavior is anomalous\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to calculate the number of parameters of a convolutional layer? I was recently asked at an interview to calculate the number of parameters for a convolutional layer. I am deeply ashamed to admit I didn't know how to do that, even though I've been working and using CNN for years now.\nGiven a convolutional layer with ten $3 \\times 3$ filters and an input of shape $24 \\times 24 \\times 3$, what is the total number of parameters of this convolutional layer?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "What are the parameters in a convolutional layer?\nThe (learnable) parameters of a convolutional layer are the elements of the kernels (or filters) and biases (if you decide to have them). There are 1d, 2d and 3d convolutions. The most common are 2d convolutions, which are the ones people usually refer to, so I will mainly focus on this case.\n2d convolutions\nExample\nIf the 2d convolutional layer has $10$ filters of $3 \\times 3$ shape and the input to the convolutional layer is $24 \\times 24 \\times 3$, then this actually means that the filters will have shape $3 \\times 3 \\times 3$, i.e. each filter will have the 3rd dimension that is equal to the 3rd dimension of the input. So, the 3rd dimension of the kernel is not given because it can be determined from the 3rd dimension of the input. \n2d convolutions are performed along only 2 axes (x and y), hence the name. Here's a picture of a typical 2d convolutional layer where the depth of the kernel (in orange) is equal to the depth of the input volume (in cyan).\n\nEach kernel can optionally have an associated scalar bias. \nAt this point, you should already be able to calculate the number of parameters of a standard convolutional layer. In your case, the number of parameters is $10 * (3*3*3) + 10 = 280$.\nA TensorFlow proof\nThe following simple TensorFlow (version 2) program can confirm this.\nimport tensorflow as tf\n\n\ndef get_model(input_shape, num_classes=10):\n model = tf.keras.Sequential()\n model.add(tf.keras.layers.Input(shape=input_shape))\n model.add(tf.keras.layers.Conv2D(10, kernel_size=3, use_bias=True))\n model.add(tf.keras.layers.Flatten())\n model.add(tf.keras.layers.Dense(num_classes))\n\n model.summary()\n\n return model\n\n\nif __name__ == '__main__':\n input_shape = (24, 24, 3)\n get_model(input_shape)\n\nYou should try setting use_bias to False to understand how the number of parameters changes.\nGeneral case\nSo, in general, given $M$ filters of shape $K \\times K$ and an input of shape $H \\times W \\times D$, then the number of parameters of the standard 2d convolutional layer, with scalar biases, is $M * (K * K * D) + M$ and, without biases, is $M * (K * K * D)$.\nSee also these related questions How is the depth of filters of hidden layers determined? and In a CNN, does each new filter have different weights for each input channel, or are the same weights of each filter used across input channels?. \n1d and 3d convolutions\nThere are also 1d and 3d convolutions. \nFor example, in the case of 3d convolutions, the kernels may not have the same dimension as the depth of the input, so the number of parameters is calculated differently for 3d convolutional layers. Here's a diagram of 3d convolutional layer, where the kernel has a depth different than the depth of the input volume.\n\nSee e.g. Intuitive understanding of 1D, 2D, and 3D convolutions in convolutional neural networks.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Do all neurons in a layer have the same activation function? I'm new to machine learning (so excuse my nomenclature), and not being a python developer, I decided to jump in at the deep (no pun intended) end writing my own framework in C++.\nIn my current design, I have given each neuron/cell the possibility to have a different activation function. Is this a plausible design for a neural network? A lot of the examples I see use the same activation function for all neurons in a given layer.\nIs there a model which may require this, or should all neurons in a layer use the same activation function? Would I be correct in using different activation functions for different layers in the same model, or would all layers have the same activation function within a model?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "From here:\n\nUsing other activation functions don\u2019t provide significant improvement in performance and tweaking them doesn\u2019t provide any big improvement. So as per simplicity we use same activation function for most of the case in Deep Neural Networks.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the appropriate way to deal with multiple paths to same state in MCTS? Many games have multiple paths to the same states. What is the appropriate way to deal with this in MCTS? \nIf the state appears once in the tree, but with multiple parents, then it seems to be difficult to define back propagation: do we only propagate back along the path that got us there \"this\" time? Or do we incorporate the information everywhere? Or maybe along the \"first\" path?\nIf the state appears once in the tree, but with only one parent, then we ignored one of the paths, but it doesn't matter because by definition this is the same state?\nIf the state appears twice in the tree, aren't we wasting a lot of resources thinking about it multiple times?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nIf the state appears twice in the tree, aren't we wasting a lot of resources thinking about it multiple times?\n\nYou're right. Precisely the same problem was also noticed decades before MCTS existed, in the classic minimax-style tree search algorithms (alpha-beta search, etc.) that were used in games before MCTS. The solution is also mostly the same; transposition tables.\nIn the case of MCTS, the statistics used by the algorithm that are normally associated with nodes (or their incoming edges) may instead be stored in entries of a transposition table. I mean stuff like visit counts and sums (or averages) of backpropagated scores.\nA brief description of how it would work, and references to more extensive relevant literature, can be found in subsubsection 5.2.4 of the well-known 2012 Survey paper on MCTS.\nThis does require that you can efficiently (incrementally) compute hash values for the states you encounter, which may not always be easy (should usually be possible, depends on the details of your problem domain). Use of transpositions in MCTS is also not always guaranteed to actually improve performance. It does come with computational overhead, and in games where transpositions are very rare it may be more efficient to simply ignore them and use the regular tree structure.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can the importance sampling ratio be different than zero when the target policy is deterministic? In the book Reinforcement Learning: An Introduction (2nd edition) Sutton and Barto define at page 104 (p. 126 of the pdf), equation (5.3), the importance sampling ratio, $\\rho _{t:T-1}$, as follows:\n$$\\rho _{t:T-1}=\\prod_{k=t}^{T-1}\\frac{\\pi(A_k|S_k)}{b(A_k|S_k)}$$\nfor a target policy $\\pi$ and a behavior policy $b$.\nHowever, on page 103, they state:\n\nThe target policy $\\pi$ [...] may be deterministic [...].\n\nWhen $\\pi$ is deterministic and greedy it gives $1$ for the greedy action and 0 for all other possible actions.\nSo, how can the above formula give something else than zero, except for the case where policy $b$ takes a path that $\\pi$ would have taken as well? If any selected action of $b$ is different from $\\pi$'s choice, then the whole numerator is zero and thus the whole result.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You're correct, when the target policy $\\pi$ is deterministic, the importance sampling ratio will be $\\geq 1$ along the trajectory where the behaviour policy $b$ happened to have taken the same actions that $\\pi$ would have taken, and turns to $0$ as soon as $b$ makes one \"mistake\" (selects an action that $\\pi$ would not have selected).\nBefore importance sampling is introduced in the book, I believe the only off-policy method you will have seen is one-step $Q$-learning, which can only propagate observations back along exactly one step. With the importance sampling ratio, you can often do a bit better. You're right, there is a risk that it turns to $0$ rather quickly (especially when $\\pi$ and $b$ are very different from each other), at which point it essentially \"truncates\" your trajectory and ignores all subsequent experience... but that still can be better than one-step, there is a chance that the ratio will remain $1$ for at least a few steps. It will occasionally still only permit $1$-step returns, but also sometimes $2$-step returns, sometimes $3$-step returns, etc., which is often better than only having $1$-step returns.\nWhenever the importance sampling ratio is not $0$, it can also give more emphasis to the observations resulting from trajectories that would be common under $\\pi$, but are uncommon under $b$. Such trajectories will have a ratio $> 1$. Emphasizing such trajectories more can be beneficial, because they don't get experienced often under $b$, so without the extra emphasis it can be difficult to properly learn what would have happened under $\\pi$.\n\nOf course, it is also worth noting that your quote says (emphasis mine):\n\nThe target policy $\\pi$ [...] may be deterministic [...]\n\nIt says that $\\pi$ may be deterministic (and in practice it very often is, because we very often take $\\pi$ to be the greedy policy)... but sometimes it won't be. The entire approach using the importance sampling ratio is well-defined also for cases where we choose $\\pi$ not to be deterministic. In such situations, we'll often be able to propagate observations over significantly longer trajectories (although there is also a risk of excessive variance and/or numeric instability when $b$ selects actions that are highly unlikely according to $b$, but highly likely according to $\\pi$).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Unclear points regarding ROC curve in machine learning Consider the ROC curve below:\n\nIt is not clear to me why \"PERFECT CLASSIFIER\" line is really perfect because there are points on this line (see the green circles) for which false positive rate is non-zero.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The \"PERFECT CLASSIFIER\" line is perfect because at the optimal threshold (somewhere near the top left corner, with TPR = 1 and FPR = 0), it makes no classification errors. The non-zero FPR points you see occur when you change the cutoff threshold score (for instance, due to imbalanced dataset or cost sensitive learning ), which includes more negatives in the positive class. The ROC curve is a summary of classifier behavior across all thresholds, but the classifier itself can still be perfect if you set the optimal threshold.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are some online courses for deep reinforcement learning? What are some (good) online courses for deep reinforcement learning?\nI would like the course to be both programming and theoretical. I really liked David Silver's course, but the course dates from 2015. It doesn't really teach deep Q-learning at this time.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Let me first say that deep RL is just the combination of RL with deep learning. So, if you study RL and deep learning, then studying deep RL should be straightforward. For this reason, this answer will point the reader to potentially useful courses on RL (also because there aren't many free courses completely dedicated to deep RL), which have at least one lesson on deep RL or function approximation. I have only followed the course by Isbell and Littman and partially the course by David Silver, so I can't ensure you that the other courses are good, but I found these two useful, although not perfect.\n\n\n\n\nTitle\nInstructor(s)\nFocus on deep RL?\nTopics\nFree\n\n\n\n\nReinforcement Learning\nCharles Isbell, Michael Littman\nNo\nTD learning, convergence, function approximation, POMDP, options, game theory\nYes\n\n\nIntroduction to Reinforcement Learning with David Silver\nDavid Silver\nNo\nMDPs, planning, dynamic programming, model-free prediction and control, function approximation, policy gradients, exploration and exploitation\nYes\n\n\nCS234: Reinforcement Learning Winter 2020\nEmma Brunskill\nNo\nSee the course schedule; lesson 6 is about DRL\nYes\n\n\nReinforcement Learning\nNPTEL\nNo\nBandits, MDPs, policy gradients, dynamic programming, TD learning, function approximation, hierarchical RL, POMDP\nYes\n\n\nReinforcement Learning in the Open AI Gym\nPhil Tabor\n?\nSARSA, double Q-learning, Monte Carlo methods, Q-learning\nYes\n\n\nAdvanced Deep Learning & Reinforcement Learning\nDeepMind\nNo\nvideo 14 discusses DRL topics\nYes\n\n\nAdvanced AI: Deep Reinforcement Learning in Python\nUdemy\nYes, it seems\n?\nNo\n\n\nMachine Learning: Beginner Reinforcement Learning in Python\nUdemy\n?\n?\nNo\n\n\nDeep Reinforcement Learning 2.0\nUdemy\n?\n?\nNo\n\n\nModern Reinforcement Learning: Deep Q Learning in PyTorch\nPhil Tabor (Udemy)\n?\n?\nNo\n\n\nModern Reinforcement Learning: Actor-Critic Methods\nPhil Tabor (Udemy)\n?\n?\nNo\n\n\n\n\nIn any case, if you are familiar with RL and deep learning topics, I encourage you to directly read the DQN papers (both by DeepMind folks)\n\nPlaying Atari with Deep Reinforcement Learning (2013)\nHuman-level control through deep reinforcement learning (2015)\n\nOf course, deep RL isn't just DQN, but these are two very important papers that you should read. Other key papers on deep RL can be found here.\nNote that, depending on your experience with and knowledge of RL and DL, you may require a few iterations to fully understand these papers, but this applies every time you need to read a research paper.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there a connection between the bias term in a linear regression model and the bias that can lead to under-fitting? Here is a linear regression model\n$$y = mx + b,$$\nwhere $b$ is known as $y$-intercept, but also known as the bias [1], $m$ is the slope, and $x$ is the feature vector.\nAs I understood, in machine learning, there is also the bias that can cause the model to underfit.\nSo, is there a connection between the bias term $b$ in a linear regression model and the bias that can lead to under-fitting in machine learning?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In machine learning, the term bias can refer to at least 2 related concepts\n\nA (learnable) parameter of a model, such as a linear regression model, which allows you to learn a shifted function. For example, in the case of a linear regression model $y = f(x) = mx + b$, the bias $b$ allows you to shift the straight-line up an down: without the bias, you would only be able to control the slope $m$ of the straight-line. Similarly, in a neural network, you can have a neuron that performs a linear combination of the inputs, then it uses a bias term to shift the straight-line, and you could also use the bias after having applied the activation function, but this will have a different effect.\n\nAnything that guides the learning algorithm (e.g. gradient descent with back-propagation) towards a specific set of solutions. For example, if you use regularization, you are biasing the learning algorithm to choose, typically, smoother or simpler functions. The bias term in the linear regression model is also a way of biasing the learning algorithm: you assume that the straight-line function does not necessarily go through zero, and this assumption affects the type of functions that you can learn (and this is why these two concepts of bias are related!). So, there are many ways of biasing a learning algorithm.\n\n\nThe bias does not always lead you to the best solutions and can actually lead to the wrong solutions, but it is often useful in many ways, for example, it can speed up learning, as you restrict the number of functions that can be learned and searched. The bias (as described in point 2) is often discussed in the context of the bias-variance trade-off, and both the bias and the variance are related to the concepts of generalization, under-fitting, and over-fitting. The linked Wikipedia article explains these concepts quite well and provides an example of how the bias and variance are decomposed, so you should probably read that article for more details.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can a reinforcement learning agent generalize if it is trained against only one opponent? I started teaching myself about reinforcement learning a week ago and I have this confusion about the learning experience. Let's say we have the game Go. And we have an agent that we want to be able to play the game and win against anyone. But let's say this agent learn from playing against one opponent, my questions then are: \n\nWouldn't the agent (after learning) be able to play only with that opponent and win? It estimated the value function of this specific behaviour only.\nWould it be able to play as good with weaker players? \nHow do you develop an agent that can estimate a value function that generalizes against any behaviour and win? Self-play? If yes, how does that work? \n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Reinforcement Learning (RL) at its core does not have anything directly to say about adversarial environments, such as board games. That means in a purely RL set up, it is not really possible to talk about the \"strength\" of a player.\nInstead, RL is about solving consistent environments, and that consistency requirement extends to any opponents or adversarial components. Note that consistency is not the same as determinism - RL theory copes well with opponents that effectively make random decisions, provided the distribution of those decisions does not change based on something the RL agent cannot know.\nProvided an opponent plays consistently, RL can learn to optimise against that opponent. This does not directly relate to the \"strength\" of an opponent, although usually strong opponents present a more challenging environment to learn overall.\n\n\nWouldn't the agent (after learning) be able to play only with that opponent and win? since it estimated the value function of this specific behavior only.\n\n\nIf the RL has enough practice and time to optimise against the opponent, then yes the value function (and any policy based on it) would be specific to that opponent. Assuming, the opponent did not play flawlessly, then the RL would learn to play such it would win as often as possible against the opponent.\nWhen playing against other opponents, the success of the RL agent will depend on how similar the new opponent was to the original that it trained against.\n\n\nwould it be able to play as good with weaker players?\n\n\nAs stated above, there is not really a concept of \"stronger\" or \"weaker\" in RL. It depends on the game, and how general the knowledge is that strong players require in order to win. \nIn theory you could construct a game, or deliberately play strongly, but with certain flaws, so that RL would play very much to counter one play style, and would fail against another player that did not have the same flaws. \nIt is difficult to measure this effect, because human players learn from their mistakes too, and are unlikely to repeat the exact same game time after time, but with small variations at key stages. Humans do not make consistent enough opponents, and individual humans do not play enough games at each stage of their ability to study fine-grained statistics of their effective policies.\nIn practice it seems likely that the effect of weakening against new players would be there in RL, due to sampling error if nothing else. However, it seems that the \"strength\" of players as we measure them in any game of skill such as chess or go, does correlate with a generalised ability. In part this is backed up by consistent results with human players and Elo ratings.\nAny game where you can form \"rings\" of winning players:\n\nPlayer B consistently beats Player A\nPlayer C consistently beats Player B\nPlayer A consistently beats Player C\n\nCould cause issues of the type you are concerned about when applying RL to optimise an artificial agent.\n\n\nHow do you develop an agent that can estimate a value function that generalizes against any behavior and win? \n\n\nIf is possible to play perfectly, then a value function which estimated for perfect play would work. No player could beat it. Think of Tic Tac Toe - it is relatively easy to construct perfect play value functions for it.\nThis is not achievable in practice in more complex games. To address this, and improve the quality of its decisions, what AlphaGo does is common to many game-playing systems, using RL or not. It performs a look-ahead search of positions. The value function is used to guide this. The end result of the search is essentially a more accurate value function, but only for the current set of choices - the search focuses lots of computation on a tiny subset of all possible game states. \nOne important detail here is that this focus applies at run time whilst playing against any new opponent. This does not 100% address your concerns about differing opponents (it could still miss a future move by a different enough opponent when searching). But it does help mitigate smaller statistical differences between different opponents. \nThis search tree is such a powerful technique that for many successful game playing algorithms, it is possible to start with an inaccurate value function, or expert heuristics instead, which are fixed and general against all players equally. IBM's Deep Blue is an example of using heuristics.\n\nself-play? if yes, how does that work?\n\nSelf-play appears to help. Especially in games which have theoretical optimal play, value functions will progress towards assessing this optimal policy, forming better estimates of state value with enough training. This can give a better starting point than expert heuristics when searching.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the typical sizes of practical/commercial artificial neural networks? I'm interested in artificial neural networks (ANN) and I wonder how big ANNs in practical use are, for example, Tesla Autopilot, Google Translate, and others.\nThe only thing I found about Tesla is this one:\n\n\"A full build of Autopilot neural networks involves 48 networks that\ntake 70,000 GPU hours to train. Together, they output 1,000 distinct\ntensors (predictions) at each timestep.\"\n\nIt seems like most companies don't publish clear information about their ANN sizes. I really can't find anything detailed on this subject.\nIs there any information about the size of big practical/commercial ANNs that include something like the amount of neurons/connections/layers etc.?\nI'm looking for a few examples in this scale with more precise information on the size of the neural networks.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "NLP Domain\nYou can easily find such open-source neural networks in NLP applications that have been published by Companies like Google. For example, in BERT models, you can see the BERT-Base has the following specifications:\n\nBERT-Base, Multilingual Cased: 104 languages, 12-layer, 768-hidden, 12-heads, 110M parameters\n\nYou can find more data about other versions of BERT in the same link.\nAnother example is GPT models, like GPT-3:\n\nAll GPT-3 models use the same attention-based architecture as their GPT-2 predecessor. The smallest GPT-3 model (125M) has 12 attention layers, each with 12x 64-dimension heads. The largest GPT-3 model (175B) uses 96 attention layers, each with 96x 128-dimension heads.\n\nImage Procssing Domain\nAnother useful domain for your expectation is image processing tasks such as image classification. Pretrained models such as VGG, ResNet, and Inception. These are mostly used for image classification tasks in different companies, and you can find their specification many where. For example for VGG-16, we can see the followings:\n\nSpeech Processing\nAnother practical domain is Auto-Speech Recognition or ASR in short. One of the renowned models in this context is DeepSpeech(2) by Baido Research center. For example, you can find some info like the number of its parameters and its structure in this github link.\nSumming up\nNote that one regular metric to measure the size of neural networks is \"the number of parameters\" of the network that is required to be learned in the training phase. Hence, you can compare the size of models even between cross domains by knowing their number of parameters (instead of going to more details about the number of hidden layers and their types). Although, sometimes the length (number of layers) and height (number of neurons in each layer) of the network are very important in the matter of performance and capability of the network.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which machine learning algorithm could I use to break up a poem by lines? I want to create a network to predict the break up of poetry lines. The program would receive as input an unbroken poem, and would output the poem broken into lines.\nFor example, an unbroken poem could be\nAnd then the day came, when the risk to remain tight in a bud was more painful\n\nwhich should be converted to\nAnd then the day came,\nwhen the risk\nto remain tight\nin a bud\nwas more painful\nthan the risk\nit took\nto Blossom.\n\nHow should I go about this? I have been using classifiers for various tasks, but this seems to be a different type of task.\nI'm thinking of it as an array of words (doesn't matter how they're represented for now), which would look like\n[6, 32, 60, 203, 40, 50, 60, 230 ...] \n\nand needs to map into an array representing line breaks\n[0, 0, 1, 0, 0, 0, 1, 0, 0, 1 ...]\n\nwhere 1 (at optimal) means there should be a line break after the word in that index (in this idea, the two arrays are of the same length).\nUnfortunately, I couldn't find an algorithm that could train a network of this shape.\nWhat machine learning or deep learning algorithm can be used for this task?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You should try to use an RNN. You feed in letter by letter and have a binary output of linebreak - no linebreak. If you have enough data it might actually work. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are LLMs \"lazy\" in their responses? (Just to preface that I do not have such a great understanding of LLMs and AI in general...)\nMy question is, when I pose a question to a LLM, will it present the fastest response that satisfies the parameters of the query, irrespective whether it is capable of providing a better answer with more compute? (\"Better\" in this sense meaning that if you posed the question and both answers to the LLM, the LLM itself would acknowledge that the second answer was \"better\" by some metric.)\nI would provide some examples but I feel that that might be counterproductive - I want to avoid focus on a specific type of query. Also, clearly there are many questions that there is no complexity to the answers - e.g. \"what is the capital of Thailand?\" - so more compute will not improve the answer in any meaningful way.\nI guess another way of asking this question is, what parameters does an LLM use to decide when an answer is complete/sufficient?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "LLM isn\u2019t holding back compute in hopes of improving an answer; it generates an answer autoregressively as soon as it can, according to its learned probability distribution and the chosen decoding parameters, and stops when those parameters indicate it\u2019s done. Decoding parameters include temperature which controls randomness to generate the next token out of the distribution more accurately or more creatively, top-p/top\u2011k or nucleus sampling which restricts candidate tokens, and the maximum output length, all of which help shape both the style and the length of the answer. This is why you often see that for simple queries like \u201cWhat is the capital of Thailand?\u201d the answer as a straightforward fact is quickly generated since most of its inferred next token distributions are thinly peaked and insensitive to the decoding parameters, whereas those of more complex or open-ended queries are more flat and sensitive to the decoding parameters.\nHaving said that, there's another decoding parameter set called beam search including num_beamsand length_penalty which does explore multiple candidate token sequences, improving quality at higher compute. Default setups often use faster greedy decoding to generate single path thus prioritize efficiency, but adjusting parameters via beam search and greater maximum output length might yield more detailed and \"better\" answer at the expense of compute.\nBecause the model isn\u2019t comparing multiple full answers by default, it doesn\u2019t internally compute that one answer is \u201cbetter\u201d than another given more compute. Of course if you were to run the generation process multiple times with different random seeds or decoding parameters, you might get answers that you\u2019d later judge as \u201cbetter\u201d in some respects, but the LLM isn\u2019t actively trying to optimize or reflect on the generation quality beyond following its learned distribution.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Transformers: how does the decoder final layer output the desired token? In the paper Attention Is All You Need, this section confuses me:\n\nIn our model, we share the same weight matrix between the two embedding layers [in the encoding section] and the pre-softmax linear transformation [output of the decoding section]\n\nShouldn't the weights be different, and not the same? Here is my understanding:\nFor simplicity, let us use the English-to-French translation task where we have $n^e$ number of English words in our dictionary and $n^f$ number of French words.\n\nIn the encoding layer, the input tokens are $1$ x $n^e$ one-hot vectors, and are embedded with a $n^e$ x $d^{model}$ learned embedding matrix.\n\nIn the output of the decoding layer, the final step is a linear transformation with weight matrix $d^{model}$ x $n^f$, and then applying softmax to get the probability of each french word, and choosing the french word with the highest probability.\n\n\nHow is it that the $n^e$ x $n^{model}$ input embedding matrix share the same weights as the $d^{model}$ x $n^f$ decoding output linear matrix? To me, it seems more natural for both these matrices to be learned independently from each other via the training data, right? Or am I misinterpreting the paper?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I found the answer by reading the paper referenced by that section, Using the output embedding to improve language models\n\nBased on this observation, we propose threeway weight tying (TWWT), where the input embedding of the decoder, the output embedding of\nthe decoder and the input embedding of the encoder are all tied. The single source/target vocabulary of this model is the union of both the source\nand target vocabularies. In this model, both in the\nencoder and decoder, all subwords are embedded\nin the same duo-lingual space.\n\nIt seems like they learned a single embedding matrix ($n^e + n^f$) x $d^{model}$ in dimension.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Medical diagnosis systems based on artificial neural networks Are there any medical diagnosis systems that are already used somewhere that are based on artificial neural networks?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, there are many, actually. A Google search turned this paper Artificial Neural Networks in Medical Diagnosis (2011) by Al-Shayea up. \nNot only are they used in disease diagnosis, but even with things like prescribing medicines. In fact, the top project for a hackathon at my school analysed thousands of research articles, and took a patient's medication history as input, to best recommend them specific medicines. Check it out.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why was ELIZA able to induce \"delusional thinking\"? From Eliza to A.L.I.C.E.:\n\nWeizenbaum tells us that he was shocked by the experience of releasing ELIZA (also known as \"Doctor\") to the nontechnical staff at the MIT AI Lab. Secretaries and nontechnical administrative staff thought the machine was a \"real\" therapist, and spent hours revealing their personal problems to the program. When Weizenbaum informed his secretary that he, of course, had access to the logs of all the conversations, she reacted with outrage at this invasion of her privacy. Weizenbaum was shocked by this and similar incidents to find that such a simple program could so easily deceive a naive user into revealing personal information.\n\nWikipedia's article on the \"ELIZA Effect\":\n\nThough designed strictly as a mechanism to support \"natural language conversation\" with a computer, ELIZA's DOCTOR script was found to be surprisingly successful in eliciting emotional responses from users who, in the course of interacting with the program, began to ascribe understanding and motivation to the program's output. As Weizenbaum later wrote, \"I had not realized ... that extremely short exposures to a relatively simple computer program could induce powerful delusional thinking in quite normal people.\" Indeed, ELIZA's code had not been designed to evoke this reaction in the first place. Upon observation, researchers discovered users unconsciously assuming ELIZA's questions implied interest and emotional involvement in the topics discussed, even when they consciously knew that ELIZA did not simulate emotion.\n\nELIZA, despite its simplicity, was incredibly successful at its task of tricking other human beings. Even those who knew ELIZA was a bot would still talk to it. Obviously, ELIZA served as an inspiration for various other, more intelligent chatbots, such as Xiaoice. But I would like to know what exactly led to such a simple program like ELIZA to be so successful in the first place.\nThis is very useful knowledge for a programmer since a simple program is one that would be easily maintainable.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I like your choice of \"induce\" instead of \"produce,\" because the delusions came from the users. This means the answer has to do mostly with human psychology; people come equipped with lots of mental machinery specialized for dealing with other humans and not very much mental machinery specialized for dealing with software. So ELIZA behaved in ways that some people classified it as a person and behaved accordingly, and others didn't.\nWhat features will trip up a person's internal person classification system seem like they vary heavily from person to person, and also with experience and familiarity. Going into more detail is, as mentioned in the comments, more appropriate for sites specializing on the human side of the keyboard.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is this idea to calculate the required number of hidden neurons for a single hidden layer neural network correct? I have an idea to find the optimal number of hidden neurons required in a neural network, but I'm not sure how accurate it is.\nAssuming that it has only 1 hidden layer, it is a classification problem with 1 output node (so it's a binary classification task), has N input nodes for N features in the data set, and every node is connected to every node in the next layer.\nI'm thinking that to ensure that the network is able to extract all of the useful relations between the data, then every piece of data must be linked to every other piece of data, like in a complete graph. So, if you have 6 inputs, there must therefore be 15 edges to make it complete. Any more and it will be recomputing previously computed information and any less will be not computing every possible relation.\nSo, if a network has 6 input nodes, 1 hidden node, 1 output node. There will be 6 + 1 connections. With 6 input nodes, 2 hidden nodes, and 1 output node, there will be 12 + 2 connections. With 3 hidden nodes there will be 21 connections. Therefore, the hidden layer should have 3 hidden nodes to ensure all possibilities are covered.\nThis answer discusses another method. For the sake of argument, I've tried to keep both examples using the same data. If this idea is computed with 6 input features, 1 output node, $\\alpha = 2$, and 60 samples in the training set, this would result in a maximum of 4 hidden neurons. As 60 samples is very small, increasing this to 600 would result in a maximum of 42 hidden neurons.\nBased on my idea, I think there should be at most 3 hidden nodes and I can't imagine anymore being useful, but would there be any reason to go beyond 3 and up to 42, like in the second example?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nI have an idea to find the optimal number of hidden neurons required in a neural network but I'm not sure how accurate it is.\n\nIt's a complete non-starter, and there is a no such calculation possible in the general case (real-valued inputs to a neural network). \nEven with one input neuron it is not possible. That is because even with one input, the output can be an arbitrarily complex mapping to classes. A good example with two inputs that would require an infinite number of hidden neurons to supply a simple classifier would be classifying x,y points as being in the Mandelbrot set. \nIn some, more constrained, examples, with well-defined functions, you can construct a minimal neural network that solves the problem perfectly. For instance a neural network model of XOR can be made with two hidden neurons (and six links). However, this kind of analysis is limited to simple problems. You might be able to come up with some variation of your idea if all inputs were boolean, and the neural network limited to some combined bitwise logic on all the inputs.\nYour idea of matching number of edges to number of possible interactions between inputs does not work because you are only considering the most basic kind of interaction between two variables, whilst variables can in practice combine in all sorts of ways to form a function. \nIn addition, each neuron in a hidden layer works with a linear weighted sum, plus a fixed transformation function. This is in no way guaranteed to match the function shape that you are trying to approximate with the neural network. An analogy that you might be aware of is discrete Fourier transforms - it is possible to model any part of a function by combine sine and cosine waves of different frequencies, but some functions will require many such waves in order to be represented accurately.\nYour link to the answer in Cross Validated Stack Exchange gives you a rule of thumb that the writers find often works with the kinds of data that they work with. This is useful experience. You can use such rules as the starting point for searching for architecture that works on your problem. This will likely be more useful than your idea based on counting the possible variable interactions. However, in both cases, the most important step is to perform a test with some unseen examples, and to search for the best neural network architecture for your problem.\nThere are things you can do with variable interactions though. For instance, try looking for linear correlations between simple polynomial combinations of variables and your target variable, e.g. plot $x_1 x_2$ vs $y$ or $x_3^2 x_4$ vs $y$ . . . you may find some combinations have a clear signal implying a relationship. Take care if you do this sort of thing though, if you test very many of these, you will find a linear relationship purely by chance that looks good initially but turns out to be a dud when testing (it's a form of overfitting). So you should generally test a lot less than the size of your dataset, and limit yourself to some modest maximum total power.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there research that employs realistic models of neurons? Is there research that employs realistic models of neurons? Usually, the model of a neuron for a neural network is quite simple as opposed to the realistic neuron, which involves hundreds of proteins and millions of molecules (or even greater numbers). Is there research that draws implications from this reality and tries to design realistic models of neurons?\nParticularly, recently, Rosehip neuron was discovered. Such neuron can be found only in human brain cells (and in no other species). Are there some implications for neural network design and operation that can be drawn by realistically modelling this Rosehip neuron?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "State of Rosehip Research\nThe Rosehip neuron is an important discovery, with vast implications to AI and its relationship to the dominant intelligence on earth for at least the last 50,000 years. The paper that has spawned other articles is Transcriptomic and morphophysiological evidence for a specialized human cortical GABAergic cell type, Buldog et. al., September 2018, Nature Neuroscience.\nThe relationship between this neuron type and its DNA expression is beginning. No data is available regarding the impact of the Rosehop distinctions on neural activity during learning or leveraging what has been learned. Surely, research along those lines is indicated, but the discovery was just published.\nBenefit of the Interdisciplinary Approach to AI\nThat those who reference papers like this can see value in the unification or at least alignment of knowledge across disciplines is most likely beneficial to AI progress and progress in the other fields of cognitive science, bioinformatics, business automation, manufacturing and consumer robotics, psychology, and even law, ethics and philosophy.\nThat such interest in aligning understanding along interdisciplinary lines is present in AI Stack Exchange is certainly beneficial to the community growth in both professional and social dimensions.\nDisparity Between What Works\nIn the human brain, neurons work. Whether Rosehip neurons are a prerequisite to language, the building of and leveraging of complex models, or transcendent emotions such as love in homo sapiens is unknown and will remain so in the near future. However, we have a fifty millennia long proof of concept.\nWe also know that artificial networks work. We use them in business, finance, industry, consumer products, and a variety of web services today. When a pop-up asks whether the answer given was helpful, our answer becomes a label in a set of real data from which samples are extracted for machine learning.\nNonetheless, the cells that are working are offspring of the 1957 perceptron with the addition of the application of gradient descent using an efficient corrective signal distribution strategy we call back propagation. The comprehension of neuron function in 1957 was grossly short of what we now know to be functional features of mammalian brain neurons. The Rosehip discovery may widen that gap.\nSpiking Networks\nThe spiking network research more realistically models neurons, and neuromorphic research and development has been placing improved models into VLSI chips. The joint venture between IBM and MIT is another.\nCorrelating Neural Function to Brain Function\nThe relationship intelligence and the number of proteins or molecules may not be the most telling. These are more likely relationships between metrics and features and the intelligence of the system.\n\nGenetic features that have been identified (22 of them) that directly affect intelligence testing results \u2014 For instance the correlation between polymorphisms of the oxytocin receptor genes OXTR rs53576, rs2254298, and rs2228485 and intelligence is known \u2014 See the question containing references to discovery of 22 genes that affect intelligence test results significantly\nNeurochemical expression resulting from environmental factors varying the levels of oxytosin, dopamine, serotonin, neuropeptide Y, and canabinoids which is involved in global and regional functional behavior in the human brain\nSignal topology (distinct from sizes and counts and distinct from the topology of created by packaging neural nets in the cranial region) \u2014 Signal topology is now being identified. Scanning technology has developed to the point where signal paths can be identified by tracking pulses in temporal space and determine causality.\nSynaptic plasticity, a type of neural plasticity\nTotal number of neurons applied to a particular brain function\nImpact on axon and cell body thermodynamics on signal transmission, a key element in modelling a brain neuron\n\nNone of these are yet modelled in such a way that simulation accuracy has been confirmed, but the need to research along these lines is clearly indicated as this question implies.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are policy gradient methods good for large discrete action spaces? I have seen this question asked primarily in the context of continuous action spaces.\nI have a large action space (~2-4k discrete actions) for my custom environment that I cannot reduce down further:\nI am currently trying DQN approaches but was wondering that given the large action space - if policy gradient methods are more appropriate and if they are appropriate for large action spaces that are discrete as in my scenario above. I have seen answers to this question with regard to large continuous action spaces.\nFinally - I imagine there isn't a simple answer to this but: Does this effectively mean DQN will not work?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I don't think that (at least from a practical standpoint), there is much difference between continuous action space and discrete action space with >2k discrete actions. Quoting the \"Continuous control with Deep RL\" paper - which I'd recommend as a starting point for your investigation:\n\nAn obvious approach to adapting deep reinforcement learning methods such as DQN to continuous\ndomains is to to simply discretize the action space. ... Such large action spaces are difficult to explore efficiently, and thus successfully training\nDQN-like networks in this context is likely intractable. Additionally, naive discretization of action spaces needlessly throws away information about the structure of the action domain, which may be essential for solving many problems.\n\nThe last sentence in the quote above is the most important point for dealing with your problem. The fundamental issue is inability to efficiently explore such a large action space - so the idea is to use its structure. I'm sure that your >2k discrete action set has a certain structure on it. Like some actions might be \"closer\" to others. If so, then you (1) can infer some information about \"neighbor\" actions even if you never took them (2) do some exploration by adding noise to your policy-preferred action.\nThe Actor-Critic class of algorithms matches perfectly the steps (1) and (2) above. The Critic Q-value network learns about your state-action space and the Actor policy network returns actions that you could smear.\n\nAre policy gradient methods good for large discrete action spaces?\n\nThe Actor-Critic class of RL algorithms is a subclass of the Policy Gradient algorithms. So, the answer is yes - it looks like going that way is your best shot at making progress.\n\nDoes this effectively mean DQN will not work?\n\nI don't think that there is a strict \"it will not work\" statement. The problem is that it just would be extremely difficult to make the DQN training stable \"by hand\". In principle you might be able to construct a neural architecture that captures the state-action space structure. And then figure out how to perform efficient exploration. And then ensure that nothing explodes anywhere. But that's exactly what DDPG and then TRPO/PPO approaches would do for you.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What should we do when the selection step selects a terminal state? In Monte Carlo tree search, what should we do when the selection step selects a terminal state (i.e. a won or lost state), which is, by definition, a leaf node? Expansion and simulation is not in order, as it's game over, but does the tree (score/visits) need to be updated (backpropagation)? Won't this particular node be selected continuously?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In the basic form, if you encounter a terminal leaf, you add visits and score depending on whether it is a win or loss, and backpropagate accordingly. The same as if you made a simulation step, but in this case the \"simulation\" is instant.\nBut you can improve that: If the leaf is losing, you can give it a very large negative score or even $-\\infty$, so in the next selection step it surely won't be chosen, unless other moves are as bad. But if it is a winning leaf, you not only can give it a very big positive score or $\\infty$, but also add a negative score for the immediate parent, so the parent won't be chosen, as it is obviously a losing state for him. This way we can save some simulations. I had encountered that situation many times in my game and Monte Carlo tree searches.\nSuppose the parent has $200$ unexplored children, $10$ of which are immediate wins for the opponent. Your search may explore $100$ non-winning children and have a score of 80/100. But then it encounters the terminate child. After that, normally, it would have $80/101$, so, still, a big chance to be chosen in the next iteration. And it would take many iterations to see that this is not a good move, as it would need to get like $80/150$ or more. But if we cancel out the score or give it a negative one like $-1/101$, then we ensure it won't be chosen.\nIt seems in literature it's called \"MCTS solver\", to backpropagate proven wins and losses.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How should the neural network deal with unexpected inputs? I recently wrote an application using a deep learning model designed to classify inputs. There are plenty of examples of this using images of irises, cats, and other objects. \nIf I trained a data model to identify and classify different types of irises and I show it a picture of a cat, is there a way to add in an \"unknown\" or \"not a\" classification or would it necessarily have to guess what type of iris the cat most looks like?\nFurther, I could easily just add another classification with the label \"not an iris\" and train it using pictures of cats, but then what if I show it a picture of a chair (the list of objects goes on).\nAnother example would be in natural language processing. If I develop an application that takes the input language and spits out \"I think this is Spanish\", what if it encounters a language it doesn't recognize?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is a very important problem that is usually overlooked. In fact, when training a neural network, there's often the implicit assumption that the data is independent and identically distributed, i.e., you do not expect the data to come from a distribution different than the distribution from which your training data comes, so there's also the implicit assumption that data comes from the same family of distributions (e.g. only Gaussians) and that all your training examples are independently drawn from the same distribution (specific mean and variance). Of course, this is a big limitation!\nA partial solution to your problem is to use a Bayesian neural network (BNN). The idea of a BNN is to associate, rather than a single number, a distribution (usually a Gaussian distribution) with each unit (or neuron) of the neural network. Therefore, for each unit of the network, there are two learnable parameters: the mean and variance of a Gaussian distribution. Consequently, a BNN usually has the double of the number of parameters of a conventional (or non-Bayesian) neural network. However, by learning a distribution for each parameter, you also learn the uncertainty about the potential true value of each unit, based on the available training data.\nThe forward passes of such a BNN are stochastic, i.e. you sample from each of these Gaussian distributions for every forward pass, so the output of the network is also stochastic (i.e. given the same input example, the output may be different each time).\nIf your dataset is small, one expects the BNN to have wide Gaussian distributions, i.e. high uncertainty about the true value of the units. So, one expects a BNN to be able to deal with unexpected inputs more robustly. To be more precise, if you train a BNN with a small dataset, the hope is that Gaussian distributions will be wide and thus the outputs of the BNN will be highly variable (i.e. the model is highly uncertain). The more data is gathered, the less uncertain the BNN should be.\nThis doesn't completely solve your problem, but it should at least mitigate it, i.e. if you provide an unseen example to the BNN, then ideally it should be uncertain about the actual label of that input.\nFor simplicity, I didn't explain certain details of BNNs, but, at least, this answer gives you a potential solution. Of course, this doesn't exclude the possibility of having an \"unknown\" class. The approaches are not mutually exclusive. There may also be other solutions, but I am not aware of any.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is dropout favoured compared to reducing the number of units in hidden layers? Why is dropout favored compared to reducing the number of units in hidden layers for the convolutional networks?\nIf a large set of units leads to overfitting and dropping out \"averages\" the response units, why not just suppress units?\nI have read different questions and answers on the dropout topic including these interesting ones, What is the \"dropout\" technique? and this other Should I remove the units of a neural network or increase dropout?, but did not get the proper answer to my question.\nBy the way, it is weird that this publication A Simple Way to Prevent Neural Networks from Overfitting (2014), Nitish Srivastava et al., is cited as being the first on the subject. I have just read one that is from 2012:\nImproving neural networks by preventing co-adaptation of feature detectors.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Dropout only ignores a portion of units during a single training batch update. Each training batch will use a different combination of units which gives them the best chance of that portion of them working together to generalize. Note the weights for each unit are kept and will be updated during the next batch in which that unit is selected. During inference, yes, all units are used (with a factor applied to activation...the same factor that defines the fraction used)...this becomes essentially an ensemble of all the different combinations of units that were used.\nContrasted with fewer units, the fewer units approach will only learn what those fewer units can be optimized for. Think of dropout as an ensemble of layers of fewer units.(with the exception that there are partial weight sharing between the layers)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why evolutionary training of neural networks is not popular? Evolutionary algorithms are mentioned in some sources as a method to train a neural network (finding weights, not hyperparameters). However, I have not heard about one practical application of such an idea yet.\nMy question is, why is that? What are the issues or limitations with such a solution that prevented it from practical use?\nI am asking because I am planning on developing such an algorithm and want to know what to expect and where to put most attention.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The main evolutionary algorithm used to train neural networks is Neuro-Evolution of Augmenting Topoloigies, or NEAT. NEAT has seen fairly widespread use. There are thousands of academic papers building on or using the algorithm.\nNEAT is not widely used in commercial applications because if you have a clean objective function, a topology that is optimized for gradient decent via backpropogation, and an implementation that is highly optimized for a GPU, you are almost certainly going to see better, faster, results from a conventional training process. Where NEAT is really useful is if you want to do something weird, like train to maximize novelty, or if you want to try to train neurons that don't have cleanly decomposable gradients. Basically, you need to have any of the usual reasons you might prefer an evolutionary algorithm to hill-climbing approaches:\n\nYou don't have a clean mapping from loss function to individual model components.\nYour loss function has many local maximia.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How good is AI at generating new, unseen [visual] examples? By new, unseen examples; I mean like the animals in No Man's Sky. \nA couple of images of the animals are:\n\n\nSo, upon playing this game, I was curious about how good is AI at generating visual characters or examples?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "We are getting pretty good at image generation, some examples:\n\nRadford, Alec, Luke Metz, and Soumith Chintala. \"Unsupervised representation learning with deep convolutional generative adversarial networks.\" arXiv preprint arXiv:1511.06434 (2015). https://arxiv.org/pdf/1511.06434.pdf\nGregor, Karol, Ivo Danihelka, Alex Graves, Danilo Jimenez Rezende, and Daan Wierstra. \"DRAW: A recurrent neural network for image generation.\" arXiv preprint arXiv:1502.04623 (2015). https://arxiv.org/pdf/1502.04623.pdf\n\nFrom (1):\n\nThen there is another research direction around evolutionary algorithms, for example:\n\nSims, Karl. \"Evolving virtual creatures.\" In Proceedings of the 21st annual conference on Computer graphics and interactive techniques, pp. 15-22. ACM, 1994. https://scholar.google.com/scholar?cluster=6031059536657676358&hl=en&as_sdt=0,22 ; https://www.youtube.com/watch?v=bBt0imn77Zg\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Would machine learning be suitable for finding the seed of a random number generator? I'm new to machine learning, and AI in general (but with 20+ years for programming). I'm wondering if machine learning is a good general approach to find the seed of a random number generator.\nSuppose I have a list of 2000 numbers. Is there a machine learning algorithm to correctly guess the next number?\nJust to be clear, as there are many random number generator algorithms, I'm talking about rand and srand from the stdlib.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Machine Learning is a bad fit to this problem.\nEven simple PRNGs that are not suitable for use in simulators (such as rand()) are varied enough that it is very hard to reverse engineer them statistically using generic techniques - essentially what 90% of ML does is fit a generic model to data statistically by altering parameters. The remaining 10% might do things in specialist manner, such as saving all the data and picking best option. \nIn theory most ML approaches would eventually solve a PRNG, however that would typically involve iterating through the entire state space of the PRNG multiple times. The statistical relationship between internal state, next state and output of a PRNG is complex by design, so that this is the only \"black box\" statistical approach, and this is clearly not feasible for any real implementation of a random number generator, which is going to have at least $2^{31}$ states on modern machines. Perhaps older 16-bit PRNGs, with a single value for state might be tractable.\nAn AI advanced enough to attempt to reverse engineer the output logically based on purely the data and researching how RNGs work is too advanced for current ML techniques to consider.\nThat leaves approaches that might try to construct a similar RNG, such as Genetic Programming (where the genome is converted to executable code). The trouble with this approach is there is no heuristic for a RNG that measures how close its output is to a target. A single bit of state difference or any tiny but meaningful change in generated RNG design will produce output that has no similarities with the target output whatsoever. Without such a measure you have no fitness function, and no way to attempt a guided search using the many discrete optimisation tools from AI.\nInstead the usual approach to \"breaking\" a PRNG is to analyse the algorithm. Knowing the algorithm of many non-cryptographic PRNGs can allow predicting the internal state of the generator, sometimes in very few steps (for really simple Linear Congruential Generators that might be just a single step!).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Would AlphaGo Zero become perfect with enough training time? Would AlphaGo Zero become theoretically perfect with enough training time? If not, what would be the limiting factor?\n(By perfect, I mean it always wins the game if possible, even against another perfect opponent.)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "We cannot tell with certainty whether AlphaGo Zero would become perfect with enough training time. This is because none of the parts (Neural Network) that would benefit from infinite training time (= a nice approximation of \"enough\" training time) are guaranteed to ever converge to a perfect solution. \nThe main limiting factor is that we do not know whether the Neural Network used is big enough. Sure, it's pretty big, it has a lot of capacity... but is that enough? Imagine if they had used a tiny Neural Network (for example just a single hidden layer with a very low number of nodes, like 2 hidden nodes). Such a network certainly wouldn't have enough capacity to ever learn a truly, perfectly optimal policy. With a bigger network it becomes more plausible that it may have sufficient capacity, but we still cannot tell for sure.\n\nNote that AlphaGo Zero does not just involve a trained part; it also has a Monte-Carlo Tree Search component. After running through the Neural Network to generate an initial policy (which in practice turns out to already often be extremely good, but we cannot tell for certain if it's perfect), it does run some MCTS simulations during it's \"thinking time\" to refine that policy.\nMCTS doesn't benefit* from increased training time, but it does benefit from increased thinking time (i.e. processing time per turn during the actual game being played, rather than offline training time / self-play time before the evaluation game). In the most common implementation of MCTS (UCT, using the UCB1 equation in the Selection Phase), we can prove that it does in fact learn to play truly perfectly if it is given an infinite amount of thinking time. Now, AlphaGo Zero does use a slightly different implementation of the Selection Phase (which involves the policy generated by the trained Neural Network as prior probabilities), so without a formal analysis I can't tell for sure whether that proof still holds up here. Intuitively it looks like it still should hold up fine though.\n\n*Note: I wrote above that \"MCTS doesn't benefit from increased training time. In practice, of course it does tend to benefit from increased training time because that tends to result in a better Network, which tends to result in better decisions during the Selection Phase and better evaluations of later game states in the tree. What I mean is that MCTS is not theoretically guaranteed to always keep benefitting from increases in training time as we tend to infinity, precisely because that's also where we don't have theoretical guarantees that the Neural Network itself will forever keep improving.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "If $\\gamma \\in (0,1)$, what is the on-policy state distribution for episodic tasks? In Reinforcement Learning: An Introduction, section 9.2 (page 199), Sutton and Barto describe the on-policy distribution in episodic tasks, with $\\gamma =1$, as being\n\\begin{equation}\n\\mu(s) = \\frac{\\eta(s)}{\\sum_{k \\in S} \\eta(k)},\n\\end{equation}\nwhere\n\\begin{equation}\n\\eta(s) = h(s) + \\sum_s \\eta(\\bar{s}) \\sum_a \\pi(a|\\bar{s})p(s|\\bar{s},a), \\text{ (9.2)}\n\\end{equation}\nis the number of time steps spent, on average, in state $s$ in a single episode.\nAnother way to represent this is setting $\\eta(s) = \\sum_{t=0}^{\\infty} d_{j,s}^{(t)}$, the average number of visits to $s$ starting from $j$, and $d_{j,s}^{(t)}$ being the probability of going from $j$ to $s$ in $t$ steps under policy $\\pi_{\\theta}$. In particular, $d_{j,s}^{(1)} = d_{j,s} = \\sum_{a \\in A}[\\pi_{\\theta}(a|j)P(s|j,a)]$. This formulation is obtained through pag 325 proof of the Policy Gradient Theorem (PGT) and some basic stochastic processes theory.\nIf instead of defining $\\gamma = 1$, we prove PGT using any $\\gamma \\in (0,1)$, we would get\n\\begin{equation*}\n\\eta_{\\gamma}(s) = \\sum_{t=0}^{\\infty} \\gamma^t d_{j,s}^{(t)}\n\\end{equation*}\nThis is not anymore the average number of visits to $s$. Here comes my first question. Would we still get a $\\mu_{\\gamma}$ on-policy distribution through the same trick done before? That is\n\\begin{equation}\n\\mu_{\\gamma}(s) = \\frac{\\eta_{\\gamma}(s)}{\\sum_{k \\in S} \\eta_{\\gamma}(k)},\n\\end{equation}\nwould be the on-policy distribution?\nMy second question is related and has to do with the phrase on page 199, that says that\n\nIf there is discounting ($\\gamma <1$) it should be treated as a form of termination, which can be done simply by including a factor of $\\gamma$ in the second term of (9.2).\n\nWhat the authors mean by \"as a form of termination\"?\nAs inferred by my previous question, my conclusion is that having $\\gamma < 1$ does not alter $\\mu_{\\gamma}$ being the on-policy distribution, so I don't get this last comment on page 199.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This question is really getting at the meaning of the discount factor in Markov decision processes. There are actually two, equivalent ways of interpreting the discount factor.\nThe first is probably what you're familiar with: the $i^{th}$ step receives a reward of $\\gamma^{i}r_i$ instead of just $r_i$.\nThe second, equivalent interpretation, is that at every step, we have a $1-\\gamma$ chance of immediately ending the episode. Assuming we don't end the episode, we receive the full $r_i$ reward. This is what Sutton and Barto mean by termination. Note that under the second interpretation, we have a $\\gamma^i$ probability of reaching the $i^{th}$ step, hence the connection to the first interpretation.\nYour definition of $\\eta_{\\gamma}(s)$ looks correct to me. Alternatively, we can write it in Sutton's, Barto's notation like\n$$\\eta_{\\gamma}(s) = h(s) + \\sum_{\\bar s}\\eta(\\bar s)\\sum_{a}\\gamma \\pi(a | \\bar s) p(s | \\bar s, a)$$\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the definition of rationality? I'm having a little trouble with the definition of rationality, which goes something like:\n\nAn agent is rational if it maximizes its performance measure given its current knowledge.\n\nI've read that a simple reflex agent will not act rationally in a lot of environments. For example, a simple reflex agent can't act rationally when driving a car, as it needs previous perceptions to make correct decisions.\nHowever, if it does its best with the information it's got, wouldn't that be rational behaviour, as the definition contains \"given its current knowledge\"? Or is it more like: \"given the knowledge it could have had at this point if it had stored all the knowledge it has ever received\"?\nAnother question about the definition of rationality: Is a chess engine rational as it picks the best move given the time it's allowed to use, or is it not rational as it doesn't actually (always) find the best solution (would need more time to do so)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nI've read that a simple reflex agent will not act rationally in a lot of environments. E.g. a simple reflex agent can't act rationally when driving a car as it needs previous perceptions to make correct decisions.\n\nI wouldn't say that the need for previous perceptions is the reason why a simple reflex agent doesn't act rationally. I'd say the more serious issue with simple reflex agents is that they do not perform long-term planning. I think that is the primary issue that causes them to not always act rationally, and that is also consistent with the definition of rationality you provided. A reflex-based agent typically doesn't involve long-term planning, and that's why it in fact does not often do best given the knowledge it has.\n\nAnother question about the definition of rationality: Is a chess engine rational as it picks the best move given the time its allowed to use, or is it not rational as it doesn't actually (always) find the best solution (would need more time to do so)?\n\nAn algorithm like minimax in its \"purest\" formulation (without a limit on search depth) would be rational for games like chess, since it would play optimally. However, that is not feasible in practice, it would take too long to run. In practice, we'll run algorithms with a limit on search depth, to make sure that they stop thinking and pick a move in a reasonable amount of time. Those will not necessarily be rational. This gets back to bounded rationality as described by DukeZhou in his answer.\nThe story is not really clear if we try to talk about this in terms of \"picking the best move given the time it's allowed to use\" though, because what is or isn't possible given a certain amount of time depends very much on factors such as:\n\nalgorithm we choose to implement\nspeed of our hardware\nefficiency of implementation / programming language used\netc.\n\nFor example, hypothetically I could say that I implement an algorithm that requires a database of pre-computed optimal solutions, and the algorithm just looks up the solutions in the database and instantly plays the optimal moves. Such an algorithm would be able to truly be rational, even given a highly limited amount of time. It would be difficult to implement in practice because we'd have difficulties constructing such a database in the first place, but the algorithm itself is well-defined. So, you can't really include something like \"given the time it's allowed to use\" in your definition of rationality.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can neurons in MLP and filters in CNN be compared? I know they are not the same in working, but an input layer sends the input to $n$ neurons with a set of weights, based on these weights and the activation layer, it produces an output that can be fed to the next layer.\nAren't the filters the same, in the way that they convert an \"image\" to a new \"image\" based on the weights that are in that filter? And that the next layer uses this new \"image\"?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "tl;dr The equivalent to a neuron in a Fully-Connected (FC) layer is the kernel (or filter) of a Convolution layer\nDifferences\nThe neurons of these two types of layers have two key differences. These are that the convolution layers implement:\n\nSparse connectivity, i.e. each neuron is connected only to an area of the input, not the whole.\nWeight sharing, i.e. similar connections end up having the same weights. This is usually visualized as the same filter traversing the image.\n\nBesides these two key differences, there are some other technical details, e.g. how the biases are implemented. Other than that they perform the same operation.\nWhat causes some confusion is that the input of a CNN is usually 2 or 3-dimensional, while a FC is usually 1-dimensional. These aren't mandatory however. To better help visualize the differences between the two I made a couple of figures illustrating the differences between a conv-layer and a FC one, both in 1D.\nSparse connectivity\nOn the left are two FC neural networks. On the right, are layers with sparse connections.\n\nWeight sharing\nOn the left is a sparsely connected network. The colors represent the different values of the weights. On the right is the same network with weight-sharing. Note that similar weights (i.e. arrows with the same direction in each layer) have the same value.\n\n\nTo answer your other questions:\n\nAre filters not the same in the way that they convert an \"image\" to a new \"image\" based on the weights that are in that filter? And that the next layers use these new \"images\"?\n\nYes, if the input of a convolution layer is an image, so will the output. The next layer will also operate on an image.\nHowever, I'd like to note that not all convolution layers accept images as their inputs. There are 1D and 3D convolutional layers as well.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to combine backpropagation in neural nets and reinforcement learning? I have followed a course on machine learning, where we learned about the gradient descent (GD) and back-propagation (BP) algorithms, which can be used to update the weights of neural networks, and reinforcement learning, in particular, Q-learning. I implemented these concepts separately.\nNow, I was thinking about using a neural network to approximate the Q-function, $Q(s, a)$, but I don't really know how to design the neural network and how to use back-propagation to update the weights of this neural network (NN).\n\nWhat should the inputs and outputs of this NN be?\n\nHow can I use GD and BP to update the weights of such an NN? Or should I use a different algorithm to update the weights?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Gradient descent and back-propagation\nIn deep learning, gradient descent (GD) and back-propagation (BP) are used to update the weights of the neural network.\nIn reinforcement learning, one could map (state, action)-pairs to Q-values with a neural network. Then GD and BP can be used to update the weights of this neural network.\nHow to design the neural network?\nIn this context, a neural network can be designed in different ways. A few are listed below:\n\nThe state and action are concatenated and fed to the neural network. The neural network is trained to return a single Q-value belonging to the previously mentioned state and action.\n\nFor each action, there is a neural network that provides the Q-value given a state. This is not desirable when a lot of actions exist.\n\nAnother option is to construct a neural network that accepts as input the state. The output layer consists of $K$-units where $K$ is the number of possible actions. Each output unit is trained to return the Q-value for a particular action.\n\n\nQ-learning update rule\nThis is the Q-learning update rule\n\nSo, we choose an action $a_t$ (for example, with $\\epsilon$-greedy behavior policy) in the state $s_t$. Once the action $a_t$ has been taken, we end up in a new state $s_{t+1}$ and receive a reward $r_{t+1}$ associated with it. To perform the update, we also need to choose the Q-value in $s_{t+1}$ associated with the action $a$, i.e. $\\max _{a} Q\\left(s_{t+1}, a\\right)$. Here, $\\gamma$ is the discount factor and $\\alpha$ is the learning rate.\nBack-propagation and Q-learning\nIf we use a neural network to map states (or state-action pairs) to Q-values, we can use a similar update rule, but we use GD and BP to update the weights of this neural network.\nHere's a possible implementation of a function that would update the weights of such a neural network.\ndef update(self, old_state, old_action, new_state, \n reward, isFinalState = False):\n \n # The neural network has a learning rate associated with it. \n # It is advised not to use two learning rates\n learningRate = 1\n \n # Obtain the old value\n old_Q = self.getQ(old_state, old_action)\n\n # Obtain the max Q-value\n new_Q = -1000000\n action = 0\n for a in self.action_set:\n q_val = self.getQ(new_state, a)\n if (q_val > new_Q):\n new_Q = q_val\n action = a \n\n # In the final state there is no action to be chosen\n if isFinalState:\n diff = learningRate * (reward - old_Q)\n else:\n diff = learningRate * (reward + self.discount * new_Q - old_Q)\n\n # Compute the target \n target = old_Q + diff\n\n # Update the Q-value using backpropagation\n self.updateQ(action, old_state, target)\n\nIn the pseudocode and in the Q-learning update formula above, you can see the discount factor $\\gamma$. This simply denotes whether we are interested in an immediate reward or a more rewarding and enduring reward later on. This value is often set to 0.9.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why can a fully convolutional network accept images of any size? On this article, it says that: \n\nThe UNET was developed by Olaf Ronneberger et al. for Bio Medical Image Segmentation. The architecture contains two paths. First path is the contraction path (also called as the encoder) which is used to capture the context in the image. The encoder is just a traditional stack of convolutional and max pooling layers. The second path is the symmetric expanding path (also called as the decoder) which is used to enable precise localization using transposed convolutions. Thus it is an end-to-end fully convolutional network (FCN), i.e. it only contains Convolutional layers and does not contain any Dense layer because of which it can accept image of any size.\n\nWhat I don't understand is how an FCN can accept images of any size, while an ordinary object detector, such as YOLO with a dense layer at the very end, cannot accept images of any size. \nSo, why can a fully convolutional network accept images of any size?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The reason is that when using a convolutional layer, you select the size of the filter kernels, which are independent of the image/layer input size (provided that images smaller than the kernels are padded appropriately).\nWhen using a dense layer, you specify the size of the layer itself and the resulting weight matrix is a function of both the size of the dense layer and the upstream layer. This is because each neuron in the upstream layer makes a connection to each neuron in the dense layer. So, if you have 50 neurons in the upstream layer and 20 neurons in the dense layer, then the weight matrix has $50 \\times 20=1000$ values. Those weights are what get determined during the training phase, and so those layer sizes are fixed.\nNow, the output of a CNN layer is a number of images/tensors (specified by the number of filters chosen), whose size is determined by the kernel size and any padding option chosen. If those are fed into a dense layer, then that fixes the the size that those images can be (because of the reason given in the previous paragraph). \nOn the other hand, if no dense layer is used in the whole network, then the input to the first CNN layer can be any size because the weights are just the individual parameters of the filter kernels, and the filter kernels remain the same size regardless of the input tensor size.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between artificial intelligence and cognitive science? Sometimes I understand that people doing cognitive science try to avoid the term artificial intelligence. The feeling I get is that there is a need to put some distance to the GOFAI.\nAnother impression that I get is that cognitive science is more about trying to find out how the human intelligence or mind works. And that it would use artificial intelligence to make tests or experiments, to test ideas and so forth.\nIs artificial intelligence (only) a research tool for cognitive science? What is the difference between artificial intelligence and cognitive science?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nAnother impression that I get is that cognitive science is more about trying to find out how the human intelligence or mind works. And that it would use artificial intelligence to make tests or experiments, to test ideas and so forth.\n\nI think that's pretty much it. I mean, clearly there is some overlap, but I feel like most people who use \"cognitive science\" are referring more to understanding human intelligence for its own sake. Artificial Intelligence, OTOH, is more about implementing \"intelligence\" on a computer, where the techniques used may or may not be influenced by research done under the rubric of cognitive science.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to recognise metaphors in texts using NLP/NLU? What are the current NLP/NLU techniques that can extract metaphors from texts?\nFor example\n\nHis words cut deeper than a knife.\n\nOr a simpler form like:\n\nLife is a journey that must be travelled no matter how bad the roads and accommodations.\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is still a research topic in linguistics. A quick google search brings up a couple of papers that might be useful:\n\nIdentifying Metaphor Hierarchies in a Corpus Analysis of Finance Articles\nMetaphor Identification in Large Texts Corpora\n\nHowever, you probably won't get an off-the-shelf tool that recognises metaphors for you.\nTo add more details, the problem with metaphors is that you cannot detect them by surface structure alone. Any sentence could (in theory) be a metaphor. This is different from a simile, which can usually be spotted easily through the word like, as in she runs like the wind. Obviously, like on its own is not sufficient, but it's a good starting point to identify possible candidates.\nHowever, his words cut deeper than a knife is -- on the surface -- a normal sentence. Only the semantic incongruence between words as the subject and cut as the main verb creates a clash. In order to detect this automatically, you need to identify possible semantic features of the verbal roles and look for violations of the expected pattern.\nThe verb cut would generally expect an animate object, preferably human, or an instrument with a blade (the knife cuts through the butter) as its actor or subject. But it also can include (water)ways: the canal cuts through the landscape, the road cuts through the field. The more closely you look, the more exceptions/extensions you will find for your initial assumption.\nAnd every extension/exception will water down the accuracy of your metaphor detection algorithm.\nThe second example is similar: Life is a journey. You could perhaps use a thesaurus and see what the hyperonyms of life are. Then you could do the same with journey, and see if they are compatible. A car is a vehicle is not a metaphor, because vehicle is a hyperonym of car. But journey is not a hyperonym of life, so could be a metaphor. But I would think that this is still very tricky to get right. In this case, the absence of a determiner might be a hint, as it's not a life is a journey -- you might restrict yourself to bare nouns for this type of metaphor. But this is also not a firm rule.\nIn short, it is a hard problem, as you need to look at the meaning, rather than just the structure or word choice. And meaning is not easy to deal with in NLP, despite decades of work on it.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Should I be decaying the learning rate and the exploration rate in the same manner? Should I be decaying the learning rate and the exploration rate in the same manner? What's too slow and too fast of an exploration and learning rate decay? Or is it specific from model to model?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First of all, I'd say that there is a reason to give Learning Rate (LR) and Exploration Rate (ER) the same decay: they play at the same scale (the number of successive batches you'll train your model on). But if I refine the analysis, I would rather say that it's a reason to choose them in the same range, i.e. close to 1, but not specifically at the same number.\n\nFor LR decay, people often choose it very close to one (which can mean really different things like 0.98 or 0.997), because it plays on a large scale, and you don't want the LR to disappear too brutally.\n\nHowever, the choice of ER decay can have more variation from model to model. It depends on the initial value of ER (you don't wanna decay fastly ER if your ER is initially low), and also to the \"learning speed\" of your model: if your model learns efficiently at the beginning, you could want to fastly decrease ER in order to reduce the noise on the action, supposing that you did enough exploration at the beginning (but I think this last opinion is more controversial). You can find an interesting paper here, where the author tries different ER decay and finds out that 0.99 is the best, for CartPole environment.\n\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Could an AI be killed in an infinite loop? Currently, we use control flow statements (such as loops) to program the artificially intelligent systems. Could an AI be killed in an infinite loop (created by itself, for example, while manipulating its source code)?\nThe question isn't baseless, it really questions the kind of computational infrastructure a modern AGI would require, and would it be able to alter itself without any intervention.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is a hard to answer question because a truly correct answer would involve static analysis of a given Intelligence to determine whether it has the computational capability to generate a looping state (e.g. some state which reproduces itself in the next instance), and in fact whether these looping states can even exist in the given architecture. \nGenerally speaking, assuming we can build AI, there is no reason it would be impossible build an AI that has the potential to get stuck in a computational loop and become non-functional. You can imagine a recurrent neural network where the continuous state inside the ANN dominates its behavior causing it to reproduce states with small variety (as input will always be relevant in a connected ANN) but are converged around a particular state space. Whether that is akin to death is a philosophical question for your own peace of mind.\nHowever, if we designed an AI agent that commonly did this, that would reflect poor design; that wouldn't necessarily devalue the contribution of the designed agent but it would bring the agent's other activities under scrutiny. If this is a bi-product of some simulated intelligence, is the process going on really that intelligent?\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is LSTM a subcategory of RNN? Is the LSTM-Architecture a subcategory of RNNs? Or are they totally different?\nLiterature doesn't seem to be unitary on this.\nThis figure appears to explain the models to be alternatives, but I thought of them otherwise (LSTM to be a subcategory of RNN)\nLSTM as a subcategory of RNN is mentioned in the Wikipedia article on LSTMs:\n\nLong short-term memory (LSTM) is an artificial recurrent neural\nnetwork (RNN) architecture...\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The Wikipedia article is more technically correct, in that the term RNN is formally taken to mean \"a neural network with recurrent connections\", and that includes many architectures that match this description, including LSTMs.\nHowever, it is also common to see \"RNN\" used as a short-hand for a kind of \"Vanilla RNN\" or \"basic RNN\", where one or more layers have weights connecting the layer to itself (its own activations from $t-1$ are concatenated to the external inputs at $t$), and there are no other gates or special combinations, just those recurrent connections.\nOddly, this basic layer-based RNN archtecture is not listed in all the options on the Wikipedia page on RNNs - probably the closest are Elman networks and Jordan networks which are ways to implement the recurrent connection. It is a valid architecture choice, and can be effective. The LSTM and GRU architectures improve on it in terms of handling longer sequences and preserving important signals over them when training (e.g. matching a starting and ending quote in text processing).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Aren't all discrete convolutions (not just 2D) linear transforms? \nThe image above, a screenshot from this article, describes discrete 2D convolutions as linear transforms. The idea used, as far as I understand, is to represent the 2 dimensional $n$x$n$ input grid as a vector of $n^2$ length, and the $m$x$m$ output grid as a vector of $m^2$ length. I don't see why this can't be generalised to higher-dimensional convolutions, since a transformation matrix can be constructed from one vector to another, no matter the length (right?)\nMy question: Aren't all discrete convolutions (not just 2D) linear transforms?\nAre there cases where such a transformation matrix cannot be found?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Convolution is a pretty misused term in recent times with the advent of CNN. \nShort answer, Convolution is a linear operator (check here) but what you are defining in context of CNN is not convolution, it is cross-correlation which is also linear in case of images (dot product).\nConvolution:\nComputers work only on discrete values, so the discrete time convolution is defined similarly as:\n$$\ny[n] = \\sum_{k=\\infty}^{\\infty} x[k] h[n-k]\n$$\nwhich has the nice property of \n$$Y(e^{j\\omega}) = X(e^{j \\omega})H(e^{j \\omega})$$\nwhere each $A(e^{j\\omega})$ is the Fourier Transform of $a(t)$\nSo this is the basic idea of discrete convolution. The point to illustrate here is that convolution operation has some nice properties and very helpful.\nNow there are 2 main types of convolution (as far as I know). One is linear convolution another is circular convolution. In terms of $2D$ signal they are defined in the following ways:\n$$y[m,n] = \\sum_{j=-\\infty}^{\\infty}\\sum_{k=-\\infty}^{\\infty} x[i,j]h[m-i,n-j]$$\nCircular convolution is the same except that the input sequence is finite from $0$ to $N-1$ giving rise to periodicity in frequency domain. The convolution operation is a little bit different due to this periodicity.\nSo these are the actual definitions of convolution. It has linearity property (clearly obvious since it is used to calculate output of LTI system), and it also has the linearity in terms of matrix multiplications, since we want to do the computer to do these calculations for us. I don't know a lot but there are many clever manipulations e.g the FFT algorithm an indispensable tool in signal processing (used to convert signals to frequency domain for a certain sampling rate). Like this you can define convolutions in terms of Hermitian matrices and stuff (only if you want to process in the $n$ domain it is much easier to process in the frequency domain). \nFor example a $1D$ circular convolution between 2 signals in $n$ domain defined in matrix form, can be written as follows $y_n=h_n*x_n$:\nwhere\n$$y_t = \\begin{bmatrix} y_0 \\\\\n y_1 \\\\\n y_2 \\\\\n y_3 \n \\end{bmatrix} = \\begin{bmatrix}\nh_0 & h_3 & h_2 & h_1\\\\\nh_1 & h_0 & h_3 & h_2\\\\\nh_2 & h_1 & h_0 & h_3 \\\\\nh_3 & h_2 & h_1 & h_0\n\\end{bmatrix} \\begin{bmatrix} x_0 \\\\\n x_1 \\\\\n x_2 \\\\\n x_3 \n \\end{bmatrix}$$\nThe same can be done quite easily by converting the functions into frequency domain, multiplying and converting back to time domain.\nWhen we move to $2D$ domain similar equation is formed except (in $n$ domain)instead of $h_0$ we will have a Hermitian matrix $H_0$ and we will perform the Kronecker product (I don't know the justification or proofs of these equations, it probably satisfies the convolution theorem and is fast when ran on computers). Again much easier to do in frequency domain.\nWhen we move to multiple dimensions, it is called Multidimensional discrete convolution as per this Wikipedia article. As the article suggests the property where everything is in frequency domain.\n$$Y(k_1,k_2,...,k_M)=H(k_1,k_2,...,k_M)X(k_1,k_2,...,k_M)$$ \nstill holds good. When we do convolutions in the $n$ domain things get tricky and we have to do clever matrix manipulations as shown in the example above. Whereas, as stated above things get much easier in the frequency domain.\nIts counter-intuitive that a picture has a frequency domain, and in general its actually not frequency. BUT in DSP we use a lot of filters whose math properties are similar to those of filters in the traditional sense of frequency and hence has the same calculations as in a frequency setting as shown in the 1st example of $1D$ signal.\nThe point convolution by definition is a linear operation. Check here if the explanations are unconvincing. There are Linear Time Varying systems and its output maybe determined by convolution, but then it uses the equation at a certain point of time i.e:\n$$Y(e^{j\\omega}, t) = H(e^{j\\omega}, t)X(e^{j\\omega} )$$. \nNow whether it can be represented by matrix products in $n$ domain or not I cannot say. But generalising, it should be possible, only it will involve increasingly complex matrix properties and operations. \nCross Correlation:\nCross correlation is nothing similar to convolution, it has a bunch of interesting properties on its own, hence I do not like the two being mixed together. In signal processing it is mainly related to finding energy (auto-correlation) and has other applications in communication channels.\nWhile in statistics, it is related to finding correlation (misused term since it can take any value, but correlation coefficient takes value between -1 to 1) between 2 stochastic processes, at different time instants, where we have multiple samplings of the signal or ensembles of the signal based on which the expectation is taken (See here). In CNNs maybe a way to see this would be, the image dataset is a ensemble of stochastic process, while the filter is another process which is fixed. And moving the filter over the image is time delay.\nIn the context of digital image processing cross correlation is just a dot product. And hence it can be represented by matrices. Whether cross correlation is linear or not is difficult to tell (at least I don't know), but in the context of image processing it seems linear. Bottom-line is that it can be definitely implemented by matrices as it is a dot product, whether it is linear in true mathematical sense is doubtful.\nThe more intuitive way in context of CNNs would be to view filters as just a bunch of shared weights for better regularisation instead of cross correlation or convolution. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "In the n-step off-policy SARSA update, why do we multiply the entire update by $\\rho$? In Sutton & Barto's book (2nd ed) page 149, there is the equation 7.11\n\nI am having a hard time understanding this equation.\nI would have thought that we should be moving $Q$ towards $G$, where $G$ would be corrected by importance sampling, but only $G$, not $G-Q$, therefore I would have thought that the correct equation would be of the form\n$Q \\leftarrow Q + \\alpha (\\rho G - Q)$\nand not\n$Q \\leftarrow Q + \\alpha \\rho (G - Q)$\nI don't get why the entire update is weighted by $\\rho$ and not only the sampled return $G$.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Multiplying the entire update by $\\rho$ has the desirable property that experience affects $Q$ less when the behavior policy is unrelated to the target policy. In the extreme, if the trajectory taken has zero probability under the target policy, then $Q$ isn't updated at all, which is good. Alternatively, if only $G$ is scaled by $\\rho$, taking zero probability trajectories would artificially drive $Q$ to zero.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When does the selection phase exactly end in MCTS? All sources I can find provide a similar explanation to each phase. \nIn the Selection Phase, we start at the root and choose child nodes until reaching a leaf. Once the leaf is reached (assuming the game is not terminated), we enter the Expansion Phase. \nIn the Expansion Phase, we expand any number of child nodes and select one of the expanded nodes. Then, we enter the Play-Out Phase.\nHere is my confusion. If we choose to only expand a single node, the nodes that were not expanded will never be considered in future selections as we only select child nodes until a leaf is reached during the Selection Phase. Is this correct? If not, what am I misunderstanding about the Selection Phase?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nIf we choose to only expand a single node, the nodes that were not expanded will never be considered in future selections as we only select child nodes until a leaf is reached during the Selection Phase. Is this correct? \n\nNo this is not correct.\n\nIf not, what am I misunderstanding about the Selection Phase?\n\nThe selection phase does not end only when you reach a node that has no expanded nodes. It ends when you reach a node that has any unexpanded nodes. At which point you typically pick one or more nodes you have not yet expanded at that point in the tree, expand them and collect one or more rollout results for them. Variations are possible such as choosing to whether to expand or continue selecting stochastically, or expanding all child nodes at the same time using value estimates to initialise them - the latter is what AlphaZero does.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is predicate argument recognition? There is a study about The Necessity of Parsing for Predicate Argument Recognition, however I couldn't find much information about 'Predicate Argument Recognition' which could explain it.\nWhat is it exactly and how does it work, briefly?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In grammar, a predicate-argument relationship is one which is implied from text but not expressed in the syntactic structure. (Asher S)\nPredicate logic or first order logic is a collection of formal systems used in mathematics, philosophy, linguistics and computer science. \nThe NLP community is interested in recognizing, representing and classifying predicate arguments for shallow semantic parsing which can be viewed as the process of assigning a WHO did WHAT to WHOM, WHEN, WHY, HOW e.t.c. structure to plain text.\nThis process entails identifying groups of words in a sentence that represent these semantic arguments and assigning specific labels to them. This could play a key role in NLP tasks like information extraction, question answering and summarization. \nAutomatic and accurate techniques that can annotate naturally occurring text with semantic/predicate argument structure can facilitate the discovery of patterns of information in large text collections. \nFor reference I recommend this paper that uses Support Vector Machine algorithms for predicate argument classification. (Sameer P Kadri H 2005) https://link.springer.com/article/10.1007/s10994-005-0912-2#enumeration\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a high dimensional state in reinforcement learning? In the DQN paper, it is written that the state-space is high dimensional. I am a little bit confused about this terminology.\nSuppose my state is a high dimensional vector of length $N$, where $N$ is a huge number. Let's say I solve this task using $Q$-learning and I fix the state space to $10$ vectors, each of $N$ dimensions. $Q$-learning can easily work with these settings as we need only a table of dimensions $10$ x number of actions.\nLet's say my state space can have an infinite number of vectors each of $N$ dimensions. In these settings, Q-learning would fail as we cannot store Q-values in a table for each of these infinite vectors. On the other hand, DQN would easily work, as neural networks can generalize for other vectors in the state-space.\nLet's also say I have a state space of infinite vectors, but each vector is now of length $2$, i.e., small dimensional vectors. Would it make sense to use DQN in these settings? Should this state-space be called high dimensional or low dimensional?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Usually when people write about having a high-dimensional state space, they are referring to the state space actually used by the algorithm.\n\nSuppose my state is a high dimensional vector of $N$ length where $N$ is a huge number. Let's say I solve this task using $Q$-learning and I fix my state space to $10$ vectors each of $N$ dimensions. $Q$-learning can easily work with these settings as we need only a table of dimensions $10$ x number of actions. \n\nIn this case, I'd argue that the \"feature vectors\" of length $N$ are quite useless. If there are effectively only $10$ unique states (which may each have a very long feature vector of length $N$)... well, it seems like a bad idea to make use of those long feature vectors, just using the states as identity (i.e. a tabular RL algorithm) is much more efficient. If you end up using a tabular approach, I wouldn't call that a high-dimensional space. If you end up using function approximation with the feature vectors instead, that would be a high-dimensional space (for large $N$).\n\nLet's also say I have a state space of infinite vectors but each vector is now of length $2$ i.e. very small dimensional vectors. Would it make sense to use DQN in these settings ? Should this state-space be called high dimensional or low dimensional ? \n\nThis would typically be referred to as having a low-dimensional state space. Note that I'm saying low-dimensional. The dimensionality of your state space / input space is low, because it's $2$ and that's typically considered to be a low value when talking about dimensionality of input spaces. The state space may still have a large size (that's a different word from dimensionality).\nAs for whether DQN would make sense in such a setting.. maybe. With such low dimensionality, I'd guess that a linear function approximator would often work just as well (and be much less of a pain to train). But yes, you can use DQN with just 2 input nodes.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is division by zero avoided when implementing back-propagation for a neural network with sigmoid at the output neuron? I am building a neural network for which I am using the sigmoid function as the activation function for the single output neuron at the end. Since the sigmoid function is known to take any number and return a value between 0 and 1, this is causing division by zero error in the back-propagation stage, because of the derivation of cross-entropy. I have seen over the internet it is advised to use a sigmoid activation function with a cross-entropy loss function.\nSo, how this error is solved?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Cross entropy loss is given by:\n\nNow as we know sigmoid function outputs values between 0-1, but what you have missed is it cannot output values exactly 0 or exactly 1 as for that to happen sigmoid(z) will have to be + or -infinity.\nAlthough your compiler gives a divide by 0 error, as very small floating point numbers are rounded off to 0, it is practically of no importance as it can happen in 2 cases only:\n\nsigmoid(z) = 0,in which case even though the compiler cannot calculate log(0) (the first term in the equation) it is ultimately getting multiplied by y_i which will be 0 so final answer is 0.\nsigmoid(z) = 1,in which case even though the compiler cannot calculate log(1-1) (the second term in the equation) it is ultimately getting multiplied by 1 - y_i which will be 0 so final answer is 0.\n\nThere are a few ways to get past this if you don't want the error at all:\n\nIncrease the precision of your compiler to float64 or infinity if available.\nWrite the program in such a way that anything multiplied by 0 is 0 without looking at the other terms.\nWrite the program in a way to handle such cases in a special way.\n\nImplementation side note: You cannot bypass divide by 0 error with your manual exception handler in most processors (AFAIK) . So you have to make sure the error does not occur at all.\nNOTE: It is assumed that the random weight initialisation takes care of the fact that at the beginning of training it does not so happen that $\\tilde y$ or $1-\\tilde y$ is 0 while the target is exactly the opposite, it is assumed that due to good training that the output is reaching near to the target and thus the 2 cases mentioned above will hold true.\nHope this helps!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How close have we come to passing the Turing Test? The Turing Test has been the classic test of artificial intelligence for a while now. The concept is deceptively simple - to trick a human into thinking it is another human on the other end of a conversation line, not a computer - but from what I've read, it has turned out to be very difficult in practice.\nHow close have we gotten to tricking a human in the Turing Test? With things like chat bots, Siri, and incredibly powerful computers, I'm thinking we're getting pretty close. If we're pretty far, why are we so far? What is the main problem?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "No one has attempted to make a system that could pass a serious Turing test. All the systems that are claimed to have \"passed\" Turing tests have done so with low success rates simulating \"special\" people. Even relatively sophisticated systems like Siri and learning systems like Cleverbot are trivially stumped.\nTo pass a real Turing test, you would both have to create a human-level AGI and equip it with the specialized ability to deceive people about itself convincingly (of course, that might come automatically with the human-level AGI). We don't really know how to create a human-level AGI and available hardware appears to be orders of magnitude short of what is required. Even if we were to develop the AGI, it wouldn't necessarily be useful to enable/equip/motivate? it to have the deception abilities required for the Turing test.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which Rosenblatt's paper describes Rosenblatt's perceptron training algorithm? I struggle to find Rosenblatt's perceptron training algorithm in any of his publications from 1957 - 1961, namely:\n\nPrinciples of Neurodynamics: Perceptrons and the Theory of Brain Mechanisms\nThe perceptron: A probabilistic model for information storage and organization in the brain\nThe Perceptron \u2014 A Perceiving and Recognizing Automaton\n\nDoes anyone know where to find the original learning formula?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The paper (or report) that formally introduced the perceptron is The Perceptron \u2014 A Perceiving and Recognizing Automaton (1957) by Frank Rosenblatt. If you read the first page of this paper, you can immediately understand that's the case. In particular, at some point (page 2, which corresponds to page 5 of the pdf), he writes\n\nRecent theoretical studies by this writer indicate that it should be feasible to construct an electronic or electromechanical system which will learn to recognize similarities or identities between patterns of optical, electrical, or tonal information, in a manner which may be closely analogous to the perceptual processes of a biological brain. The proposed system depends on probabilistic rather than deterministic principles for its operation, and gains its reliability from the properties of statistical measurements obtained from large populations of elements. A system which operates according to these principles will be called a perceptron.\n\nSee also Appendix I (page 19, which corresponds to page 22 of the pdf).\nThe paper The perceptron: A probabilistic model for information storage and organization in the brain (1958) by F. Rosenblatt is apparently an updated and nicer version of the original report.\nA more accessible (although not the most intuitive) description of the perceptron model and its learning algorithms can be found in the famous book Perceptrons: An Introduction to Computational Geometry (expanded edition, third printing, 1988) by Minsky and Papert (from page 161 onwards).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do I recognise a bandit problem? I'm having difficulty understanding the distinction between a bandit problem and a non-bandit problem. \nAn example of the bandit problem is an agent playing $n$ slot machines with the goal of discovering which slot machine is the most probable to return a reward. The agent learns to find the best strategy of playing and is allowed to pull the lever of one slot machine per time step. Each slot machine obeys a distinct probability of winning. \nIn my interpretation of this problem, there is no notion of state. The agent potentially can utilise the slot results to determine a state-action value? For example, if a slot machine pays when three apples are displayed, this is a higher state value than a state value where three apples are not displayed. \nWhy is there just one state in the formulation of this bandit problem? As there is only one action (\"pulling the slot machine lever\" ), then there is one action. The slot machine action is to pull the lever, which starts the game.\nI am taking this a step further now. An RL agent purchases $n$ shares of an asset and its not observable if the purchase will influence the price. The next state is the price of the asset after the purchase of the shares. If $n$ is sufficiently large, then the price will be affected otherwise there is a minuscule if any effect on the share price. Depending on the number of shares purchased at each time step, it's either a bandit problem or not. \nIt is not a bandit problem if $n$ is large and the share price is affected? It is a bandit problem if $n$ is small and the share price is not affected?\nDoes it make sense to have a mix of a bandit and non-bandit states for a given RL problem? If so, then the approach to solving should be to consider the issue in its entirety as not being a bandit problem?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The bandit problem has one state, in which you are allowed to choose one lever among $n$ levers to pull.\n\nWhy is there just one state in the formulation of this bandit problem?\n\nThere is one state because the state does not change over time. Two notable consequences are that (i) pulling a lever does not change the internals of any slot machine (e.g. the distribution of rewards) and (ii) you are allowed to choose any lever without restrictions. More generally, there is no sequential aspect of the state in this problem, as future states are unaffected by past states, actions, and rewards. \n\nIt is not a bandit problem if $n$ is large and the share price is affected?\n\nCorrect! If the share price is affected, then future states would be influenced by past actions. This is because the price per share is affected, which is one aspect of the state. Thus, you would need to plan a sequential strategy for your purchases. \n\nIt is a bandit problem if $n$ is small and the share price is not affected?\n\nIt all depends on the problem: as long as the state before buying shares remains completely the same after you purchase some shares, then yes. Share price being unaffected is only one of the requirements; another example requirement is that the maximum number of shares purchased is fixed at each time step, independent of the shares purchased previously. \n\nDoes it make sense to have a mix of a bandit and non-bandit states for a given RL problem? If so, then the approach to solving should be to consider the issue in its entirety as not being a bandit problem?\n\nIt makes sense to allow the share price to either be affected or unaffected based on $n$ in the same problem. Since some actions (large $n$) change the state, then there are multiple states, and actions sequentially affect the next state. Hence it is not a bandit problem as a whole, as you correctly stated.\n\nThe agent potentially can utilise the slot results to determine a state-action value?\n\nCorrect! I suggest reading Chapter 2 of Sutton and Barto to learn some fundamental algorithms of developing such strategies. \nNice work on analyzing this problem! To help solidify your understanding and formalize the arguments above, I suggest that you rewrite the variants of this problem as MDPs and determine which variants have multiple states (non-bandit) and which variants have a single state (bandit).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "To what does the number of hidden layers in a neural network correspond? In a neural network, the number of neurons in the hidden layer corresponds to the complexity of the model generated to map the inputs to output(s). More neurons creates a more complex function (and thus the ability to model more nuanced decision barriers) than a hidden layer with less nodes.\nBut what of the hidden layers? What do more hidden layers correspond to in terms of the model generated?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is a very interesting question that you ask. I believe, this post and this post (written by me) well address your question. However, it deserves an explanation here.\n1. Fully connected networks\nThe more layers you add, the more \"nonlinear\" your network becomes. For instance, in the case of two spirals problem, which requires a \"highly nonlinear separation\", the first known architecture to solve the problem was pretty advanced for that time: it had 3 hidden layers and also it had skip-connections (very early ResNet in 1988). Back then, computing was a way less powerful and training methods with momentum were not known. Nevertheless, thanks to the multilayer architecture, the problem was solved. Here, however, I was able to train a single-hidden layer network to solve the spirals problem using Adam.\n2. Convolutional nets (CNNs)\nAn interesting partial case of neural networks are CNNs. They restrict the architecture of the first layers, known as convolutional layers, so that there is a much smaller number of trainable parameters due to the weights sharing. What we have learned from computer vision, moving towards the end of CNNs layers, their receptive fields become larger. That means that the subsequent CNN layers \"see\" more than their predecessors. Conceptually, first CNN layers can recognize simpler features such as edges and textures, whereas final CNN layers contain information about more abstract objects such as trees or faces.\n3. Recurrent nets (RNNs)\nRNNs are networks with layers which receive some of their outputs as inputs. Technically, a single recurrent layer is equivalent to an infinite (or at least large) number of ordinary layers. Thanks to that recurrence, RNNs retain an internal state (memory). Therefore, it is much more difficult to answer your question in the case of recurrent nets. What is known, due to their memory, RNNs are more like programs, and thus are in principle more complex than other neural networks. Please let me know if you find an answer to your question in the last case.\nTo conclude, the higher number of hidden layers may help to structure a neural network. Thanks to the recent developments such as ResNets and backpropagation through time, it is possible to train neural networks with a large number of hidden layers.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is ChatGPT able to repeat random numbers? From what I understand, ChatGPT is just a fancy neural network, operating like a sophisticated Markov Chain generator. As such, it should only be able to generate tokens that are in its training dataset. One thing it should not be able to generate is a token unique to the conversation, such as a random number, since the conversation is not part of its training.\nHowever, ChatGPT very easily, and with complete accuracy, repeats many long random numbers I give it. I also split up the random number across my request, and have ChatGPT piece it together again.\n\nEric Holloway: How about concatenating these numbers, and removing the\nintermittent filler words? 9475 3008 3305 11 frog 4357 5075 0021 3385\n0894 2324 3812 9336 29 dog 52 1375 8236 3840 5500 6080 3841 log 7266\n0722 9112 9774 4967 4707 81\nChatGPT: To concatenate the numbers you have provided, while removing\nthe filler words \u201cfrog\u201d, \u201cdog\u201d, and \u201clog\u201d, you can simply combine the\nnumbers in the order that they are given. Here is the resulting\nnumber: 9475 3008 3305 1143 5750 7500 2133 8508 9423 2438 1293 3629\n5213 7582 3638 4055 0060 8038 4172 6607 2291 1297 7449 6747 0781\n\nHow is a neural network able to do this?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Turns out ChatGPT is indeed human curated, by open admission.\nDuring this conversation ChatGPT outright states the OpenAI team filters and edits the GPT generated responses.\n\n...the response you are receiving is being filtered and edited by the OpenAI team, who ensures that the text generated by the model is coherent, accurate and appropriate for the given prompt.\n\nApparently, the fact that OpenAI actively curates ChatGPT's responses is indirectly implied in the documentation here.\n\nHuman in the loop (HITL):\nWherever possible, we recommend having a\nhuman review outputs before they are used in practice. This is\nespecially critical in high-stakes domains, and for code generation.\nHumans should be aware of the limitations of the system, and have\naccess to any information needed to verify the outputs (for example,\nif the application summarizes notes, a human should have easy access\nto the original notes to refer back).\n\nSo, that explains that :)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Binary classifier that minimizes false positive error I have a binary classification problem, where a false positive error has a very big cost compared to the false negative error. \nIs there a way to design a classifier for such problems (preferably, with an implementation of the algorithm)? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is no predefined classifier for any problem. Two main features of a classifier are\n\nits cost function and\nits corresponding weight update formula.\n\nSince your problem statement requires a huge cost for falsely classifying a particular class one approach will be.\n\nYou have to define a cost function that will penalize hugely for misclassifying for that class only. So your cost function will be $J$ and $J'$ put together. You can look up the cost function of a logistic classifier to see how two separate cost functions are merged together here.\n\nThe second approach can be (assuming you are using supervised learning), the learning rate $\\alpha$ for both the classes should be different. The larger learning rate will be for the one which is the more important class, since you don't want to classify it improperly (increasing $\\alpha$ compared to the other class will reduce or risk of misclassifying it). The exact learning rate depends from case to case.\n\n\nThus, I have tailored the two main features of the classifier to solve this problem:\n\nThe cost function.\n\nThe weight update scheme (by changing learning rate for different cases).\n\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Reinforcement Learning with long term rewards and fixed states and actions I have read a lot about RL algorithms, that update the action-value function at each step with the currently gained reward. The requirement here is, that the reward is obtained after each step.\nI have a case, where I have three steps, that have to be passed in a specific order. At each step the agent has to make a choice between a range of actions. The actions are specific for each step.\nTo give an example for my problem:\nI want the algorithm to render a sentence of three words. For the first word the agent may choose a word out of ['I', 'Trees'], the second word might be ['am', 'are'] and the last word could be chosen from ['nice', 'high']. After the agent has made its choices, the reward is obtained once for the whole sentence.\nDoes anyone know which algorithms to use in this kind of problem?\n\nTo give a bit more detail on what I already tried:\nI thought that using value iteration would be an reasonable approach to test. My problem here is that I don't know how to assign the discounted reward for the chosen operations.\nFor example after the last choice I get a reward of 0.9. But how do I update the value for the first action (choosing out of I and Trees in my example)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You are describing a straightforward Markov Decision Process that could be solved by almost any Reinforcement Learning algorithm.\n\nI have read a lot about RL algorithms, that update the action-value function at each step with the currently gained reward. The requirement here is, that the reward is obtained after each step.\n\nThis is true. However, the reward value can be zero, and it is quite common to have most states and actions result in zero reward with only some specific ones returning a non-zero value that makes a difference to the goals of the agent.\nWhen this is more extreme - e.g. only one non-zero reward per thousand steps - this is referred to as \"sparse rewards\" and can be a problem to handle well. Your three steps then reward situation is nowhere near this, and not an issue at all.\n\nI thought that using value iteration would be an reasonable approach to test. My problem here is that I don't know how to assign the discounted reward for the chosen operations.\n\nValue iteration should be fine for your test problem, providing the number of choices for words is not too high.\nThe way you assign discounted rewards is to use the Bellman equation as an update:\n$$v(s) \\leftarrow \\text{max}_{a}[\\sum_{s',r} p(s',r|s,a)(r + \\gamma v(s'))]$$\nFor a deterministic environment you can simplify the sum, as $p(s',r|s, a)$ will be 1 for a specific combination of $s', r$\nIt doesn't matter that $r = 0$ for the first two steps. The Bellman equation links time steps, by connecting $v(s)$ and $v(s')$. So, over many repetitions of value iteration's main loop, the episode end rewards get copied - with the discount applied - to their predecessor states. Very quickly in your case you will end up with values for the start states.\n\nFor example after the last choice I get a reward of 0.9. But how do I update the value for the first action (choosing out of I and Trees in my example)?\n\nYou don't do it directly in a single step. What happens is repeating the value iteration loop copies the best values to their predecessor states, one possible time step at a time. \nOn the first loop through all states, you will run an update something like:\n$$v(\\text{'I'}) \\leftarrow 0 + \\gamma v(\\text{'I am'})$$\nand $v(\\text{'I am'}) = 0$ initially, so it will learn nothing useful in this first loop. However, it will also learn in the same loop:\n$$v(\\text{'I am'}) \\leftarrow 0 + \\gamma v(\\text{'I am nice'})$$ \nSo assuming $\\gamma = 0.9$ and $v(\\text{'I am nice'}) = 0.9$, and that \"I am high\" scores less than 0.9, then it will set $v(\\text{'I am'}) = 0.81$. \nOn the next loop through states in value iteration, it will then set $v(\\text{'I'}) = 0.727$ (assuming \"I am\" beats \"I are\" for maximum value)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why AlphaGo didn't use Deep Q-Learning? In the previous research, in 2015, Deep Q-Learning shows its great performance on single player Atari Games. But why do AlphaGo's researchers use CNN + MCTS instead of Deep Q-Learning? is that because Deep Q-Learning somehow is not suitable for Go?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "$Q$-learning (and also its deep variant, and most of the other well-known reinforcement learning algorithms) are inherently learning approaches for single-agent environments. The entire problem setting that these algorithms are developed for (Markov decision processes, or MDPs) is always framed in terms of a single agent situated in some environment, where that agent can take actions that have some level of influence over the states that they lead to, and rewards may be observed.\nIf you have a problem that is, in reality, a multi-agent environment, there is a way to translate this environment to a single-agent setting; you simply have to assume that all other agents (i.e. your opponent in Go) are an inherent part of \"the world\" or \"the environment\", and that all the states in which these other agents make moves are not really states (not visible to your agent), but just intermediate steps where these part-of-the-environment-agents cause the environment to change and, as a result, create state transitions.\nThe primary issue with this approach is; we still need to model the decision-making of these agents in order to implement this new view of \"the world\", where our opponents are really a part of the world. Whatever implementation we give them, that is what our single-agent RL algorithm will learn to play against. We can just implement our opponents to be random agents, and run a single-agent RL algorithm like DQN, and then we will likely learn to play well against random agents. We'll probably still be very bad against strong opponents though. If we want to use a single-agent RL algorithm to learn to play well against strong opponents, we need to have an implementation for those strong opponents first. But if we already have that... why even bother with learning at all? We've already got the strong Go player, so we're already done and don't need to learn!\nMCTS is a tree search algorithm, one that actively takes into account the fact that there is an opponent with opposing goals, and tries to model the choices that this opponent can make, and can do so better the more computation time we give it. This algorithm, and learning approaches built around it, are inherently designed to tackle the multi-agent setting (with agents having opposing goals).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to define an action space when an agent can take multiple sub-actions in a step? I'm attempting to design an action space in OpenAI's gym and hitting the following roadblock. I've looked at this post which is closely related but subtly different.\nThe environment I'm writing needs to allow an agent to make between $1$ and $n$ sub-actions in each step. Leaving it up to the agent to decide how many sub-actions it wants to take. So, something like (sub-action-category, sub-action-id, action) where the agent can specify between $1$ and $n$ such tuples.\nIt doesn't seem possible to define a Box space without specifying bounds on the shape which is what I need here. I'm trying to avoid defining an action space where each sub-action is explicitly enumerated by the environment like (action) tuple with n entries for each sub-action.\nAre there any other spaces I could use to dynamically scale the space?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "One way to handle an arbitrarily large sequence is by adding a STOP signal as one possible token in the sequence, just like LSTM.\nSo you could divide your game in turns:\n\nWhat you now call a single action (composed by multiple sub-actions) would become a turn.\nNow, you can have as many actions you'd like inside a turn.\nEach action is simply a list accumulated inside the environment, but won't evaluate the game yet.\nWhen the player is satisfied with their actions, they can call the action: \"End Turn\".\nWhen turn ends, you can concatenate every sub-actions, evaluate the game and proceed as usual.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is creating an AI that can code a hard task? For people who have experience in the field, why is creating AI that has the ability to write programs (that are syntactically correct and useful) a hard task? \nWhat are the barriers/problems we have to solve before we can solve this problem? If you are in the camp that this isn't that hard, why hasn't it become mainstream?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "AI has been applied to programming (check out TabNine, my favorite autocomplete engine) although not in as robust a fashion as you describe. \nProgramming requires a high level of abstract while AI is typically trained to solve a very specific task. Given thousands of examples of insert sort in Python I think a model could be trained (perhaps after autocomplete and syntax correction) figure it out. However at this point the field has not developed a more general intelligence that can apply the ideas of the algorithm to other problems.\nAddition based on comments:\nBig picture, training an algorithm to solve a general class of problems (say, web dev) requires a huge number of examples or an immense number of trials. Further, as the complexity of the problem grows the number of parameters necessary to build the model grows. Writing code is a very complex problem and would thus require a huge amount of data and a huge number of parameters making it totally infeasible with today's math and (because of how the math is solved) hardware.\nModern AI is has a very simple goal: find the model that solves a problem optimally. If we could quickly search every possible model this would be simple. Fields like machine (deep) learning and reinforcement learning are concerned with finding a good solution in a reasonable amount of time. At this point no such solution exists for a problem of such complexity. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there any difference between reward and return in reinforcement learning? I am reading Sutton and Barto's book on reinforcement learning. I thought that reward and return were the same things. \nHowever, in Section 5.6 of the book, 3rd line, first paragraph, it is written:\n\nWhereas in Chapter 2 we averaged rewards, in Monte Carlo methods we average returns.\n\nWhat does it mean? Are rewards and returns different things?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Return refers to the total discounted reward, starting from the current timestep.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the relation between a policy which is the solution to a MDP and a policy like $\\epsilon$-greedy? In the context of reinforcement learning, a policy, $\\pi$, is often defined as a function from the space of states, $\\mathcal{S}$, to the space of actions, $\\mathcal{A}$, that is, $\\pi : \\mathcal{S} \\rightarrow \\mathcal{A}$. This function is the \"solution\" to a problem, which is represented as a Markov decision process (MDP), so we often say that $\\pi$ is a solution to the MDP. In general, we want to find the optimal policy $\\pi^*$ for each MDP $\\mathcal{M}$, that is, for each MDP $\\mathcal{M}$, we want to find the policy which would make the agent behave optimality (that is, obtain the highest \"cumulative future discounted reward\", or, in short, the highest \"return\").\nIt is often the case that, in RL algorithms, e.g. Q-learning, people often mention \"policies\" like $\\epsilon$-greedy, greedy, soft-max, etc., without ever mentioning that these policies are or not solutions to some MDP. It seems to me that these are two different types of policies: for example, the \"greedy policy\" always chooses the action with the highest expected return, no matter which state we are in; similarly, for the \"$\\epsilon$-greedy policy\"; on the other hand, a policy which is a solution to an MDP is a map between states and actions.\nWhat is then the relation between a policy which is the solution to an MDP and a policy like $\\epsilon$-greedy? Is a policy like $\\epsilon$-greedy a solution to any MDP? How can we formalise a policy like $\\epsilon$-greedy in a similar way that I formalised a policy which is the solution to an MDP?\nI understand that \"$\\epsilon$-greedy\" can be called a policy, because, in fact, in algorithms like Q-learning, they are used to select actions (i.e. they allow the agent to behave), and this is the fundamental definition of a policy.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nfor example, the \"greedy policy\" always chooses the action with the highest expected return, no matter which state we are in\n\nThe \"no matter which state we are in\" there is generally not true; in general, the expected return depends on the state we are in and the action we choose, not just the action.\nIn general, I wouldn't say that a policy is a mapping from states to actions, but a mapping from states to probability distributions over actions. That would only be equivalent to a mapping from states to actions for deterministic policies, not for stochastic policies.\nAssuming that our agent has access to (estimates of) value functions $Q(s, a)$ for state-action pairs, the greedy and $\\epsilon$-greedy policies can be described in precisely the same way.\nLet $\\pi_g (s, a)$ denote the probability assigned to an action $a$ in a state $s$ by the greedy policy. For simplicity, I'll assume there are no ties (otherwise it would in practice be best to randomize uniformly across the actions leading to the highest values). This probability is given by:\n$$\n\\pi_g (s, a) = \n\\begin{cases}\n1, & \\text{if } a = \\arg\\max_{a'} Q(s, a') \\\\\n0, & \\text{otherwise}\n\\end{cases}\n$$\nSimilarly, $\\pi_{\\epsilon} (s, a)$ could denote the probability assigned by an $\\epsilon$-greedy strategy, with probabilities given by:\n$$\n\\pi_{\\epsilon} (s, a) = \n\\begin{cases}\n(1 - \\epsilon) + \\frac{\\epsilon}{\\vert \\mathcal{A}(s) \\vert}, & \\text{if } a = \\arg\\max_{a'} Q(s, a') \\\\\n\\frac{\\epsilon}{\\vert \\mathcal{A}(s) \\vert}, & \\text{otherwise}\n\\end{cases}\n$$\nwhere $\\vert \\mathcal{A}(s) \\vert$ denotes the size of the set of legal actions in state $s$.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to measure sample efficiency of a reinforcement learning algorithm? I want to know if there is any metric to use for measuring sample-efficiency of a reinforcement learning algorithm? From reading research papers, I see claims that proposed models are more sample efficient but how does one reach this conclusion when comparing reinforcement learning algorithms?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First of all, let's recall some definitions.\nA sample in the context of (deep) RL is a tuple $(s_t, a_t, r_t, s_{t+1})$ representing the information associated with a single interaction with the environment.\nAs for sample efficiency, it is defined as follows [1]:\n\nSample efficiency refers to the amount of data required for a learning system to attain any chosen target level of performance.\n\nSo, how you measure it is closely related to the way it is defined.\nFor example, one way to do it would be as shown in the figure below:\n\nOn the y-axis you have the performance of your RL algorithm (e.g. in terms of average return over episodes as done in [2], or mean total episode reward across different environment runs as done in [3])\n\nOn the x-axis you have the number of samples that you took.\n\nThe dashed line corresponds to your performance baseline (e.g. the performance at which a certain game or any other RL environment is considered solved).\n\n\nSo, you can measure sample efficiency at the intersection, where you get the number of samples needed to reach the performance baseline. So, an algorithm that requires less samples would be more sample-efficient.\n\nAnother way to do it would be the other way around, i.e. the RL agent is provided with a limited budget for the number of samples it could take. As a result, you can measure sample efficiency my measuring the area under the curve, as illustrated below. So, that would be how much performance you got just by using those samples in the budget. An algorithm that achieves a higher performance than another with the same amount of samples would then be more sample efficient.\n\nI am not aware if there exist RL libraries that would provide you with this measure out-of-the-box. However, if you're using Python for example, I believe that using libraries like scipy or scikit-learn along with matplotlib could do the job.\nNB: Image credits go to the following presentation: DLRLSS 2019 - Sample Efficient RL - Harm Van Seijen\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why can't neural networks learn functions outside of the specified domains? I understand that neural nets are fundamentally interpolative tools. Meaning, given a training dataset, a well trained neural net can approximate values within the domain of the training dataset. However, we are unsure about their behavior once we test against values outside that domain.\nSpeaking in the context of Imagenet, a NN trained on one of the classes in Imagenet will probably be able to predict an image of the same class outside Imagenet because Imagnet itself covers a huge domain for each class that whatever image we come across in the wild, its features will be accounted for by Imagnet. \nNow, this intuition breaks down for me when I talk about simple functions with simple inputs. For example, consider $sin(x)$. Our goal is to train a neural net to predict the function given $x$ with a training domain $[-1, 1]$. Theoretically, the neural net should not be able to predict the values well outside that domain, right? This seems counterintuitive to me because the function behaves in a very simple and periodic way that I find it hard to believe that a neural net cannot figure out the proper transformation of that function even outside the training domain.\nIn short, are neural nets inherently unable to find a generalizable transformation outside the training domain no matter how simple is the function we are trying to approximate? Is this a property of the Deep Learning framework?\nAre there problems where researchers were able to learn a robust generalizable transformation using neural nets outside the training domain? What are the possible conditions so that such results can happen?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The problem you discuss extends past the machine but to the man behind the machine (or woman). ML can be broken down into 3 components, the model, the data, and the learning procedure. This by the way extends to us as well. The model is our brain, the data is our experience and sensory input, and the learning procedure is there but unknown (for now $<$insert evil laugh$>$). \nYour model's inability to understand that it is a sin function is normally by construction. First, though lets start with the fact that if someone showed me $sin(x)$ on $[-1,1]$, a sinusoid is the last thing id think of:\n\n It looks almost linear. So for sake of argument i'm going to continue on the assumption you meant an entire period ($[-\\pi, \\pi])$. \nNow, given this most people who ever got past pre-calculus would assume sinusoid, as youd expect, but let me show you how unstable that idea is. Lets use a full period, shifted by $\\frac{\\pi}{2}$\n\nNow i don't know about you but my spidey-sense would make me think of a Gaussian before anything. This is the same sinusoid along an entire period but just the slight difference changes an entire perspective. \nNow lets talk about some of the mathematics. Given the uncountable $(x,sin(x))$ pairs between $[-1, 1]$, we can extract the function $sin(x)$ with certainty (assuming infintely differentiable) by simply taking the taylor series along any of the points in that domain. More so, we only need an infinitiscemally small continuous subset of the function to achieve that result, but as a person, would you be able to tell from $[-.0001, .0001]$? (i don't think so!), because by default we quantize, and what were gonna give to the computer is a quantization as well. We are giving it a finite countable set of points and expect it to to generalize to an uncountable set. This is silly, since there exists an infinite set of functions that can fit those exact points (concept of overfitting steps in here). \nSo if its so unfeasible for a computer to correctly solve the function, why can us humans extrapolate it so well from the $[-\\pi, \\pi]$ domain? The answer is our preset biases. Growing up we have dealt so much with periodicity, specifically sins and cosines, that graphed period triggered something in our brains and we just know what it is. But this isnt always a benefit, i could draw you a low-ordered polynomial on that domain that would make you think that exact same thought making you wrong. \nSo going back to my initial point, the problems lies with the models creator and not the model. Like i explained just now, its unfeasible without preset biases to learn the function we want, so what should we do? give up? NO, its our goal as the model architect to figure out what we want and how we can best achieve it! so if we want it to accomplish this task, lets try our best in modeling these biases. A quick example of how you could do that, is to force the function to fit the fourier coefficients, thatll probably solve this quite quickly (ofcourse this limits this models ability to solve for other common functions) \nTakeaway: It's not the model thats struggling, its us using preset biases that the model does not have access to. The solution to this is be clever and figure out how to have it either start with these preset biases or learn them.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does increasing the number of Q functions in Q-Learning scale? Q-Learning (Watkins, 1989) uses a single function to estimate the value of actions and to choose the next action. Double Q-Learning (Hasselt, 2010) extends this and uses two functions which are updated using different subsets of experience. The paper claims this tends to calm down the overestimation of Q-Learning and Hasselt further claims: \"Therefore, this algorithm is not less data-efficient than Q-learning.\"\nSo my question enters, is there a Q-Learning with n functions? If so, does it scale on the two claims of Double Q?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, there are variations of Q-learning which use $n$ Q-functions named \"enseble Q-learning\" or \"ensemble Q-functions\". You can have a look at REDQ algorithm.\nThe main benefit of having multiple but uncorrelated Q-functions is that you can reduce the overestimation bias of the q-values, and therefore update them more often (with the same data) such that to achieve a better sample-efficiency, or, equivalently, update-to-data (UTD) ratio.\nThe drawback is that an ensemble is always costly (so it does NOT scale with $n$, at least naively), and so training is slowed down (regarding wall-clock time) although you use less data to learn.\nTo fix this issue, DroQ uses dropout to easily create an ensemble of Q-functions, which is also cheap to evaluate. Therefore, you get speed, efficiency and SOTA performance.\nUpdate: Ensemble of Q-functions are also popular in offline RL (where you want to learn a policy from a previously collected dataset of demonstrations), where the ensemble allows you to select the next best experience tuple by evaluating the uncertainty about the predicted q-values: http://arxiv.org/abs/2110.01548.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How should the racing agent take into account the velocity of the vehicle, given the images with a speedometer? I'm developing a game AI, which tries to master racing simulations. I already trained a CNN (AlexNet) on in-game footage of me playing the game and the pressed keys as the target. As the CNN is only making predictions on a frame-to-frame basis, and I resized the image input to 160x120 due to GPU memory limitations, it cannot read the speedometer, so it seems not to have a feeling for its current velocity.\nI thought of different ways to fix this issue:\n\nCrop the captured image down to the size of the speedometer, which displays the current speed in mph, and feed the low-resolution game image, as well as the relatively high-res image (70x30) of the current speed into the neural network, which makes predictions based on the two images.\n\nAs I don't know whether AlexNet can serve as an OCR as well, my second thought was to use an existing one (like tesseract-ocr/PyTesser) on the cropped image and feed its output to the fully connected layer.\n\nI already tried to implement an optical-flow algorithm, but, sadly, non of the Python ones seems to output good real-time results. I wonder whether I can input the current frame as well as the last one, and let AlexNet figure out the movement.\n\n\nAs the processing has to happen in real-time, and the only performance reviews of pytesser I found reported a processing time of ~100ms (never tested that).\nMy question is: what method would work best?\nThe optical flow approach would have the advantage of the AI knowing in which direction other cars are moving as well.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Option 1 would be a very interesting one from a research perspective. I cannot imagine that CNNs have to capacity at the moment, to learn the concept of numbers and apply them in a useful way. If it was an analog speedometer, things would be different. But it would be really interesting to try it and see what you can achieve with this approach. I haven't read any research papers yet, where such a challenge would have been mastered.\nIf you are less concerned with research but rather get this project to work, I would propose an approach similar to option 2. The OCR tools you mentioned were designed to identify symbols, even if distorted or otherwise hard to read. In your case, the numbers will always look the same and are most likely always in fixed positions. Therefore, using fancy OCR algorithms or neural nets are overkill for the problem at hand. You can write a simple algorithm that crops the speedometer, searches for the 10 possible patterns (0 to 9) with 10 specific kernels and calculate the speed from the result. This can be implemented efficiently without the need to train a CNN or some other complex algorithm.\n\nMethod for implementation:\nTo answer the first question in the comments. The algorithm for this is really easy. Your image will be represented by a 2D array (or maybe a 3D array if you are working with colors). All you need to do is find out, what your numbers look like and store the appropriate array. You should end up with 10 different arrays for 10 different numbers.\nTo find out if a number is in your current picture, you only have to check if the array for this number is a subset of the array of your current picture. The position, where the arrays are matching, will also indicate the position of the number. You do this for all 10 numbers and can calculate the actual value displayed on the speedometer afterwards from the results.\nThis is very easy if the numbers always look exactly identical. In this case you can simply look for an exact match. If there are slight variations, you can look for parts of the image array that is similar to your template arrays. Just sum the absolute values of the diffs of each pixel value and if it is below a certain threshold, you have your match. That's all there is to it.\nIn python I like working with PIL for this kind of image manipulation, but there are other frameworks out there as well.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "In Value Iteration, why can we initialize the value function arbitrarily? I have not been able to find a good explanation of this, other than statements that the algorithm is guaranteed to converge with arbitrary choices for initial values in each state. Is this something to do with the Bellman optimality constraint itself?\nIt's hard to see that this is true intuitively since my intuition states that there ought to be ways in which an arbitrary choice of values could cause the value function to converge incorrectly compared to the ground truth. For instance, what if a state that in practice had low reward is assigned a very high initial reward value in value iteration? Would the algorithm not construct a value function that highly values trajectories passing through that state?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "If the value function of a state $v(s)$ is relatively high, then you are absolutely correct in saying that a greedy policy may choose to visit $s$, since the high $v(s)$ makes it very promising. The key idea here is that the update rule of value iteration will gradually change the value function and likewise will gradually change the policy.\nSuppose that the optimal value function $v_*(s)$ of a specific state $s$ is low, yet the value function $v(s)$ is initialized much higher. Then, the update rule in the pseudocode you provided will eventually decrease $v(s)$ to $v_*(s)$. To see this fact intuitively, note that $v(s)$ can be decomposed as the expected return (sum of rewards) from that state:\n$$v(s) = \\mathbb{E}[R_k + R_{k+1} + R_{k+2} + \\ldots + R_T|S_k = s].$$\nIf the expected return from $s$ is smaller than $v(s)$, then $v(s)$ will decrease with the aforementioned update. The actual update rule approximates the expected return from $s$ using the next reward $R_k$ and the value function of the next state $v(s')$ via bootstrapping. Note that $v(s')$ can be decomposed as follows:\n$$v(s') = \\mathbb{E}[R_{k+1} + R_{k+2} + \\ldots + R_T|S_{k+1}=s'].$$\nTherefore, $v(s')$ quantifies the part of the return aside from the next reward $R_k$, and the update rule indeed quantifies the expected return from $s$. If $v(s')$ is initialized too high or low, then the update rule will simultaneously be adjusting it to the optimal $v_*(s')$ while adjusting $v(s)$ closer to $v_*(s)$.\nOnce the value functions change as described above, then the greedy policy may also change and favor other states aside from $s$ with higher value functions.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does TensorFlow docs discourage using softmax as activation for the last layer? The beginner colab example for tensorflow states:\n\nNote: It is possible to bake this tf.nn.softmax in as the activation function for the last layer of the network. While this can make the model output more directly interpretable, this approach is discouraged as it's impossible to\n provide an exact and numerically stable loss calculation for all models when using a softmax output. \n\nMy question is, then, why? What do they mean by impossible to provide an exact and numerically stable loss calculation?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It's because of gradient computations: automatic differentiation will compute the gradient for each module and if you have a standalone crossentropy module the over all loss will be unstable (~1/x so it will diverge for small input values) whereas if you use a softmax + crossentropy module all-in-one, then it becomes numerically stable (y-p)\nSlides from DeepMind's Simon Osindero lecture at UCL in 2016:\n\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there an open-source implementation for graph convolution networks for weighted graphs? Currently, I'm using a Python library, StellarGraph, to implement GCN. And I now have a situation where I have graphs with weighted edges. Unfortunately, StellarGraph doesn't support those graphs\nI'm looking for an open-source implementation for graph convolution networks for weighted graphs. I've searched a lot, but mostly they assumed unweighted graphs. Is there an open-source implementation for GCNs for weighted graphs?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A Comprehensive Survey on Graph Neural Networks (2019) presents a list of ConvGNN's. All of the following accept weighted graphs, and three accept those with edge weights as well:\n\nAnd below is a series of open source implementations of many of the above:\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can a vanilla neural network theoretically achieve the same performance as CNN? I perfectly understand that CNN takes into account the local dependency of each pixel to the nearby pixels. In addition, CNNs are spatially invariant which means that they are able to detect the same feature anywhere in the image. These qualities are useful in image classification problems given the nature of the problem. \nHow does a vanilla neural net exactly falls short on these properties? Am I right in claiming that a vanilla neural net has to learn a given feature in every part of the image? This is different than how a CNN does it, which learns the feature once and then detects it anywhere in the image. \nHow about local pixel dependancy? Why can't a vanilla neural network learn the local dependency by relating one pixel to its neighbors in the 1D input? \nIn other words, is there more information present while training a CNN that are simply absent when training a normal NN? Or is a CNN just better at optimizing in the space of image classification problems? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "All CNNs can be represented as vanilla networks on the flattened image data. Just to do so, you would need A LOT of parameters (most of which would be 0) for what CNNs do freely. You can think of a CNN as reusing a filter on a masked input (whichever receptive field it's looking at whatever point during the convolution) repetitively. \nIn other words, fully connected layers use all the information, so it can still learn spatial dependence as a CNN does, while CNNs for each neuron only look at a specific receptive field and will reuse that filter for all neurons in that channel. This constraint saves computation and allows wider and deeper models under some budget.\nThis is nice because the hypothesis of why CNN's work are, is that at each point in the network we care about looking at localized features rather than global ones and that creating a composition of these makes it so even if each neuron only relates to a handful of neurons in the previous layer, the receptive field from the initial image can still be quite large if not the whole thing.\nTake away: CNNs are an efficient implementation of a vanilla NN, given the locality constraint that each neuron only looks at a small localized subset of neurons from the previous layer.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is Reinforcement Learning? What is the cleanest, easiest way to explain someone who is a non-STEM work colleague the concept of Reinforcement Learning? What are the main ideas behind Reinforcement Learning?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Humans are set loose in the world and go about their days doing stuff.\nWhenever they do specific things, their brain sends them good signals (endorphins, joy, etc.) or bad signals (pain, sadness, etc.). They learn through these signals which things they should be doing and which things they shouldn't be doing.\nSometimes the signal is immediate and you know exactly what you're being \"rewarded\" or \"punished\" for (e.g. touch a hot stove and it hurts). Sometimes it takes a bit longer and there could be many possible reasons for the brain signal (even a combination of reasons), but you can hopefully figure out what caused it after it happens a few times (e.g. getting a stomach ache a few hours after eating a specific food).\nThat's basically what Reinforcement Learning is.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can GANs be used to generate something other than images? AFAIK, GANs are used for generating/synthesizing near-perfect human faces (deepfakes), gallery arts, etc., but can GANs be used to generate something other than images?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "They can indeed. Although generally they are kept to images because at the moment, they are the best at that, but not the best in other areas that you might consider.\nGANs can be used for audio generation, with many examples such as GANsynth and GAN voice generation. But each of these tasks are outperformed by other methods. With music generation, WaveNet is the best (last I checked, and it also performs very well at speech synthesis), and a more powerful model for voice generation is achieved through the use of a VAE.\nThis is only looking at one area that you could use GANs for, because in reality you could use them for any kind of generation if you wanted to, but at the moment the vast majority of the research into GANs is into image generation, and as such other areas do not compete with the current SOTA techniques, unless there's some big paper I've missed within the last few months.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does the agent in reinforcement learning exactly do? What is an agent in reinforcement learning (RL)? I think it is not the neural network behind. What does the agent in RL exactly do?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The agent in RL is the component that makes the decision of what action to take.\nIn order to make that decision, the agent is allowed to use any observation from the environment, and any internal rules that it has. Those internal rules can be anything, but typically in RL, it expects the current state to be provided by the environment, for that state to have the Markov property, and then it processes that state using a policy function $\\pi(a|s)$ that decides what action to take. \nIn addition, in RL we usually care about handling a reward signal (received from the environment) and optimising the agent towards maximising the expected reward in future. To do this, the agent will maintain some data which is influenced by the rewards it received in the past, and use that to construct a better policy.\nOne interesting thing about the definition of an agent, is that the agent/environment boundary is usually considered to be very close to the abstract decision making unit. For instance, for a robot, the agent is typically not the whole robot, but the specific program running on the robot's CPU that makes the decision on the action. All the relays/motors and other parts of the physical body of the robot are parts of the environment in RL terms. Although often loose language is used here, as the distinction might not matter in most descriptions - we would say that \"the robot moves its arm to achieve the goal\" when in stricter RL terms we should say that \"the agent running on the robot CPU instructs the arm motors to move to achieve the goal\".\n\nI think it is not the Neural Net behind?\n\nThat is correct, the agent is more than the neural network. One or more neural networks might be part of an agent, and take the role of estimating the value of a state, or state/action pair, or even directly driving the policy function. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is elitism preferred over non-elitism in the cross-over operator? There are two potential approaches when performing cross-over operation in genetic algorithms.\n\nUse only the elites in the pool, probably the ones that are also going to be directly transferred to the next generation.\n\nUse all the population present in the pool.\n\n\nIs there any evidence that cross-over only with the elites of the population makes the GA converge faster to a good solution? I guess that, in order to escape from local minima, cross-over with all the population is needed. On the other hand, why should we perform cross-over with the least fit individuals?\nAny idea?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First of all the answer to your question is largely dependent on the problem you are trying solve, the size of your population, the size of your problem's search space and the rest of your GA's hyper-parameters such as your mutation rate. \n\nIf the problem has a large search space, then applying the elites strategy you described above will most likely cause your algorithm to never reach the optimal solution or reach it after too many iterations. The reason for this being that if your search space is big, then since the initialization of your initial population is random, the chances is that the \"fittest\" individual(s) in the first few iterations are not necessarily the gonna lead you to the optimal solution. Hence applying the elites strategy too early might make you get stuck on a local optima forever or for too long. The way I have personally found to be effective for this kind of situations is to allow your algorithm to explore as large a search space as possible earlier on(i.e use \"all the population present in the pool\") and then gradually introduce the elite strategy you described above(this is an idea similar to momentum in neural networks). In short, you want to explore earlier on, and then when you gradually start exploiting what you have found. \nIf the search space is relatively small, I think the elites strategy would be a very good idea. What you might also try to do, if you really want to stick to using elitism, you can try to mutate the elite individual(this kinda allows you to explore a little bit), or choose a higher elitism rate(i.e the number of individuals to be elite). \n\nNow to answer you other questions: \n\nIs there any certain belief that cross-over on only elites of the population, converges the solutions faster?\n\nNo, but I don't have reference for this so I guess I speak under correction, but I will explain why I said no:\nThe problem with pure elitism is that it causes the genetic algorithm to converge to local maxima instead of the global maxima. Basically pure elitism is just a race to the nearest local maxima and and as soon as you get to the local maxima, if you continue with elitism, you get almost no improved from there. \n\nI guess in order to escape from local minima, cross-over on all the population is needed; on the other hand I also say why performing cross over on weak population?\n\n\"why perform cross-over on weaker individuals in the population?\" - to explore. The hope is that applying a cross-over or a mutation on a weaker individual will produce a fitter individual.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are there RL algorithms that also try to predict the next state? So far I've developed simple RL algorithms, like Deep Q-Learning and Double Deep Q-Learning. Also, I read a bit about A3C and policy gradient but superficially.\nIf I remember correctly, all these algorithms focus on the value of the action and try to get the maximum one. Is there an RL algorithm that also tries to predict what the next state will be, given a possible action that the agent would take?\nThen, in parallel to the constant training for getting the best reward, there will also be constant training to predict the next state as accurately as possible? And then have that prediction of the next state always be passed as an input into the NN that decides on the action to take. Seems like a useful piece of information.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, there are algorithms that try to predict the next state. Usually this will be a model based algorithm -- this is where the agent tries to make use of a model of the environment to help it learn. I'm not sure on the best resource to learn about this but my go-to recommendation is always the Sutton and Barto book.\nThis paper introduces PlanGAN; the idea of this model is to use a GAN to generate a trajectory. This will include not only predicting the next state but all future states in a trajectory.\nThis paper introduces a novelty function to incentivise the agent to visit unexplored states. The idea is that for unexplored states, a model that predicts the next state from the state-action tuple will have high error (measured by Euclidean distance from true next state) and they add this error to the original reward to make a modified reward.\nThis paper introduces Dreamer. This is where all learning is done in a latent space and so the transition dynamics of this latent space must be learned, another example of needing to learn the next state.\nThese are just some examples of papers that try to predict the next state, there are many more out there that I would recommend you look for.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can I start learning mathematics for machine learning? I am an Android programmer. Now, I would like to learn machine learning. I know it requires a mathematical background, like statistics, probability, calculus and linear algebra. However, I am a bit lost. Where should I start from? Can someone provide me a road map for how to learn the mathematical background required for machine learning?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You should begin from Dr Andrew Ng machine learning course on Coursera. It's probably the most popular course for newcomers in machine learning. It's a free course.\nYou should also grab \"Elements of Statistical Learning\" ebook PDF. It's a free book.\nYou may want to focus on:\n\nRegression\nCross validation\nBias-variance tradeoff\nDecision surface\nGradient descent\n\nAnd more...\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What makes multi-layer neural networks able to perform nonlinear operations? As I know, a single layer neural network can only do linear operations, but multilayered ones can.\nAlso, I recently learned that finite matrices/tensors, which are used in many neural networks, can only represent linear operations.\nHowever, multi-layered neural networks can represent non-linear (even much more complex than being just a nonlinear) operations.\nWhat makes it happen? The activation layer?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Nonlinear relations between input and output can be achieved by using a nonlinear activation function on the value of each neuron, before it's passed on to the neurons in the next layer.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are options in reinforcement learning? According to a lecture (week 10) about Reinforcement Learning [1], the concept of an option allows searching the state space of an agent much faster. The lecture was hard to follow because many new terms were introduced in a short time. For me, the concept of an option sounds a bit like skills [2], which are used for describing high-level actions as well.\nAre skills an improvement over options that includes the trajectory, or are both the same?\nI'm asking for a certain reason. Normal deep reinforcement learning has the problem that the agent comes very often to a dead end, for example, in Montezuma's Revenge played at the Atari emulator. And the options framework promises to overcome the issue. But the concept sounds a bit too esoteric, and apart from the Nptel lecture, nobody else has explained the idea. So, is it useful at all?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "An option is a generalization of the concept of action. The concept of an option (or macro-action) was introduced in the context of reinforcement learning in the paper Between MDPs and semi-MDPs: A framework for temporal abstraction in reinforcement learning (1998) by Richard Sutton et al., so that to capture the idea that certain actions are composed of other sub-actions. Section 2 of the mentioned paper formally defines the concept of an option, which is a tuple composed of an initiation set, a policy, and a termination condition/set.\nThe authors of the mentioned paper give examples of options\n\nExamples of options include picking up an object, going to lunch, and traveling to a distant city, as well as primitive actions such as muscle twitches and joint torques.\n\nThe option picking up an object, going to lunch, and traveling to a distant city is composed of other sub-actions (e.g. picking up an object), but is itself an action (or macro-action). A primitive action (e.g. joint torques) is itself an option.\nA set of options defined over an MDP constitutes a semi-Markov decision process (SMDP), which are MDPs where the time between actions is not constant but it is variable. In other words, a semi-MDP (SMDP) is an extension of the concept of MDP that is used to deal with problems where there are actions of different levels of abstraction. For example, consider a footballer that needs to take a freekick. The action \"take a freekick\" involves a sequence of other actions, like \"run towards the ball\", \"look at the wall\", etc. The action \"take a freekick\" takes a variable number of time steps (which depends on the other sub-actions).\nSemi-MDPs are thus used to deal with such problems that involve actions of different levels of abstraction. Hierarchical reinforcement learning (HRL) is a generalization (or extension) of reinforcement learning where the environment is modeled as a semi-MDP.\nCuriously, certain models that have won the RoboCup (the famous AI football) context are based on the concept of semi-MDPs, options and HRL. See e.g. WrightEagleBASE, which use the MAXQ-OP (MAXQ online planning) algorithm.\nSemi-MDPs can be converted to MDPs. The picture below (which is a screenshot of figure 1 of the mentioned paper that introduces the \"options framework\" in RL) illustrates the relationship between semi-MDPs and MDPs.\n\nThe empty circles (in the middle) are options, while the black circles (at the top) are primitive actions (which are themselves options).\nIn the paper Reinforcement learning of motor skills with policy gradients mentioned in the question, apparently, the term skill is not formally defined. However, I suppose that skills can be represented as options.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does \"semantic gap\" mean? I was reading DT-LET: Deep transfer learning by exploring where to transfer, and it contains the following:\n\nIt should be noted direct use of labeled source domain data on a new scene of target domain would result in poor performance due to the semantic gap between the two domains, even they are representing the same objects.\n\nCan someone please explain what the semantic gap is?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In terms of transfer learning, semantic gap means different meanings and purposes behind the same syntax between two or more domains. For example, suppose that we have a deep learning application to detect and label a sequence of actions/words $a_1, a_2, \\ldots, a_n$ in a video/text as a \"greeting\" in a society A. However, this knowledge in Society A cannot be transferred to another society B that the same sequence of actions in that society means \"criticizing\"! Although the example is very abstract, it shows the semantic gap between the two domains. You can see the different meanings behind the same syntax or sequence of actions in two domains: Societies A and B. This phenomenon is called the \"semantic gap\".\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do we need both the validation set and test set? I know that this has been asked a hundred times before, however, I was not able to find a question (and an answer) which actually answered what I wanted to know, respectively, which explained it in a way I was able to understand. So, I'm trying to rephrase the question\u2026\nWhen working with neural networks, you typically split your data set into three parts:\n\nTraining set\nValidation set\nTest set\n\nI understand that you use the training set for, well, train the network, and that you use the test set to verify how well it has learned: By measuring how well the network performs on the test set, you know what to expect when actually using it later on. So far, so good.\nNow, a model has hyper parameters, which \u2013\u00a0besides the weights \u2013 need to be tuned. If you change these, of course, you get different results. This is where in all explanations the validation set comes into play:\n\nTrain using the training set\nValidate how well the model performs using the validation set\nRepeat this for a number of variants which differ in their hyperparameters (or do it in parallel, right from the start)\nFinally, select one and verify its performance using the test set\n\nNow, my question is: Why would I need steps 2 and 3? I could as well train multiple version of my model in parallel, and then run all of them against the test set, to see which performs best, and then use this one.\nSo, in other words: Why would I use the validation set for comparing the model variants, if I could directly use the test set to do so? I mean, I need to train multiple versions either way. What is the benefit of doing it like this?\nProbably, there is some meaning to it, and probably I got something wrong, but I can't figure out what. Any hints?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The difference between the validation and test set in my opinion should be explained in this way:\n\nthe validation set is meant to be used multiple times.\nthe test set is meant to be used only once. \n\nI think that the misunderstanding here arise because machine learning is mostly taught focusing only on a specific part of a large pipeline, which is the model training. In every tutorial standard datasets are used so that you don't have to worry about data collection, data labelling (it's really sad to see that lot of people have not a clue about what the inter annotator agreement is), data pre-processing and especially, all the part about the real application of the model is almost never mentioned.\nThe importance of having a set of instances that you can use for fine tuning (validation) and a set of instances that your model never encountered neither in training nor during fine tuning (test) becomes particularly clear if you focus on the subsequent deployment of the model you trained. No one expect a model to have the same performance scores in training and when applied to some unknown data. And the crucial point is that the performance of a model on the validation set are not representative either of the behaviour of a model with unknown data, because the same validation data have been used to fine tuned the model! So here's why having a set of data completely new to the model is important, because it gives you a much more unbiased view about the model performance on a real use case scenario. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is this Pytorch expression equivalent to the KL divergence? I found the following PyTorch code (from this link)\n-0.5 * torch.sum(1 + sigma - mu.pow(2) - sigma.exp())\n\nwhere mu is the mean parameter that comes out of the model and sigma is the sigma parameter out of the encoder. This expression is apparently equivalent to the KL divergence. But I don't see how this calculates the KL divergence for the latent.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The code is correct. Since OP asked for a proof, one follows.\nThe usage in the code is straightforward if you observe that the authors are using the symbols unconventionally: sigma is the natural logarithm of the variance, where usually a normal distribution is characterized in terms of a mean $\\mu$ and variance. Some of the functions in OP's link even have arguments named log_var.$^*$\nIf you're not sure how to derive the standard expression for KL Divergence in this case, you can start from the definition of KL divergence and crank through the arithmetic. In this case, $p$ is the normal distribution given by the encoder and $q$ is the standard normal distribution.\n$$\\begin{align}\nD_\\text{KL}(P \\| Q) &= \\int_{-\\infty}^{\\infty} p(x) \\log\\left(\\frac{p(x)}{q(x)}\\right) dx \\\\\n&= \\int_{-\\infty}^{\\infty} p(x) \\log(p(x)) dx - \\int_{-\\infty}^{\\infty} p(x) \\log(q(x)) dx\n\\end{align}$$\nThe first integral is recognizable as almost definition of entropy of a Gaussian (up to a change of sign).\n$$\n\\int_{-\\infty}^{\\infty} p(x) \\log(p(x)) dx = -\\frac{1}{2}\\left(1 + \\log(2\\pi\\sigma_1^2) \\right)\n$$\nThe second one is more involved.\n$$\n\\begin{align}\n-\\int_{-\\infty}^{\\infty} p(x) \\log(q(x)) dx \n&= \\frac{1}{2}\\log(2\\pi\\sigma_2^2) - \\int p(x) \\left(-\\frac{\\left(x - \\mu_2\\right)^2}{2 \\sigma_2^2}\\right)dx \\\\\n&= \\frac{1}{2}\\log(2\\pi\\sigma_2^2) + \\frac{\\mathbb{E}_{x\\sim p}[x^2] - 2 \\mathbb{E}_{x\\sim p}[x]\\mu_2 +\\mu_2^2} {2\\sigma_2^2} \\\\\n&= \\frac{1}{2}\\log(2\\pi\\sigma_2^2) + \\frac{\\sigma_1^2 + \\mu_1^2-2\\mu_1\\mu_2+\\mu_2^2}{2\\sigma_2^2} \\\\\n&= \\frac{1}{2}\\log(2\\pi\\sigma_2^2) + \\frac{\\sigma_1^2 + (\\mu_1 - \\mu_2)^2}{2\\sigma_2^2}\n\\end{align}\n$$\nThe key is recognizing this gives us a sum of several integrals, and each can apply the law of the unconscious statistician. Then we use the fact that $\\text{Var}(x)=\\mathbb{E}[x^2]-\\mathbb{E}[x]^2$. The rest is just rearranging.\nPutting it all together:\n$$\n\\begin{align}\nD_\\text{KL}(P \\| Q) &= -\\frac{1}{2}\\left(1 + \\log(2\\pi\\sigma_1^2) \\right) + \\frac{1}{2}\\log(2\\pi\\sigma_2^2) + \\frac{\\sigma_1^2 + (\\mu_1 - \\mu_2)^2}{2\\sigma_2^2} \\\\\n&= \\log (\\sigma_2) - \\log(\\sigma_1) + \\frac{\\sigma_1^2 + (\\mu_1 - \\mu_2)^2}{2\\sigma_2^2} - \\frac{1}{2}\n\\end{align}\n$$\nIn this special case, we know that $q$ is a standard normal, so\n$$\n\\begin{align}\nD_\\text{KL}(P \\| Q) &= -\\log \\sigma_1 + \\frac{1}{2}\\left(\\sigma_1^2 + \n\\mu_1^2 - 1 \\right) \\\\\n&= - \\frac{1}{2}\\left(1 + 2\\log \\sigma_1- \\mu_1^2 -\\sigma_1^2 \\right)\n\\end{align}\n$$\nIn the case that we have a $k$-variate normal with diagonal covariance for $p$, and a multivariate normal with covariance $I$, this is the sum of $k$ univariate normal distributions because in this case the distributions are independent.\nThe code is a correct implementation of this expression because $\\log(\\sigma_1^2) = 2 \\log(\\sigma_1)$ and in the code, sigma is the logarithm of the variance.\n\n$^*$The reason that it's convenient to work on the scale of the log-variance is that the log-variance can be any real number, but the variance is constrained to be non-negative by definition. It's easier to perform optimization on the unconstrained scale than it is to work on the constrained scale in $\\eta^2$. Also, we want to avoid \"round-tripping,\" where we compute $\\exp(y)$ in one step and then $\\log(\\exp(y))$ in a later step, because this incurs a loss of precision. In any case, autograd takes care of all of the messy details with adjustments to gradients resulting from moving from one scale to another.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does the \"lowest layer\" refer to the first or last layer of the neural network? People sometimes use 1st layer, 2nd layer to refer to a specific layer in a neural net. Is the layer immediately follows the input layer called 1st layer?\nHow about the lowest layer and highest layer?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nPeople sometimes use 1st layer, 2nd layer to refer to a specific layer in a neural net. Is the layer immediately follows the input layer called 1st layer?\n\nThe 1st layer should typically refer to the layer that comes after the input layer. Similarly, the 2nd layer should refer to the layer that comes after the 1st layer, and so on.\nHowever, note that this convention and terminology may not be applicable in all cases. You should always take into account your context!\n\nHow about lowest layer and highest layer?\n\nTo be honest, I also dislike this ambiguous terminology. From my experience, I don't think there's an agreement on the actual meaning of \"lowest\" or \"highest\". It depends on how you depict the neural network, but it's possible that \"lowest\" refers to the layers closer to the inputs, because, if you think of a neural network as a hierarchy that starts from the inputs and builds more complex representations of it, the \"lowest\" may refer to the \"lowest in the hierarchy\" (but who knows!).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to create and train (with mutation and selection) a neural network to predict the next state of a board? I'm aiming to create a neural network that can learn to predict the next state of a board using the rules of Conway's Game of Life.\nTechnically, I have three questions, but I felt that they needed to be together to get the full picture.\nMy network will look at each cell individually (to reduce the computing power needed and to increase learning speed) and its surrounding cells. 9 input nodes for the network will go into one hidden layer. The output layer will be one node for the state of that cell in the next state of the game.\nNodes have two states (alive and dead) and connections between nodes can either transfer that value or invert it.\nFor the learning part, I was going to make use of mutation and natural selection. The starting network will have the input and output layers with no hidden layer and no connections. My idea was then to introduce mutation by randomly generating a number of new networks by adding nodes and randomly connecting them to inputs and to the output. The number of nodes in the middle layer will be limited to 512, since there are 512 possible inputs; however, I may reduce this if it is too slow.\nShould I also have it randomly delete nodes and connections, in case they also make improvements?\nEach network will be tested on the same board state, and their accuracy will be calculated by comparing their output to a correct output generated by a computer program. The most accurate network will then be used for the next generation.\nMy issue is that I don't know how to program the nodes. Should the nodes in the hidden layer perform a logical AND on all of their inputs or an OR?\nI know that the network won't learn the rules within the first few turns, but how do I know if it will ever get above 90% accuracy, or even just 50%?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Re: Should I also have it randomly delete nodes and connections, in case they also make improvements?\nYou may read about \"dropout\". In this case it's not preferred since overfitting is actually a benefit. \nRe: Should the nodes in the hidden layer perform a logical AND on all of their inputs or an OR?\nThere are no logical operations in Neural Networks. You need to multiply the input by the weights. At the end you will arrive to a fraction number that you need to convert back to 1 or 0, here I suggest to look into \"softmax\" that is an activation function exactly for this. \nRe:how do I know if it will ever get above 90% accuracy, or even just 50%?\nAs Jaden suggested you will need a benchmark. You may simply take my results from your other post. (i.e 100% in 20 epochs) \nI agree with Jaden, you have a lot on your table. Perhaps it would make sense to first develop a DNN to learn the GOL, you will need the activations, the loss calculation and at least one optimizer. Once this is tested and working you could start with the second model for the genetic algorithm that will need a different loss function and also the genetic operations, population selection etc. Nice big project, good luck!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do neural networks manage to do regression? I'm trying to learn about neural networks, and I'm interested in gaining a better conceptual understanding of how they work to solve certain problems. I'm having trouble in conceptually understanding how they succeed in doing regression (i.e. predicting continuous variables), however, and wondered if anybody has a good explanation. I know the mathematics of how NNs work, but a clearer conceptual understanding would be helpful.\nTo give an idea of what I mean by a \"conceptual understanding\", here's the one that I have for how multilayer NN's with a sigmoid activation function are able to be effective classifiers. Each NN takes the scalar product of its inputs and a set of weights. The weights define a plane in the input space, and the sign of the scalar product indicates which side of the plane the point defined by the inputs is on. The sigmoid activation function outputs 1 if the point is on one side and 0 or -1 (depending on which function is used) if the point is on the other. So the first hidden layer of neurons can be considered to identify which side of each of a group of planes the input point is on. The neurons can also act as AND and OR gates, so subsequent layers of neurons give an output indicating whether the point lies in a region bounded by several of the planes (e.g. a neuron activates only if the point is above one plane and below another, indicating it is in a region of the space associated with one class of points). So if the network learns an appropriate set of planes to bound regions containing different classes of inputs and the AND/OR relations that determine whether a point is in a given region, then it can classify the input points, and this can work for regions with arbitrarily shaped boundaries.\nI've not found or been able to think of a similar way of explaining why an NN can perform well in general regression problems (if it's big enough). Does anyone here know a way to explain this?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I came across the article A visual proof that neural nets can compute any function that explains how a neural network can approximate any function, which pretty much answers my question.\nI suppose connections between neurons do not generally arrange themselves in the way described, though, so it would still be interesting to get insight into whether there are patterns of how the inter-neuron connections arrange themselves in neural networks trained to solve actual problems.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "If the Turing test is passed, does this imply that computers exhibit intelligence? Turing test was created to test machines exhibiting behavior equivalent or indistinguishable from that of a human. Is that the sufficient condition of intelligence?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "We don't know. \nHowever, an important line will have been crossed - it will be impossible to tell the difference between an intelligent agent and the machine by use of a text interface. Which is the main point of the test - \"if it quacks like a duck\".\nIt is also an important philosophical point. Whether intelligence is defined purely by behaviour in an environment, or by the mechanisms that arrive at that behaviour. A suitably large database of conversational openers and \"correct\" responses can in theory mimic a lot of real world conversations. Some chatbots take advantage of this and use modern computer capacity to store a lot of responses, and that approach has gained competitive scores in the Loebner prize competition (although not to the stage of actually passing the test). This leads us to the Chinese Room issue, and wondering which part of the system is actually intelligent, or even how much of human conversation is actually intelligent or meaningful (and it what ways).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can neuroevolution be combined with gradient descent? Is there any precedent for using a neuroevolution algorithm, like NEAT, as a way of getting to an initialization of weights for a network that can then be fine-tuned with gradient descent and back-propagation? \nI wonder if this may be a faster way of getting to a global minimum before starting a decent to a local using backpropagation with a large set of input parameters.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The paper The Comparison and Combination of Genetic and Gradient Descent Learning in Recurrent Neural Networks: An Application to Speech Phoneme Classification (2007), by Rohitash Chandra and Christian W. Omlin, uses genetic algorithms to train a recurrent neural network and then uses gradient descent to fine tune the trained model.\nThe paper Evolutionary Stochastic Gradient Descent for Optimization of Deep Neural Networks (2018), by Xiaodong Cui, Wei Zhang, Zolt\u00e1n T\u00fcske and Michael Picheny, also combines evolutionary algorithms and gradient descent, but, in this case, they alternate between a gradient descent step and an evolution step. This is an example of a evolutionary stochastic gradient descent (ESGD) method, as opposed to a population-based training (PBT) method, which uses only evolutionary algorithms to train neural networks.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are PAC learnability and the No Free Lunch theorem contradictory? I am reading the Understanding Machine Learning book by Shalev-Shwartz and Ben-David and based on the definitions of PAC learnability and No Free Lunch Theorem, and my understanding of them it seems like they contradict themselves. I know this is not the case and I am wrong, but I just don't know what I am missing here.\nSo, a hypothesis class is (agnostic) PAC learnable if there exists a learner A and a function $m_{H}$ s.t. for every $\\epsilon,\\delta \\in (0,1)$ and for every distribution $D$ over $X \\times Y$, if $m \\geq m_{H}$ the learner can return a hypothesis $h$, with a probability of at least $1 - \\delta$\n$$ L_{D}(h) \\leq min_{h'\\in H} L_{D}(h') + \\epsilon $$\nBut, in layman's terms, the NFL theorem states that for prediction tasks, for every learner there exists a distribution on which the learner fails. \nThere needs to exists a learner that is successful (defined above) for every distribution $D$ over $X \\times Y$ for a hypothesis to be PAC learnable, but according to NFL there exists a distribution for which the learner will fail, aren't these theorems contradicting themselves?\nWhat am I missing or misinterpreting here?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is no contradiction. \nFirst, agnostic PAC learnable doesn't mean that the there is a good hypothesis in the hypothesis class; it just means that there is an algorithm that can probably approximately do as well as the best hypothesis in the hypothesis class.\nAlso, these NFL theorems have specific mathematical statements, and hypothesis classes for which they apply are often not the same as the hypothesis class for which PAC-learnability holds. For example, in Understanding Machine Learning by Shalev-Shwartz and Ben-David, a hypothesis class is agnostic PAC learnable if and only if has finite VC dimension (Theorem 6.7). Here, the algorithm is ERM.\nOn the other hand, the application of the specific version of NFL that this book uses has Corollary 5.2, that the hypothesis class of all classifiers is not PAC learnable, and note that this hypothesis class has infinite VC dimension, so the Fundamental Theorem of PAC learning does not apply.\nThe main takeaway is that in order to learn, we need some sort of inductive bias (prior information). This can be seen in the form of measuring the complexity of the hypothesis class or using other tools in learning theory. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the available exploration strategies for continuous action space scenarios in RL? I'm building a deep neural network to serve as the policy estimator in an actor-critic reinforcement learning algorithm for a continuing (not episodic) case. I'm trying to determine how to explore the action space. I have read through this text book by Sutton, and, in section 13.7, he gives one way to explore a continuous action space. In essence, you train the policy model to give a mean and standard deviation as an output, so you can sample a value from that Gaussian distribution to pick an action. This just seems like the continuous action-space equivalent of an $\\epsilon$-greedy policy.\nAre there other continuous action space exploration strategies I should consider?\nI've been doing some research online and found some articles related to RL in robotics and found that the PoWER and PI^2 algorithms do something similar to what is in the textbook.\nAre these, or other, algorithms \"better\" (obviously depends on the problem being solved) alternatives to what is listed in the textbook for continuous action-space problems?\nI know that this question could have many answers, but I'm just looking for a reasonably short list of options that people have used in real applications that work.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I have not personally worked enough with continuous action spaces to be capable of confidently giving advise based on my own experience, but I can point you to likely relevant research (more recent than the research you already pointed to yourself):\n\nThe most common / \"popular\" area of research in recent years that involves RL and continuous action spaces uses robot / physics simulators such as MuJoCo. Some examples:\n\nAsynchronous Methods for Deep Reinforcement Learning mentions using an entropy cost term in the loss function used for training to encourage exploration (see Supplementary Material after References).\nParameter Space Noise for Exploration describes the idea of adding noise directly to the learned parameters on the Neural Network. That way it basically always predicts a different action to be \"optimal\" (due to the noise), and therefore a \"greedy\" policy based on the noisy parameters will in fact have exploration and not be fully greedy.\nDeepMind Control Suite is a somewhat recent paper that proposes a suite of benchmarks for continuous control problems. It is filled with references to relevant papers describing all kinds of algorithms, and hopefully every single one of those papers would also describe how they perform exploration.\n\n\nRecently, at the ICML 2018 conference, there was a complete workshop dedicated to Exploration in Reinforcement Learning. Here is the list of accepted papers at this workshop. Note that it's about Exploration in RL, not only about continuous action spaces, so there might be papers in there that are only applicable to discrete action spaces. Nevertheless, I would be highly surprised if there's nothing in there that's relevant.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between on and off-policy deterministic actor-critic? In the paper Deterministic Policy Gradient Algorithms, I am really confused about chapter 4.1 and 4.2 which is \"On and off-policy Deterministic Actor-Critic\". \nI don't know what's the difference between two algorithms. \nI only noticed that the equation 11 and 16 are different, and the difference is the action part of Q function where is $a_{t+1}$ in equation 11 and $\\mu(s_{t+1})$ in equation 16. If that's what really matters, how can I calculate $a_{t+1}$ in equation 11?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The twist here is that the $a_{t+1}$ in (11) and the $\\mu(s_{t+1})$ in (16) are the same and actually the $a_t$ in the on-policy case and the $a_t$ in the off-policy case are different.\nThe key to the understanding is that in on-policy algorithms you have to use actions (and generally speaking trajectories) generated by the policy in the updating steps (to improve the policy itself). This means that in the on-policy case $a_i = \\mu(s_{i})$ (in equations 11-13).\nWhereas in the off-policy case you can use any trajectory to improve your value/action-value functions, which means that the actions $a_t$ can be generated by any distribution $a_t~\\pi(s_t,a_t)$. In (16) the algorithm explicitly states however that the action-value function ($Q^w$) has to be evaluated at $\\mu_{s_{t+1}}$ (just like in the on-policy case) and not at $a_t$ which was the actual action in the trajectory generated by policy $\\pi$.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do Bellman equations indirectly create a policy? I was watching a lecture on policy gradients and Bellman equations. And they say that a Bellman equation indirectly creates a policy, while the policy gradient directly learns a policy. Why is this?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Policy gradient methods directly learn parameters of a policy function, which is a mapping from states to actions. For example, $p(s, a)$ can denote a function which takes a state $s$ and an action $a$ as input, and returns a probability of taking action $a$ in state $s$ as output (equivalently it could just take $s$ as input, and output a vector or a distribution of probabilities for all actions). Such a function will often have some parameters (for example, a vector of weights if it's a linear function of the state, or matrices of weights in the case of a neural network). Policy gradient methods directly modify the function by modifying (learning) the parameters of that function.\nThe Bellman equation is typically used to learn a function that computes different kinds of values, such as $Q(s, a)$ values, which can intuitively be understood to denote all the future rewards that we expect to get if we take action $a$ in state $s$ (and follow a certain policy, typically \"the optimal policy\" afterwards until the end of time). Such a $Q(s, a)$ function that we learn is not a directly learned policy, because it is not a direct mapping from current states to actions, it doesn't directly tell us which action to take.\nIt can still be used indirectly to create a policy. For example, once such a $Q(s, a)$ function is learned, the greedy policy can be easily implemented by looping over all possible actions, and taking the action that gives the greatest $Q(s, a)$ output. This is indirect because the learned function does not directly give you the actions, but only provides information which you can convert into actions with some extra processing.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are some academic AI podcast out there? I am looking for AI podcasts that are purely academic-oriented that I can use for learning purposes. Thanks for any resource pointers.\nThe AI podcasts I am aware of are (not sure how many of these can be considered academic):\n\nThe AI Podcast\nLinear Digressions\nO'Reilly Bots Podcast\nA16z Podcast\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Also a few others options (that I listen to) include:\n\nLearning Machines 101\nMachine Learning Guide\nMachine Learning - Software Engineering Daily\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is iterative deepening A* better than A*? The iterative deepening A* search is an algorithm that can find the shortest path between a designated start node and any member of a set of goals. \nThe A* algorithm evaluates nodes by combining the cost to reach the node and the cost to get from the node to the goal. How is iterative deepening A* better than the A* algorithm?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A* is a best-first search algorithm, which means that it is an algorithm that uses both \"past knowledge\", gathered while exploring the search space, denoted by $g(n)$, and an admissible heuristic function, denoted by $h(n)$, which estimates the distance to the goal node, for each node $n$. There are other best-first search algorithms, which differ only in the definition of their \"evaluation function\", denoted by $f(n)$. For example, the evaluation function of A* is $f(n) = g(n) + h(n)$, where $h$ is admissible.\nA* is optimal, that is, it finds the optimal path between the starting and goal nodes or states. The optimality of A* is due to the use of an admissible heuristic function, which is a heuristic function which always underestimates the distance to the goal. A* is also complete, that is, it eventually finds this optimal path. However, the problem with A*, in many real-world situations, is that it has an exponential space complexity; more specifically, its space complexity is $\\mathcal{O}(b^m)$, where $b$ is the (maximum) branching factor and $m$ is the maximum depth of the search tree. It also has a time complexity of $\\mathcal{O}(b^m)$, but, in practice, it tends to find the solutions quite \"fast\" (for relatively small search spaces).\nIDA* combines A* and IDDFS (or IDS). It does it \"well\", so it gets the advantages of both algorithms. It can be thought of as the IDDFS which uses, instead of the depth, the evaluation function $f(n) = g(n) + h(n)$ as the \"cost threshold\" or \"cutoff\". In the IDA* algorithm, a child $c$ of a node $n$ is added to the frontier (or fringe or border) if $f(c) < T$. This threshold $T$ is, at the beginning of the algorithm, the estimate of the distance to the goal from the starting node $s$, that is, $T = h(s)$. $T$ increases at each iteration of the algorithm (See the pseudocode of the IDA* algorithm for the details).\nIDA* is also complete and optimal, but, as opposed to A*, it has a polynomial space complexity, more specifically, $\\mathcal{O}(bd)$, where $b$ is the (maximum) branching factor and $d$ is the maximum depth fo the tree. IDA* still has an exponential time complexity of A*.\nTo conclude, IDA* has a better memory usage than A*. As in A* and unlike IDDFS, it concentrates on exploring the most promising nodes, and thus does not go to the same depth everywhere in the search tree (whereas ordinary IDDFS does). A* can be thought of as a dynamic programming algorithm. IDA* often ends up exploring the same nodes many times (as IDDFS), but, asymptotically, both A* and IDA* have the same exponential time complexity, that is, $\\mathcal{O}(b^m)$.\nSo, which one is the best one? A* becomes impractical when the search space is huge, because of the memory constraints. So, in those cases, IDA* is definitely more appropriate. In general, IDA* is one of the very best optimal state space\nsearch techniques around. However, A* is conceptually simpler than IDA*. As a consequence, in practice, A* may be easier to implement than IDA*, but, in real-world scenarios, this is not really a problem, as they are both relatively easy to implement (anyway).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between a Bayesian Network and a Markov Chain? I am trying to understand the difference between a Bayesian Network and a Markov Chain.\nWhen I search for this one the web, the unanimous solution seems to be that a Bayesian Network is directional (i.e. it's a DAG) and a Markov Chain is not directional.\nHowever, often a Markov Chain example is overtime, where the weather today is impacting the weather tomorrow, but the weather tomorrow is not (obviously) impacting the weather today. So I am quite confused how is a Markov Chain not directional?\nI seem to be missing something here. Can someone please help me understand?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I am not an expert on this, but I'll try to explain my understnding of this.\nA Bayesian Network is a Directed Graphical Model (DGM) with the ordered Markov property i.e the relationship of a node (random variable) depends only on its immediate parents and not its predecessors (generalized from first order Markov process).\nA Markov chain on the other hand can be of order $\\geq 1$. Thus it may depends on not so immediate predecessors (although there can be no gap between predecessors).\n(Defintions according to Kevin Murphy's book, A Probabilistic Approach to MAchine Learning).\nNow the reason why such a confusion/ambiguity exists is, in my opinion, due to the fact that Bayesian Nets has been generally used to model causal relationships (and hence directed cause $\\rightarrow$ effect) between random variables, which are of different type, i.e the each random variable has a completely different state space (e.g sky is cloudy or sunny vs the ground is wet or dry). \nWhereas, we generally use Markov Chains to represent Stochastic Process (a collection of r.v's indexed by time: $X_0, X_1...$) having the Markov Property. And thus for Markov Chain's we have a state transition matrix. Thus, the collection of r.v's indexed with time has the same state space along with a transition matrix specifying the transition probabilities. The directed graph or DGM exists in Markov Chains to show you are moving forward in time, but the state space for each $X_k$ remains the same, and hence no 'real parent' exists.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does each filter in each convolution layer create a new image? Say I have a CNN with this structure:\n\ninput = 1 image (say, 30x30 RGB pixels)\nfirst convolution layer = 10 5x5 convolution filters\nsecond convolution layer = 5 3x3 convolution filters\none dense layer with 1 output\n\nSo a graph of the network will look like this:\n\nAm I correct in thinking that the first convolution layer will create 10 new images, i.e. each filter creates a new intermediary 30x30 image (or 26x26 if I crop the border pixels that cannot be fully convoluted).\nThen the second convolution layer, is that supposed to apply the 5 filters on all of the 10 images from the previous layer? So that would result in a total of 50 images after the second convolution layer.\nAnd then finally the last FC layer will take all data from these 50 images and somehow combine it into one output value (e.g. the probability that the original input image was a cat).\nOr am I mistaken in how convolution layers are supposed to operate? \nAlso, how to deal with channels, in this case RGB? Can I consider this entire operation to be separate for all red, green and blue data? I.e. for one full RGB image, I essentially run the entire network three times, once for each color channel? Which would mean I'm also getting 3 output values.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You are partially correct. On CNNs the output shape per layer is defined by the amount of filters used, and the application of the filters (dilation, stride, padding, etc.). \nCNNs shapes\nIn your example, your input is 30 x 30 x 3. Assuming stride of 1, no padding, and no dilation on the filter, you will get a spatial shape equal to your input, that is 30 x 30. Regarding the depth if you have 10 filters (of shape 5 x 5 x 3) you will end up with a 30 x 30 x 10 output at your first layer. Similarly, on the second layer with 5 filters (of shape 3 x 3 x 10, note the depth to work on the previous layer) you have 30 x 30 x 5 output. The FC layer has the same amount of weights as the input (that is 4500 weights) to create a linear combination of them.\nCNN vs Convolution\nNote that the CNNs operate differently from the traditional signal processing convolution. In the former, the convolution operation performs a dot product with the filter and the input to output a single value (and even add bias if you want to). While the latter outputs the same amount of channels.\nThe CNNs borrow the idea of a shifting kernel and a kernel response. But they do not apply a convolution operation per se. \nOperation over the RGB\nThe CNN is not operating on each channel separately. It is merging the responses of the three channels and mixing them further. The deeper you get the more mix you get over your previous results. \nThe output of your FC is just one value. If you want more, you need to add more FC neurons to get more linear combinations of your inputs.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does \"e\" do in the Sigmoid Activation Function? Within the Sigmoid Squishification function,\nf(x) = 1/(1 + e^(-x))\n\n\"e\" is unnecessary, as it can be replaced by any other value that is not 0 or 1. Why is \"e\" used here?\nAs shown below, the function is working well without that, and in replacement, any other number that's greater than 1. All of them\n\nSquish the number between 0 and 1\nReach (0, 0.5)\nMake an \"S\" curve\nHas a working derivative\nHave similar derivatives, with Maximas varying on the replacement of Euler's number\n\nThe function and derivative with \"d\" as the parameter replacement can be written as:\nconst sigmoid = (x, d) => 1/(1 + d**(-x));\nconst sigmoid_derivative = (x, d) => (d**x) * Math.log(d) / ((d**(x)) + 1)**2;\n\nhttps://www.desmos.com/calculator/xpkhdijt3v\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The choice of $e$ is convenient when taking derivatives.\nCompare $\\frac{d}{dx} \\exp(x)$ to $\\frac{d}{dx} a^x$ for any other $a > 0$.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the generation of deep style images so slow and resource-hungry? Consider these neural style algorithms which produce some art work:\n\nNeural Doodle\nneural-style\n\nWhy is generating such images so slow and why does it take huge amounts of memory? Isn't there any method of optimizing the algorithm?\nWhat is the mechanism or technical limitation behind this? Why we can't have a realtime processing?\nHere are few user comments (How ANYONE can create Deep Style images):\n\n\nAnything above 640x480 and we're talking days of heavy crunching and an insane amount of ram.\n\n\nI tried doing a 1024pixel image and it still crashed with 14gigs memory, and 26gigs swap. So most of the VM space is just the swapfile. Plus it takes several hours potentially days cpu rendering this.\n\n\nI tried 1024x768 and with 16gig ram and 20+ gig swap it was still dying from lack of memory.\n\n\nHaving a memory issue, though. I'm using the \"g2.8xlarge\" instance type.\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Real time style transfer and neural doodle is very much possible and is an active topic I see users working on to improve upon. The basic idea is to do only feed forward propagation at test time and train with appropriate loss functions at train time.\nPerceptual Losses for Real-Time Style Transfer\nand Super-Resolution is a good starting point to understand a methodology for this purpose.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Deep Q-Learning poor convergence on Stochastic Environment I'm trying to implement a Deep Q-network in Keras/TF that learns to play Minesweeper (our stochastic environment). I have noticed that the agent learns to play the game pretty well with both small and large board sizes. However, it only converges/learns when the layout of the mines is the same for each game. That is, if I randomize the mine distribution from game to game, the agent learns nothing - or near to it. I tried using various network architectures and hyperparameters but to no avail.\nI tried a lot of network architectures including:\n\nThe input to the network is the entire board matrix, with the individual cells having values of -1 if unrevealed, or 0 to 8 if revealed.\nThe output of the network is also the entire board representing the desirability of clicking each cell.\nTried fully connected hidden layers (both wide and deep).\nTried Convolutional hidden layers (tried stacked them, using different kernel sizes, padding, etc.).\nTried adding Dropout after hidden layers too.\n\nIs DQN applicable for environments that change every episode or have I approached this from the wrong side?\nIt seems no matter the network architecture, the agent won't learn. Any input is greatly appreciated. Please let me know if you require any code or further explanations.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The inputs that you describe seem like they should be sufficient for a DQN-based agent to learn a good strategy for playing Minesweeper, regardless of whether or not the starting layout changes. The inputs contain all information that is necessary.\nHowever, the problem certainly becomes much easier (probably too easy) if the initial problem is always the same. The DQN algorithm will be very likely to \"pick up\" on this trend and \"exploit\" it. The inputs may be sufficient to learn a more general Minesweeper strategy, but if it is consistently faced with the same \"level\" every single time, it will be much easier for the DQN algorithm to just memorize exactly where the mines are and play perfectly based on that memory, rather than any actual strategy. Due to the way learning is implemented (based on gradient descent), the algorithm will generally tend to converge to such an easily-reachable \"memorization\" strategy rather than something that is actually \"smart\".\nFor that reason, I do think training will be much slower in the case where the layout is randomized. I'm not just thinking along the lines of e.g. twice as slow here, but would expect multiple orders of magnitude more experience required for successful learning. That's just my educated guess though, never tried training DQN for minesweeper specifically so can't tell for sure. It might also require more elaborate hyperparameter tuning, and maybe require a different network architecture (probably require a larger network).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "2 Player Games in OpenAI Retro I have been using OpenAI Retro for awhile, and I wanted to experiment with two player games. By two player games, I mean co-op games like \"Tennis-Atari2600\" or even Pong, where 2 agents are present in one environment.\nThere is a parameter for players in the OpenAI documentation, but setting this variable to 2 does nothing in terms of the game.\nHow do you properly implement this? Can this even be done? \nThe end goal is to have 2 separate networks per one environment.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "OpenAI Retro is an extension to OpenAI Gym.\nAs such, it does not support multiple agents in multi-player environments. Instead, the environment is always presented from the perspective of a single agent that needs to solve a control problem.\nWhen there is more than one agent in a Gym problem, everything other than the first agent is considered part of the environment. Typically player 2 in 2-player problems is controlled by whatever game AI already exists.\nYou can work around this in a couple of ways, both involve you modifying existing environments, requiring a solid understanding of the integration and wrapper layers in Gym so that you can make correct edits. However you might find environments where either of these are done for you.\nIn fact, within the Retro environments, some multiplayer environments are supported using the second option below.\n1. Supply additional player(s) as part of the environment\nYou could modify the environment code so that it accepts a parameter which is the agent used to control other players. Typically such an agent would not be set up to learn, it could just be some earlier version of the agent that is learning. You would need to code the interface between the supplied agent and the game engine - taking care to allow for its potentially different view of success.\nIf a Gym environment has been set up for you (or any human) to compete against your own agent using the keyboard, that is already halfway there to this solution. You could take a look at where the Gym environment has been set up for this, and modify the code to allow for automated input as opposed to action selection by keyboard.\nThis approach probably works best for competitive games where you can use a random selection of previous agents inserted into the environment to train a next \"generation\".\n2. Present actions for multiple players as if there was a single player\nProvided the game emulator allows you to do this, you can edit the code so that multiple players are controlled at once. The Gym environment does not specify how you construct your action choices, so you are then free to split the action vector up so that parts of it are chosen by one trained agent and parts of it by another.\nYou may need to work on different views of the environment and/or reward signal in this case. For instance in a competitive game (or a co-operative game with competitive elements such as personal scores) then you will need to add custom code to re-interpret reward values compared to single player game. For something simple like Pong, that could just be that Player 2 receives the negative of Player 1's reward signal.\nThis approach probably works best for cooperative games where success is combined. In that case, you have the choice of writing any number of separate agents that control different aspects of the action space - that would include having agents that separately controlled P1 and P2 game controller inputs. \nEach agent would still effectively treat its partner as a part of the environment, so you may want to mix training scenarios so that agents for each controller did not get too co-dependent. For instance, if you hope to step in to control P1, you probably don't want the AI running P2 to have too specific expectations of P1's role and behaviour in the game.\nThis second option is what OpenAI Retro interface does. For instance Pong supports this:\nenv = retro.make(game='Pong-Atari2600', players=2)\n\nI verified this using the sample code in the documentation, which controls both paddles, and receives the reward signal as a Python list mostly [0.0, 0.0] but whenever a player scores it becomes [-1.0, 1.0] or [1.0, -1.0] depending on which player got the point.\nThis will only be supported on retro games where someone has made the effort to make it work as above. If you have a game which does not do this, but in theory supports multiplayer on the ROM, you will need to look at and alter either the AI retro wrapper or the emulator or both.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "CNNs: What happens from one neuron volume to the next? I've gone through several descriptions of CNNs online and they all leave out a crucial part as if it were trivial.\nA \"volume\" of neurons consists of several parallel layers (\"feature maps\"), each the result of convolving with a different kernel.\nBetween volumes, there is usually a step where layers are pooled and subsampled.\nThe next volume has a different number of parallel layers.\nHow do the feature maps from one volume connect to the feature maps of the next volume? Is it one-to-many? Many-to-many? Do N kernels apply to each of the M feature maps in the first volume, yielding N*M feature maps in the second volume? Are these N kernels the same for each feature map in the first volume, or do different kernels apply to each one?\nOr, is the number of maps in the second volume not necessarily a multiple of the number in the first volume? If so, do maps in the first volume get cross-synthesized somehow? Or, maybe different numbers of maps in the second volume follow from each one in the first?\nOr, is it some other of umpteen trillion possibilities?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Short answer: One to many\nLong answer:\nThe point is that you use a 3D convolution in a CNN. Each kernel has the size of n*m*C (C is the number of feature maps) and every feature map has its own kernel(=weights) and bias.\nAn example:\nThe size of layer 2 is 9x9x10 (stride 1, no padding), the kernel size is 3x3x10.\nThe dimension of the next layer would be 3x3xn (n are the number of kernels that layer 2 has).\nHere I found a very clear explanation.\nI hope this helps.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the purpose of the hidden layers? Why would anybody want to use \"hidden layers\"? How do they enhance the learning ability of the network in comparison to the network which doesn't have them (linear models)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\"Hidden\" layers really aren't all that special... a hidden layer is really no more than any layer that isn't input or output. So even a very simple 3 layer NN has 1 hidden layer. So I think the question isn't really \"How do hidden layers help?\" as much as \"Why are deeper networks better?\". \nAnd the answer to that latter question is an area of active research. Even top experts like Geoffrey Hinton and Andrew Ng will freely admit that we don't really understand why deep neural networks work. That is, we don't understand them in complete detail anyway.\nThat said, the theory, as I understand it goes something like this... successive layers of the network learn successively more sophisticated features, which build on the features from preceding layers. So, for example, an NN used for facial recognition might work like this: the first layer detects edges and nothing else. The next layer up recognizes geometric shapes (boxes, circles, etc.). The next layer up recognizes primitive features of a face, like eyes, noses, jaw, etc. The next layer up then recognizes composites based on combinations of \"eye\" features, \"nose\" features, and so on. \nSo, in theory, deeper networks (more hidden layers) are better in that they develop a more granular/detailed representation of a \"thing\" being recognized. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to deal with episode termination in Advantage Actor-Critic algorithm? Advantage Actor-Critic algorithm may use the following expression to get 1-step estimate of the advantage:\n$ A(s_t,a_t) = r(s_t, a_t) + \\gamma V(s_{t+1}) (1 - done_{t+1}) - V(s_t) $\nwhere $done_{t+1}=1$ if $s_{t+1}$ is a terminal state (end of the episode) and $0$ otherwise.\nSuppose our learning environment has a goal, collecting the goal gives reward $r=1$ and terminates the episode. Agent also receives $r=-0.1$ for every step, encouraging it to collect the goal faster. We're learning with $\\gamma=0.99$ and we terminate the episode after $T$ timesteps if the goal wasn't collected.\nFor the state before collecting a goal we have the following advantage, which seems very reasonable: $A(s_t,a_t) = 1 - V(s_t)$.\nFor the timestep $T-1$, regardless of the state, we have: $ A(s_{T-1},a_{T-1}) = r(s_{T-1}, a_{T-1}) - V(s_{T-1}) \\approx -0.1 -\\frac{-0.1}{1-\\gamma} = -0.1 + 10 = 9.9 $ \n(this is true under the assumption that we're not yet able to collect the goal reliably often, therefore the value function converges to something close to $\\frac{r_{avg}}{1-\\gamma} \\approx -10 $ ).\nUsually, $T$ is not a part of the state, so the value function has no way to anticipate the sudden change in reward-to-go. So, all of a sudden, we got a (relatively) big advantage for the arbitrary action that we took at the timestep $T-1$. Following the policy gradient rule, we will significantly increase the probability of an arbitrary action that we took at the end of the episode, even if we didn't achieve anything. This can quickly destroy the learning process.\nHow do people deal with this problem in practice? My ideas:\n\nDifferentiate between actual episode terminations and ones caused by the time limit, e.g. for them we will not replace next step value estimate with $0$.\nSomehow add $t$ to the state such that the value function can learn to anticipate the termination of the episode.\n\nAs I noticed, the A2C implementation in OpenAI baselines does not seem to bother with any of that:\n\nA2C implementation - calculation of discounted rewards\ndiscount_with_dones function\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First a small note: I don't think your expression for $A(s_{T-1}, a_{T - 1})$ looks correct. If we assume that $V(s_T) = 0$ (i.e., assume that we cannot possibly reach the goal in one single step from $s_{T - 1}$), we have:\n\\begin{align}\nA(s_{T-1}, a_{T-1}) &= r(s_{T-1}, a_{T-1}) + \\gamma V(s_{T}) (1 - done_{T}) - V(s_{T-1}) \\\\\n&= r(s_{T-1}, a_{T-1}) - V(s_{T-1}).\n\\end{align}\nIn this expression, we'd normally have that $r(s_{T-1}, a_{T-1}) = -0.1$, whereas you seem to have mistakenly taken $+0.1$ in your post.\n\nThose details aside; yes, there can be sudden bumps of positive advantage estimates as you described. This is not a problem though, this is exactly what we'd expect to happen given your description of the environment.\nYou describe an environment in which the agent is likely going to be wandering around randomly (at least when it hasn't learned a good policy yet), and incurring negative rewards over and over again. This naturally leads to negative value estimates for all encountered states. Suddenly, it does something and the episode terminates; it receives a nice reward of $0$ rather than yet another negative reward (this actually \"feels\" like a bonus, a positive reward, something more than was expected). When your agent has not yet learned a good policy that can reach the better reward of $1$, this is indeed a good result, a good action, and it rightfully should get reinforced.\nBecause this event of the episode terminating is mostly uncorrelated with the state (I say \"mostly\", because in theory it probably ends up being a slightly rarer event in states close to the goal than in states far away from the goal), it will eventually (after sufficient training time) end up occurring approximately equally often in all states. From the perspective of an agent that is oblivious to the current time step, this will be perceived as an event that can simply occur by pure chance in a nondeterministic environment.\nThis is not necessarily a problem. It can slow down learning due to increased variance in your reward observations (which can be addressed by using low learning rates / large batch sizes), but Reinforcement Learning algorithms are almost always naturally built to handle nondeterministic environments, it can work this out, it can average out all the different outcomes observed for the same state+action pairs. This is not a problem that requires dealing with.\n\n\nMy ideas:\n\nDifferentiate between actual episode terminations and ones caused by the time limit, e.g. for them we will not replace next step value estimate with $0$.\nSomehow add $t$ to the state such that the value function can learn to anticipate the termination of the episode.\n\n\nThe first idea fundamentally changes the quantity that your algorithm is learning, it will essentially make your learning algorithm incorrect. There's always a chance that it might still appear to learn something useful (many Machine Learning/Reinforcement Learning algorithms can still appear to be okay even when there are bugs/technically incorrect parts), but it'll very likely perform worse.\nThe second idea, while not necessary as explained in my answer above, may still be beneficial to learning speed provided it is done well. It may help because it can add to the power of your algorithm to \"explain\" its observations, and more importantly \"explain\" the variance in its observations.\nThe main problem I see with adding $t$ to your input is that it is not naturally a binary variable. Very often you'll find that we're just using a bunch of binary inputs in (Deep) Reinforcement Learning algorithms. When all inputs are of the same magnitude like that, it tends to be easier to get the learning process to run well, tune hyperparameters like learning rate, etc. If you suddenly plug in an additional input which can take significantly larger values (like straight up adding $t$ as an input), this will be more difficult. Adding $\\frac{t}{T}$ as an input may be better, since that will always still be bounded between $0$ and $1$.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What loss function to use when labels are probabilities? What loss function is most appropriate when training a model with target values that are probabilities? For example, I have a 3-output model. I want to train it with a feature vector $x=[x_1, x_2, \\dots, x_N]$ and a target $y=[0.2, 0.3, 0.5]$. \nIt seems like something like cross-entropy doesn't make sense here since it assumes that a single target is the correct label.\nWould something like MSE (after applying softmax) make sense, or is there a better loss function?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Actually, the cross-entropy loss function would be appropriate here, since it measures the \"distance\" between a distribution $q$ and the \"true\" distribution $p$.\nYou are right, though, that using a loss function called \"cross_entropy\" in many APIs would be a mistake. This is because these functions, as you said, assume a one-hot label. You would need to use the general cross-entropy function,\n$$H(p,q)=-\\sum_{x\\in X} p(x) \\log q(x).$$\n$ $\nNote that one-hot labels would mean that\n$$\np(x) = \n\\begin{cases}\n1 & \\text{if }x \\text{ is the true label}\\\\\n0 & \\text{otherwise} \n\\end{cases}$$\nwhich causes the cross-entropy $H(p,q)$ to reduce to the form you're familiar with:\n$$H(p,q) = -\\log q(x_{label})$$\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the state-action value function used more than the state value function? In reinforcement learning, the state-action value function seems to be used more than the state value function. Why is it so?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "We are ultimately interested in getting an optimal policy, that is the optimal sequence of actions to reach the final goal. State values on its own don't provide that, they tell you expected return from specific state onward but they don't tell you which action to take. In order to derive an optimal action in a specific state you would have to simulate all possible actions one step ahead and then pick the action that leads you to the state with highest state value. That is often inconvenient or impossible. State action values connect the expected return with actions, not states, so you don't need to simulate all actions one step ahead and see where you end up, you only need to pick an action that has the highest value because you know that is the best action to take in that state.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it possible to implement reinforcement learning using a neural network? I've implemented the reinforcement learning algorithm for an agent to play snappy bird (a shameless cheap ripoff of flappy bird) utilizing a q-table for storing the history for future lookups. It works and eventually achieves perfect convergence after enough training.\nIs it possible to implement a neural network to do function approximation in order to accomplish the purpose of the q-table? Obviously, storage is a concern with the q-table, but it doesn't seem to ever train with the neural net alone. Perhaps training the NN on an existing q-table would work, but I would like to not use a q-table at all if possible.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Andrej Karpathy's blog has a tutorial on getting a neural network to learn pong with reinforcement learning. His commentary on the current state of the field is interesting.\nHe also provides a whole bunch of links (David Silver's course catches my eye). Here is a working link to the lecture videos.\nHere are demos of DeepMinds game playing.\nGet links to the papers at Andrej Karpathy's blog above\n- rat fps\n\nnice demos at 19 minutes into this\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between artificial intelligence and robots? What is the difference between artificial intelligence and robots?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Although there are several definitions of \"robot\", an essential feature of everything called \"robot\" is that it is capable of movement. This does not necessarily mean displacement; a robot arm in a factory also moves.\nThere is a single exception to this rule, which is bot-programs like chatbots; I will discuss them later.\nArtificial Intelligence does not need to move; a chess program can be argued to be an AI, but does not move. \nA robot can actually have AI; one of the definitions of robot is that it is a system, capable of autonomous movement. In order to be autonomous, to be able to make decisions of its own, a certain amount of AI may be necessary. \nThere is one class of \"robots\" that does not move, and does not even have physical presence; bot programs, like chatbots, that operate inside systems. I do not consider them robots, because they are not physical devices operating in the real world. A chatbot can be an AI, however - a good chatbot may have some natural language processing to interact with humans in a way that humans find natural.\nTo summarize; an AI can exist purely in software. But to be a robot, there must be a moving physical component in the real world.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between asymmetric and depthwise separable convolution? I have recently discovered asymmetric convolution layers in deep learning architectures, a concept which seems very similar to depthwise separable convolutions.\nAre they really the same concept with different names? If not, where is the difference? To make it concrete, what would each one look like if applied to a 128x128 image with 3 input channels (say R,G,B) and 8 output channels?\nNB: I cross-posted this from stackoverflow, since this kind of theoretical question is maybe better suited here. Hoping it is OK...\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "They are not the same thing. \nasymmetric convolutions work by taking the x and y axes of the image separately. For example performing a convolution with an $(n \\times 1)$ kernel before one with a $(1 \\times n)$ kernel. \nOn the other-hand depth-wise separable convolutions separate the spatial and channel components of a 2D convolution. It will first perform the $(n \\times n)$ convolution on each channel separately (full kernel shape will be $(n \\times n \\times 1)$ rather than $(n \\times n \\times k)$ where $k$ is the number of channels in the previous layer) before doing a $(1 \\times 1)$ convolution to learn a relationship between the channels (full kernel size for that being $(1 \\times 1 \\times k)$)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to turn a ternary constraint into three binary constraints? I'm trying to solve problem 6.6 from the book Artificial Intelligence: A Modern Approach, by Peter Norvig and Stuart Russell.\nThis is in the context of Constraint Satisfaction Problem and how you can re-formulate some problems with the constraints expressed as a bunch of binary constraints to use the generalized solver CSP algorithm.\nBut I'm stuck with that exercise, I can't sketch a demonstration.\n\n6.6 Show how a single ternary constraint such as \"A + B = C\" can be turned into three binary constraints by using an auxiliary variable. You may assume finite domains.\n(Hint: Consider a new variable that takes on values that are pairs of others values, and consider constraints such as \"X is the first element of the pair Y.\") Next, show how constraints can be eliminated by altering the domain of variables. This completes the demonstration that any CSP can be transformed into a CSP with only binary constraints.\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Let $D_a$ be the domain for A, and $a_i$ the elements of $D_a$. Let $D_b$ and $D_c$ work similarly for $B$ and $C$ respectively.\nWe introduce $D_t = \\{t | t = (c_i - b_j, c_i)\\}$ for all $c_i$ in $D_c$ and $b_j$ in $D_b$. We can see that $\\{t[0]\\}$ (i.e. $\\{c_i - b_j, \\forall i,j\\}$) must be equal to $D_a$.\nSo we can represent the constraint on $A$ by the relation $R_At = { (a_k, t_l) | a_k = t_l[0]}$ for $a_k$ in $D_a$ and $t_l$ in $D_t$. That is, $a_k$ must equal the first element in the pair from $t_l$, which means there is a $b_j$ and a $c_i$ consistent with that $a_k$.\nThe constraint on $B$ is the relation $R_{Bt} = \\{(b_j, t_l) | b_j + t_l[0] = t_l[1]\\}$. Since $t_l$[0] = $c_i - b_j$, $t_l$[0] + $b_j$ must equal $c_i$, which is t[1], so if this holds, there is a $b_j$ in $D_b$ that is consistent with $t_l$.\nLastly, $R_{Ct} = \\{ (c_i, t_l) | c_i = t_l[1]\\}$, which is really just an identity. So what we've done is solved $A + B = C$ for $A$ and encoded that into $R_{At}$. From that solution and knowledge of the original $C$ (stored in t[1]) we can re-create $C$ from a valid $B$, which is the $R_{Bt}$ relation.\nAnd lastly $C$ must be in the original set of $C$'s used to build all the $t$'s. If all three of these constraints hold, then we must have a $C$, a $B$ used to solve for $A$, and an $A$ that matches that solution. \nThe second part is really just path-consistency. For every $A$, choose a $B$, and see if there's a possible $C = A + B$. If so, Add that those values to final domains $D_a$, $D_b$, and $D_c$. I forget if there's a better performing algorithm than this, but I doubt it since here you can use associativity of addition to avoid checking the opposite order of selecting $A$ and $B$. In general, you have to consider both orders.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How are the kernels initialized in a convolutional neural network? I am currently learning about CNNs. I am confused about how filters (aka kernels) are initialized.\nSuppose that we have a $3 \\times 3$ kernel. How are the values of this filter initialized before training? Do you just use predefined image kernels? Or are they randomly initialized, then changed with backpropagation?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The kernels are usually initialized at a seemingly arbitrary value, and then you would use a gradient descent optimizer to optimize the values, so that the kernels solve your problem.\nThere are many different initialization strategies.\n\nSet all values to a constant (for example, zero)\nSample from a distribution, such as a normal or uniform distribution\nThere are also some heuristic methods that seem to work very well in practice; a popular one is the so-called Glorot initializer, which is named after Xavier Glorot, who introduced them here. Glorot initializers also sample from distribution, but they truncate the values based on the kernel complexity.\nFor specific types of kernels, there are other defaults that seem to perform well. See for example this paper.\n\nExploring initialization strategies is something I do when my model is not able to converge (gradient problems) or when the training seems to be stuck for a long time before the loss function starts to decrease. These are signs that there might be a better initialization strategy to look for.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is reinforcement learning needed to create Strong AI? By reinforcement learning, I don't mean the class of machine learning algorithms such as DeepQ, etc. I have in mind the general concept of learning based on rewards and punishment.\nIs it possible to create a Strong AI that does not rely on learning by reinforcement, or is reinforcement learning a requirement for artificial intelligence?\nThe existence of rewards and punishment implies the existence of favorable and unfavorable world-states. Must intelligence in general and artificial intelligence, in particular, have a way of classifying world-states as favorable or unfavorable?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It's impossible to give a definitive 'yes' answer to your question, since that would require proving that alternatives cannot exist.\nMore philosophically, it depends on what you mean by \"preference over world states\":\nHowever counter-intuitive it might seem, it is conceivably possible to create Strong AI purely from local condition-action rules, in which there is no global concept of 'preference value' and/or no integrated notion of 'world state'.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How would an AI learn idiomatic phrases in a natural language? After an AI goes through the process described in How would an AI learn language?, an AI knows the grammar of a language through the process of grammar induction. They can speak the language, but they have learned formal grammar. But most conversations today, even formal ones, use idiomatic phrases. Would it be possible for an AI to be given a set of idioms, for example, \n\nImmer mit der Ruhe\n\nWhich, in German, means 'take it easy' but an AI of grammar induction, if told to translate 'take it easy' to German, would not think of this. And if asked to translate this, it would output\n\nAlways with the quiet\n\nSo, it is possible to teach an AI to use idiomatic phrases to keep up with the culture of humans?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Short answer: Yes.\nTL;DR\nIn the presence of good datasets this can be accomplished with a pipeline.\nLong Answer\nIn reality an idiom is a series of words which is supposed to have a semantic meaning that is not denoted by the literal reading (source). This means that any system that is used must be capable of considering multiple words at a time. Additionally, some idioms are context dependent. Example:\n\nThe fisherman broke the ice with his tool.\n\nAre we to believe that this is a very suave fisherman?\n\nSo, it is possible to teach an AI to use idiomatic phrases to keep up with the culture of humans?\n\nObserve that humans do not come linguistically \"pre-loaded\" with idioms. So we can safely assume that idiom usage is a learning task and that the only way for them to keep up is for them to keep learning. So if we solve the idiom learning task we just need to keep our agent online or periodically retrain it on nascent corpora.\nOne difficulty is that, in the absence of a label, a metaphor could be easily mistaken for an idiom and vice versa. So semantic outlier (sorry it's not free) approaches may suffer from precision issues. Example:\n\nShe's a thorny wildflower (metaphor - could easily be an idiom)\nShe's a diamond in the rough (idiom - could easily be a metaphor)\n\nThough, idioms will most likely be repeated if a dataset is large whereas a \"custom metaphor\" is less likely to repeat. \nAdditionally, some idioms (eg bite the bullet or break a leg) do not have readily available \"interpretable semantics\" that allow us to extract their intended meaning. For example, if one did not know the idiom \"cut me some slack\" one could think:\n\"Slack implies loosening or to make less tight/taut. I was being very uptight. They probably want me to loosen up and not be so critical.\"\nOf course the human understanding of it might happen in a flash and not follow such a delineated path. The idea is that some NLP pipeline might be constructible that satisfactorily handles idioms in some specific use cases (example of a pipeline). For example, one module might attempt to process outliers like \"diamond in the rough\" which have said interpretable semantics. Though, something like \"bite the bullet\" may have to be labelled with the correct semantics.\nI've only scratched the surface of this. Natural language understanding is already a hard problem - and idioms are thus a tough task in a tough task. I hope that this motivates the reading of some more thorough articles. I have gathered some articles that can be used as a springboard into the literature. \nHere's a source that uses a dictionary type approach to train the model to recognize idioms. Excerpt:\n\nFor identification, we assume data of the form ${(\u27e8p_i,d_i\u27e9,y_i) : i = 1...n}$ where $p_i$ is the phrase associated with definition $d_i$ and $y_i \u2208 \\{literal, idiomatic\\}$.\n\nThis source provides pseudo-code for idiom extraction.\nThis source describes a dataset to help solve the idiom difficulties.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is my test error lower than the training error? I am trying to train a CNN regression model using the ADAM optimizer, dropout and weight decay.\nMy test accuracy is better than training accuracy. But, as far as I know, usually, the training accuracy is better than test accuracy.\nSo I wonder how this is happening.\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You use dropout during traing to reduce overfitting, but this reduces the training accuracy. The dropout will not be used during testing, therefore the accuracy will be higher.\nThat's normal behavior if you work with dropout.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does Hearthstone AI deal with random events I want to learn a lot about the AI of CCG, such as Hearthstone. And now I have known one of the main algorithms that used in this kind of games, MCTS. It analyses the most promising moves, and expands the search tree based on random sampling of the search space. But there are too many random events in this game that can cause different results to one battle. For example, a card can randomly deal X damage to a hero or other follower, and X is a random number from 0 to 30. The number of X is important for the next decision, but there will be a low accuracy by only using MCTS.\nSo what does the AI do to deal with these random events?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The most \"standard\" implementation of MCTS probably involves storing copies of game states inside nodes. This works fine for deterministic games, but not for non-deterministic games due to the reasons you mentioned.\nIn non-deterministic games, one of the easiest ways to make MCTS work is to take the perspective that every node in your tree should map to / represent / encode a trajectory or sequence of actions, rather than a state. This means that every node collects statistics (num wins / num visits etc.) for the trajectory of actions it represents, rather than for the state it represents.\nThis perspective can be implemented very easily by simply not storing any game states in nodes at all. Instead, whenever you traverse the tree (in the Selection phase of MCTS), you should simply re-simulate all the actions along that path through the tree, starting from the root state again. This way, different visits through a single node can result in different game states being \"observed\" in that node due to nondeterministic game state transitions. In the limit (after an infinite amount of time), every node will estimate the expected value of the trajectory of actions leading to that node, rather than the game-theoretic value of a single, deterministic resulting game state. This whole idea is sometimes referred to as \"Open-Loop MCTS\", for example in this paper.\n\nWhat I described above is a simple way to get better performance from MCTS in games involving nondeterministic state transitions as you described (such as random amounts of damage being dealt), but there are many much more complicated ideas out there too. I suspect more complex approaches will especially be necessary to deal with more \"drastic\" forms of nondeterminism (resulting from random card draws, or resulting from randomization-based approaches for dealing with imperfect information such as not knowing which cards your opponent has).\nThere was a Hearthstone AI competition relatively recently, and some useful ideas may be found, for example, on this page of work related to that competition.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can action recognition be achieved? For example, I would like to train my neural network to recognize the type of actions (e.g. in commercial movies or some real-life videos), so I can \"ask\" my network in which video or movie (and at what frames) somebody was driving a car, kissing, eating, was scared or was talking over the phone.\nWhat are the current successful approaches to that type of problem?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are several approaches as to how this can be achieved.\nOne recent study from 2015 about Action Recognition in Realistic Sports VideosPDF uses the action recognition framework based on the three main steps of feature extraction (shape, post or contextual information), dictionary learning to represent a video, and classification (BoW framework). \nA few examples of methods:\n\nSpatio-Temporal Structures of Human Poses\n\na joint shape-motion\n\nMulti-Task Sparse Learning (MTSL)\nHierarchical Space-Time Segments\n\nSpatio-Temporal Deformable Part Models (SDPM)\n\n\nHere are the results based on training of 10 action classes based on the UCF sports dataset:\n\nSource: Action Recognition in Realistic Sports Videos.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Do we have to use CNN for Deep Q Learning? I read top articles on Google Search about Deep Q-Learning:\n\nhttps://medium.freecodecamp.org/an-introduction-to-deep-q-learning-lets-play-doom-54d02d8017d8\nhttps://skymind.ai/wiki/deep-reinforcement-learning\nhttps://neuro.cs.ut.ee/demystifying-deep-reinforcement-learning/\nQ-Learning page on wikipedia*\n\nand then I noticed that they all use CNN as approximator. If deep learning has a broader definition than just CNN, can we use the term \"Deep Q-Learning\" on our model if we don't use CNN? or is there a more appropriate definition for that kind of Q-Learning model? for example, if my model only using deep fully-connected layer.\n*it doesn't say explicitly Deep RL means CNN on RL, but it uses the DeepMind (that uses CNN) as an example on Deep Q-Learning \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "No. DQN and other deep RL methods work well with fully connected layers. Here's an implementation of DQN which doesn't use CNNs: github.com/keon/deep-q-learning/blob/master/dqn.py\nDeepMind mostly use CNN because they use image as input state, and that because they tried to evaluate performance of their methods vs humans performance. Humane performance is easy to measure at games with image as input state, and that's why CNN based methods present so promptly in RL now. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does data skew matter in classification problem? I'm working on an image classification problem using a neural network. In the training data set, 90% of the samples fall into 10% of all categories, while 10% of the sample fall into the other 90% categories. So an example is not evenly distributed among all categories. If we assume this distribution reflects the real-world distribution, do I need to filter my dataset before training so that each category has a similar number of samples?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes. Skewed data is one of the biggest problems in AI applications. As you rightly identified, the real world distribution is skewed. Doing a random sampling results in one major issue of an uneven sampling (like in your case). Even worse could happen, all of the samples may fall into a single class and other classes may not even be recognized by your classifier. This is called as the class imbalance problem.\nThere are many ways to mitigate this problem. Few of them have been mentioned here. I'll summarize them for you:\n\nSampling based mitigation (when you try to deal with skewed data)\nCost function based mitigation (when you try to improve the classifier, in case skewed data cannot be avoided)\n\nSampling based mitigation can be done by oversampling from the minority class(es), or undersampling from the majority class(es) or using a combination of both. \nAnother fairer method to do this is by doing a stratified sampling. If class A has 1/6th, class B has 2/6th and class C has 3/6th of the total population, then, you should take 1/6th of the samples by random sampling from objects in class A, 2/6th from class B and 3/6th from class C. This way all of the sample may represent the population in the right proportion, and none of the classes will be missed.\nIn case this doesn't help (say, you dataset is small and sampling doesn't make sense) and the data is skewed too much), the cost function can be modified to make a more sensible classifier. Keep different costs for misclassification and/or correct classification. Misclassification could be given a higher penalty. This could help in reaching to a better classifier with a skewed data.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is my implementation of Q-learning not converging to the right values in the FrozenLake environment? I am trying to learn tabular Q learning by using a table of states and actions (i.e. no neural networks). I was trying it out on the FrozenLake environment. It's a very simple environment, where the task is to reach a G starting from a source S avoiding holes H and just following the frozen path which is F. The $4 \\times 4$ FrozenLake grid looks like this\nSFFF\nFHFH\nFFFH\nHFFG\n\nI am working with the slippery version, where the agent, if it takes a step, has an equal probability of either going in the direction it intends or slipping sideways perpendicular to the original direction (if that position is in the grid). Holes are terminal states and a goal is a terminal state.\nNow I first tried value iteration which converges to the following set of values for the states\n[0.0688909 0.06141457 0.07440976 0.05580732 0.09185454 0. 0.11220821 0. 0.14543635 0.24749695 0.29961759 0. 0. 0.3799359 0.63902015 0. ]\n\nI also coded policy iteration, and it also gives me the same result. So I am pretty confident that this value function is correct.\nNow, I tried to code the Q learning algorithm, here is my code for the Q learning algorithm\ndef get_action(Q_table, state, epsilon):\n \"\"\"\n Uses e-greedy to policy to return an action corresponding to state\n \n Args:\n Q_table: numpy array containing the q values\n state: current state\n epsilon: value of epsilon in epsilon greedy strategy\n env: OpenAI gym environment \n \"\"\"\n return env.action_space.sample() if np.random.random() < epsilon else np.argmax(Q_table[state]) \n\n\ndef tabular_Q_learning(env):\n \"\"\"\n Returns the optimal policy by using tabular Q learning\n \n Args:\n env: OpenAI gym environment\n \n Returns:\n (policy, Q function, V function) \n \"\"\"\n \n # initialize the Q table\n # \n # Implementation detail: \n # A numpy array of |x| * |a| values\n \n Q_table = np.zeros((env.nS, env.nA))\n \n # hyperparameters\n epsilon = 0.9\n episodes = 500000\n lr = 0.81\n\n \n for _ in tqdm_notebook(range(episodes)):\n # initialize the state\n state = env.reset()\n \n if episodes / 1000 > 21:\n epsilon = 0.1\n \n t = 0\n while True: # for each step of the episode\n # env.render()\n # print(observation)\n \n # choose a from s using policy derived from Q \n action = get_action(Q_table, state, epsilon) \n \n # take action a, observe r, s_dash\n s_dash, r, done, info = env.step(action)\n \n # Q table update \n Q_table[state][action] += lr * (r + gamma * np.max(Q_table[s_dash]) - Q_table[state][action])\n \n state = s_dash\n \n t += 1\n \n if done:\n # print(\"Episode finished after {} timesteps\".format(t+1))\n break\n # print(Q_table)\n \n policy = np.argmax(Q_table, axis=1)\n V = np.max(Q_table, axis=1)\n \n return policy, Q_table, V\n\nI tried running it and it converges to a different set of values which is following [0.26426802 0.03656142 0.12557195 0.03075882 0.35018374 0. 0.02584052 0. 0.37657211 0.59209091 0.15439031 0. 0. 0.60367728 0.79768863 0. ]\nI am not getting, what is going wrong. The implementation of Q learning is pretty straightforward. I checked my code, it seems right.\nAny pointers would be helpful.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I was able to solve the problem.\nThe main issue for non-convergence was that I was not decaying the learning rate appropriately. I put a decay rate of $-0.00005$ on the learning rate lr, and subsequently Q-Learning also converged to the same value as value iteration.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to avoid falling into the \"local minima\" trap? How do I avoid my gradient descent algorithm into falling into the \"local minima\" trap while backpropogating on my neural network?\nAre there any methods which help me avoid it?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are several elementary techniques to try and move a search out of the basin of attraction of local optima. They include:\n\nProbabalistically accepting worse solutions in the hope that this\nwill jump out of the current basin (like Metropolis-Hastings acceptance in Simulated Annealing). \nMaintaining a list of recently-encountered states (or attributes thereof) and not returning\nto a recently-encountered one (like Tabu Search). \nPerforming a random walk of a length determined by the current state of the search (an explicit 'Diversification strategy', e.g. as used in 'Reactive Tabu Search').\n\nSee the excellent (and free online) book 'Essentials of Metaheuristics' by Sean Luke for more details on these kind of techniques and some rules of thumb about when and how to use them.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do Transformers have a sequence limit at inference time? As far as I understand, Transformer's time complexity increases quadratically with respect to the sequence length. As a result, during training to make training feasible, a maximum sequence limit is set, and to allow batching, all sequences smaller are padded.\nHowever, after a Transformer is trained, and we want to run it on a single sequence at inference time, the computational costs are far less than training. Thus, it seems reasonable that I would want to run the transformer on a larger input sequence length during inference time. From a technical perspective, this should be feasible.\nI keep reading online that a Transformer cannot be run on a sequence size larger than the one seen during training. Why is this? Is it because the network weights will be unfamiliar with sequences of this length? Or is it more fundamental?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Transformer models have limited sequence length at inference time\nbecause of positional embeddings. But there are workarounds.\nSelf-attention in transformer does not distinguish the order of keys/values,\nit works as if the sequence is a bag of words.\nSo to expose the sequence order to the model, one typically adds an extra\n\"positional embedding\" vector to each input token embedding.\nThis extra positional information then allows the model to construct primitives like \"attention head that looks at previous token\".\nThere are several variants of how to do this exactly.\nOne way is to use an extra trainable parameter matrix [L,M]\nwhere L is maximum input length and M is model dimension.\nAfter training a model this way, it simply becomes impossible\nto embed tokens with position > L. So we get a hard limit for which there is no workaround.\nAnother way is to use a non-trainable matrix [L,M]\ninitialized with a specially crafted set of sinusoids\n(original \"attention is all you need\" paper does this).\nA model trained this way would not have a length limit,\nbecause this matrix of sinusoids you can extend to arbitrary size.\nYes another way is to use \"relative positional encoding\".\nWith this, for each pair of tokens you take relative position,\nwhich would be in range [-L ... +L], and embed that instead.\nThen you inject this vector into attention layer in the right way\n(section 3.3 in https://arxiv.org/pdf/1901.02860.pdf).\nNow you still kind of have a limit of [-L, L].\nBut you can always \"clip\" relative position to this range,\nand pretend that all pairs of tokens at distance >= L\nhave the same relative position (\"very far from each other\").\nAnd this allows to run inference with longer inputs.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Has reinforcement learning been used to prove mathematical theorems? Coq exists, and there are other similar projects out there. Further, Reinforcement Learning has made splashes in the domain of playing games (a la Deepmind & OpenAI and other less well-known efforts).\nIt seems to me that these two domains deserve to be married such that machine learning agents try to solve mathematical theorems. Does anyone know of any efforts in this area?\nI'm a relative novice in both of these domains, but I'm proficient enough at both to take a stab at building a basic theorem solver myself and trying to make a simple agent have a go at solving some basic number theory problems. When I went to look for prior art in the area I was very surprised to find none. I'm coming here as an attempt to broaden my search space.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Artificial Intelligence for Theorem Proving is an active research area as witnessed by the existence of the AITP conference and of many publications on the topic. Some papers are mentioned in this thread: https://coq.discourse.group/t/machine-learning-and-hammers-for-coq/303. I haven't read these papers myself, so I cannot point you to a paper using reinforcement learning specifically, but given the important activity in this domain, I would be very surprised if it hadn't been attempted.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which courses in computer science and logic are relevant to Machine Learning? Although I have a decent background in math, I'm trying to understand which courses from CS and logic to look into. My aim is to get into a Machine Learning PhD program.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I worked as a professor for a time, and often advised students on this. For a PhD in machine learning, I think the ideal background is:\n\nCore CS Courses\n\nProgramming (typically 3-4 courses). Language choice is not highly important, but Python, C++, Java, and perhaps JavaScript, are reasonable picks, if only because of their prevalence.\nCore topics: data structures, algorithms, operating systems, databases\nnumerical linear algebra or numerical methods\nadvanced algorithm design and analysis\n\n\nTogether these will allow you to read and write the code that even highly optimized versions of ML algorithms are written in, and to understand what might be going wrong within them.\n2. AI & ML courses, usually offered through a CS department\n\na broad survey course in AI (like AI:AMA by Russel & Norvig), usually offered to senior undergraduates. \nA course applied machine learning or data mining. \n\nYou may also take other AI courses, but they are not as common to see offered to undergraduates, so many students wait until graduate school:\n\nreinforcement learning\nsoft computing\ncomputational learning theory\nBayesian Methods\nDeep Learning\nMultiagent Systems\nInformation Retrieval\nNatural Language Processing\nComputer Vision\nRobotics\n\nTogether, these will give you the broadest possible background in AI & ML. These can allow you to find new applications of ML, or to pull AI techniques from one area into another as you need.\n3. Statistics courses\n\na 1 or 2 term course in probability theory, ideally a version that requires and uses calculus. \nat minimum a course in statistical hypothesis testing. \n\nMuch stronger would be to also take courses in:\n\nregression\ngeneralized linear models\nexperiment design\ncausal inference\nBayesian methods\n\nThese courses allow you to reason formally and comfortably about uncertainty. They also give you the correct framework for answering questions about whether your ML algorithm is working, and what patterns an ML algorithm uncovers mean.\n4. Mathematics courses\n\n3 semesters of calculus, going at least as far as multi-variate/vector calculus. \noptionally, a more advanced course that builds on calculus, like real analysis, but only to reinforce calculus concepts.\nat least 1, and preferably 2, courses in linear algebra\nat least 1, and preferably 2, courses in discrete mathematics. \nideally, something like Knuth et al.'s Concrete Mathematics\nideally a course in advanced optimization techniques\noptionally, courses in logic, but be aware that this is almost a fringe area in AI now, and essentially irrelevant to a PhD in machine learning. The parts you need are usually covered in a broad survey AI course.\n\nThese courses give you the basic mathematical fluency to understand most machine learning algorithms well.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there an argument against using the (reviewed) predictions of a model as ground truth to further train exactly this model? I plan to use my predictions as ground truth to continue training my model. These predictions are of course reviewed during this process. Is there an argument against that (reinforcement of slight mistakes/overfitting etc.)?\n\nHere my specific use case described:\nI am using detectron's faster R-CNN implementation to train a (pretrained) model to find defects of a machine part in images.\nThe goal is to find bounding boxes around these defects and to label them.\nA colleague labeled some of the images (1500 images, making up 20% of the whole set) and I used those to train my model. Then I had the model predict defects on all 7500 images. My colleague asked me if he can review the predictions (and adjust/add if necessary) so he doesn't have to label the remaining images from scratch, and then I would like to continue the training with all the images.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Using the (unchecked) predictions of the model as training data is an approach known as \"pseudo-labeling\". It can help in certain situations, depending on the underlying structure of your dataset, but you have to be a bit careful about how you use it (e.g. only using high-confidence predictions as your pseudo-labels) and you always want to keep your pseudo-labels separate from your true labels, so you can potentially update them as your model changes.\n\nBut it sounds like you're not using the raw predictions as labels, but rather using the predictions of the models as a pointer to (currently unlabeled) examples which you then will manually label.\n\"Training on errors\" is recognized mode of augmenting your training dataset, especially for \"on-line\" style systems where you're getting a continuous stream of new examples. The concept is to identify those examples which are predicted either inaccurately or with low confidence, identify the accurate labels for these instances, and then include them with the rest of the training set to help improve the predictions for similar sorts of examples in the future.\nIn contrast to pseudo-labeling, you're looking to correct the low confidence examples or the incorrectly predicted. Adding in high-confidence examples doesn't gain you much, as your current training set is already sufficient to correctly predict these. And with an on-line model where you're continually getting new examples, adding the well-predicted examples to your training set does potentially cause issues with subclass imbalance issues, as \"normal\" examples are expected to swamp out the rare outliers.\n\nBut it sounds like you have a fixed-size training set. In that case, the standard recommendation for the best course of action of dealing with unlabeled data applies: \"pay someone to label it for you\". What you're looking for is accurate labeling. How you get that is left somewhat nebulous, so long as the labeling is accurate. Using model results as a starting point is perfectly valid, assuming that whoever is doing the checking/correction is willing to actually do all the corrections (to the same quality level as a \"from scratch\" prediction) and won't wave through the model predictions as \"ehh, good enough\".\nIn addition to label accuracy, another issue may be selection bias (that is, the model may have certain subsets of examples which it performs worse/better on, and picking which examples to include in labeling on that basis may bias future training). But if you have a pre-determined, fixed-size training set this is not really an issue if you label all of them (or a model-independent random subset). The selection bias comes not from the initial model predictions/selection, but instead the (model-independent) selection of the examples to be labeled.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are there any laws or regulations precluding AGI models from creating their own accounts for online platforms? By artificial general intelligence (AGI), I am referring to autonomous AI models that satisfy IBM\u2019s AGI definition:\n\nArtificial general intelligence (AGI) is a hypothetical stage in the development of machine learning (ML) in which an artificial intelligence (AI) system can match or exceed the cognitive abilities of human beings across any task.\n\nAre there any laws or regulations precluding AGI models from creating their own accounts for online platforms (Facebook, Stack Exchange, etc.)?\nI understand these platforms can implement rules restricting AI interactions with their sites (like how some SE sites ban the use of GenAI outright for any content generation). However, AGI is distinct from GenAI and I haven\u2019t yet seen any regulations or laws surrounding it.\nPersonally, I don\u2019t see us with AGI anytime soon, but you never know.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nAre there any laws or regulations precluding AGI models from creating their own accounts for online platforms (Facebook, Stack Exchange, etc.)?\n\nAny site that requires that the account holder is a legal entity would exclude an AI or AGI from being the \"owner\" of an account. In order to, for instance, agree to terms and conditions, you (and any bot) need to be able to enter into contracts and take legal responsibility for your actions.\nSo, this is most sites that make user accounts available.\nWhat that would mean for creating an account would then depend on other T&Cs for the site:\n\nA site that allows automation of account creation would allow you to have the AGI sign up with you being the legal person responsible for its actions in practice.\n\nA site that doesn't allow automation of account creation could legally ban bots it found signing up, and you would have no legal recourse to challenge that. The AGI would have no abilty to even start with legal recourse, because it would not count as a person in the legal sense.\n\n\nThese results would be different if AGIs were to be granted \"personhood\" in a legal sense, but that is a separate issue to any intelligence-based abilities they can exhibit. Although it is the subject of debate and conjecture, this has not happened, and seems unlikely in the next few years.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "During neural network training, can gradients leak sensitive information in case training data fed is encrypted (homomorphic)? Some algorithms in the literature allow recovering the input data used to train a neural network. This is done using the gradients (updates) of weights, such as in Deep Leakage from Gradients (2019) by Ligeng Zhu et al.\nIn case the neural network is trained using encrypted (homomorphic) input data, what could be the output of the above algorithm? Will the algorithm recover the data in clear or encrypted (as it was fed encrypted)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It will recover the encrypted inputs.\nThe algorithm starts with dummy data and dummy labels, and then iteratively optimizes the dummy gradients to be close as to the original. This makes the dummy data close to the real training data:\n$$\\mathbf{x}^{\\prime *}, \\mathbf{y}^{\\prime *}=\\underset{\\mathbf{x}^{\\prime}, \\mathbf{y}^{\\prime}}{\\arg \\min }\\left\\|\\nabla W^{\\prime}-\\nabla W\\right\\|^{2}=\\underset{\\mathbf{x}^{\\prime}, \\mathbf{y}^{\\prime}}{\\arg \\min }\\left\\|\\frac{\\partial \\ell\\left(F\\left(\\mathbf{x}^{\\prime}, W\\right), \\mathbf{y}^{\\prime}\\right)}{\\partial W}-\\nabla W\\right\\|^{2}$$\nAs the distance is minimized, the algorithm restores the original training data; in the case of encrypted training data - you should get an encrypted input (up to failures when the resulted 'input' isn't close to the original input).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the evidence equal to the KL divergence plus the loss? Why is the equation $$\\log p_{\\theta}(x^1,...,x^N)=D_{KL}(q_{\\theta}(z|x^i)||p_{\\phi}(z|x^i))+\\mathbb{L}(\\phi,\\theta;x^i)$$ true, where $x^i$ are data points and $z$ are latent variables?\nI was reading the original variation autoencoder paper and I don't understand how the marginal is equal to the RHS equation. How does the marginal equal the KL divergence of $p$ with its approximate distribution plus the variational lower bound?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In variational inference, the original objective is to minimize the Kullback-Leibler divergence between the variational distribution, $q(z \\mid x)$, and the posterior, $p(z \\mid x) = \\frac{p(x, z)}{\\int_z p(x, z)}$, given that the posterior can be difficult to directly infer with the Bayes rule, due to the denominator term, which can contain an intractable integral. \nTherefore, more formally, the optimization objective can be written as\n\\begin{align}\nq^*(z \\mid x) = \\operatorname{argmin}_{q(z \\mid x)} D_{\\text{KL}}(q(z \\mid x) \\| p(z \\mid x))\\tag{1} \\label{1}\n\\end{align}\nHowever, solving this optimization problem can be as difficult as the original inference one of computing the posterior $p(z \\mid x)$ using the Bayes rule, given that it still involves the possibly intractable term $p(z \\mid x)$.\nIf you use the definition of the KL divergence, you can derive the following equation\n\\begin{align}\nD_{\\text{KL}}(q(z \\mid x) \\| p(z \\mid x)) = \\mathbb{E}_{q(z \\mid x)} \\left[ \\log q(z \\mid x) \\right] - \\mathbb{E}_{q(z \\mid x)} \\left[ \\log q(z, x) \\right] + \\log p(x) \\tag{2} \\label{2}\n\\end{align}\nFirst, note that the expectations are with respect to the variational distribution, which means that, if you want to approximate these expectations with Monte Carlo estimates, you can do it with respect to the variational distribution, and, given that it is assumed that one can easily sample from the variational distribution (which can e.g. be a Gaussian), this is a nice feature. \nSecond, the KL divergence contains the term $p(x) = \\int_z p(x, z)$, the denominator term in the Bayes rule to compute the posterior $p(z \\mid x)$, which (as I said) can be intractable. $p(x)$ is often called the evidence.\nThe solution is then to optimize an objective that does not contain this annoying intractable term $p(x)$. The objective that is optimized is the so-called ELBO objective\n\\begin{align}\n\\text{ELBO}(q) = \\mathbb{E}_{q(z \\mid x)} \\left[ \\log q(z, x) \\right] - \\mathbb{E}_{q(z \\mid x)} \\left[ \\log q(z \\mid x) \\right]\\tag{3} \\label{3}\n\\end{align}\nThe KL divergence \\ref{2} and the ELBO objective \\ref{3} are similar. In fact, ELBO is an abbreviation for Evidence Lower BOund, because the ELBO is a lower bound on the evidence $p(x)$, i.e. it is a number that is smaller than $p(x)$ or, more formally, $\\text{ELBO}(q) \\leq \\log p(x)$. Therefore, if we maximize $\\text{ELBO}(q)$, we also maximize the evidence $p(x)$ of the data (where $x$ is the data in your dataset). \nSo, the objective in variational inference is\n\\begin{align}\nq^*(z \\mid x) \n&= \\operatorname{argmax}_{q(z \\mid x)} \\operatorname{ELBO}({q}) \\\\\n&= \\operatorname{argmax}_{q(z \\mid x)} \\mathbb{E}_{q(z \\mid x)} \\left[ \\log q(z, x) \\right] - \\mathbb{E}_{q(z \\mid x)} \\left[ \\log q(z \\mid x) \\right]\n\\tag{4} \\label{4}\n\\end{align}\nFirst, note that \\ref{4} only contains terms that depend on the variational distribution, so we got rid of intractable terms, which was our goal.\nSecond, note that, as opposed to \\ref{1}, we are maximizing (or finding the parameters that maximize the objective).\nThe ELBO objective is actually the negative of \\ref{2} plus the logarithm of the evidence term, $\\log p(x)$ (and you can easily verify it), that is\n\\begin{align}\n\\text{ELBO}(q) = -D_{\\text{KL}}(q(z \\mid x) \\| p(z \\mid x)) + \\log p(x)\n\\end{align}\nwhich can also be rearranged as\n\\begin{align}\n\\log p(x) = D_{\\text{KL}}(q(z \\mid x) \\| p(z \\mid x)) + \\text{ELBO}(q) \\tag{5}\\label{5}\n\\end{align}\nwhich is your equation (where $\\text{ELBO}(q)$ is your $\\mathcal{L}$). Therefore, your equation is true by definition, i.e. we define the ELBO such that \\ref{5} is true. However, note that we haven't defined the ELBO in the way we dit only for the sake of it, but because it is a lower bound on the log evidence (and this follows from the fact that the KL divergence is never negative).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How are continuous actions sampled (or generated) from the policy network in PPO? I am trying to understand and reproduce the Proximal Policy Optimization (PPO) algorithm in detail. One thing that I find missing in the paper introducing the algorithm is how exactly actions $a_t$ are generated given the policy network $\\pi_\\theta(a_t|s_t)$.\nFrom the source code, I saw that discrete actions get sampled from some probability distribution (which I assume to be discrete in this case) parameterized by the output probabilities generated by $\\pi_\\theta$ given the state $s_t$.\nHowever, what I don't understand is how continuous actions are sampled/generated from the policy network. Are they also sampled from a (probably continuous) distribution? In that case, which type of distribution is used and which parameters are predicted by the policy network to parameterize said distribution?\nAlso, is there any official literature that I could cite which introduces the method by which PPO generates its action outputs?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As long as your policy (propensity) is differentiable, everything's is good. Discrete, continuous, other, doesn't matter! :)\nA common example for continuous spaces is the reparameterization trick, where your policy outputs $\\mu, \\sigma = \\pi(s)$ and the action is $a \\sim \\mathcal{N}(\\mu, \\sigma)$.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When should we use separable convolution? I was reading the \"Deep Learning with Python\" by Fran\u00e7ois Chollet. He mentioned separable convolution as following\n\nThis is equivalent to separating the learning of spatial features and\nthe learning of channel-wise features, which makes a lot of sense if\nyou assume that spatial locations in the input are highly correlated,\nbut different channels are fairly independent.\n\nBut I could not understand what he meant by saying \"correlated spatial locations\". Can some explain what he means or the purpose of separable convolutions? (except performance-related part).\nEdit: Separable convolution means that first depthwise convolution is applied then pointwise convolution is applied.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Context of the question\nThis is a link to the text cited in the question.\nIt refers to the usage of SeparableConv2D (tf, keras name). A related question on StackOverflow is \"What is the difference between SeparableConv2D and Conv2D layers\". This answer points to this excellent article by Chi-Feng Wang:\nA Basic Introduction to Separable Convolutions\nAnswer to the question\nIn image processing, a separable convolution converts a NxM convolution to two convolutions with kernels Nx1 and 1xM. Using this idea, in NN a SeparableConv2D converts a WxHxD convolution (width x height x depth, where depth means number of incoming features ) to two convolutions with kernels WxHx1 and 1x1xD.\nNote the first kernel doesn't handles information across features, thus, it is \"learning of spatial features\". The 1x1xD kernel doesn't handles different points, it is \"learning of channel-wise features\".\nAbout the phrase \"spatial locations in the input are highly correlated\", my understanding of what the author means is: Assume we have a channel (feature) image that each pixel measures the \"distance to the background\". When we pass from one pixel to a neighbors one, it is expected some continuity in the value (except for edge pixels): correlation. Instead, if we have a channel that measures \"brightness\" and another one that measures \"distance to background\" the two values for one specific pixel has little correlation.\nFinally, about title question \"When should we use separable convolution?\" : if the final output must depend of some features of one pixel and some other features of neighbors pixels in a very unpredictable way, a complete WxHxD convolution must be used. However if, as is more usual, you can handle first spatial dependencies (neighborhood) to extract pixel features and next handle pixel-by-pixel these features to get the output, better use a WxHx1 followed by 1x1xD, saving lots of network parameters, thus, saving training time.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do larger language models still fail on simple compositional reasoning tasks? Large language models often perform impressively on benchmark tasks, coding, and natural language generation, but they can still fail on reasoning problems that seem simple for humans, especially when multiple constraints must be combined step by step.\nI want to understand this from a technical perspective.\nWhy do these models remain weak on compositional reasoning despite scaling in parameter count and training data?\nIs this primarily a limitation of autoregressive next-token prediction, training objective mismatch, lack of symbolic structure, or benchmark contamination effects?\nI\u2019m looking for an explanation grounded in model architecture and learning behavior rather than anecdotal examples.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Simple answer: LLM are not designed for Reasoning.\nAs I suppose you know, they are designed to generate the most likely next word (token) in a sequence.\nMore to the point...\n\ndespite scaling in parameter count and training data?\n\nBrute force can only get you so far, law of diminishing returns...\n\nIs this primarily a limitation of autoregressive next-token prediction\n\nYes. As simple as that.\n\ntraining objective mismatch\n\nYou can say that as well, they are not trained for Reasoning.\nDon't expect LLM is equivalent to AI (*)\nI'd say that for Reasoning we need to make the AI (intentionally not using LLM here) to learn more like humans do, explore the environment.\n(*) I disagree we need to dilute the classic AI (because allegedly we already achieved AI - or was that Turingian AI?) and invent other abstractions / refined goals (?) as AGI, etc.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Smallest possible network to approximate the $sin$ function The main goal is: Find the smallest possible neural network to approximate the $sin$ function.\nMoreover, I want to find a qualitative reason why this network is the smallest possible network.\nI have created 8000 random $x$ values with corresponding target values $sin(x)$. The network, which am currently considering, consists of 1 input neuron, 3 neurons in two hidden layers, and 1 output neuron:\nNetwork architecture:\n\nThe neural network can be written as function\n$$y = sig(w_3 \\cdot sig(w_1 \\cdot x) + w_4 \\cdot sig(w_2 \\cdot x)),$$\nwhere $\\text{sig}$ is the sigmoid activation function.\n$tanh$ activation function:\nWhen I use $tanh$ as an activation function, the network is able to hit the 2 extrema of the $sin$ function:\n$tanh$ activation function\" />\nSigmoid activation function:\nHowever, when I use the sigmoid activation function $\\text{sig}$, only the first extremum is hit. The network output is not a periodic function but converges:\n\nMy questions are now:\n\nWhy does one get a better approximation with the $tanh$ activation function? What is a qualitative argument for that?\nWhy does one need at least 3 hidden neurons? What is the reason that the approximation with $tanh$ does not work anymore, if one uses only 2 hidden neurons?\n\nI really appreciate all your ideas on this problem!\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Before anything, the function you have wrote for the network lacks the bias variables (I'm sure you used bias to get those beautiful images, otherwise your tanh network had to start from zero).\nGenerally I would say it's impossible to have a good approximation of sinus with just 3 neurons, but if you want to consider one period of sinus, then you can do something. for clarity look at this picture:\n\nI've write the code for this task in colab and you can find it here, and you can play with it if you want.\nIf you run the network several times you may get different results (because of different initializations) and you can see some of them at the Results section of the link above. What you showed us in the images above are just two possibilities. But it's interesting that you can get better results with tanh rather than sigmoid and if you want to know why, I highly recommend you to look at this lecture of CS231n. In summary it's because tanh has the negative part and the network can learn better with it.\nBut actually their power of approximation are almost similar because 2*sigmoid(1.5*x) - 1 almost looks the same as tanh(x) and you can find it by looking the picture below:\n\nSo why you can't get the same results as tanh? that's because tanh suits the problem better and if the network wants to get the same result as tanh with sigmoid it should learn their transformation parameters and learning these parameters makes the learning task harder. So It's not impossible to get the same result with sigmoid but it's harder. And to show you that its possible, I have set the parameters of the network using sigmoid manually and got the result below (you can get better results if you have more time):\n\nAt last if you want to know why you can't get the same result with 2 neurons instead of 3 neurons, it's better to understand what does the network do with 3 neurons.\nIf you look at the output of the first layer, you may see something like this (which are outputs of two neurons it has):\n\nThen the next layer gets the difference between the output of these two neurons (which is like sinus) and applies sigmoid or tanh to it, and that's how you get a good result. But when you have just one neuron in the first layer, you can't imagine some scenario like this and approximating one period of sinus is out of it's ability (underfitting).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there any good reference for double deep Q-learning? I am new in reinforcement learning, but I already know deep Q-learning and Q-learning. Now, I want to learn about double deep Q-learning. \nDo you know any good references for double deep Q-learning? \nI have read some articles, but some of them don't mention what the loss is and how to calculate it, so many articles are not complete. Also, Sutton and Barto (in their book) don't describe that algorithm either. \nPlease, help me to learn Double Q-learning.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "If you're interested in the theory behind Double Q-learning (not deep!), the reference paper would be Double Q-learning by Hado van Hasselt (2010). \nAs for Double deep Q-learning (also called DDQN, short for Double Deep Q-networks), the reference paper would be Deep Reinforcement Learning with Double Q-learning by Van Hasselt et al. (2016), as pointed out in\n ddaedalus's answer. \nAs for how the loss is calculated, it is not explicitly written in the paper. But, you can find it in the Dueling DQN paper, which is a subsequent paper where Van Hasselt is a coauthor. In the appendix, the authors provide the pseudocode for Double DQN. The relevant part for you would be:\n\n$y_{j}=\\left\\{\\begin{array}{ll}r & \\text { if } s^{\\prime} \\text { is terminal } \\\\ r+\\gamma Q\\left(s^{\\prime}, a^{\\max }\\left(s^{\\prime} ; \\theta\\right) ; \\theta^{-}\\right), & \\text {otherwise}\\end{array}\\right.$\nDo a gradient descent step with loss $ \\left\\|y_{j}-Q(s, a ; \\theta)\\right\\|^{2}$\n\nHere, $y_j$ is the target, $\\theta$ are the parameters of the regular network and $\\theta^{-}$ are the target network parameters.\nThe most important thing to note here is the difference with the DQN target:\n$y_{i}^{D Q N}=r+\\gamma \\max _{a^{\\prime}} Q\\left(s^{\\prime}, a^{\\prime} ; \\theta^{-}\\right)$. \nIn DQN, we evaluate the Q-values based on parameters $\\theta^{-}$ and we take the max over actions based on these Q-values parametrized with the same $\\theta^{-}$. The problem with this is that it leads to an overestimation bias, especially at the beginning of the training process, where the Q-values estimates are noisy. \nIn order to address this issue, in double DQN, we instead take the max based on Q-values calculated using $\\theta$ and we evaluate the Q-value of $a^{max}$ based on a different set of parameters i.e. $\\theta^{-}$.\nIf you want to learn more about this, by watching a video lecture instead of reading a paper, I'd suggest you take a look at this lecture from UC Berkley's DRL course, where the professor (Sergey Levine) discusses this in detail with examples. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How could AI solve planet's major problems? I had been reading that AI could solve planet's major problems. How could it be done? For example, how exactly could AI be applied to address climate change? What are examples of applications of AI to solve these problems? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There's indeed a lot of research work being done in this field.\nHere are a few ways in which AI can help/is helping in fighting major problems:\nClimate change\n\nIdentify deforestation and the rate at which it's happening using computer vision and help in fighting back based on how critical the rate is.The World Resources Institute had entered into a partnership with Orbital Insight on this.\n\nProtecting Nature\n\nResearchers and institutes are using computer vision to accurately identify total remaining members of extremely threatened species to observe their behavior and patterns that can help in protecting them, keep track and monitor at an individual level.\nEnvironmental/ Research agencies are trying to detect sounds from ocean audio from which they can identify inhabiting fish and route the ships away from threatened habitats.\n\nEnergy\n\nOptimise energy usage based on consumption in big companies to save energy for public use and in turn reduce energy overall demands on the grid.\nPredict the demand for energy and ensure continuous supply matching the demand. For example, Google's Deepmind is in talks National Grid of UK on this.\n\nOf course, these ideas might look too tiny or too broad at first sight, but I feel taking one step at a time and then quickly expanding the ideas into wider areas would be the way to go, like how DeepMind is doing it in the area of energy. Other areas like education, transportation, and healthcare are seeing lots of activity with the involvement of AI too.\nFor further reading, here's what World Economic Forum thinks about how AI can help solve world's problems.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the conditions of convergence of temporal-difference learning? In reinforcement learning, temporal difference seem to update the value function in each new iteration of experience absorbed from the environment. \nWhat would be the conditions for temporal-difference learning to converge in the end? How is it guaranteed to converge?\nAny intuitive understanding of those conditions that lead to the convergence?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are different TD algorithms, e.g. Q-learning and SARSA, whose convergence properties have been studied separately (in many cases). \nIn some convergence proofs, e.g. in the paper Convergence of Q-learning: A Simple Proof (by Francisco S. Melo), the required conditions for Q-learning to converge (in probability) are the Robbins-Monro conditions\n\n$\\sum_{t} \\alpha_t(s, a) = \\infty$\n$\\sum_{t} \\alpha_t^2(s, a) < \\infty,$\n\nwhere $\\alpha_t(s, a)$ is the learning rate at time step $t$ (that can depend on the state $s$ and action $a$), and that each state is visited infinitely often. \n(The Robbins-Monro conditions (1 and 2) are due to Herbert Robbins and Sutton Monro, who started the field of stochastic approximation in the 1950s, with the paper A Stochastic Approximation Method. The fields of RL and stochastic approximation are related. See this answer for more details.)\nHowever, note again that the specific required conditions for TD methods to converge may vary depending on the proof and the specific TD algorithm. For example, the Robbins-Monro conditions are not assumed in Learning to Predict by the Methods of Temporal Differences by Richard S. Sutton (because this is not a proof of convergence in probability but in expectation).\nMoreover, note that the proofs mentioned above are only applicable to the tabular versions of Q-learning. If you use function approximation, Q-learning (and other TD algorithms) may not converge. Nevertheless, there are cases when Q-learning combined with function approximation converges. See An Analysis of Reinforcement Learning with Function Approximation by Francisco S. Melo et al. and SBEED: Convergent Reinforcement Learning with Nonlinear Function Approximation by Bo Dai et al.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is this proof of $\\epsilon$-greedy policy improvement correct? The following paragraph about $\\epsilon$-greedy policies can be found at the end of page 100, under section 5.4, of the book \"Reinforcement Learning: An Introduction\" by Richard Sutton and Andrew Barto (second edition, 2018).\n\nbut with probability $\\varepsilon$ they instead select an action at random. That is, all nongreedy actions are given the minimal probability of selection, $\\frac{\\varepsilon}{|\\mathcal{A}(s)|}$, and the remaining bulk of the probability, $1-\\varepsilon+\\frac{\\varepsilon}{|\\mathcal{A}(s)|}$, is given to the greedy action. The $\\varepsilon$-greedy policies are\n\nSo, the non-greedy actions are given the probability $\\frac{\\varepsilon}{|\\mathcal{A}(s)|}$, and the greedy action is given the probability $1-\\varepsilon+\\frac{\\varepsilon}{|\\mathcal{A}(s)|}$. All clear up to this point.\nHowever, I have a doubt in the policy improvement theorem that is mentioned in page 101, under section 5.4. I have enclosed a copy of this proof for your convenience:\n$$\n\\begin{aligned}\nq_{\\pi}(s, \\pi^{\\prime}(s)) &=\\sum_{a} \\pi^{\\prime}(a \\mid s) q_{\\pi}(s, a) \\\\\n&=\\frac{\\varepsilon}{|\\mathcal{A}(s)|} \\sum_{a} q_{\\pi}(s, a)+(1-\\varepsilon) \\max _{a} q_{\\pi}(s, a) \\\\\n& \\geq \\frac{\\varepsilon}{|\\mathcal{A}(s)|} \\sum_{a} q_{\\pi}(s, a)+(1-\\varepsilon) \\sum_{a} \\frac{\\pi(a \\mid s)-\\frac{\\varepsilon}{|\\mathcal{A}(s)|}}{1-\\varepsilon} q_{\\pi}(s, a)\\\\\n&=\\frac{\\varepsilon}{|\\mathcal{A}(s)|} \\sum_{a} q_{\\pi}(s, a)-\\frac{\\varepsilon}{|\\mathcal{A}(s)|} \\sum_{a} q_{\\pi}(s, a)+\\sum_{a} \\pi(a \\mid s) q_{\\pi}(s, a) \\\\\n&=v_{\\pi}(s) .\n\\end{aligned}\n$$\nMy question is shouldn't the greedy action be chosen with a probability of $1-\\varepsilon+\\frac{\\varepsilon}{|\\mathcal{A}(s)|}$?\nThe weighing factors do not add up to 1, as they are probability values. With this argument, the proof (with a slight modification) would be:\n$$\n\\begin{aligned}\nq_{\\pi}(s, \\pi^{\\prime}(s)) \n&=\\sum_{a} \\pi^{\\prime}(a \\mid s) q_{\\pi}(s, a) \\\\\n&=\\frac{\\varepsilon}{|\\mathcal{A}(s)|} \\sum_{a} q_{\\pi}(s, a)+ \\left( 1-\\varepsilon+\\frac{\\varepsilon}{|\\mathcal{A}(s)|} \\right) \\max _{a} q_{\\pi}(s, a) \\\\\n& \\geq \\frac{\\varepsilon}{|\\mathcal{A}(s)|} \\sum_{a} q_{\\pi}(s, a)+\\left(1-\\varepsilon+\\frac{\\varepsilon}{|\\mathcal{A}(s)|} \\right) \\sum_{a} \\frac{\\pi(a \\mid s)-\\frac{\\varepsilon}{|\\mathcal{A}(s)|}}{1-\\varepsilon+\\frac{\\varepsilon}{|\\mathcal{A}(s)|} } q_{\\pi}(s, a)\\\\\n&=\\frac{\\varepsilon}{|\\mathcal{A}(s)|} \\sum_{a} q_{\\pi}(s, a)-\\frac{\\varepsilon}{|\\mathcal{A}(s)|} \\sum_{a} q_{\\pi}(s, a)+\\sum_{a} \\pi(a \\mid s) q_{\\pi}(s, a) \\\\\n&=v_{\\pi}(s) .\n\\end{aligned}\n$$\nThough the end result isn't changed, I just want to know what I am conceptually missing, in order to understand the proof that is originally provided.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The weights do sum to one. Note that in the second line where we have \n$$\\frac{\\epsilon}{|\\mathcal{A}(s)|} \\sum_a q_{\\pi}(s,a) + (1-\\epsilon)\\max_aq_{\\pi}(s,a) \\; ,$$\nthe sum is over the whole action space, including the greedy action, so the sum of the weights will be $\\frac{\\epsilon}{|\\mathcal{A}(s)|} \\times |\\mathcal{A}(s)| + (1-\\epsilon) = 1$. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Understanding multi-iteration updates of the model in the Proximal Policy Optimization algorithm I have a general question about the updating of the network/model in the PPO algorithm.\nIf I understand it correctly, there are multiple iterations of weight updates done on the model with data that is created from the environment (with the model before the update). Now, I think that the updates of the model weights are not correct anymore after the first iteration/optimization step, because the model weights changed and therefore the training data is outdated (since the model would now give different actions in the environment and therefore different rewards).\nBasically, in the pseudo-code of the algorithm, I don't understand the line \"Optimize surrogate L ... with K epochs...\". If the update is done for multiple epochs, the data that is learned is outdated already after the first iteration of optimization, since the model's weights changed. In other algorithms, like A2C, there is only one optimization step done, instead of $K$ epochs.\n\nIs this some form of approximation or augmentation on the data by using the data that was created by an older model for multiple iterations or am I missing something here? If yes, where was this idea first introduced or better described? And where is an (empirical) proof that this still leads to a correct weight updating?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Seems this question was asked and answered in openai/baselines github issue. The issue has been closed for a while.\nBelow is an answer provided by @matthiasplappert which has the most \"thumbs up\":\n\nTo clarify: PPO is an on-policy algorithm so you are correct that going over the same data multiple times is technically incorrect.\nHowever, we found that PPO is actually quite okay with doing this and we still get stable convergence. This is likely due to the proximal trust region constrained that we enforce, which means that the policy cannot change that much anyway when going over the current set of transitions multiple times, making it still approximately on-policy. You can of course get rid of this but then you'll need more samples.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it feasible to train a Machine Learning Model (with image inputs) in an average personal computer? There are lots of examples of machine learning systems that can recognize objects and extract other information from images with very high precision. To train the models of such systems is necessary (I guess) a computer with a lot of computational power. \nMy question is: For a system with images as inputs, depending on the complexity of the problem, is feasible to train a model in an average laptop? It will take to much time?\nI know the time taken to train any machine learning model will be a function of lots of variables. I really don't expect a quantitative answer here, I just want to know whether I will be forced to upgrade my computer to develop and train machine learning models that have images as inputs.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You may play around on an average laptop but training will be very slow and you will be limited on the size of your model.\nOnce you try to build something more serious you will run out of memory very fast. A system with a GPU is recommended if you want to really do things like image recognition. If you buy something I would not go for any GPU with less than 8 GB memory and for an X99 motherboard to keep the flexibility to add a second GPU on full speed later if needed.\nDon't mix up image recognition running on phones etc. Those are trained models and actually just being applied that is much easier process. Training is way much more expensive.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Has anybody tried unsupervised deep learning from youtube videos? YouTube has a huge amount of videos, many of which also containing various spoken languages. This would presumably provide something like the data that a \"challenged\" baby would experience - \"challenged\" meaning a baby without arms or legs (unfortunately many people are born that way). \nWould this not allow unsupervised learning in a deep learning system that has both vision and audio capabilities? The neural network would presumably learn correlations between words and images, and could perhaps even learn rudimentary language skills, all without human supervision. I believe that the individual components to do this already exist.\nHas this been tried, and if not, why?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Answer is quite yes, please have a look what Google did around this:\n\nGoogle Cloud Video Intelligence makes videos searchable, and discoverable, by extracting metadata with an easy to use REST API. You can now search every moment of every video file in your catalog. It quickly annotates videos stored in Google Cloud Storage, and helps you identify key entities (nouns) within your video; and when they occur within the video.\n\nhttps://cloud.google.com/video-intelligence/\nSo, Google does recognize all kinds of data from the video: it classifies the whole content of it to tags.\nWhat about Humanoid Robot Sophia?\n\nCameras within Sophia's eyes combined with computer algorithms allow her to see. She can follow faces, sustain eye contact, and recognize individuals. She is able to process speech and have conversations using a natural language subsystem. \n\nhttps://en.wikipedia.org/wiki/Sophia_(robot)\nThese intent to the direction to understand (Google) and produce (Sophia) language from sounds and images. To learn think by themselves, machines are still not ready. If you get into these two cases more you would see that these are quite mechanical and manual (requiring human pre-effort) things still.\nIt is said that machines are now on a phases of toddler who can ask names for things around her and name them. Take some years more, maybe the abilities are more advanced ;)\nedit:\nYou asked about unsupervised learning. There is a video about speech of MIT researcher, who made experiments on text and images and in final notes he denoted that it would be nice to make the same with videos, actually with the same reasoning you had: to learn a language. He promised to keep that in mind with his colleagues, maybe some of them already work on that.\nedit2:\nInteresting research paper on the topic was on this link :\n\nWe address the problem of automatically learning the\n main steps to complete a certain task, such as changing a\n car tire, from a set of narrated instruction videos. The con-\n tributions of this paper are three-fold. [..] Third, we experimentally demonstrate that the proposed method can automatically discover, in an unsupervised manner, the main steps to achieve the task and locate the steps in the input videos.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between neural networks and other ways of curve fitting? For simplicity, let's assume we want to solve a regression problem, where we have one independent variable and one dependent variable, which we want to predict. Let's also assume that there is a nonlinear relationship between the independent and dependent variables.\nNo matter the way we do it, we just need to build a proper curved line based on existing observations, such that the prediction is the best.\nI know we can solve this problem with neural networks, but I also know other ways to create such curves. For example:\n\nsplines\n\nkriging\n\nlowess\n\nSomething I think would also work (do not know if exists): fitting curve using a series of Fourier sine waves, and so on\n\n\nMy questions are:\n\nIs it true that neural networks are just one of the ways to fit a non-linear curve to the data?\n\nWhat are the advantages and disadvantages of choosing a neural network over other approaches? (maybe it becomes better when I have many independent variables, and another little guess: maybe the neural network is better in omitting the effect of linear dependent input variables?)\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nIn some sense, you're right that a neural net is just another tool to fit data. However, it's quite the tool! There's this universal approximation theorem saying that, under decent conditions, a neural network can get as close as you want to a wide class of functions. This means that you can get the network to give you complicated shapes with squiggles all over if that's the right trend.\n\nThe universal approximation theorem is a big upside. You don't have to specify that you want to model with sine curves or a particular type of spline. You just let the computer figure that out for you. The result is the ability to model complex patterns and make accurate predictions. The drawback is that the modeling can pick up on coincidences in the data that look like a trend but are not. This causes overfitting. When your goal is to make accurate predictions, a model that has badly overfit does nothing for you. A second drawback is that neural networks are hard to interpret. A third drawback is that they can take a long time to train, while a linear regression is just a matrix inversion and a few matrix products (the $\\hat{\\beta}=(X^TX)^{-1}X^Ty$).\n\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Has any research been done on DNN Music? DNNs are typically used to classify things (of course) but can we let them go wild with sounds and then tell them if we think it sounds good or not? I'd like to think after a training class has been made (perhaps comparing the output to an existing song) we could get an NN that has a basic concept of music.\nTiming would be an issue; I'm not sure how feasible this is. A strongly weighted input attached to all hidden layers perhaps? Use it as the bias?\nIs this even slightly feasible? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The first thing is to define what is a \u00abgood\u00bb and a \u00abbad\u00bb sound. This is an extremely tricky issue, since the networks need numeric inputs. And music is whole bunch of numbers.\nI know from people doing research in identifying how similar two sounds are, and imitation, say: you hear a sound and try to make another that sounds like it. Like when you hum a song or similar. That is by no means easy. These guys are using something similar to feature extraction, with Fourier transforms and energy and such things. They feed the networks with the (selected) features and... Train. \nNow, to return to your original question: *What do you present as target during training?* You can present different types of music as categories and classify (I couldn't help but think on this research with fish). Or you define categories of music you like and see if the network can classify them ;)\nOne basic decision here is how long you get a piece of sound. Since it is needed to analyse frequency, this is a key issue. Since you talked about DNN, I was wondering if you wanted to do it online, as a stream, in which case I don't have the slightest idea where to begin, other than do it after a little while.\n\nOther idea: I remember a little sketch in this series about a researcher that makes use of the relations between peaks in the Fourier spectrum in order to differentiate noise from music.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is the distance between pointers in Stochastic Universal Sampling determined? I'm studying about different selection methods in genetic algorithms. My question is about the Stochastic Universal Sampling (SUS) selection method. I know that each individual will occupy a segment of the line according to its fitness value and then equally spaced pointers will be placed over this line.\nI want to know how the distance between pointers is determined. I have seen 1/6 and 1/4 as the distance between pointers. I want to choose the number of pointers dynamically according to the situation. I want to know what conditions or factors affect the determination of this distance. For example, when do we decide to choose 1/4 as distance? I want to know if it is possible to change the number of samples in each iteration according to different conditions or situations. If so, what are these conditions?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As originally conceived in James Baker's 1989 paper Reducing bias and inefficiency in the selection algorithm, Stochastic Universal Sampling accepts a population containing $N$ individuals, and a number of parents to sample, denoted $n$. Assuming fitness values are normalized so that they sum up to $N$, at each step, a new pointer is placed a step equal in size to the fraction $\\frac{N}{n}$ ahead of the location of the previous pointer (and the location of the first pointer is set to a random value in the range [0, $\\frac{N}{n}$) ). So, for example, if you want to sample 6 individuals from a population of size 10, you would make steps of size $\\frac{10}{6}$, spacing your pointers at even intervals of $\\frac{10}{6}$.\nModern implementations, like the one on Wikipedia sometimes do not document this fact clearly, although it is apparent what is intended if you already understand the method. They often write the step size as $\\frac{F}{n}$, where $F$ is the total fitness of the population, without discussing its relation to the size of the population. The extra normalization step is actually not essential, so modern implementations generally seem to skip it.\nSo in summary, the step size $\\frac{F}{n}$ used if fitness values of a population sum to $F$, and you want to select $n$ individuals. If you want to select more individuals, use a higher value for $n$. If you want to select fewer, use a lower value for $n$, which updates your step size accordingly.\nValues of this parameter of $\\frac{1}{4}$ or $\\frac{1}{6}$ suggest that the implementation may be normalizing the sum of fitness values is being normalized to N, and then using the parameter as a multiplicative factor automatically. This is a fairly reasonable design. You could interpret these values as \"Select $\\frac{1}{4}$ of the population\" and \"Select $\\frac{1}{6}$ of the population\". \nNote that this sort of bumps your question up a level: how do you pick the fraction of the population to keep? That question doesn't have a clean answer, and picking it is generally an art developed by experts through practice. It is very closely related to the exploration/exploitation tradeoff. \nSome ways you might pick $n$:\n\nUse a fixed value, for instance, keep half the population at each step. The exact proportion you will want to pick is not something you can know in advance. Expert practitioners can make effective guesses. Others will need to just try out different values using a technique like cross validation, and pick whichever one seems to work best.\nYou can use a value that changes over time. A common strategy for this would be to use one of the temperature schedules developed in the simulated annealing literature, and keep a portion of the population that was inversely proportionate to the temperature. That is, early on, you'd use a large $n$, and keep most of the population around (probably with mutations). Later, you'd use a small $n$ and keep only the best individuals around.\nYou could use a value of $n$ that changes in response to the fitness of the population. This is much like the adaptive learning rates used in some algorithms to train neural networks (most notably: the ADAM optimizer). When fitness levels have a lot of variety, use low values of $n$ to encourage more exploitation. When fitness levels are all within a narrow band, use high values of $n$ to encourage more exploration. \n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is second-order backpropagation useful? Raul Rojas's book on Neural Networks dedicates section 8.4.3 to explaining how to do second-order backpropagation, that is, computing the Hessian of the error function with respect to two weights at a time.\nWhat problems are easier to solve using this approach rather than first-order backpropagation?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Second-order optimization algorithms like Hessian optimization have more information on the curvature of the loss function, so converge much, much faster than first-order optimization algorithms like gradient descent. I remember reading somewhere that if you have $n$ weights in the neural network, one iteration of a second-order optimization algorithm will reduce the loss function at approximately the same rate as $n$ iterations of a standard first-order optimization algorithm. However, with recent advancements to gradient descent (momentum, adaptive rates, etc), the difference isn't as large anymore -- @EmmanuelMess pointed out a paper that states:\n\nThe performance of the proposed first order and second order methods with adaptive gain (BP-AG, CGFR-AG, BFGS-AG) with standard second order methods without gain (BP, CGFR, BFGS) in terms of speed of convergence evaluated in the number of epochs and CPU time. Based on some simulation results, it\u2019s showed that the proposed algorithm had shown improvements in the convergence rate with 40% faster than other standard algorithms without losing their accuracy.\n\nHere is a great post explaining the background behind the math of why this is the case.\nAlso, second-order gradients can help the optimizer identify states like saddle points, and help the solver get out of those states. Saddle points give standard gradient descent a lot of issues, as the gradient descent has difficulty and is slow to move out of the saddle point. Fixing the saddle point issue is one of the motivations for improving gradient descent over the last two decades (SDG with momentum, adaptive learning rates, ADAM, etc). More info.\n\nThe issue though is that to compute the second-order derivative requires a matrix $n^2$ in size, as opposed to gradient descent which requires a matrix $n$ in size. The memory and computation become intractable for large networks, especially if you have millions of weights.\nSome approaches exist which efficiently approximates the second-order optimizations, solving the tractability problem. A popular one is L-BFGS. I haven't played around with it much, but I believe L-BFGS is not as popular as gradient descent algorithms (such as SGD-M, ADAM) because it is still very memory demanding (requires storing about 20-100 previous gradient evaluations), and cannot work in a stochastic context (you cannot sample mini-batches to train on; you must train the entire dataset in one pass per iteration). If those two are not an issue for you, then L-BFGS works pretty well I believe.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can an AGI convince another AGI to modify its code? Let's suppose there are two AGIs, $A$ and $B$. Assume that $B$ has the ability to modify $A$, but this action of modifying is considered bad by $B$. Can $A$ ever convince $B$ to modify $A$?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "An AI takes the decision based on the output of their utility function. This is just a fancy word for the calculations that AI perform to compare profit and loss of taking a certain decision. \nThere is always a tight analogy between an AGI and a human. You can juxtapose the utility function to how we make decisions by considering marginal profits of doing something over the other.\nNow your question. The answer is a big NO. This is because an AI (or a human) never takes an action that gives a low score on its utility function or is against the fundamental view of the machine (or human). AI only cares about the utility function and goal state (plus the instrumental goals), nothing else. Our AI outside the box has been created with the purpose of not opening the box. For it, the action of opening the box has a very low score, or a negative score.\nNow you might be wondering why an AI can't be convinced of doing something that gives a low score in its utility function. Keep reading.\nConsider this for a second. Suppose an AGI was created, assigned with the task of copying the handwriting of others and improving its own writing. You can think of it as a smart writing hand. Now, what this AI might come up with is that, in order to practice writing, it needs more pages and thus it needs to cut more trees for that. No matter what you do, AI will not stop from cutting more and more trees. It might even replicate itself into machines that will cut trees for him. Now, the only thing that can be done is to turn off the AGI. But, a smart machine would have known the possibility of being turned off and thus will have transferred itself to many other machines over the globe. The important question to ask here is, why it is doing all this? It is not because the machine wants to live, as we humans want to. The only reason why it wants to live is to fulfill its goal.\nYou simply can't change the fundamental view of the machine. The change can result in, the machine not able to attain its goal or not to that extend (optimal profit). This is the reason why you can't convince a machine to do something that it was asked not to do as its primary task.\nYou, as a person, are living a life now, and have some fundamental beliefs. Let us consider that you believe in not killing someone. Now, suppose that I give you a pill, and tell you that after taking this pill it will rewire your brain and you will kill the first four people you see. But, after that, you will achieve pure satisfaction and happiness. Now you will definitely not take that pill as it conflicts with something that you believe in now. Also, you will try your best and fight back not to take that pill. The same thing applies to an AGI too. It doesn't matter what your future version will feel or attain after rewiring of the brain (changes in code), it is what and who you are now matters. This video link will help.\nI hope it answers your question. There are lots of things to consider here. I have assumed a few things and tried to answer according to that. \nThere is one more thing. We don\u2019t tell the machines how to do something, instead, we only tell them what to do (at least in the case of an AI). This is because sometimes we don't know the optimal way of solving certain problems. In the case of your question, we don't know what these two machines will do or say to each other. It will be a very interesting thing to hear or watch.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How should I handle invalid actions in a grid world? I'm building a really simple experiment, where I let an agent move from the bottom-left corner to the upper-right corner of a $3 \\times 3$ grid world.\nI plan to use DQN to do this. I'm having trouble handling the starting point: what if the Q network's prediction is telling the agent to move downward (or leftward) at the beginning?\nShall I program the environment to immediately give a $-\\infty$ reward and end this episode? Will this penalty make the agent \"fear\" of moving left again in the future, even if moving left is a possible choice?\nAny suggestions?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In a toy environment, this is a choice you can make relatively freely, depending on what you want to achieve with the learning challenge.\nIt may help if you think through what the actual consequences for making the \"wrong\" move are in your environment. There are a few self-consistent options:\n\nThe move simply cannot be made and count as playing the game as intended. In which case, do not allow the agent to make that choice. You can achieve that by filtering the list of choices that the agent is allowed to make. In DQN that will mean supplying an action mask to the agent based on the state so it does not include the action at the stage it makes a choice. This \"available actions\" function is usually coded as part of the environment.\n\nThe move can be attempted, but results in no change to state (e.g. the agent bumps into a wall). If the goal is to reach a certain state in shortest possible time, then you will typically have 0 reward and a discount factor, or negative reward for each attempted action. Either way, the agent should learn that the move was wasted and avoid it after a few iterations.\n\nThe move can be attempted, but results in disaster (e.g. the agent falls off a cliff). This is the case where a large negative reward plus ending the episode is appropriate. However, don't use infinite rewards, positive or negative, because that will cause significant problems with numeric stability. Simply large enough to offset any interim positive rewards associated with that direction should be adequate. For a simple goal-seeking environment with no other positive rewards than reaching the goal, ending the episode early is already enough.\n\n\nWhen you don't have a toy environment where you get to decide, then the three basic scenarios above can still help. For instance, in most board games we are not interested in having the agent learn the rules for valid moves when they are already supplied by the environment, so the first scenario applies - only select actions from the valid ones as provided by the environment.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can we compute the ratio between the distributions if we don't know one of the distributions? Here is my understanding of importance sampling. If we have two distributions $p(x)$ and $q(x)$, where we have a way of sampling from $p(x)$ but not from $q(x)$, but we want to compute the expectation wrt $q(x)$, then we use importance sampling. \nThe formula goes as follows: \n$$\nE_q[x] = E_p\\Big[x\\frac{q(x)}{p(x)}\\Big]\n$$\nThe only limitation is that we need a way to compute the ratio. Now, here is what I don't understand. Without knowing the density function $q(x)$, how can we compute the ratio $\\frac{q(x)}{p(x)}$? \nBecause if we know $q(x)$, then we can compute the expectation directly. \nI am sure I am missing something here, but I am not sure what. Can someone help me understand this? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The rationale behind importance sampling is that $q(x)$ is difficult to sample from but easy to evaluate. Or at least you can easily evaluate some $\\tilde{q}$ such that:\n$$\n\\tilde{q}(z) = Zq(z)\n$$\nwhere $Z$ (scalar) might be unknown. The geometrical example would be here e.g. sampling uniformly from an area under the curve $q(x)$ (in general it's not easy).\n\nBecause if we know $q(x)$, then we can compute the expectation directly.\n\nThat's the task we're trying to solve to begin with. And calculating expectation might be hard if we can't sample efficiently from $q$. \nSay you want to compute an expectation of $x$, $E[x]$. For this you need to calculate the following integral:\n$$\nE[x] = \\int{xq(x)dx}\n$$\nwhere $q$ is a probability distribution of $x$ for which you have an expression - so you can evaluate $q(x)$ (up to the constant of proportionality). This integral might be hard to evaluate analytically so we need to use other methods such as Monte Carlo. Let's say it is hard to generate samples from $q$ (as per example above, e.g. generating samples from the area under the curve $q(x)$ uniformly). \nWhat you can do is to calculate an expectation under a simple distribution $p$ (proposal distribution) which is a distribution of your choice that needs to allow you to easily sample from it (say Gaussian). Then you can rewrite your integral as:\n$$\nE_q[x] = \\int{xq(x)dx} = \\int{xq(x) \\color{blue}{\\frac{p(x)}{p(x)}} dx}\n= \\int{x \\frac{q(x)}{\\color{blue}{p(x)}} \\color{blue}{p(x)} dx}\n= E_p \\Big[{x\\frac{q(x)}{p(x)}}\\Big]\n$$\n(added index $p$ and $q$ to expectation to denote the sampling distribution). Now you can approximate the last expectation by Monte Carlo:\n$$\nE_p \\Big[{x\\frac{q(x)}{p(x)}}\\Big] = \\frac{1}{S} \\sum_{s}{x^{(s)} \\frac{q(x^{(s)})}{p(x^{(s)})} }, \\ x^{(s)} \\sim q(x)\n$$\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the state-of-the-art meta-reinforcement learning methods? This question can seem a little bit too broad, but I am wondering what are the current state-of-the-art works on meta reinforcement learning. Can you provide me with the current state-of-the-art in this field?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "One of the most recent papers on meta-RL is meta-Q-learning. This paper introduces Meta-Q-Learning (MQL), a new off-policy algorithm for meta-reinforcement learning (meta-RL). MQL builds upon three simple ideas.\n\nQ-learning is competitive with state-of-the-art meta-RL algorithms if given access to a context variable that is a representation of the past trajectory.\n\nUsing a multi-task objective to maximize the average reward across the training tasks is an effective method to meta-train RL policies.\n\npast data from the meta-training replay buffer can be recycled to adapt the policy on a new task using off-policy updates\n\n\nExperiments on standard continuous-control benchmarks suggest that MQL compares favorably with state-of-the-art meta-RL algorithms.\nI think that other references to other work on meta-RL are present in the experiments part of the MQL paper.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is the state transition matrix known to the agents in a Markov decision processes? The question is more or less in the title.\nA Markov decision process consists of a state space, a set of actions, the transition probabilities and the reward function. If I now take an agent's point of view, does this agent \"know\" the transition probabilities, or is the only thing that he knows the state he ended up in and the reward he received when he took an action?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In reinforcement learning (RL), there are some agents that need to know the state transition probabilities, and other agents that do not need to know. In addition, some agents may need to be able to sample the results of taking an action somehow, but do not strictly need to have access to the probability matrix. This might be the case if the agent is allowed to backtrack for instance, or to query some other systems that simulates the target environment.\nAny agent that needs to have access to the state transition matrix, or look-ahead samples of the environment is called model-based. The model in this case can either be a distribution model i.e. the state transition matrix, or it can be a sampling model that simulates the outcome from a given state/action combination.\nThe state transition function $p(r, s'|s, a)$ which returns the probability of observing reward $r$ and next state $s'$ given the start state $s$ and action $a$, is another way to express the distribution model. It often maps simply to the state transition matrix, but can be a more complete description of the model.\nOne example model-based approach is Value Iteration, and that requires access to the full distribution model in order to process value update steps. Also, any reinforcement learning that involves planning must use some kind of model. MCTS, as used in AlphaGo, uses a sampling model for instance.\nMany RL approaches are model-free. They do not require access to a model. They work by sampling from the environment, and over time learn the impact on expected results due to behaviour of the unknown state transition function. Example methods that do this are Monte Carlo Control, SARSA, Q learning, REINFORCE.\nIt is possible to combine model-free and model-based methods by using observations to build an approximate model of the environment, and using it in some form of planning. Dyna-Q is an approach which does this by simply remembering past transitions and re-using them in the background to refine its value estimates. Arguably, the experience replay table in DQN is a similar form of background planning (the algorithm is essentially the same). However, more sophisticated model-learning and reuse is not generally as successful, and is not seen commonly in practice. See How can we estimate the transition model and reward function?\nIn general, model-based methods on the same environment can learn faster than model-free methods, since they start with more information that they do not need to learn. However, it is quite common need to learn without having an accurate model available, so there is lots of interest in model-free learning. Sometimes an accurate model is possible in theory, but it would be more work to calculate predictions from the model than to work statistically from the observations.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is AI capable to replace pilots entirely on the commercial flights? Since we've self-driving cars already, would we have self-flying commercial flights in the near future? Basically the AI which can do take off, flying, landing and parking.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Self-flight is already running on all commercial airlines, but only at the cruising altitude. When you flight from London to New York, most of the time the pilots are monitoring the autopilot systems. Running AI on cruising altitude is arguably a simper problem than self-driving cars. The system has been in-place for years.\nThe real danger of airlines is taking off/landing. As you can imagine, the costs for a bad judgement could be quite serious. Anything could happen while the plane is still under the clouds. While our AI technology is improving, it will never replace human intervention, especially when the costs of collision is very high. If you don't believe me, google for how Facebook is hiring humans for reading \"fake news\". Facebook has publicity acknowledged AI will never be sufficient for them, then why would AI good enough for replacing well trained pilots?\nAI on a commercial airplane is already taking place, but there is no possibility ever it will take over the world. We will always need pilots who knows how to work with the system, making important decisions.\nTrained pilots + good AI assistance will make the world a better place.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Do neurons of a neural network model a linear relationship? I'm certain that this is a very naive question, but I am just beginning to look more deeply at neural networks, having only used decision tree approaches in the past. Also, my formal mathematics training is more than 30 years in the past, so please be kind. :)\nAs I'm reading Fran\u00e7ois Chollet's book on Deep Learning with Python, I'm struck that it appears that we are effectively treating the weights (kernel and biases) as terms in the standard linear equation ($y=mx+b$). At page 72 of the book, the author writes\noutput = dot(W, input) + b\noutput = (output < 0 ? 0 : output)\n\nAm I reading too much into this, or is this correct (and so fundamental I shouldn't be asking about it)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In a neural network (NN), a neuron can act as a linear operator, but it usually acts as a non-linear one. The usual equation of a neuron $i$ in layer $l$ of an NN is \n$$o_i^l = \\sigma(\\mathbf{x}_i^l \\cdot \\mathbf{w}_i^l + b_i^l),$$ \nwhere $\\sigma$ is a so-called activation function, which is usually a non-linearity, but it can also be the identity function, $\\mathbf{x}_i^l$ and $\\mathbf{w}_i^l$ are the vectors that respectively contain the inputs and the weights for neuron $i$ in layer $l$, and $b_i^l \\in \\mathbb{R}$ is a bias. Similarly, the output of a layer of a feed-forward neural network (FFNN) is computed as\n$$\\mathbf{o}^l = \\sigma(\\mathbf{X}^l \\mathbf{W}^l + \\mathbf{b}^l).$$\nIn your specific example, you set the new weight to $0$, if the output of the linear combination is less than $0$, else you use the output of the linear combination. This is the definition of the ReLU activation function, which is a non-linear function.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How should I define the action space for a card game like Magic: The Gathering? I'm trying to learn about reinforcement learning techniques. I have little background in machine learning from university, but never more than using a CNN on the MNIST database.\nMy first project was to use reinforcement learning on tic-tac-toe and that went well.\nIn the process, I thought about creating an AI that can play a card game like Magic: The Gathering, Yu-gi-oh, etc. However, I need to think of a way to define an action space. Not only are there thousands of combinations of cards possible in a single deck, but we also have to worry about the various types of decks the machine is playing and playing against.\nAlthough I know this is probably way too advanced for a beginner, I find attempting a project like this, challenging and stimulating. So, I looked into several different approaches for defining an action space. But I don't think this example falls into a continuous action space, or one in which I could remove actions when they are not relevant.\nI found this post on this stack exchange that seems to be asking the same question. However, the answer I found didn't seem to solve any of my problems.\nWouldn't defining the action space as another level of game states just mask the exact same problem?\nMy main question boils down to:\nIs there an easy/preferred way to make an action space for a game as complex as Magic? Or, is there another technique (other than RL) that I have yet to see that is better used here?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are several different ways you can model the state and action spaces in such sequential (extensive-form) environments/games. For environments with small action spaces or those typically introduced to beginning-RL students, the state space and action space remains constant along an agent's trajectory (termed normal form games when there are multiple agents). In sequential games which can be illustrated as trees, a \"state\" is analogous to \"information set\" which is defined as the sequence (tuple) of actions and observations since the beginning of the game's episode. Terminal states (leaf nodes) exist, and the action space $\\mathcal{A}[x]$ at an information set $x$ can be defined as a union of action sequences that can be taken to each terminal state, not counting terminal states that cannot be reached from the current information set.\nIn the above examples, I discussed games such as the examples you stated where more than one agent can interact with the environment, but this is a generalization over RL and can be applied to when only one agent is maximizing its reward.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do recommendation systems work? How do recommendation systems (e.g. on Youtube) work? Apparently, every user gets different recommendations depending on his location, his past liked videos, etc. So it would seem like a training model is applied to every single user, but that can't be possible, so how are these recommendations user-specific without applying a unique training model to every single user?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Let me try to explain how recommender systems work in production, as intuitively as possible:\nLet's say we want to build a rec sys. for a restaurant discovery product, where users can rate restaurants, add reviews, photos, etc and also order food from there.\nSo, the user's feed will have a list of restaurants in his/her area. But, as I gain money from restaurants in the $-per-click model, I need to maximize the number of times a user clicks on a restaurant.\nAlso, it is obvious that a user is more likely to click on a restaurant if he tends to like it the most. [Restaurant features being Cost-for-two, cuisines, ratings, etc]\nSo here, a user is a data point and so is the restaurant. So, let's say the distance between the user vectors and the restaurant is the \"likeability\" of the user for the restaurant.\nLet's say the vector is in the form [Japanese Spanish Mexican Chinese Indian Thai Turkish Lebanese]\nLet's say a restaurant's vector is: A = [0 0 0 1 1 0 0 0]\nand the user's is: B = [2 23 4 53 43 21 2 45]\nEach number being a particular cuisine. For restaurant, it is yes or no (1 or 0), a.k.a whether the cuisine is served or not.\nFor user, it can be the number of clicks he/she did on restaurants with that cuisine. (I am over-simplifying here. But, this can be as complex as a weighted score for clicks+transactions+content_generated like review, ratings, etc)\nNow, the the cosine similarity measure between the 2 vectors in an 8-dimensional space (length of the vector) is the likeability score.\nNow, the system uses these scores while doing it's feed ranking for each user. \nThis can be near-realtime to being updated hourly/daily, depending on the servers the company can afford.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is the discount not needed in a deterministic environment for Reinforcement Learning? I'm now reading a book titled as \"Deep Reinforcement Learning Hands-On\" and the author said the following on the chapter about AlphaGo Zero:\n\nSelf-play\nIn AlphaGo Zero, the NN is used to approximate the prior probabilities of the actions and evaluate the position, which is very similar to the Actor-Critic (A2C) two-headed setup. On the input of the network, we pass the current game position (augmented with several previous positions) and return two values. The policy head returns the probability distribution over the actions and the value head estimates the game outcome as seen from the player's perspective. This value is undiscounted, as moves in Go are deterministic. Of course, if you have stochasticity in the game, like in backgammon, some discounting should be used.\n\nAll the environments that I have seen so far are stochastic environments, and I understand the discount factor is needed in stochastic environment.\nI also understand that the discount factor should be added in infinite environments (no end episode) in order to avoid the infinite calculation.\nBut I have never heard (at least so far on my limited learning) that the discount factor is NOT needed in deterministic environment. Is it correct? And if so, why is it NOT needed?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The motivation for adding the discount factor $\\gamma$ is generally, at least initially, based simply in \"theoretical convenience\". Ideally, we'd like to define the \"objective\" of an RL agent as maximizing the sum of all the rewards it gathers; its return, defined as:\n$$\\sum_{t = 0}^{\\infty} R_t,$$\nwhere $R_t$ denotes the immediate reward at time $t$. As you also already noted in your question, this is inconvenient from a theoretical point of view, because we can have many different such sums that all end up being equal to $\\infty$, and then the objective of \"maximizing\" that quantity becomes quite meaningless. So, by far the most common solution is to introduce a discount factor $0 \\leq \\gamma < 1$, and formulate our objective as maximizing the discounted return:\n$$\\sum_{t = 0}^{\\infty} \\gamma^t R_t.$$\nNow we have an objective that will never be equal to $\\infty$, so maximizing that objective always has a well-defined meaning.\n\nAs far as I am aware, the motivation described above is the only motivation for a discount factor being strictly necessary / needed. This is not related to the problem being stochastic or deterministic.\nIf we have a stochastic environment, which is guaranteed to have a finite duration of at most $T$, we can define our objective as maximizing the following quantity:\n$$\\sum_0^T R_t,$$\nwhere $R_t$ is a random variable drawn from some distribution. Even in the case of stochastic environments, this is well-defined, we do not strictly need a discount factor.\n\nAbove, I addressed the question of whether or not a discount factor is necessary. This does not tell the full story though. Even in cases where a discount factor is not strictly necessary, it still might be useful. \nIntuitively, discount factors $\\gamma < 1$ tell us that rewards that are nearby in a temporal sense (reachable in a low number of time steps) are more important than rewards that are far away. In problems with a finite time horizon $T$, this is probably not true, but it can still be a useful heuristic / rule of thumb.\nSuch a rule of thumb is particularly useful in stochastic environments, because stochasticity can introduce greater variance / uncertainty over long amounts of time than over short amounts of time. So, even if in an ideal world we'd prefer to maximize our expected sum of undiscounted rewards, it is often easier to learn how to effectively maximize a discounted sum; we'll learn behaviour that mitigates uncertainty caused by stochasticity because it prioritizes short-term rewards over long-term rewards.\nThis rule of thumb especially makes a lot of sense in stochastic environments, but I don't agree with the implication in that book that it would be restricted to stochastic environments. A discount factor $\\gamma < 1$ has also often been found to be beneficial for learning performance in deterministic environments, even if afterwards we evaluate an algorithm's performance according to the undiscounted returns, likely because it leads to a \"simpler\" learning problem. In a deterministic environment there may not be any uncertainty / variance that grows over time due to the environment itself, but during a training process there is still uncertainy / variance in our agent's behaviour which grows over time. For example, it will often be selecting suboptimal actions for the sake of exploration.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What's the difference between LSTM and GRU? I have been reading about LSTMs and GRUs, which are recurrent neural networks (RNNs). The difference between the two is the number and specific type of gates that they have. The GRU has an update gate, which has a similar role to the role of the input and forget gates in the LSTM.\nHere's a diagram that illustrates both units (or RNNs).\n\nWith respect to the vanilla RNN, the LSTM has more \"knobs\" or parameters. So, why do we make use of the GRU, when we clearly have more control over the neural network through the LSTM model?\nHere are two more specific questions.\n\nWhen would one use Long Short-Term Memory (LSTM) over Gated Recurrent Units (GRU)?\n\nWhat are the advantages/disadvantages of using LSTM over GRU?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "On the same problems, sometimes GRU is better, sometimes LSTM. \nIn short, having more parameters (more \"knobs\") is not always a good thing. The training process needs to learn those parameters. There is a higher chance of over-fitting, amongst other problems. \nThe parameters are assigned specific roles inside either GRU or LSTM, so if that role is less important for a specific learning challenge, then it can be wasteful or even counter-productive to have the system attempt to learn values for them.\nThe only way to find out if LSTM is better than GRU on a problem is a hyperparameter search. Unfortunately, you cannot simply swap one for the other, and test that, because the number of cells that optimises a LSTM solution will be different to the number that optimises a GRU.\n\nWhen would one use Long Short-Term Memory (LSTM) over Gated Recurrent Units (GRU)?\n\nWhen it proves better, experimentally. In some problem domains, this may be established and you can check. However, in other problem domains if either GRU or LSTM works well enough to solve a problem (and the superiority of either LSTM or GRU is not the main point of the work), then it may not so clear.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do you encode a chess move in a neural network? In a neural network for chess (or checkers), the output is a piece or square on the board and an end position.\nHow would one encode this?\nAs far as I can see choosing a starting square is 8x8=64 outputs and an ending square is 8x8=64 outputs. So the total number of possible moves is 64x64 4096 outputs. Giving a probability for every possible move.\nIs this correct? This seems like an awful lot of outputs!\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The number is 4672 from Google.\n\nhttps://arxiv.org/pdf/1712.01815.pdf\n\nA move in chess may be described in two parts: selecting the piece to move, and then\nselecting among the legal moves for that piece. We represent the policy \u03c0(a|s) by a 8 \u00d7 8 \u00d7 73\nstack of planes encoding a probability distribution over 4,672 possible moves. Each of the 8\u00d78\npositions identifies the square from which to \u201cpick up\u201d a piece.\n\n4672 might sound a big number but it's nothing to what Google (and many other competitors) has been doing to deep learning for image analysis. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is an embedding a representation of a word or its meaning? What does the term \"embedding\" actually mean?\nAn embedding is a vector, but is that vector a representation of a word or its meaning? Literature loosely uses the word for both purposes. Which one is actually correct?\nOr is there anything like: A word is its meaning itself?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "An embedding is a representation of a word that can be used as a proxy for some of its linguistic properties.\nThe 'human' representation of a word, a sequence of letters and other symbols, is not related at all to its meaning or use in actual text. It only serves as a look-up key into our cognitive language processing facility (however that actually works) which enables us to understand the meaning in the context of its usage. However, a computer system does not have such a facility.\nIn order to convert the character string into something more usable for language processing, embeddings are created. These are typically vectors describing other words that surround a word in question (as the meaning of a word depends on its context). There are obvious problems with ambiguities (eg is bank the side of a river or a place where you deposit money?), but there are probably ways around that.\nSo the embedding (a vector) represents the usage of a word, which strongly correlates with its meaning. Because words as character sequences are useless for most sub-symbolic processing, the terms embedding and word are possibly used interchangably.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to stop DQN Q function from increasing during learning? Following the DQN algorithm with experience replay:\nStore transition $\\left(\\phi_{t}, a_{t}, r_{t}, \\phi_{t+1}\\right)$ in $D$ Sample random minibatch of transitions $\\left(\\phi_{j}, a_{j}, r_{j}, \\phi_{j+1}\\right)$ from $D$ Set\n$$y_{j}=\\left\\{\\begin{array}{cc}r_{j} & \\text { if episode terminates at j+1} \\\\ r_{j}+\\gamma \\max _{d^{\\prime}} \\hat{Q}\\left(\\phi_{j+1}, a^{\\prime} ; \\theta^{-}\\right) & \\text {otherwise }\\end{array}\\right.$$\nPerform a gradient descent step on $\\left(y_{j}-Q\\left(\\phi, a_{j} ; \\theta\\right)\\right)^{2}$ with respect to the network parameters $\\theta$.\n\nWe calculate the $loss=(Q(s,a)-(r+Q(s+1,a)))^2$.\n\n\nAssume I have positive but changing rewards. Meaning, $r>0$.\n\nThus, since the rewards are positive, by calculating the loss, I notice that almost always $Q(s)< Q(s+1)+r$.\nTherefore, the network learns to always increase the $Q$ function , and eventually, the $Q$ function is higher in same states in later learning steps.\nHow can I stabilize the learning process?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I changed the rewards to be negative and positive by substructing the mean reward. \nIt seems to improve the Q function boundries.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "\"AI will kill us all! The machines will rise up!\" - what is being done to dispel such myths? Science Fiction has frequently shown AI to be a threat to the very existence of mankind. AI systems have often been the antagonists in many works of fiction, from 2001: A Space Odyssey through to The Terminator and beyond.\nThe Media seems to buy into this trope as well. And in recent years we have had people like Elon Musk warn us of the dangers of an impending AI revolution, stating that AI is more dangerous than nukes.\nAnd, apparently, experts think that we will be seeing this AI revolution in the next 100 years.\nHowever, from my (albeit limited) study of AI, I get the impression that they are all wrong. I am going to outline my understanding below, please correct me if I am wrong:\n\nFirstly, all of these things seem to be confusing Artificial Intelligence with Artificial Consciousness. AI is essentially a system to make intelligent decisions, whereas AC is more like the \"self-aware\" systems that are shown in science fiction.\n\nNot AI itself, but intelligence and intelligent decision-making algorithms are something we've been working with and enhancing since before computers have been around. Moving this over to an artificial framework is fairly easy. However, consciousness is still something we are learning about. My guess is we won't be able to re-create something artificially if we barely understand how it works in the real world.\n\nSo, my conclusion is that no AI system will be able to learn enough to start thinking for itself, and that all our warnings of AI are completely unjustified.\n\nThe real danger comes from AC, which we are a long, long way from realizing because we are still a long way off from defining exactly what consciousness is, let alone understanding it.\n\n\n\nSo, my question is, assuming that my understanding is correct, are any efforts are being made by companies or organizations that work with AI to correct these popular misunderstandings in sci-fi, the media, and/or the public?\nOr are the proponents of AI ambivalent towards this public fear-mongering?\nI understand that the fear mongering is going to remain popular for some time, as bad news sells better than good news. I am just wondering if the general attitude from AI organizations is to ignore this popular misconception, or whether a concerted effort is being made to fight against these AI myths (but unfortunately nobody in the media is listening or cares).\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Nothing. \nIts in almost everyone's favor for it to stay that way financially. Having non-technical individuals associate AI with terminators makes a perception that the field has greater capabilities than it does $\\rightarrow$ this leads to grants, funding, etc... \nIs there any negative? Yes. Misconceptions always have drawbacks. We see the creation of dumb ethics boards and such cough cough Elon Musk.\nBut if history has anything to say about this, as the field gains popularity (which it is dnagerously quick), information will spread by definition, and eventually misconceptions will be laid to rest.\nNote that this answer is biased and based upon my own opinions\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What makes learned feature detectors specialize in CNN? It has been shown that it is possible to use unsupervised learning techniques to produce good feature detectors in CNNs. I can't understand what drives specialization of those feature detectors. In publications https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf (page 6) they show a very reasonable set of edge and blob detectors with little or no overlap. It goes against intuition - in absence of incentive to specialize, one would expect at least some duplication of learned kernels.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You are thinking along the correct line when you consider intuitivity when examining the strange self-specialization aspect of the layers in any deep network that has been tuned, through toil, mental machinations, and late nights, to work.\nDo AI experimenters manipulated parameters, topology, and algorithmic hierarchies to force circuit evolution that produces data flows through specialized functions like this one.\n\nNoisy, normalized, cubes (horizontal, vertical, depth) of integers straight from video hardware or the video channel of a multimedia file\nIndications of edges\nIndications of corners, ends, and bends\nIndications of relative angles (in the case of size independent recognition)\nIndications of shapes\nIndications of 2D topology\nIndications of object forms\nIndication of scene\nIndication of action (when a hypercube is used and frame is another dimension)\n\nOf course, one could design a solution and then tune layers, one by one, to follow the design, but it is not necessary because of the concept of entropy removal, the elimination of information that is redundant or irrelevant.\nThe principle in information science is this, in general: As redundancy is removed from the information, the number of bits representing the information decreases and the level of abstraction increases.\nIn minimalist art, a single word an identical twin might say to the other twin as the train rolls away, or a good Pictionary player, given a small window of information passing opportunity, adaptations can be made to pass large amounts of information base on previously agreed upon conventions.\nWhen you think of it this way, it makes sense that by narrowing the bit width of the aggregate data representation from layer to layer that only certain parametric optimizations will provide an end-to-end indication of convergence, given a goal such as fully categorizing objects based on a small number of features.\nWhen Leibniz envisioned a world tied together by mathematical certainty, he was overly optimistic, however he was correct in at least one important respect, mathematics had a reality all its own. The success of Newtonian mechanics is one early example of a huge reality that has become apparent and has been so widely applicable, deduced from a thought experiment involving a cannon ball and the moon.\nThere are few demonstrations of discoveries that originally appear to be wild inventions than the amazingly accurate prediction of the previously anomalous orbit of Mercury. But Einstein was not surprised by his success. He had deduced general relativity from the challenge of Ernst Mach and the undeniable results from light and gravity experiments. He discovered how it must be before it was found.\nIn the same sense, the above sequence of events can be proven mathematically to be the efficient strategy for vision. The sequence of processes to transform incoming visual signals to collision avoidance control was there in mathematics before there were visual receptors on microbes. That is why the narrowing of the visual pathways of a Pterodactyl have similarities to those of a shark shark even though their common ancestor may not have been able to see.\nThe incentive to specialize is the incentive to converge on the objective even after redundancy is stripped by force by limiting the information channel aperture. Even if the aperture is in multiple dimensions, the same principle applies.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Would a general-purpose AI need to collaborate? Human beings are more productive in groups than individually, possibly due to the fact that there is a limit to how much one human brain can improve itself in terms of speed of computation and areas of expertise.\nBy contrast, if a machine with general-purpose artificial intelligence is created and then assigned a task, would it be possible that the machine will be able to better accomplish its task by continuously improving its own computational power and mastery of various skills, as opposed to collaborating with other agents (whether copies of itself, other AI's, or even humans)?\nIn other words, would an AGI ever need to collaborate, or would it always be able to achieve its goals alone?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In my answer, I have often switched between AGI and ASI for reference. This is fine as an AGI will reach ASI as it is optimizing itself and learning.\nI think it is not only important by necessary that AGI and ASI are of collaborative nature. Nick Bostrom, in his book Superintelligence: Paths, Dangers, Strategies in Chapter 10 described three ways in which an ASI might function:\n\nAs an oracle, which answers nearly any question posed to it with accuracy, including complex questions that humans cannot easily answer\u2014i.e. How can I manufacture a more efficient car engine? Google is a primitive type of oracle.\n As a genie, which executes any high-level command it\u2019s given\u2014Use a molecular assembler to build a new and more efficient kind of car engine\u2014and then awaits its next command.\n As a sovereign, which is assigned a broad and open-ended pursuit and allowed to operate in the world freely, making its own decisions about how best to proceed\u2014Invent a faster, cheaper, and safer way than cars for humans to privately transport themselves.\n\nThis is when and if AGI and ASI are of controlled manner and their output are as expected. By controlled I mean they don't start seeing human as a threat and start eliminating the human race. More on this here. As you can see, all the above ASI are of collaborative nature. Either they are collaborating with humans or they need to collaborate with other systems.\nNow to your answer:\nFirst, collaborative nature is of great use in terms of efficiency and performance. This is the reason why Distributed Systems are being made. We even have distributed OS now. Also, Modular approach in coding/ developments and huge success of Object Oriented Model are proofs of advantages of using collaboration among different entities.\nIf you think about it even the AGI is collaborating and using resources from other places in some way. As your AGI is learning, it is gaining information from the internet. It reads the information and tries to structure is accordingly (This will depend on its neural schema) and create knowledge (or something valuable) for itself. It is collaborating using network protocols with the outer world (other systems). If it doesn't collaborate then the firewall of the system might not allow it to use the service. Different services on the internet require a different set of protocols to be followed. So, if AGI wants to communicate for information it needs to follow those protocols. This way the AGI will learn to collaborate with different entities even at an early stage.\nFrom AGI point of view communicating a web server and communicating another AGI machine is very similar. As we, humans, don't store all the information in our brain; similarly AGI won't find it efficient to store all the information within. Not all information is needed all the time. The memory hierarchy is proof of that. Even if AGI is made to store all the information within, with time it will figure out how inefficient it is and will re-program itself to only hold very vital information and use the internet for less frequently used information.\nI will like to add one more thing to this. Let us begin with the human analogy first. We, as humans, collaborate with other humans. But we also collaborate with our different body parts. Like, what about the collaboration within us. Collaboration (or coordination) between our legs, hands, our body, and mind, etc. This leads us to the question of who as a person we are, our whole body, or just our brain. If I remove my hand and replace it with an organic implant, would I be still me?\nSimilarly, what is AGI? Is it the whole structure, or just the code. Does the RAM, ROM, hard disks also a part of AGI? If you think the hardware is not the part of AGI then your AGI is co-ordinating with these devices too, using certain protocols. To some level, this is collaboration too.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are iterative deepening, principal variation search or quiescence search extensions of alpha-beta pruning? I know that there are several optimizations for alpha-beta pruning. For example, I have come across iterative deepening, principal variation search, or quiescence search.\nHowever, I am a little bit confused about the nature of these algorithms.\n\nAre these algorithms an extension of the alpha-beta algorithm, or\nAre they completely new algorithms, in that they have got nothing to do the alpha-beta algorithm?\n\nOn this site, these algorithms fall into one of 4 categories, namely\n\nmandatory\nselectivity\nscout and friends \nAlpha-beta goes best-first\n\nDoes this mean that the alpha-beta algorithm is split into four areas and that they are specialized optimization algorithms for each area?\nHow do I even begin to decide which optimized algorithm to pick?\nI advise people to visit this site:\nhttp://www.fierz.ch/strategy2.htm\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\n\nAre these algorithms an extension of the alpha-beta algorithm, or\nAre they completely new algorithms, in that they have got nothing to do the alpha-beta algorithm?\n\n\nMost of them are extensions of the Alpha-Beta pruning algorithm. For example, Iterative Deepening is almost the same as Alpha-Beta pruning, but automatically keeps repeating the algorithm with gradually-increasing depth limits until some time limit is reached, rather than just running once for a pre-determined depth limit.\nPrincipal Variation Search also still uses Alpha-Beta as a basis, but performs many searches with significantly smaller [alpha, beta] windows than the standard Alpha-Beta pruning algorithm.\nIn most cases, these extensions would start out from an existing Alpha-Beta implementation, and build from there with some adaptations in the code. This is not necessarily the case for all of those extensions though, just for most. For example, Transposition Tables are kind of a separate extension that could be plugged into vanilla Minimax, or Alpha-Beta, or Principal Variation Search, or whatever you're using.\n\n\nOn this site, these algorithms fall into one of 4 categories, namely\n\nmandatory \nselectivity\nscout and friends \nAlpha-beta goes best-first\n\nDoes this mean that the alpha-beta algorithm is split into four areas and that they are specialized optimization algorithms for each area?\n\nThose four categories are not mutually exclusive, they're more like... broad \"flavours\". What they list under Obligatory are some of the more basic extensions that any programmer should probably look into first if they were developing a chess-playing program. The other category are different \"flavours\", different \"broad ideas\". For example, everything listed under \"Selectivity\" is about searching \"interesting\" or \"exciting\" parts of the search tree deeper than \"less interesting\" or \"boring\" parts. Many of those ideas could be used regardless of whether you're using Alpha-Beta, Iterative Deepening, or PVS, and probably all could be combined with Transposition Tables as well.\n\nHow do I even begin to decide which optimized algorithm to pick?\n\nThis is really really difficult to decide just based on the names. In theory, which algorithm is the \"best\" will also highly depend on your specific game, and maybe even hardware. And, in many cases it's not even a choice between mutually exclusive parts; different ideas can be combined with each other in different ways.\nThe only solution here is really just to do lots of reading, lots of research, try implementing different things to better understand them.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there ever a need to combine deep learning frameworks? (Eg. TensorFlow & Torch)? Imagine a simple scenario of having a large repository using one framework and integrated with data/robots, etc., then having a new feature requested and the framework missing some vital functionality that is available in another framework (say a new kind of layer).\nFor many mathematical libraries, it can be easy to reverse engineer the specific function that one would want to form the other framework so as to not import the entire framework but in the case of deep learning, this isn't so trivial nor that easily testable.\nIn these cases, does one take on the problem of reverse engineering the functionality or do they attempt to combine the architectures? If it's the combination, what are the biggest issues with integration?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In the time since I asked this question, I have been able to combine Tensorflow and Chainer considerably well. That being said, one should try to avoid combining deep learning frameworks if one can for a few reasons:\n\nIt doubles the amount of documentation one needs to reference \nIt makes it difficult for new developers to become familiar with the\ncode base. \nIt creates multiple data transfer bottlenecks when one\nhas to transfer data between the deep learning different\nconfigurations such as: CPU -> GPU (Tensorflow) -> CPU -> GPU\n(Chainer) -> CPU ... etc.\n\nThat being said, I combined them because of time constraints on a research project which would not be finding its way into an industrial product. In this research setting, I still wouldn't recommend combining frameworks if one can avoid it but if it means doubling the time it takes to do the project for a proof of concept or experiment, then it seems reasonable and can drastically speed up development until the missing functionality is added to the desired framework.\nThere are 2 issues with integration:\n\nAbstracting the networks so that the main\ntraining/testing script does not depend on the framework.\nThis is important in the event that the missing functionality of your desired framework is added. It also helps new developers understand what the overall algorithm or experiment is without being bogged down by framework details.\nTensorflow and similar frameworks which require a Session object.\nChainer, PyTorch (which came from Chainer), and any other framework that doesn't require a something like Tensorflow's Session all play very nicely together and can be used (almost) interchangeably. For Session based frameworks, the main script/loop/experiment must all take place within a Session. With proper abstraction, my experiment only required a with tf.Session() as sess: to be used in the main experiment and was the only reference that Tensorflow was being used.\n\nAlthough I still don't recommend combining frameworks for the reasons specified above, if one abstracts their framework calls enough, it is almost seamless to integrate deep learning frameworks.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does \"statistical efficiency\" mean in this context? Consider the following statement(s) from Deep Learning book (p. 333, chapter 9: Convolutional Networks) by Ian Goodfellow et al.\n\nConvolution is thus dramatically more efficient than dense matrix\nmultiplication in terms of the memory requirements and statistical\ne\ufb03ciency.\n\nBook is saying that statistical efficiency is due to the decrease in the number of parameters due to convolution (using kernel) compared to fully connected feed forward neural networks.\nWhat is meant by statistical efficiency in this context? And how does decrease in the number of parameters increase statistical efficiency?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Statistical efficiency in this context essentially means that a CNN would require fewer training examples than a fully connected network to learn. Intuitively this seems reasonable: more parameters to learn should mean more samples needed. Of course it is always desirable to minimise the number of training samples needed, so that's a definite advantage of CNNs.\nThere is a paper on the efficiency of CNNs which attempts to make that statement more precise. They examine the case of a convolutional network using a linear activation function.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a \"surrogate model\"? In the following paragraph from the book Automated Machine Learning: Methods, Systems, Challenges (by Frank Hutter et al.)\n\nIn this section we first give a brief introduction to Bayesian optimization, present alternative surrogate models used in it, describe extensions to conditional and constrained configuration spaces, and then discuss several important applications to hyperparameter optimization.\n\nWhat is an \"alternative surrogate model\"? What exactly does \"alternative\" mean?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "What is Bayesian optimization?\nIntroduction\nBayesian optimization (BO) is an optimization technique used to model an unknown (usually continuous) function $f: \\mathbb{R}^d \\rightarrow Y$, where typically $d \\leq 20$, so it can be used to solve regression and classification problems, where you want to find an approximation of $f$. In this sense, BO is similar to the usual approach of training a neural network with gradient descent combined with the back-propagation algorithm, so that to optimize an objective function. However, BO is particularly suited for regression or classification problems where the unknown function $f$ is expensive to evaluate (that is, given the input $\\mathbf{x} \\in \\mathbb{R}^d$, the computation of $f(x) \\in Y$ takes a lot of time or, in general, resources). For example, when doing hyper-parameter tuning, we usually need to first train the model with the new hyper-parameters before evaluating the specific configuration of hyper-parameters, but this usually takes a lot of time (hours, days or even months), especially when you are training deep neural networks with big datasets. Moreover, BO does not involve the computation of gradients and it usually assumes that $f$ lacks properties such as concavity or linearity.\nHow does Bayesian optimization work?\nThere are three main concepts in BO\n\nthe surrogate model, which models an unknown function, \na method for statistical inference, which is used to update the surrogate model, and\nthe acquisition function, which is used to guide the statistical inference and thus it is used to update the surrogate model\n\nThe surrogate model is usually a Gaussian process, which is just a fancy name to denote a collection of random variables such that the joint distribution of those random variables is a multivariate Gaussian probability distribution (hence the name Gaussian process). Therefore, in BO, we often use a Gaussian probability distribution (the surrogate model) to model the possible functions that are consistent with the data. In other words, given that we do not know $f$, rather than finding the usual point estimate (or maximum likelihood estimate), like in the usual case of supervised learning mentioned above, we maintain a Gaussian probability distribution that describes our uncertainty about the unknown $f$.\nThe method of statistical inference is often just an iterative application of the Bayes rule (hence the name Bayesian optimization), where you want to find the posterior, given a prior, a likelihood and the evidence. In BO, you usually place a prior on $f$, which is a multivariate Gaussian distribution, then you use the Bayes rule to find the posterior distribution of $f$ given the data.\nWhat is the data in this case? In BO, the data are the outputs of $f$ evaluated at certain points of the domain of $f$. The acquisition function is used to choose these points of the domain of $f$, based on the computed posterior distribution. In other words, based on the current uncertainty about $f$ (the posterior), the acquisition function attempts to cleverly choose points of the domain of $f$, $\\mathbf{x} \\in \\mathbb{R}^d$, which will be used to find an updated posterior. Why do we need the acquisition function? Why can't we simply evaluate $f$ at random domain points? Given that $f$ is expensive to evaluate, we need a clever way to choose the points where we want to evaluate $f$. More specifically, we want to evaluate $f$ where we are more uncertain about it.\nThere are several acquisition functions, such as expected improvement, knowledge-gradient, entropy search, and predictive entropy search, so there are different ways of choosing the points of the domain of $f$ where we want to evaluate it to update the posterior, each of which deals with the exploration-exploitation dilemma differently.\nWhat can Bayesian optimization be used for?\nBO can be used for tuning hyper-parameters (also called hyper-parameter optimisation) of machine learning models, such as neural networks, but it has also been used to solve other problems. \nWhat is an alternative surrogate model?\nIn the book Automated Machine Learning: Methods, Systems, Challenges (by Frank Hutter et al.) that you are quoting, the authors say that the commonly used surrogate model Gaussian process scales cubically in the number of data points, so sparse Gaussian processes are often used. Moreover, Gaussian processes also scale badly with the number of dimensions. In section 1.3.2.2., the authors describe some alternative surrogate models to the Gaussian processes, for example, alternatives that use neural networks or random forests.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is Expected SARSA an off-policy or on-policy algorithm? I understand that SARSA is an On-policy algorithm, and Q-learning an off-policy one.\nSutton and Barto's textbook describes Expected Sarsa thusly:\n\nIn these cliff walking results Expected Sarsa was used on-policy, but\n in general it might use a policy different from the target policy to\n generate behavior, in which case it becomes an off-policy algorithm.\n\nI am fundamentally confused by this - specifically, how do we define when Expected SARSA adopts or disregards policy. The Coursera Course states that it is On-Policy, further confusing me.\nMy confusions became realized when tackling the Udacity course, specifically a section visualizing Expected SARSA for simple a gridworld (See section 1.11 and 1.12 in link below). Note that the course defines Expected Sarsa as on-policy.\nhttps://www.zhenhantom.com/2019/10/27/Deep-Reinforcement-Learning-Part-1/\nYou'll notice the calculation for the new state value Q(s0,a0) as\n\nQ(s0, a0) <\u2014 6 + 0.1( -1 + [0.1 x 8] + [0.1 x 7] + [0.7 x 9] + [0.1\n x 8] - 6) = 6.16.\n\nThis is also the official answer. But this would mean that it is running off policy, given that it is stated that the action taken at S1 corresponds to a shift right, and hence expected SARSA (On policy) should yield you.\n\nQ(s0, a0) <\u2014 6 + 0.1( -1 + [0.1 x 8] + [0.1 x 7] + [0.1 x 9] + [0.7 x\n 8] - 6) = 6.1\n\nThe question does state\n\n(Suppose that when selecting the actions for the first two timesteps\n in the 100th episode, the agent was following the epsilon-greedy\n policy with respect to the Q-table, with epsilon = 0.4.)\n\nBut as this same statement existed for the regular SARSA example (which also yields 6.1 as A1 is shift right, as before), I disregarded it.\nAny advice is welcome.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Expected SARSA can be used either on-policy or off-policy.\nThe policy that you use in the update step determines which it is. If the update step uses a different weighting for action choices than the policy that actually took the action, then you are using Expected SARSA in an off-policy way.\nQ-learning is a special case of Expected SARSA, where the target policy is greedy with respect to the action values, so there is only ever one $r_{t+1} + \\gamma \\text{max}_{a'} Q(s_{t+1}, a')$ term to add with a probability $1$.\nYou can also use Expected SARSA, similarly to SARSA, where the behaviour policy and target policy are identical. It is not identical to SARSA though, because it calculates the TD Target over all possible actions $r_{t+1} + \\gamma \\sum_{a'} \\pi(a'|s_{t+1}) Q(s_{t+1}, a')$\nYou can construct Expected SARSA updates where $\\pi(a|s)$ is different when selecting which action to explore in the environment (behaviour) and when updating the Q values (target). For instance, you can decide to explore using $\\epsilon$-greedy with $\\epsilon=0.1$ and update the value function with $\\epsilon=0.01$.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the intuition behind self-attention? I've been watching a few lectures on transformers, especially for language translation, though it seemingly becomes more confusing the more I watch.\nIn this lecture, there seems to be two conflicting views of self-attention. First, there's an Iron Man example (at around 44:25) where the lecturer claims that self-attention helps identify the important aspects of the input, but she details the math in which a \"self-attention heat map\", which is the dot product of the query and key matrices, is multiplied by a value matrix giving an output, which I assume is an attention head. It seems like this attention head just encodes how words are related to each other (the map) and the words themselves (the value).\nI don't understand how this extracts the important information, or why you only want the important information anyways for translation. Is it extracting the important relationships between words, because that would make more sense, but in what way does that relate to her Iron Man example then? What's the relationship of Iron Man to himself? Also, would each attention head contain its own set of three matrices? Is the idea perhaps that words that more words depend on are important? But wouldn't that simply remove single words that still are important for translation?\nTLDR: Essentially, how does the idea of relationships between words translate to selecting important words in a sentence (if this is even what self-attention does).\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First of all, I totally agree that the Iron Man example is a little off the topic and not really clear to explain the concept of self-attention.\nBut she had a point there. Just like what you said, the self-attention mechanism extracts the relationships between words and then after being scaled down and multiply with the value tensor, it makes more sense for what are the important keys that need to be attended by the model.\nNow let's get back to the Iron Man example. I think the idea is that our brains can immediately know which parts are the important part of the image to focus on because we all have that attention filter that is always turning on.\nIt's different from the CNN or the RNN model, which needs to know the feature first (feature extraction). The self-attention calculates the relationship between each token and the importance on the whole image first and then can use that information to focus on feature extraction on those really important parts.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why isn't conditional probability sufficient to describe causality? I read these comments from Judea Pearl saying we don't have causality, physical equations are symmetric, etc. But the conditional probability is clearly not symmetric and captures directed relationships. \nHow would Pearl respond to someone saying that conditional probability already captures all we need to show causal relationships?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Perhaps the shortest answer to this question is that Bayes' Theorem itself allows us to easily change the direction of a conditional probability:\n$$\nP(A|B) = \\frac{P(B|A)P(A)}{P(B)}\n$$\nSo if you have $P(B|A)$, $P(A)$, and $P(B)$, we can determine $P(A|B)$, and similarly you can determine $P(B|A)$ from $P(A|B)$, $P(B)$ and $P(A)$. Just by looking at $P(B|A)$ and $P(A|B)$, it is therefore impossible to tell what the causal direction is (if any).\nIn fact, probabilistic inference usually works the other way round: When there is a known causal relation, say from diseases $A$ to symptoms $B$, we usually have $P(B|A)$, and are interested in the diagnostic reasoning task of determining $P(A|B)$ from that. (The only other thing we need for that is the prior probability $P(A)$ since $P(B)$ is just a normalization factor.)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Reinforcement Learning with more actions than states I have read a lot about RL recently. As far as I understood, most RL applications have much more states than there are actions to choose from.\nI am thinking about using RL for a problem where I have got a lot of actions to choose from, but only very few states. \nTo give a handy example:\nThe algo should render (for whatever reason) a sentence with three words. I always want to have a sentence with three words, but I have many words to choose from. After choosing the words, I get some sort of reward.\nAre RL algorithms an efficient way to solve this? \nI am thinking about using policy gradients with an \u03b5-greedy algorithm to explore a lot of the possible actions before exploiting the knowledge gained.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nAs far as I understood, most RL applications have much more states than there are actions to choose from.\n\nYes, this is quite common, but in no way required by the underlying theory of Markov Decision Processes (MDPs). The most extreme version of the opposite thing - with one state (or effectively no state, as state is not relevant) - are k-armed bandit problems, where an agent tries to find a single best long-term action in general from a selection of actions. These problems typically would not use RL algorithms such as Q-learning or policy-gradients. However, that is partly because they are described with different goals in mind (e.g. minimising \"regret\" or simply gaining as much reward as possible during the learning process), and RL algorithms will work to solve them, albeit less efficiently than algorithms designed to work on bandit problems directly.\n\nI am thinking about using RL for a problem where I have got a lot of actions to choose from, but only very few states.\n\nThat should work, provided your problem is still a MDP. That means for instance that the state evolves according to rules depending on which action was taken in which starting state. If the state evolution is instead arbitrary or random, then you may have a contextual bandit problem instead.\nThere is an important difference here between:\n\na large number of entirely different actions, each with different results, which need enumeration and have to be explored separately\n\nand\n\na large action space due to measurable values which are part of an action, such as how much force to apply in a motor\n\nThe former will require lots of exploration, since any specific combination of action and state could be the ideal. With the latter, you can use that fact that numerical values that are similar will often give similar results, which will make generalisation via function approximation (e.g. neural networks) work efficiently in your favour.\n\nThe algo should render (for whatever reason) a sentence with three words. I always want to have a sentence with three words, but I have many words to choose from. After choosing the words, I get some sort of reward\n\nThis seems more like the first bullet-point above, although that may depend if a natural language model could be applied for example. E.g. if \"This is good\" and \"This is great\" would produce similar rewards in a specific state, then there is maybe some benefit to generalisation, although I am not quite sure where you would fit this knowledge - possibly in a generator for a sentence vector as the \"raw\" action and then have a LSTM-based language model produce the actual action from that vector, similar to seq2seq translation models.\n\nAre RL algorithms an efficient way to solve this?\n\nYes, but whether or not it is the most efficient will depend on other factors, such as:\n\nWhether the environment is stochastic or deterministic with regard to both reward and state progression. \nWhether state progression is key to obtaining the best rewards in the long term (e.g. there is some \"goal\" or \"best\" state that can only be reached by a certain route).\nWhat the actual size of the MDP is $|\\mathcal{S}| \\times |\\mathcal{A}|$. Small MDPs can be fully enumerated, allowing you to estimate action values in a simple table. If you have 10 states and 1,000,000 discrete actions, with no real pattern of actions mapping to results, then a big 10 million entry table will actually be reasonably efficient.\n\nCompetitive algorithms to RL here might be global search and optimisation ones, such as genetic algorithms. The more arbitrary and deterministic your environment is, the more likely it is that an exhaustive search will find your optimal policy faster than RL.\n\nI am thinking about using policy gradients with an \u03b5-greedy algorithm to explore a lot of the possible actions before exploiting the knowledge gained.\n\nThis should be fine. Exploration here is definitely important, but finding the sweet spot for the right amount of it will be hard, and depend on other traits of the environment. \nYou may want to use something like upper confidence bound action selection or simply optimistic initial values, in order to ensure exploration does not miss certain actions. An epsilon greedy approach will miss a certain fraction of actions over time, and the expectation of that fraction grows smaller progressively more slowly, so it may be possible to miss an important action for a long time if you rely on being able to randomly select it.\n\nTo give a handy example: The algo should render (for whatever reason) a sentence with three words. I always want to have a sentence with three words, but I have many words to choose from. After choosing the words, I get some sort of reward.\n\nI would consider modelling this as sequences of 3 actions, each of which chooses a word, with the state being a start token (whatever the state you already have) plus the sentence so far, and on every 3 words the environment is consulted to reset the state to the next start token and to gather a reward (rewards for interim steps would be zero).\nDoing this immediately makes the state space much larger than the action space, as your state includes history of up to two actions. If you had 10 different start states, and 100 word choices, then your state space would be 101,010 and action space 100.\nThis will fit available designs of RL algorithms, and allow for learning some internal language modelling if it is relevant. It will reduce your need to model sentence construction outside of the agent. Most importantly, if \"good\" or \"bad\" sentences tend to start or end with certain words, and you use function approximation, then the algorithm may discover combinations more efficiently than iterating over all sentences as if they were completely independent.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can the discriminator determine the sample is fake or real? Based on the articles I've read, the discriminator can identify whether a sample is fake or real. However, the articles don't clarify the conditions used to determine if a sample is fake or real. I came across information suggesting that labeling all the samples generated by the generator as fake before the training process, but I'm not sure if this is correct. Could someone please provide clarification? Thanks\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In a GAN, the discriminator starts untrained, and the generator and discriminator are trained alongside each other. The process relies on neither being too strong for the other at any one stage, so that training can continue.\nSo the reason the discriminator can determine the difference between a real or fake sample is because it has learned from the GAN training process.\nYou should start with some training data, in the form of real images that you want the generator to produce similar output to.\nWhen you train the discriminator:\n\nFor every real image you show it, the target label is \"real\" (for a simple binary discrimintor the single target output is $p(real) = 1$)\n\nFor every generated image you show it, the target label is \"fake\" (e.g. $p(real) = 0$ for a binary class prediction)\n\nIn every minibatch you should train the discriminator on a mix of real and fake images, labelled accordingly.\n\n\nWhen you train the generator:\n\nYou still show the generator outputs to the discriminator, but now your target is to make the generator better, so you lie to the discriminator and label the generator's image as \"real\" ($p(real) = 1$). The trick here is that you only do this to get the gradients at the generator output layer. The discriminator is not updated for these training examples, only the generator is.\n\nThere are a few variations of this process, but the core idea is always similar, and to answer your main question, the discriminator determines real or fake because this is part of the training process. It is very bad at its job at the start, and you need that to be the case.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can an decoder-only transformer be used for document embedding? GPT3 and 4 are both examples of decoder-only models. However OpenAI offers an text embedding API endpoint based on these models. This begs the general question how can one obtain text embeddings from a decoder-only transformer model?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The GPT models (as manifested using the decoder block in the original Transformer architecture) are not generating the embedding. However, the weights from the GPT are being used as the initial weights in a new model, dubbed CPT [1], that can create embeddings.\nThe key lies in Contrastive Modeling techniques - acquire pair data and train a new model to minimize loss on the known pairs. Look at the CLIP model for a good review of contrastive loss. The CLIP model embeds the text and image into the same vector space. Thus, CLIP and contrastive models know how to create embeddings.\nPair data, luckily, is prevalent on the web and easy to acquire: [image, caption], [docstring, code], [podcast titles, podcast descriptions], etc.\nOne key ingredient: you get way better results when you start with an initialized pre-trained model. That's where the GPT leverage comes in. They are using the GPT models (at various sizes like Ada, Babbage, Curie, DaVinci...) as the initial weights on a new constrastive model.\nThus, the formula is:\n\nA pre-trained GPT for initial weights\nPair data for training\nContrastive loss training\n\nThe resulting model is what OpenAI calls a \"cpt\" model.\nIt's unclear how well these contrastive loss embedding models work compared to a more traditional encoder-based LLM block (like universal-sentence-encode). See this blog post for more.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does the Alpha Zero's move encoding work? I am a beginner in AI. I'm trying to train a multi-agent RL algorithm to play chess. One issue that I ran into was representing the action space (legal moves/or honestly just moves in general) numerically. I looked up how Alpha Zero represented it, and they used an 8x8x73 array to encode all possible moves. I was wondering how it actually works since I got a bit confused in their explanation:\n\nA move in chess may be described in two parts: selecting the piece to move, and then selecting among the legal moves for that piece. We represent the policy $\\pi(a \\mid s)$ by a $8 \\times 8 \\times 73$ stack of planes encoding a probability distribution over 4,672 possible moves. Each of the $8 \\times 8$ positions identifies the square from which to \"pick up\" a piece. The first 56 planes encode possible \"queen moves\" for any piece: a number of squares $[1..7]$ in which the piece will be moved, along one of eight relative compass directions {N, NE, E, SE, S, SW, W, NW}. The next 8 planes encode possible knight moves for that piece. The final 9 planes encode possible under-promotions for pawn moves or captures in two possible diagonals, to knight, bishop or rook respectively. Other pawn moves or captures from the seventh rank are promoted to a queen.\n\nHow would one numerically represent the move 1. e4 or 1. NF3 (and how would the integer for 1. NF3 differ from 1. f3) for example? How do you tell what integer corresponds to which move? This is what I'm essentially asking.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Let's do the code, so all the details are down.\nEncoding dictionary:\ncodes, i = {}, 0\nfor nSquares in range(1,8):\n for direction in [\"N\", \"NE\", \"E\", \"SE\", \"S\", \"SW\", \"W\", \"NW\"]:\n codes[(nSquares,direction)] = i\n i += 1\n\nYou'll see that the codes dictionary will have 56 entries in it for each (nSquares,direction) pair.\nThe knight moves we'll encode as the long \"two\"-cell edge move first and the short \"one\"-cell edge second:\nfor two in [\"N\",\"S\"]:\n for one in [\"E\",\"W\"]:\n codes[(\"knight\", two, one)] , i = i , i + 1\nfor two in [\"E\",\"W\"]:\n for one in [\"N\",\"S\"]:\n codes[(\"knight\", two, one)] , i = i , i + 1\n\nNow we should have 64 codes. As I understand, the final 9 moves are when a pawn reaches the final rank and chosen to be underpromoted. It can reach teh final rank either by moving N, or by capturing NE, NW. Underpromotion is possible to three pieces. Writing the code:\nfor move in [\"N\",\"NW\",\"NE\"]:\n for promote_to in [\"Rook\",\"Knight\",\"Bishop\"]:\n codes[(\"underpromotion\", move, promote_to)] , i = i , i + 1\n\nWe get 73 codes as described.\nPolicy\nThe distribution over actions is a (8,8,73) tensor (it is not formally a \"policy\", since policy should also depend on state, but lets cut this corner for this discussion):\npolicy = np.zeros((8,8,73))\n\nLet's also do codes for columns for convenience:\ncolumns = { k:v for v,k in enumerate(\"abcdefgh\")}\n\n\nHow would one numerically represent the move 1. e4\n\nThe first two dimensions choose the figure you are moving. So, that'd be e2 pawn. And we move north 'N' by 2 cells.\nSo, we put 1 into the tensor at the appropriate indices. Note that you have to subtract 1 from the row index, to make it zero-based.\ne4policy = np.zeros((8,8,73))\ne4policy[ columns['e'] , 2 - 1 , codes[(2 , \"N\")]] = 1\n\n\nHow would one numerically represent the move 1. NF3\n\nThe first two dimensions choose the figure you are moving. So, that'd be g1 knight. And we perform north-west N,W knight jump.\nNF3policy = np.zeros((8,8,73))\nNF3policy[ columns['g'] , 1 - 1 , codes[(\"knight\", 'N' , 'W')]] = 1\n\nGenerally, the policy is a probability distribution over all possible moves, so the policy tensor would have several non-zero probability values in it. For example an opening policy that does 1.e4 or 1.Nf3 with 50/50 probability would be:\nopeningPolicy = (e4policy + NF3policy) / 2 \n\nHope this clears things up.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why use a \"square root\" in the scaled dot product In attention settings, typically when the both Query Q and Key K are of the same dimension d we can compute their attention score in the following manner:\n$$\\frac{Q^T K}{\\sqrt{d}}$$\nThe justification being that the dot product tends to blow up in higher dimension, and $\\sqrt{d}$ helps to \"keep things reasonable\". I also read that it serves to reduce the standard deviation to 1, however chatGPT contradicts that statement, and I can't find resources that support this claim.\nTherefore what is the mathematical justification behind $\\sqrt{d}$ and not another form such as $\\log d$, $d^5$, $e^{\\pi d}$ or simply $|Q||V|$ (a cosine similarity!) if we want to keep things \"bounded\"?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In the official paper the justification for this scaling is given in footnote $[4]$ on page 4.\nHere is a more lengthy explanation of the same thing:\nLet\u2019s assume that the keys $K$ and queries $Q$ have zero mean and unit std. The attention score between some query $i$ and some key $j$ is:\n$$ \\alpha = q_i k_j^T = \\sum_{n=1}^{d_k} q_{in}k_{jn} $$\nWe know that the variance of a sum of random variables equals the sum of the variances of those variables. Thus, for the variance of the attention score we get:\n$$ \\text{Var}(\\alpha) = d_k, $$\nsince $ \\text{Var}(q_{in}k_{jn}) = 1 \\quad \\forall n.$\nThe standard deviation is:\n$$ \\text{std}(\\alpha) = \\sqrt{d_k} $$\nAfter you compute the attention scores you need to apply softmax in order to obtain the attention probabilities. The problem is that the softmax function saturates very quickly. This means that if one of the attention scores is slightly bigger than the others, then the softmax function will put almost all of the weight on that element. See for example this:\nx = torch.FloatTensor([1, 1, 1, 5])\ny = torch.softmax(x, dim=-1)\n# y: [0.0174, 0.0174, 0.0174, 0.9479]\n\nSince the variance of the attention scores is $d_k$ then almost certainly one random score will be much higher than the others. The softmax will output attention probability of $1.$ for that element and zeros for the others and you will get no gradient propagation.\nWhat you want to do to ensure stable gradient flow is normalize your attention scores. That is, make them with zero mean and unit std. We already assumed that the keys and queries have zero mean and unit std, so the only thing you need to do in order to achieve this is to scale the attention scores with $\\sqrt{d_k}$.\nBut is it safe to assume that our keys and queries have unit variance?\nWell, yes! The architecture of the Transformer includes LayerNorm layers that are used exactly for this reason: normalizing the inputs before applying the self-attention layer. In addition the weights of the self-attention layer are initialized using Xavier initialization and so the computed keys, queries and values will also have unit std. In my opinion this scaled dot-product works so well only when combined with LayerNorm and Xavier initialization. I have written a very detailed blog post about the Transformer architecture, if you want to read it here is a link:\nhttps://pi-tau.github.io/posts/transformer\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What if the more fit parent has fewer nodes compared to the other, will the disjoint and excess genes be discarded? In the paper Efficient Evolution of Neural Network Topologies (2002), the authors say \n\nGenes that do not match are inherited from the more fit parent\n\nWhat if the more fit parent has fewer nodes compared to the other, will the disjoint/excess genes be discarded?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "When crossover happens and one parent is fitter than the other, the nodes from the more fit parent are carried over to the child. This is the case as disjoint and excess genes are only carried over from the fittest parent.\nHere's an example:\n// Node Crossover\nParent 1 Nodes: {[0][1][2]} // more fit parent\nParent 2 Nodes: {[0][1][2][3]}\n\nChild Nodes: {[0][1][2]} // after crossover\n\nGene information is also passed to the child during crossover. Matching genes (those that have the same innovation number) are chosen at random and passed to the child. The disjoint and excess genes are chose from the more fit parent.\n// Gene Crossover\nParent 1 Genes: [1][2][3] [6] [8][9][10] // more fit parent\nParent 2 Genes: [1][2][3][4][5] [7]\n\nChild Genes: [1][2][3][6][8][9][10] // after crossover\n\nAs you can see, the gene innovation numbers in the child match up with the innovation numbers of the fittest parent. However the gene information from matching genes (in the example genes 1, 2 and 3 match) have an equal chance of being carried over to the child. In the example, the child's first three genes could have come from either parent.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to generalise over multiple simultaneous dependent actions in Reinforcement Learning I am trying to build an RL agent to price paid-for-seating on commercial flights. I should reiterate here - I am not talking about the price of the ticket - rather, I am talking about the pricing you see if you click on the seat map to choose where on the plane you sit (exits rows, window seats, etc). The general set up is:\n\nAfter choosing their flights (for a booking of n people), a customer will view a web page with the available seat types and their prices visible.\nThey select between zero and n seats from a seat map with a variety of different prices for different seats, to be added to their booking.\nThe revenue from step 2 is observed as the reward.\n\nEach 'episode' is the selling cycle of one flight. Whether the customer buys a chosen seat or not, the inventory goes down as they still have a ticket for the flight so will get a seat at departure. I would like to change prices on the fly, rather than fix a set of optimal prices throughout the selling cycle. \nI have not decided on a general architecture yet. I want to take various booking, flight, and inventory information into account, so I know I will be using function approximation (most likely a neural net) to generalise over the state space.\nHowever, I am less clear on how to set up my action space. I imagine an action would amount to a vector with a price for each different seat type (window seat, exit row, etc). If I have, for example, 8 different seat types, and 10 different price points for each, this gives me a total of 10^8 different actions, many of which will be very similar. In a sense, each action is comprised of a combination of sub-actions - the action of pricing each seat type.\nAdditionally, each sub-action (pricing one seat type) is somewhat dependent on the others, in the sense that the price of one seat type will likely affect the demand (and hence reward contribution) for another. For example, if you set window seats to a very cheap price, people will be less likely to spend a normal amount for the other seat types. Hence, I doubt the problem can be decomposed into a set of sub-problems.\nI'm interested if there has been any research into dealing with a problem like this. Clearly any agent I build needs some way to generalise across actions to some degree, since collecting real data on millions of actions is not possible, even just for one state.\nAs I see it, this comes down to three questions:\n\nIs it possible to get an agent that can deal with a set of actions (prices) as a single decision?\nIs it possible to get this agent to understand actions in relative terms? Say for example, one set of potential prices is [10, 12, 20], for middle seats, aisle seats, and window seats. Can I get my agent to realise that there is a natural ordering there, and that the first two pricing actions are more similar to each other than to the third possible action?\nFurther to this, is it possible to generalise from this set of actions - could an agent be set up to understand that the set of prices [10, 13, 20] is very similar to the first set?\n\nI haven't been able to find any literature on this, especially relating to the second question - any help would be much appreciated!\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "If you want to treat the problem as a full Reinforcement Learning problem, I'd recommend to try avoiding the combinatorial explosion of the action space by treating every sub-action as a separate decision point, a separate full action. If you have, for example, already selected 4 sub-actions for a particular customer, you can try to include those in some way in the state representation / input when moving on to the 5th sub-action. By including already-selected sub-actions in the state space, your algorithm can learn to take into account that optimal prices for some seat types will depend on what prices were already selected for others.\nI do suspect such a full RL formulation will still be a difficult problem to learn though, will require huge amounts of experience. It may be worth considering to simplify it anyway, treat it as a Contextual + Combinatorial Multi-Armed Bandit Problem. That way you won't be able to learn long-term effects across multiple different customers as you described in the comments, but you will likely at least be able to learn something that works decently well with less experience. Recently, an interesting new book appeared on MAB problems, which is available for free here. You will find many chapters on Contextual MABs there, and also one chapter (chapter 30) on Combinatorial MABs.\nNote that with either of these \"combinatorial\" approaches, you can also try to play around with the order in which you select sub-actions. For example, the sub-action / price point selected for seat type A might have a significant influence on what the optimal remaining policy would be for other seat types, whereas the sub-action for seat type B might have no influence on other seat types. It would then be useful to always prioritize selecting sub-actions for seat type A. You can try to identify these kinds of effects by keeping track of (co)variances in observed returns.\n\n\n\nIs it possible to get an agent that can deal with a set of actions (prices) as a single decision?\n\n\nThe solutions I proposed above do not do this explicitly, they circumvent the issue by taking multiple sequential decisions. There does appear to be some research in RL with vector-valued actions. For example, the paper Clipped Action Policy Gradient briefly mentions vector-valued actions in Subsection 3.2. I am not personally familiar enough with RL + vector-valued actions to make a direct recommendation as to what approaches do or don't work well, but maybe this can at least help you find more relevant literature if this is a direction you'd like to pursue.\n\n\nIs it possible to get this agent to understand actions in relative terms? Say for example, one set of potential prices is [10, 12, 20], for middle seats, aisle seats, and window seats. Can I get my agent to realise that there is a natural ordering there, and that the first two pricing actions are more similar to each other than to the third possible action?\nFurther to this, is it possible to generalise from this set of actions - could an agent be set up to understand that the set of prices [10, 13, 20] is very similar to the first set?\n\n\nThis kind of generalization should again come naturally from using function approximation with either of the solutions proposed above.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Video summarization similar to Summe's TextRank We have the popular TextRank API which given a text, ranks keywords and can apply summarization given a predefined text length. \nI am wondering if there is a similar tool for video summarization. Maybe a library, a deep model or ML-based tool that given a video file and a length, it ranks frames, or video scenes/shots. I'd like to generate a short summary of a video with visual features.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "From \"Deep learning-based video summarization \u2014 A detailed exploration\" by Surya Remanan:\nVideo summarization can be considered as the process of distilling a raw video into a more compact form without losing much information. In a general video summarization system, image features of video frames are extracted, and then the most representative frames are selected through analyzing the visual variations among visual features. This is done either by taking a holistic view of the entire video or by identifying the local differentiation among the adjacent frames. Most of those attempts rely on global features such as colour, texture, motion information, etc. Clustering techniques are also used for summarization. Video summarization can be categorized into two forms:\n\nStatic video summarization (keyframing) and\nDynamic video summarization (video skimming)\n\nStatic video summaries are composed of a set of keyframes extracted from the original video, while dynamic video summaries are composed of a set of shots and are produced taking into account the similarity or domain-specific relationships among all video shots.\nFollowing is an attention-based video summarization model - PyTorch implementation of the ACCV 2018-AIU2018 paper Video Summarization with Attention\nThere is a video summarisation focused models using reinforcement learning - Unsupervised video summarization with deep reinforcement learning (Theano)\nThere is an LSTM - GAN based approach to video summarization - video summarization lstm-gan pytorch implementation\nMicrosoft Bing Search has come up with a video summarization technique using thumbnails. Intelligent Search: Video summarization using machine learning\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it ok to struggle with mathematics while learning AI as a beginner? I have a decent background in Mathematics and Computer Science .I started learning AI from Andrew Ng's course from one month back. I understand logic and intuition behind everything taught but if someone asks me to write or derive mathematical formulas related to back propagation I will fail to do so.\nI need to complete object recognition project within 4 months.\nAm I on right path?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I think the key part of your question is \"as a beginner\". For all intents and purposes you can create a state of the art (SoTA) model in various fields with no knowledge of the mathematics what so ever. \nThis means you do not need to understand back-propagation, gradient descent, or even mathematically how each layer works. Respectively you could just know there exists an optimizer and that different layers generally do different things (convolutions are good at picking up local dependencies, fully connected layers are good at picking up connections among your neurons in an expensive manner when you hold no previous assumptions), etc.. Follow some common intuitions and architectures built upon in the field and your ability to model will follow (thanks to the amazing work on opensource ML frameworks -- Looking at you Google and Facebook)! But this is only a stop-gap. \nA Newton quote that I'm about to butcher: \"If I have seen further it's because I'm standing on the shoulders of giants\". In other words he saw further because he didn't just use what people before him did, he utilized it to expand even further. So yes, I think you can finish your object detection project on time with little understanding of the math (look at the Google object detection API, it does wonders and you don't even need to know anything about ML to use it, you just need to have data. But, and this is a big but, if you ever want to extend into a realm that isn't particularly touched upon or push the envelope in any meaningful way, you will probably have to learn the math, learn the basics, learn the foundations.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does TD Learning require Markovian domains? One of my friends and I were discussing the differences between Dynamic Programming, Monte-Carlo, and Temporal Difference (TD) Learning as policy evaluation methods - and we agreed on the fact that Dynamic Programming requires the Markov assumption while Monte-Carlo policy evaluation does not.\nHowever, he also pointed out that Temporal Difference Learning cannot handle non-Markovian domains, i.e. it depends on the Markov assumption. Why is it so?\nThe way I understand it, the TD learning update is, in essence, the same as the Monte-Carlo update, except for the fact that the return instead of being calculated using the entire trajectory, is bootstrapped from the previous estimate of the value function, i.e. we can update the value as soon as we encounter a $(s,a,r,s')$ tuple, we don't have to wait for the episode (if finite) to terminate.\nWhere is the Markov assumption being used here, i.e the future is independent of the past given the present?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The Markov assumption is used when deriving the Bellman equation for state values:\n$$v(s) = \\sum_a \\pi(a|s)\\sum_{r,s'} p(r,s'|s,a)(r + \\gamma v(s'))$$\nOne requirement for this equation to hold is that $p(r,s'|s,a)$ is consistent. The current state $s$ is a key argument of that function. There is no adjustment for history of previous states, actions or rewards. This is the same as requiring the Markov trait for state, i.e. that $s$ holds all information necessary to predict outcome probabilities of the next step.\nThe one step TD target that is sampled in basic TD learning is simply the inner part of this:\n$$G_{t:t+1} = R_{t+1} + \\gamma \\hat{v}(S_{t+1})$$\nwhich when sampled is equal to $v(s)$ in expectation *, when $S_t = s$. That is, when you measure a single instance of the TD target and use it to update a value function, you implicitly assume that the values or $r_{t+1}$ and $s_{t+1}$ that you observed occur with probabilities determined by $\\pi(a|s)$ and $p(r,s'|s,a)$ as shown by the Bellman equation.\nSo the theory behind TD learning uses the Markov assumption, otherwise the sampled TD targets would be incorrect.\nIn practice you can get away with slightly non-Markov environments - most measurements of state for machinery are approximations that ignore details at some level, for instance, and TD learning can solve optimal control in many robotics environments. However, Monte Carlo methods are more robust against state representations that are not fully Markov.\n\n* Technically this sample is biased because $\\hat{v}(S_{t+1})$ is not correct when learning starts. The bias reduces over time and multiple updates. So the expected value during learning is approximately the same as the true value as shown by the Bellman equation.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When is the Markov decision process not adequate for goal-directed learning tasks? In the book Reinforcement Learning: An Introduction (Sutton and Barto, 2018). The authors ask\n\nExercise 3.2: Is the MDP framework adequate to usefully represent all goal-directed learning tasks? Can you think of any clear\n exceptions?\n\nI thought maybe a card game would be an example if the state does not contain any pieces of information on previously played cards. But that would mean that the chosen state leads to a system that is not fully observable. Hence, if I track all cards and append it to the state (state vector with changing dimension) the problem should have the Markov Property (no information on the past states is needed). This would not be possible if the state is postulated as invariant in MDP.\nIf the previous procedure is allowed, then it seems to me that there are no examples where the MDP is not appropriate.\nI would be glad if someone could say if my reasoning is right or wrong. What would be an appropriate answer to this question?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Background\nThe Markov Decision Process is an extension of Andrey Markov's action sequence that visualize action-result sequence possibilities as a directed acyclic graph. One path through the acyclic graph, if it satisfies the Markov Property is called a Markov Chain.\nThe Markov Property requires that the probability distribution of future states at any point within the acyclic graph be evaluated solely on the basis of the present state.\nMarkov Chains are thus a stochastic model theoretically representing one of the set of possible paths. And the action-result sequence is a list of state transitions corresponding to actions chosen solely by each action's previous state and the expectations that the expected subsequent state will most probably lead to the desired outcome.\nAndrey Markov based his work on Gustav Kirchhoff's work on spanning trees, which is based on Euler's initial directed graph work.\nThe Exercise\nExercise 3.2 was given with two parts.\n\nIs the MDP framework adequate to usefully represent all goal-directed learning tasks?\nCan you think of any clear exceptions?\n\nThe first question is subjective in that it inquires about usefulness but does not define what it means. If \"useful\" means the MDP will improve the chances of achieving a goal over a random selection of action at each state, then except in no win scenarios or the most contrived case where all actions have equal distribution of probable results, then the MDP is useful.\nIf \"useful\" means optimal, then there are other approaches, with additional complexity and requiring additional computing resources that will improve odds of goal achievement. These other approaches overcome one or more of the limitations of pure MDP.\nAdvancements and Alternatives\nAdvancements made to MDP and alternatives to MDP, which number in the hundreds, include these.\n\nLogical detection of the infeasibility of goal achievement (no win scenario)\nCalculation of probabilities when only partial information is available about the current state\nInvocation of the decision at any point (continuous MDP used in real time systems)\nProbabilities are not known and must be learned from past experience where simple Q-learning is employed\nPast experience is used by statistically relating action-state details to generalizations derived from past action-result sequences or such information acquired or shared\nThe action-state decisions, made within the context of an unknown system of changing or not reliably applied rules, can be used to tune a set of fuzzy rules in a fuzzy logic container and utilize fuzzy inference in the decisions\nBluff and fraud detection\n\nCard Games\nGame play for a typical card game could make use of MDP, so MDP would be strictly useful, however not optimal. Some of the above decisioning features would be more optimal, particularly those that deals with unknowns and employ rules, since the card game has them.\nRandom or Decoupled\nTwo obvious cases are (a) a truly randomized action-result world where goal achievement has equal probability no matter the sequence of moves or (b) a scenario where goal achievement is entirely decoupled from actions the actor can take. In those cases, nothing will be useful with regard to the particular objective chosen.\nChallenge\nThe way to best learn from the exercise, though, is to find a scenario where MDP would be useless and one of the above listed Advancements and Alternatives would be required rather than simply preferred. If you look at the list, there will be some cases that will eventually come to mind. I suggest you think it through, since the goal is to learn from the book.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Do convolutional neural networks perform convolution or cross-correlation? Typically, people say that convolutional neural networks (CNN) perform the convolution operation, hence their name. However, some people have also said that a CNN actually performs the cross-correlation operation rather than the convolution. How is that? Does a CNN perform the convolution or cross-correlation operation? What is the difference between the convolution and cross-correlation operations?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Short answer\nTheoretically, convolutional neural networks (CNNs) can either perform the cross-correlation or convolution: it does not really matter whether they perform the cross-correlation or convolution because the kernels are learnable, so they can adapt to the cross-correlation or convolution given the data, although, in the typical diagrams, CNNs are shown to perform the cross-correlation because (in libraries like TensorFlow) they are typically implemented with cross-correlations (and cross-correlations are conceptually simpler than convolutions). Moreover, in general, the kernels can or not be symmetric (although they typically won't be symmetric). In the case they are symmetric, the cross-correlation is equal to the convolution.\nLong answer\nTo understand the answer to this question, I will provide two examples that show the similarities and differences between the convolution and cross-correlation operations. I will focus on the convolution and cross-correlation applied to 1-dimensional discrete and finite signals (which is the simplest case to which these operations can be applied) because, essentially, CNNs process finite and discrete signals (although typically higher-dimensional ones, but this answer applies to higher-dimensional signals too). Moreover, in this answer, I will assume that you are at least familiar with how the convolution (or cross-correlation) in a CNN is performed, so that I do not have to explain these operations in detail (otherwise this answer would be even longer).\nWhat is the convolution and cross-correlation?\nBoth the convolution and the cross-correlation operations are defined as the dot product between a small matrix and different parts of another typically bigger matrix (in the case of CNNs, it is an image or a feature map). Here's the usual illustration (of the cross-correlation, but the idea of the convolution is the same!).\n\nExample 1\nTo be more concrete, let's suppose that we have the output of a function (or signal) $f$ grouped in a matrix $$f = [2, 1, 3, 5, 4] \\in \\mathbb{R}^{1 \\times 5},$$ and the output of a kernel function also grouped in another matrix $$h=[1, -1] \\in \\mathbb{R}^{1 \\times 2}.$$ For simplicity, let's assume that we do not pad the input signal and we perform the convolution and cross-correlation with a stride of 1 (I assume that you are familiar with the concepts of padding and stride).\nConvolution\nThen the convolution of $f$ with $h$, denoted as $f \\circledast h = g_1$, where $\\circledast$ is the convolution operator, is computed as follows\n\\begin{align}\nf \\circledast h = g_1\n&=\\\\\n[(-1)*2 + 1*1, \\\\\n(-1)*1 + 1*3, \\\\\n(-1)*3 + 1*5, \\\\\n(-1)*5+1*4] \n&=\\\\ \n[-2 + 1, -1 + 3, -3 + 5, -5 + 4]\n&=\\\\\n[-1, 2, 2, -1] \\in \\mathbb{R}^{1 \\times 4}\n\\end{align}\nSo, the convolution of $f$ with $h$ is computed as a series of element-wise multiplications between the horizontally flipped kernel $h$, i.e. $[-1, 1]$, and each $1 \\times 2$ window of $f$, each of which is followed by a summation (i.e. a dot product). This follows from the definition of convolution (which I will not report here).\nCross-correlation\nSimilarly, the cross-correlation of $f$ with $h$, denoted as $f \\otimes h = g_2$, where $\\otimes$ is the cross-correlation operator, is also defined as a dot product between $h$ and different parts of $f$, but without flipping the elements of the kernel before applying the element-wise multiplications, that is\n\\begin{align}\nf \\otimes h = g_2\n&=\\\\\n[1*2 + (-1)*1, \\\\ \n1*1 + (-1)*3, \\\\ \n1*3 + (-1)*5, \\\\ \n1*5 + (-1)*4] \n&=\\\\ \n[2 - 1, 1 - 3, 3 - 5, 5 - 4]\n&=\\\\\n[1, -2, -2, 1] \\in \\mathbb{R}^{1 \\times 4}\n\\end{align}\nNotes\n\nThe only difference between the convolution and cross-correlation operations is that, in the first case, the kernel is flipped (along all spatial dimensions) before being applied.\n\nIn both cases, the result is a $1 \\times 4$ vector. If we had convolved $f$ with a $1 \\times 1$ vector, the result would have been a $1 \\times 5$ vector. Recall that we assumed no padding (i.e. we don't add dummy elements to the left or right borders of $f$) and stride 1 (i.e. we shift the kernel to the right one element at a time). Similarly, if we had convolved $f$ with a $1 \\times 3$, the result would have been a $1 \\times 3$ vector (as you will see from the next example).\n\nThe results of the convolution and cross-correlation, $g_1$ and $g_2$, are different. Specifically, one is the negated version of the other. So, the result of the convolution is generally different than the result of the cross-correlation, given the same signals and kernels (as you might have suspected).\n\n\nExample 2: symmetric kernel\nNow, let's convolve $f$ with a $1 \\times 3$ kernel that is symmetric around the middle element, $h_2 = [-1, 2, -1]$. Let's first compute the convolution.\n\\begin{align}\nf \\circledast h_2 = g_3\n&=\\\\\n[(-1)*2 + (2)*1 + (-1)*3,\\\\ \n(-1)*1 + (2)*3 + (-1)*5,\\\\ \n(-1)*3 + (2)*5 + (-1)*4] \n&=\\\\ \n[-2 + 2 + -3,\\\\ \n-1 + 6 + -5,\\\\ \n-3 + 10 + -4] \n&=\\\\\n[-3, 0, 3]\n\\in \\mathbb{R}^{1 \\times 3}\n\\end{align}\nNow, let's compute the cross-correlation\n\\begin{align}\nf \\otimes h_2 = g_4\n&=\\\\\n[(-1)*2 + (2)*1 + (-1)*3, \\\\ \n(-1)*1 + (2)*3 + (-1)*5, \\\\ \n(-1)*3 + (2)*5 + (-1)*4] \n&=\\\\\n[-3, 0, 3]\n\\in \\mathbb{R}^{1 \\times 3}\n\\end{align}\nYes, that's right! In this case, the result of the convolution and the cross-correlation is the same. This is because the kernel is symmetric around the middle element. This result applies to any convolution or cross-correlation in any dimension. For example, the convolution of the 2d Gaussian kernel (a centric-symmetric kernel) and a 2d image is equal to the cross-correlation of the same signals.\nCNNs have learnable kernels\nIn the case of CNNs, the kernels are the learnable parameters, so we do not know beforehand whether the kernels will be symmetric or not around their middle element. They won't probably be. In any case, CNNs can perform either the cross-correlation (i.e. no flip of the filter) or convolution: it does not really matter if they perform cross-correlation or convolution because the filter is learnable and can adapt to the data and tasks that you want to solve, although, in the visualizations and diagrams, CNNs are typically shown to perform the cross-correlation (but this does not have to be the case in practice).\nDo libraries implement the convolution or correlation?\nIn practice, certain libraries provide functions to compute both convolution and cross-correlation. For example, NumPy provides both the functions convolve and correlate to compute both the convolution and cross-correlation, respectively. If you execute the following piece of code (Python 3.7), you will get results that are consistent with my explanations above.\n# Using Python 3.11.9 and NumPy 2.0.2\n\nimport numpy as np\n\nf = np.array([2.0, 1.0, 3.0, 5.0, 4.0])\n\nh = np.array([1.0, -1.0])\n\nconv = np.convolve(f, h, mode=\"valid\")\ncross = np.correlate(f, h, mode=\"valid\")\n\nprint(f\"Convolution of f = {f} and h = {h} = {conv}\")\nprint(f\"Correlation of f = {f} and h = {h} = {cross}\")\n\nh2 = np.array([-1.0, 2.0, -1.0])\n\nconv = np.convolve(f, h2, mode=\"valid\")\ncross = np.correlate(f, h2, mode=\"valid\")\n\nprint(f\"Convolution of f = {f} and h2 = {h} = {conv}\")\nprint(f\"Correlation of f = {f} and h2 = {h} = {cross}\")\n\nResult\nConvolution of f = [2. 1. 3. 5. 4.] and h = [ 1. -1.] = [-1. 2. 2. -1.]\nCorrelation of f = [2. 1. 3. 5. 4.] and h = [ 1. -1.] = [ 1. -2. -2. 1.]\nConvolution of f = [2. 1. 3. 5. 4.] and h2 = [ 1. -1.] = [-3. 0. 3.]\nCorrelation of f = [2. 1. 3. 5. 4.] and h2 = [ 1. -1.] = [-3. 0. 3.]\n\nHowever, NumPy is not really a library that provides out-of-the-box functionality to build CNNs.\nOn the other hand, TensorFlow's and PyTorch's functions to build the convolutional layers actually perform cross-correlations. As I said above, although it does not really matter whether CNNs perform the convolution or cross-correlation, this naming is misleading. Here's a proof that TensorFlow's tf.nn.conv1d actually implements the cross-correlation.\n# Using Python 3.11.9 and TensorFlow 2.18.0\n\nimport tensorflow as tf\n\nf = tf.constant([2.0, 1.0, 3.0, 5.0, 4.0], dtype=tf.float32)\nh = tf.constant([1.0, -1.0], dtype=tf.float32)\n\n# Reshaping the inputs because conv1d accepts only certain shapes.\nf = tf.reshape(f, [1, int(f.shape[0]), 1])\nh = tf.reshape(h, [int(h.shape[0]), 1, 1])\n\nc = tf.nn.conv1d(f, h, stride=1, padding=\"VALID\")\n\n# Using tf.squeeze to improve readability.\nprint(f\"conv1d of f = {tf.squeeze(f)} and h = {tf.squeeze(h)} = {tf.squeeze(c)}\")\n\nResult\nconv1d of f = [2. 1. 3. 5. 4.] and h = [ 1. -1.] = [ 1. -2. -2. 1.]\n\nFurther reading\nAfter having written this answer, I found the article Convolution vs. Cross-Correlation (2019) by Rachel Draelos, which essentially says the same thing that I am saying here, but provides more details and examples.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there a theoretical maximum for intelligence? From Artificial Intelligence: A Modern Approach, Third Edition, Chapter 26:\n\nNote that the concept of ultraintelligent machines assumes that intelligence is an especially important attribute, and if you have enough of it, all problems can be solved. But we know there are limits on computability and computational complexity. If the problem of defining ultraintelligent machines (or even approximations to them) happens to fall in the class of, say, NEXPTIME-complete problems, and if there are no heuristic shortcuts, then even exponential progress in technology won't help\u2014the speed of light puts a strict upper bound on how much computing can be done; problems beyond that limit will not be solved. We still don't know where those upper bounds are.\n\nIf the textbook's argument is correct, then there may be a strict upper bound to intelligence, meaning that the potential (or damage) of super-intelligence is limited. However, it is contingent on there actually being a theoretical maximum for intelligence.\nIs there any literature that suggests that we know for sure whether such a maximum exist? Is the existence of that maximum dependent on our definition of intelligence (so adopting a vague and hand-wavey definition would imply no theoretical maximum, while adopting a strict and formalized definition would imply a theoretical maximum)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Note that the statement says nothing directly about the limit of intelligence, nor even about the limit of computational intelligence - but about the limit of computing power.\nPerhaps the sentence \"the speed of light puts a strict upper bound on how much computing can be done\" needs a better explanation: \nThe authors are probably referring to Bremermann's limit, which defines an upper bound in bits per second per kilogram. It is an upper bound on the processing power per unit of time of a computer with a given weight.\nThere is also Margolus\u2013Levitin theorem which defines an upper limit in operations per second per joule. It is an upper bound on the processing power per unit of energy.\nThese principles do not define a theoretical limit on computing power, but a practical one. If you'll limit your computer and your energy source to the size and capacity of the earth (or to the those of the universe) - you'll get a very practical limit.\nCheck the reference section in Wikipedia article Limits to computation\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to use computer vision to find corners of a soccer field based on location coordinates? I want to use computer vision to allow my robot to detect the corners of a soccer field based on its current position. Matlab has a detectHarrisFeatures feature, but I believe it is only for 2D mapping.\nThe approach that I want to try is to collect the information of the lines (using line detection), store them in a histogram, and then see where the lines intersect based on their angles.\nMy questions are:\n\n\nHow do I know where the lines intersect?\nHow do I find the angles of the lines using computer vision?\nHow do I update this information based on my coordinates?\n\n\nI am in the beginning stages of this task, so any guidance is much appreciated!\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I assume that you are familiar with homogeneous transformations and the meaning of global and local coordinate frames. If not, global frame is the fixed frame; a reference frame for your whole problem, such as the starting position of your robot. Local frame should be placed anywhere on your robot, preferably in the middle-point of the virtual line (called \"robot base\") that connects the two actuating wheels in the back of your robot (given that you follow the differential drive setup). If not, just place the local frame anywhere that makes sense on the robot, such as its geometrical center.\nAnswering your questions:\n\nHow do I know where the lines intersect?\n\nThe accepted answer in this is by far the best I have seen around, which I have also used successfully for a project regarding robotic exploration in an unknown maze.\n\nHow do I find the angles of the lines using computer vision?\n\nYou DON'T need computer vision for that. For every line, pick 2 points expressed in global frame (x1,y1),(x2,y2) and calculate the slope of the line as:\nlambda = (y2-y1) / (x2-x1)\n\nThen the angle of the line is atan(lambda), in global frame. Do this for all lines and then subtract the angles of any two lines to find their relative angle (pay attention to the sign).\nAlternatively, I would personally use the RANSAC algorithm to de-noise the detected points and give me the line equation based on the consensus of all points. This line equation should already have the slope in it:\ny = ax + b\n\nwhere a is the slope and b is the vertical offset. Then do the aforementioned steps, i.e. atan(a) and subtraction to find the relative angle between two lines.\nIf you explicitly want to use computer vision, maybe train a neural network on known angles and then classify images of lines to output their angles. This approach will be by far the most painful and I do NOT recommend it at all.\n\nHow do I update this information based on my coordinates?\n\nThis can be quite tricky. If the line points are detected by your on-board camera, you first of all need to convert them from the camera's coordinate frame (found in the camera's datasheet) to your robot's local frame, as explained above. To do this, you need to calculate the static transformation between the two frames (static because it will never change if the camera is fixed on the robot, you only define it once).\nThen you need to convert the detected line equation from your robot's frame to the global frame. In order to do so, you need to keep track of the robot's pose (position + orientation) while it moves in the 2D or 3D space. This is generally a hard task because it needs an excellent implementation of your localization algorithms, such as an Extended Kalman Filter or Particle Filter. The localization algorithm will provide you with the information that you need at any point in time in order to convert the lines/points from your robot frame to the global frame and visualize them.\nIn short: you need to transform the detected lines / points from camera frame -> robot (local) frame -> global frame. The first transformation is static (calculated once and never changes) whereas the second one is dynamic (changes every time the robot moves or turns). The first one is fairly easy to calculate but the second one can be a real pain.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a \"logit probability\"? DeepMind's paper \"Mastering the game of Go without human knowledge\" states in its \"Methods\" section on its \"Neural network architecture\" that the output layer of AlphaGo Zero's policy head is \"A fully connected linear layer that outputs a vector of size 19^2+1=362, corresponding to the logit probabilities for all intersections and the pass move\" (emphasis mine). I am self-trained regarding neural networks, and I have never heard of a \"logit probability\" before this paper. I have not been able by searching and reading to figure out what it means. In fact, the Wikipedia page on logit seems to make the term a contradiction. A logit can be converted into a probability using the equation $p=\\frac{e^l}{e^l+1}$, and a probability can be converted into a logit using the equation $l=\\ln{\\frac{p}{1-p}}$, so the two cannot be the same. The neural network configuration for Leela Zero, which is supposed to have a nearly identical architecture to that described in the paper, seems to indicate that the fully connected layer described in the above quote needs to be followed with a softmax layer to generate probabilities (though I am absolutely new to Caffe and might not be interpreting the definitions of \"p_ip1\" and \"loss_move\" correctly). The AlphaGo Zero cheat sheet, which is otherwise very helpful, simply echoes the phrase \"logit probability\" as though this is a well-known concept. I have seen several websites that refer to \"logits\" on their own (such as this one), but this is not enough to satisfy me that \"logit probability\" must mean \"a probability generated by passing a logit vector through the softmax function\".\nWhat is a logit probability? What sources can I read to help me understand this concept better?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Indeed I haven't seen the term \"logit probability\" used in many places other than that specific paper. So, I cannot really comment on why they're using that term / where it comes from / if anyone else uses it, but I can confirm that what they mean by \"logit probability\" is basically the same thing that is more commonly referred to simply as \"logits\": they are the raw, unbounded scores of which we generally push a vector through a softmax function to generate a discrete probability distribution that nicely adds up to $1$.\nThis definition fits the one you linked from wikipedia (although that link only covers the binary case, and AlphaGo Zero would have multinomial logits since it has more than two outputs for the policy head).\nIn the AlphaGo Zero paper, the described architecture has a \"linear output layer\" (i.e. no activation function for the outputs, or the identity function as activation function for the outputs, or however you like to describe it) for the policy head. This means that these outputs are essentially unbounded, they could be any real number. We know for sure that these outputs cannot directly be interpreted as probabilities, even if this isn't stated quite explicitly in the paper.\nBy calling them logits (or logit probabilities for reasons unknown to me), they are essentially implying that these outputs will still be post-processed by a softmax to convert them into a vector that can be interpreted as a discrete probability distribution over the actions, even if they do not explicitly describe a softmax layer as being a part of the network.\nIt is indeed possible that in Leela Zero they decided to make the softmax operation explicitly a part of the Neural Network architecture. Mathematically they end up doing the same thing... the AlphaGo Zero paper implies (by using the word \"logit\") that a softmax is used as a \"post-processing\" step, and in Leela Zero they explicitly make it a part of the Neural Network.\nHere are a couple more sources for the reasoning that usage of the word \"logit\" basically implies usage of a softmax, though indeed they do not cover the term \"logit probability\":\n\nhttps://stats.stackexchange.com/a/52836/144483\nhttps://stackoverflow.com/a/34243720/6735980\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to show temporal difference methods converge to MLE? In chapter 6 of Sutton and Barto (p. 128), they claim temporal difference converges to the maximum likelihood estimate (MLE). How can this be shown formally?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The convergence and optimality proofs of (linear) temporal-difference methods (under batch training, so not online learning) can be found in the paper Learning to predict by the methods of temporal differences (1988) by Richard Sutton, specifically section 4 (p. 23). In this paper, Sutton uses a different notation than the notation used in the famous book Reinforcement Learning: An Introduction (2nd ed.), by Sutton and Barto, so I suggest you get familiar with the notation before attempting to understand the theorem and the proof. For example, Sutton uses letters such as $i$ and $j$ to denote states (rather than $s$), $z$ to denote (scalar) outcomes and $x$ to denote (vector) observations (see section 3.2 for example of the usage of this notation).\nIn the paper The Convergence of TD($\\lambda$) for General $\\lambda$ (1992), Peter Dayan, apart from recapitulating the convergence proof provided by Sutton, he also shows the convergence properties of TD($\\lambda$) and he extends Watkins' Q-learning convergence theorem, whose sketch is presented in his PhD thesis Learning from Delayed Rewards (1989), and defined in detail in Technical Note: Q-learning (1992), by Dayan and Watkins, to provide the first strongest guarantee or convergence proof for TD(0).\nThere is much more research work on the convergence properties of TD methods, such as Q-learning and SARSA. For example, in the paper On the Convergence of Stochastic Iterative Dynamic Programming Algorithms (1994), where Q-learning is presented as a stochastic form of dynamic programming methods, the authors provide a proof of convergence for Q-learning by making direct use of stochastic approximation theory. See also Convergence of Q-learning: a simple proof by Francisco S. Melo. In the paper Convergence Results for Single-Step On-Policy Reinforcement-Learning Algorithms, the authors provide a proof of the convergence properties of on-line temporal difference methods (e.g. SARSA).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is the play of strong Chess AI easily distinguishable from human play? I don't play nearly enough Chess to be able to answer. For context, AlphaGo is stronger than the current strongest human player, but AlphaGo's game play has been cast as \"inhuman\" in the sense that it doesn't resemble human play. (In Go, this can involve aesthetic qualities.)\nReally I'm wondering about \"narrow\" application of the Imitation Game/Turing Test, where one might design an automata to play more like a human, so that human players would be unable to determine if their opponent was a human or an automata.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "AI programs that exist in today's world fall into the category of Narrow Intelligence. Narrow Intelligence\nare easy to distinguish when compared to General Intelligence (ones that resemble more like humans).\nHighly advanced AI can often resemble to act like humans thought. I will like to talk about Deep Blue here.\nGarry Kasparov, in a series of matches during Feb 1996, even though\nwon three matches but, had a \" shattering experience\". Deep Blue\nflummoxed him in that first game by making a move with no immediate\nmaterial advantage; nudging a pawn into a position where it could be\neasily captured. He said, \"It was a wonderful and extremely human\nmove\" and this threw him for a loop. He further added that he had\nplayed a lot of computers but had never experienced anything like\nthis. He added, \"I could feel, I could smell, a new kind of intelligence\nacross the table.\"\nNext year he lost to an improved version of Deep Blue. Here also he\nlost mostly because of psychological reason. He later said that he\nwas riled by a move the computer made that was so surprising and\nso un-machine-like that he was sure that IBM team had cheated.\nIt was later found out that it was a glitch in Deep Blue. The program\ncame across too many options and had no clear preference and thus\nplayed a random move.\nIt was this random move that shifted the game in favour of Deep Blue.\n\nOne advantage that Deep Blue (or other programs) have is the ability to perform far more computations in a given time. Humans, on the other hand, can extend their decision tree only to very limited depth. On having no clear decision to take, we take a random decision and try to learn from the experience, unlike most Narrow Intelligence programs present today. We need a fair amount of\nrandomness and learning from experience to be added to the program in order\nto make it more like a human.\nThe answer to this question also depends on your position on \"Chinese Room Argument\".\nThe argument holds that a program can't give a computer understanding\nor consciousness regardless of how intelligently or human like\nthe program may make the computer behave. Chinese Room Argument focuses on something very important when it comes to \"Consciousness v/s Simulation of Consciousness\". John Searle argued there that it is possible for a machine (or human) to follow a huge number of predefined rules (algorithm), in order to complete the task, without thinking or possessing the mind.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can I formulate the map colouring problem as a hill climbing search problem? I have a map. I need to colour it with $k$ colours, such that two adjacent regions do not share a colour. \nHow can I formulate the map colouring problem as a hill climbing search problem?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First of all you need an initial solution. You will then improve this solution with hill climbing.\nFor your initial solution, you can color the map randomly using the K colors. This will most likely result in conflicts (adjacent regions of the same color).\nThen the hill climbing part: Find a region which has conflicts and swap its color for another color, making sure that the new color does not incur more conflicts than the old one. With each iteration your solution should slowly improve.\nNote that hill climbing is not perfect and that you may not find a feasible solution in the end.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do feedforward neural networks require the inputs to be of a fixed size, while RNNs can process variable-size inputs? Why does a vanilla feedforward neural network only accept a fixed input size, while RNNs are capable of taking a series of inputs with no predetermined limit on the size? Can anyone elaborate on this with an example?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You are talking about two different types of 'size'. The size of the input for a FFNN and a RNN must always remain fixed for the same network architecture, i.e. they take in a vector $x \\in \\mathbb{R}^d$ and could not take as input for instance a vector $y \\in \\mathbb{R}^b$ where $b \\neq d$. The size you refer to in the context of the RNN is the length of the input sequence.\nWhat you are getting confused with is that RNN's can make predictions relating to sequences, that is imagine now rather than one $x$ we have a sequence of related, i.e. not i.i.d. data such as time series data, data $\\{x_i\\}_{i=1}^n$. Assuming we are given some initial $h_0$ (a hidden state) then an RNN will take as input $x_1$ and $h_0$ and output a prediction $y_1$ and a new hidden state $h_1$. In general an RNN will take as input $x_n$ and $h_{n-1}$ and output $y_n$ and $h_n$ where the hidden state is passed as input to the RNN at the next time step. However, the dimensionality of all the $x$'s and $h$'s will all be the same, i.e. $x_i \\in \\mathbb{R}^d$ and $h_i \\in \\mathbb{R}^c$ for all $i$, where $d$ does not necessarily have to be equal to $c$ (and in my experience rarely is).\nNote that RNN's can also perform sequence to sequence prediction (such as language translation) where the predicted sequence can be a different length to the input sequence, as is the case when doing translation (the input sentence is not necessarily the same length in the translated language). They do this by having an encoder and a decoder which are two separate RNNs. The encoder is fed the input sequence and we maintain all the hidden states outputted by the encoder $\\{e_i\\}_{i=1}^n$. The decoder is then given a token that represents the start of a sequence and the last hidden state of the encoder $e_n$ as input to which it will make a prediction on what the word should be (I believe but am not 100% certain that the decoder outputs a probability distribution over the dictionary of words it can predict from) and then the word chosen is passed as input to the decoder at the next step, along with the hidden state from the decoder at the previous step and another word is predicted. This continues until the system predicts an End of Sequence token (or until it is forced to by some time limit). More details can be found in this paper but I believe in NLP it is much more common to use attention models now rather than the methods introduced in this paper.\nNow, with this data $\\{x_i\\}_{i=1}^n$ you could in theory pass each one individually to a FFNN but a) it would not capture the sequential nature of the data as the assumption is that each data point is independent of the others and you can see this from the architecture of a FFNN -- they are Directed Acyclic Graphs, the Acyclic-ness is what causes the issue as there is no recursion which stops any sequential information from being passed from one time step to another and b) training using SGD would likely cause issues as we have violated the i.i.d. assumption needed for SGD to converge to local optima. More info on the i.i.d. requirement can be found here.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How was ChatGPT trained? I know that large language models like GPT-3 are trained simply to continue pieces of text that have been scraped from the web. But how was ChatGPT trained, which, while also having a good understanding of language, is not directly a language model, but a chatbot? Do we know anything about that? I presume that a lot of conversations was needed in order to train it. Did they simply scrape those conversations from the web, and where did they find such conversations in that case?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The key ingredient is called Reinforcement Learning from Human Feedback (RLHF), that is having humans rate the model answers and use the feedback to guide the model training.\n\nThe official blog explains this fairly well.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Benchmarks for reinforcement learning in discrete MDPs To compare the performance of various algorithms for perfect information games, reasonable benchmarks include reversi and m,n,k-games (generalized tic-tac-toe). For imperfect information games, something like simplified poker is a reasonable benchmark.\nWhat are some reasonable benchmarks to compare the performance of various algorithms for reinforcement learning in discrete MDPs? Instead of using a random environment from the space of all possible discrete MDPs on $n$ states and $k$ actions, are there subsets of such a space with more structure that are more reflective of \"real-world\" environments? An example of this might be so-called gridworld (i.e. maze-like) environments.\nThis is a related question, though I'm looking for specific examples of MDPs (with specified transitions and rewards) rather than general areas where MDPs can be applied.\nEdit: Some example MDPs are found in section 5.1 (Standard Domains) of Efficient Bayes-Adaptive Reinforcement Learning using Sample-Based Search (2012) by Guez et al.:\n\nThe Double-loop domain is a 9-state deterministic MDP with 2actions,\n 1000 steps are executed in this domain. Grid5 is a 5\u00d75 grid with no\n reward anywhere except for a reward state opposite to the reset state.\n Actions with cardinal directions are executed with small probability\n of failure for 1000 steps. Grid10 is a 10\u00d710 grid designed like Grid5.\n We collect 2000 steps in this domain. Dearden\u2019s Maze is a 264-states\n maze with 3 flags to collect. A special reward state gives the number\n of flags collected since the last visit as reward, 20000 steps are\n executed in this domain.\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Although I am not aware of any \"benchmark problems\" for (discrete) MDPs, I'll comment a bit on possible benchmarks and I will show some benchmarks used to test POMDP algorithms.\nMDP vs POMDP\nIn Markovian Decision Processes (MDPs) the whole state space is known, this means you know all the information for your problem; therefore, you can use them to find solutions for perfect information problems or games. \nMany of these games could use an MDP, some examples: 2048 and chess. Note that you must take into mind that the computational complexity grows with the number of states.\nAlthough I could not find any benchmarks for MDPs, games with perfect information can be used to compare MDP solvers.\nWhen a problem or game has imperfect information, you should use a Partially Observable Markovian Decision Processes (POMDPs); in which you do not need to know the current state, but you keep track of the probabilities of being in any of the (discrete) states.\nPOMDP Benchmarks\nSince I worked with POMDPs, I will comment some of the benchmarks researches used for discrete POMDPs (Pineau et al. (2003), Spaan and Vlassis (2004), Kurniawati et al. (2008), Ong et al. (2010), ArayaLopez et al. (2010)):\n\nTag: a robot and target move in a grid environment and can move one step at a time, moving has a cost, and a reward is gained if the robot is at the same position as the target (i.e. tagged it).\nTwo-Robot Tag: two robots attempt to catch a target, thereby sharing their observations and actions; the target tries to get away from them.\nMazes (Littman et al. (1995), Kaelbling et al. (1998), Spaan and Vlassis (2004)): \n\n\nHallway and Hallway2 are robot navigation tasks in a hallway, where the robot has only local noisy sensor information. The difficulty of hallways is it being long areas which look alike, which causes ambiguity in the localization.\nTiger-grid a two world state with a tiger being either behind the left or right door. The actions are listen, open the right or left door and there is a positive reward when opening the door without the tiger, otherwise a large negative reward.\n\nRock Sample: a rover explores a grid area, it knows its own position and the position of the rocks, however, it does not know which rocks are valuable. The rover can sense how valuable they are, but this sensor is less reliable when it is used farther away.\n\n\n\nThe tag game: the robot (blue) and target on a map with 29 positions and 870 states (29 for the robot, 29 + 1 (tagged) for the target).\nThese problems tend to be of the same size (number of states and actions) such that the results of different algorithms can be compared easily.\nReferences:\n\nAraya-Lopez, M., Thomas, V., Buffet, O., and Charpillet, F. (2010). A closer look at MOMDPs. In 2010 22nd IEEE International Conference on Tools with Artificial Intelligence, volume 2, pages 197\u2013204.\nKaelbling, L.P., Littman, M.L., Cassandra, A.R. (1998). \nPlanning and acting in partially observable stochastic domains. Artificial Intelligence, 101(1-2): 99-134\nKurniawati, H., Hsu, D., and Lee, W. (2008). SARSOP: Efficient point-based POMDP planning by approximating optimally reachable belief spaces. In Proceedings of Robotics: Science and Systems IV, Zurich, Switzerland.\nLittman, M.L., Cassandra, A.R. and Kaelbling, L.P. (1995). Learning policies for partially observable environments: Scaling up. in Proc. 12th Int. Conf. on Machine Learning, San Francisco, CA.\nOng, S. C. W., Png, S. W., Hsu, D., and Lee, W. S. (2010). Planning under Uncertainty for Robotic Tasks with Mixed Observability. The International Journal of Robotics Research, 29(8):1053\u20131068.\nPineau, J., Gordon, G., and Thrun, S. (2003). Point-based value iteration: An anytime algorithm for POMDPs. In Proceedings of the International Joint Conference on Artificial Intelligence (IJCAI),\npages 477\u2013484.\nSpaan, M. T. J. and Vlassis, N. (2004). A point-based POMDP algorithm for robot planning. In Proceedings of the IEEE International Conference on Robotics and Automation (ICRA), pages 2399\u20132404, New Orleans, Louisiana.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are filters fixed or learned? No matter what I google or what paper I read, I can't find an answer to my question. In a deep convolutional neural network, let's say AlexNet (Krizhevsky, 2012), filters' weights are learned by means of back-prop.\nBut how are kernels themselves selected? I know kernels had been used in image processing long before CNNs, hence I'd imagine there would be a set of filters based on kernels (see, for example, this article) that are proven to be effective for edge detection and the likes.\nReading around the web, I also found something about \"randomly generated kernels\". Does anyone know if and when this practice is adopted?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "What are filters in image processing?\nIn the context of image processing (and, in general, signal processing), the kernels (also known as filters) are used to perform some specific operation on the image. For example, you can use a Gaussian filter to smooth the image (including its edges).\nWhat are filters in CNNs?\nIn the context of convolutional neural networks (CNNs), the filters (or kernels) are the learnable parameters of the model.\nBefore training, the kernels are usually randomly initialised (so they are not usually hardcoded). During training, depending on the loss or error of the network (according to the loss function), the kernels (or filters) are updated, so that to minimise the loss (or error). After training, they are typically fixed. Incredibly, the filters learned by CNNs can be similar to the Gabor filter (which is thought to be related to our visual system [1]). See figure 9.19 of chapter 9 (p. 365) of the Deep Learning book by Goodfellow et al.\nThe number of kernels that are applied to a given input (and more than one kernel is often applied) in a CNN is a hyper-parameter.\nWhat are the differences and similarities?\nIn both contexts, the words \"kernel\" and \"filter\" are roughly synonymous, so they are often used interchangeably. Furthermore, in both cases, the kernels are related to the convolution (or cross-correlation) operation. More specifically, the application of a filter, which is a function $h$, to an input, which is another function $f$, is equivalent to the convolution of $f$ and $h$. In mathematics, this is often denoted by $f \\circledast h = g$, where $\\circledast$ is the convolution operator and $g$ is the result of the convolution operation and is often called the convolution (of $f$ and $h$). In the case of image processing, $g$ is the filtered image. In the case of CNNs, $g$ is often called an activation map.\nFurther reading\nTake a look at this and this answers for more details about CNNs and the convolution operation, respectively.\nYou may also want to have a look at Visualizing what ConvNets learn\n for some info about the visualization of the kernels learned during the training of a CNN.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When to expand and when to simulate in Monte Carlo Tree Search? In Monte Carlo Tree Search (MCTS), we start at root node $R$. Then we select some leaf node $L$. And we expand $L$ by one or more child nodes and simulate from the child to the end of the game. \n\nWhen should we expand and when should we simulate in MCTS? Why not expand 2 or 3 levels, and simulate from there, then back-propagate the values to the top? Should we just expand 1 level? Why not more?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The most common strategy is to simply expand exactly one node per iteration; you can view this as expanding the first node of the Play-Out phase (\"simulation\" in your image), and not expanding any other nodes of the Play-Out phase. This is also what's done in your image.\nThat is the most common and probably most simple strategy, but it's certainly not the only one. It is pretty much the minimum you have to expand, but you can expand more if you like. The most common approach of only expanding one node per iteration is basically there because it minimizes the risk of running out of memory; when you only add one new node to the tree per iteration, the tree grows relatively slowly, so you'd have to keep the algorithm running for a really long time before you run out of memory.\nIf you're not afraid of running out of memory, you can choose to expand as many nodes as you like. For example, my General Video Game AI agent expands every single node encountered during the play-out at once, because in that particular domain we only get to run relatively few iterations anyway so I'm not afraid of running out of memory, even if I do expand lots of nodes.\nThe backpropagation step can only store results (information) from your iterations in nodes that actually exist, nodes that have been expanded. So, the benefit of expanding more (if possible) is that you'll retain more information from early iterations, your backpropagation step immediately gets to store results in all nodes along the path instead of only the top few nodes. Generally, this is a relatively minor benefit; nodes deep in the tree / deep inside the simulations are quite unlikely to ever get visited more than once anyway, and then this doesn't matter. But expanding more can, in theory, result in slightly more accurate value estimates in nodes closer to the root.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the state-of-the-art approaches for continual learning with neural networks? There seems to be a lot of literature and research on the problems of stochastic gradient descent and catastrophic forgetting, but I can't find much on solutions to perform continual learning with neural network architectures.\nBy continual learning, I mean improving a model (while using it) with a stream of data coming in (maybe after a partial initial training with ordinary batches and epochs).\nA lot of real-world distributions are likely to gradually change with time, so I believe that we should be able to train NNs in an online fashion.\nDo you know which are the state-of-the-art approaches on this topic, and could you point me to some literature on them?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "What I understand from your questions is that you are trying to avoid catastrophic forgetting while applying online learning. \nThis problem should be addressed by implementing methods that reduce catastrophic forgetting for different tasks. At first glance it might seem that they don't apply because it's data that change and not a particular task but changing data result in a change of the task. Say your goal is to classify different breeds of dogs. Your online data-set morphs into excluding \"Great Danes\". Your neural network after enough epochs would forget about \"Great Danes\". The task is still serving its purpose by classifying different breeds but the task still changed. It changed from recognizing \"Great Danes\" as a dog breed to not recognizing \"Great Danes\" as a dog breed. The weights changed to exclude them but the methods I linked tries and keep weights intact even though it was not intended for the purpose of online learning. Just set the hyper parameters to include these techniques to low as I believe data won't have an instant change but would change over time, and you should be fine. \nThe most obvious technique being storing information as you train. This is called pseudo-rehearsal. With this at least you would be able to use stochastic gradient decent but you need memory and resources as the data set grows. \nThen there was an attempt to reduce impacts of weights on old tasks to keep some relevancy to them. Structural Regularization. \nLater these guys implemented HAT which seems to keep some weights static while others adapt to new tasks. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can I use AI to interpret XML documents? I think about a system which gets XML documents in various structures but with essentially the same data structure in it. For the example, let's assume each document contains data about one or more persons. So the AI would recognize a name. Somewhere else in the document there is the post address of our fictional person. The AI should now \"see\" the address and conclude, it belongs to our person. Anywhere else, there is a phone number in the document. Again, our AI should see the connection between our person and this phone number.\nThis wouldn't be a job for an AI if there wasn't a catch. If the task was merely to find and map strings like addresses and phone numbers, we could simply use a regex to match our \"target strings\". The catch in this scenario would be this: the XML document might contain other data, which does not belong to our person but is a valid phone number for example and thus will match an regex.\nWould it be possible for an AI to learn this? If yes, with which framework would someone create such an AI?\n\nSample XML document:\n\n\n \n \n \n \n John Doe\n \n \n
\n Main street 1\n 1111 Twilight town\n sample country\n
\n +123 123 123\n
\n \n \n \n Jane Doe\n \n \n
\n Broadway 42\n 4521 Traverse town\n sample country\n
\n +123 412123\n
\n
\n \n \n \n Sam Smith\n \n Seaside road 5\n 4521 Traverse town\n sample country\n \n +123 555 555\n \n
\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "XML, HTML and less formal languages all respond quite nicely to being transformed or interrogated within a graph framework. XML and HTML are particularly useful in that they conform strictly to a tree-structure. That means that any good data components can be measured in terms of tree-distance to any other \"good\" data components. \nIf you extract your regex-friendly terms and keep track of where within their tree they are found, you may be able to cast those values into a general document-space vector (it might only need to be one-dimensional), allowing you to identify clusters of \"good\" vs anomalous sections of \"bad\" data based on a simple distance metric, or anomaly detection algorithm - say an isolation-forest that runs on information density for example. \nThis depends on your data, and how much of it you can find, ideally already tagged up containing good vs bad. \nIf you're looking to scrape reliable address-contents, then yes, you're likely to score hits on names, addresses, postcodes and phone-numbers all appearing as tightly connected clustered groups, all within one or two nodes-distance from one another.\nMeanwhile, an annotation containing a phone number lodged somewhere else is less likely to be a match. \nDifferent documents will have different threshold densities, and differing anomaly to conformant ratios, so you'd have a task on your hands to figure out some way to automatically tune your parameters on any given document set. \nIn the past, I've tried doing this against html by flattening all the content into a single string of text and a similar approach yielded half-decent results, but if you're looking at XML, it's fair to expect the structure to yield more information. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "My Deep Q-Learning Network does not learn for OpenAI gym's cartpole problem I am implementing OpenAI gym's cartpole problem using Deep Q-Learning (DQN). I followed tutorials (video and otherwise) and learned all about it. I implemented a code for myself and I thought it should work, but the agent is not learning. I will really really really appreciate if someone can pinpoint where I am doing wrong.\nNote that I have a target neuaral network and a policy network already there. The code is as below.\nimport numpy as np\nimport gym\nimport random\nfrom keras.optimizers import Adam\nfrom keras.models import Sequential\nfrom keras.layers import Dense\nfrom collections import deque\n\nenv = gym.make('CartPole-v0')\n\nEPISODES = 2000\nBATCH_SIZE = 32\nDISCOUNT = 0.95\nUPDATE_TARGET_EVERY = 5\nSTATE_SIZE = env.observation_space.shape[0]\nACTION_SIZE = env.action_space.n\nSHOW_EVERY = 50\n\nclass DQNAgents:\n \n def __init__(self, state_size, action_size):\n self.state_size = state_size\n self.action_size = action_size\n self.replay_memory = deque(maxlen = 2000)\n self.gamma = 0.95\n self.epsilon = 1\n self.epsilon_decay = 0.995\n self.epsilon_min = 0.01\n self.model = self._build_model()\n self.target_model = self.model\n \n self.target_update_counter = 0\n print('Initialize the agent')\n \n def _build_model(self):\n model = Sequential()\n model.add(Dense(20, input_dim = self.state_size, activation = 'relu'))\n model.add(Dense(10, activation = 'relu'))\n model.add(Dense(self.action_size, activation = 'linear'))\n model.compile(loss = 'mse', optimizer = Adam(lr = 0.001))\n \n return model\n\n def update_replay_memory(self, current_state, action, reward, next_state, done):\n self.replay_memory.append((current_state, action, reward, next_state, done))\n \n def train(self, terminal_state):\n \n # Sample from replay memory\n minibatch = random.sample(self.replay_memory, BATCH_SIZE)\n \n #Picks the current states from the randomly selected minibatch\n current_states = np.array([t[0] for t in minibatch])\n current_qs_list= self.model.predict(current_states) #gives the Q value for the policy network\n new_state = np.array([t[3] for t in minibatch])\n future_qs_list = self.target_model.predict(new_state)\n \n X = []\n Y = []\n \n # This loop will run 32 times (actually minibatch times)\n for index, (current_state, action, reward, next_state, done) in enumerate(minibatch):\n \n if not done:\n new_q = reward + DISCOUNT * np.max(future_qs_list)\n else:\n new_q = reward\n \n # Update Q value for given state\n current_qs = current_qs_list[index]\n current_qs[action] = new_q\n \n X.append(current_state)\n Y.append(current_qs)\n \n # Fitting the weights, i.e. reducing the loss using gradient descent\n self.model.fit(np.array(X), np.array(Y), batch_size = BATCH_SIZE, verbose = 0, shuffle = False)\n \n # Update target network counter every episode\n if terminal_state:\n self.target_update_counter += 1\n \n # If counter reaches set value, update target network with weights of main network\n if self.target_update_counter > UPDATE_TARGET_EVERY:\n self.target_model.set_weights(self.model.get_weights())\n self.target_update_counter = 0\n \n def get_qs(self, state):\n return self.model.predict(np.array(state).reshape(-1, *state.shape))[0]\n \n\n''' We start here'''\n\nagent = DQNAgents(STATE_SIZE, ACTION_SIZE)\n\nfor e in range(EPISODES):\n \n done = False\n current_state = env.reset()\n time = 0 \n total_reward = 0\n while not done:\n if np.random.random() > agent.epsilon:\n action = np.argmax(agent.get_qs(current_state))\n else:\n action = env.action_space.sample()\n \n next_state, reward, done, _ = env.step(action)\n\n agent.update_replay_memory(current_state, action, reward, next_state, done)\n \n if len(agent.replay_memory) < BATCH_SIZE:\n pass\n else:\n agent.train(done)\n \n time+=1 \n current_state = next_state\n total_reward += reward\n \n print(f'episode : {e}, steps {time}, epsilon : {agent.epsilon}')\n \n if agent.epsilon > agent.epsilon_min:\n agent.epsilon *= agent.epsilon_decay\n\nResults for first 40ish iterations are below (look for the number of steps, they should be increasing and should reach a maximum of 199)\nepisode : 0, steps 14, epsilon : 1\nepisode : 1, steps 13, epsilon : 0.995\nepisode : 2, steps 17, epsilon : 0.990025\nepisode : 3, steps 12, epsilon : 0.985074875\nepisode : 4, steps 29, epsilon : 0.9801495006250001\nepisode : 5, steps 14, epsilon : 0.9752487531218751\nepisode : 6, steps 11, epsilon : 0.9703725093562657\nepisode : 7, steps 13, epsilon : 0.9655206468094844\nepisode : 8, steps 11, epsilon : 0.960693043575437\nepisode : 9, steps 14, epsilon : 0.9558895783575597\nepisode : 10, steps 39, epsilon : 0.9511101304657719\nepisode : 11, steps 14, epsilon : 0.946354579813443\nepisode : 12, steps 19, epsilon : 0.9416228069143757\nepisode : 13, steps 16, epsilon : 0.9369146928798039\nepisode : 14, steps 14, epsilon : 0.9322301194154049\nepisode : 15, steps 18, epsilon : 0.9275689688183278\nepisode : 16, steps 31, epsilon : 0.9229311239742362\nepisode : 17, steps 14, epsilon : 0.918316468354365\nepisode : 18, steps 21, epsilon : 0.9137248860125932\nepisode : 19, steps 9, epsilon : 0.9091562615825302\nepisode : 20, steps 26, epsilon : 0.9046104802746175\nepisode : 21, steps 20, epsilon : 0.9000874278732445\nepisode : 22, steps 53, epsilon : 0.8955869907338783\nepisode : 23, steps 24, epsilon : 0.8911090557802088\nepisode : 24, steps 14, epsilon : 0.8866535105013078\nepisode : 25, steps 40, epsilon : 0.8822202429488013\nepisode : 26, steps 10, epsilon : 0.8778091417340573\nepisode : 27, steps 60, epsilon : 0.8734200960253871\nepisode : 28, steps 17, epsilon : 0.8690529955452602\nepisode : 29, steps 11, epsilon : 0.8647077305675338\nepisode : 30, steps 42, epsilon : 0.8603841919146962\nepisode : 31, steps 16, epsilon : 0.8560822709551227\nepisode : 32, steps 12, epsilon : 0.851801859600347\nepisode : 33, steps 12, epsilon : 0.8475428503023453\nepisode : 34, steps 10, epsilon : 0.8433051360508336\nepisode : 35, steps 30, epsilon : 0.8390886103705794\nepisode : 36, steps 21, epsilon : 0.8348931673187264\nepisode : 37, steps 24, epsilon : 0.8307187014821328\nepisode : 38, steps 33, epsilon : 0.8265651079747222\nepisode : 39, steps 32, epsilon : 0.8224322824348486\nepisode : 40, steps 15, epsilon : 0.8183201210226743\nepisode : 41, steps 20, epsilon : 0.8142285204175609\nepisode : 42, steps 37, epsilon : 0.810157377815473\nepisode : 43, steps 11, epsilon : 0.8061065909263957\nepisode : 44, steps 30, epsilon : 0.8020760579717637\nepisode : 45, steps 11, epsilon : 0.798065677681905\nepisode : 46, steps 34, epsilon : 0.7940753492934954\nepisode : 47, steps 12, epsilon : 0.7901049725470279\nepisode : 48, steps 26, epsilon : 0.7861544476842928\nepisode : 49, steps 19, epsilon : 0.7822236754458713\nepisode : 50, steps 20, epsilon : 0.778312557068642\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is a really small mistake in here that causes the problem: \n\nfor index, (current_state, action, reward, next_state, done) in enumerate(minibatch):\n if not done:\n new_q = reward + DISCOUNT * np.max(future_qs_list) #HERE \n else:\n new_q = reward\n \n # Update Q value for given state\n current_qs = current_qs_list[index]\n current_qs[action] = new_q\n \n X.append(current_state)\n Y.append(current_qs)\n\nSince np.max(future_qs_list) should be np.max(future_qs_list[index]) since you're now getting the highest Q of the entire batch.\nInstead of the getting the highest Q from the current next state.\nIt's like this after changing that (remember an epsilon of 1 means that you get 100% of your actions taken by the a dice roll so I let it go for a few more epochs, also tried it with the old code but indeed didn't get more then 50 steps (even after 400 epochs/episodes))\nepisode : 52, steps 16, epsilon : 0.7705488893118823\nepisode : 53, steps 25, epsilon : 0.7666961448653229\nepisode : 54, steps 25, epsilon : 0.7628626641409962\nepisode : 55, steps 36, epsilon : 0.7590483508202912\nepisode : 56, steps 32, epsilon : 0.7552531090661897\nepisode : 57, steps 22, epsilon : 0.7514768435208588\nepisode : 58, steps 55, epsilon : 0.7477194593032545\nepisode : 59, steps 24, epsilon : 0.7439808620067382\nepisode : 60, steps 46, epsilon : 0.7402609576967045\nepisode : 61, steps 11, epsilon : 0.736559652908221\nepisode : 62, steps 14, epsilon : 0.7328768546436799\nepisode : 63, steps 13, epsilon : 0.7292124703704616\nepisode : 64, steps 113, epsilon : 0.7255664080186093\nepisode : 65, steps 33, epsilon : 0.7219385759785162\nepisode : 66, steps 33, epsilon : 0.7183288830986236\nepisode : 67, steps 39, epsilon : 0.7147372386831305\nepisode : 68, steps 27, epsilon : 0.7111635524897149\nepisode : 69, steps 22, epsilon : 0.7076077347272662\nepisode : 70, steps 60, epsilon : 0.7040696960536299\nepisode : 71, steps 40, epsilon : 0.7005493475733617\nepisode : 72, steps 67, epsilon : 0.697046600835495\nepisode : 73, steps 115, epsilon : 0.6935613678313175\nepisode : 74, steps 61, epsilon : 0.6900935609921609\nepisode : 75, steps 43, epsilon : 0.6866430931872001\nepisode : 76, steps 21, epsilon : 0.6832098777212641\nepisode : 77, steps 65, epsilon : 0.6797938283326578\nepisode : 78, steps 45, epsilon : 0.6763948591909945\nepisode : 79, steps 93, epsilon : 0.6730128848950395\nepisode : 80, steps 200, epsilon : 0.6696478204705644\nepisode : 81, steps 200, epsilon : 0.6662995813682115\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to improve the reward signal when the rewards are sparse? In cases where the reward is delayed, this can negatively impact a models ability to do proper credit assignment. In the case of a sparse reward, are there ways in which this can be negated?\nIn a chess example, there are certain moves that you can take that correlate strongly with winning the game (taking the opponent's queen) but typically agents only receive a reward at the end of the game, so as to not introduce bias. The downside is that training in this sparse reward environment requires lots of data and training episodes to converge to something good.\nAre there existing ways to improve the agent's performance without introducing too much bias to the policy?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Andrew Y. Ng (yes, that famous guy!) et al. proved, in the seminal paper Policy invariance under reward transformations: Theory and application to reward shaping (ICML, 1999), which was then part of his PhD thesis, that potential-based reward shaping (PBRS) is the way to shape the natural/correct sparse reward function (RF) without changing the optimal policy, i.e. if you apply PBRS to your sparse RF, the optimal policy associated with the shaped, denser RF is equal to the optimal policy associated with the original unshaped and sparse RF. This means that PBRS creates an equivalence class of RFs associated with the same optimal policy, i.e. there are multiple RFs associated with the same optimal policy. So, PBRS is the first technique that you can use to deal with sparse reward functions.\nTo give you more details, let $R\\left(s, a, s^{\\prime}\\right)$ be your original (possibly sparse) RF for your MDP $M$, then\n$$R\\left(s, a, s^{\\prime}\\right)+F\\left(s, a, s^{\\prime}\\right)\\tag{1}\\label{1}$$\nis the shaped, denser RF for a new MDP $M'$.\nIn PBRS, we then define $F$ (the shaping function) as follows\n$$\nF\\left(s, a, s^{\\prime}\\right)=\\gamma \\Phi\\left(s^{\\prime}\\right)-\\Phi(s),\n\\tag{2}\\label{2}\n$$\nwhere $\\Phi: S \\mapsto \\mathbb{R}$ is a real-valued function that indicates the desirability of being in a specific state. So, if we define $F$ as defined in \\ref{2}, we call it a potential-based shaping function.\nThe intuition of $F$ in \\ref{2} is that it avoids the agent to \"go in circles\" to get more and more reward. To be more precise, let's say that there's a state $s^* = s_t$ that is desirable but not the goal state. If you shaped the reward function by adding a positive reward (e.g. 5) to the agent whenever it got to that state $s^*$, it could just go back and forth to that state in order to get the reward without ever reaching the goal state (i.e. reward hacking). That's, of course, not desirable. So, if your current state is $s^*$ and your previous state was $s_{t-1}$, and whenever you get to $s_{t-1}$ you just shaped the reward function by adding a zero reward, to avoid going back to $s_{t-1}$ (i.e. to avoid that the next state $s_{t+1} = s_{t-1}$, and then go back to $s^*$ again, $s_{t+2} = s^*$, i.e. going in circles), if you use \\ref{2}, you will add to your original sparse reward function the following\n$$\nF\\left(s, a, s^{\\prime}\\right)=\\gamma 0 - 5 = -5,\n\\tag{3}\\label{3}\n$$\nIn other words, going back to $s_{t+1}$ (to later try to go back to $s^*$) is punished because this could again lead you to go back to $s^*$. So, if you define $F$ as in equation \\ref{2}, you avoid reward hacking, which can arise if you shape your RF in an ad-hoc manner (i.e. \"as it seems good to you\").\nOne of the first papers that reported this \"going in circles\" behaviour was Learning to Drive a Bicycle using Reinforcement Learning and Shaping\n\nWe agree with Mataric [Mataric, 1994] that these heterogeneous reinforcement functions have to be designed with great care. In our first experiments we rewarded the agent for driving towards the goal but did not punish it for driving away from it. Consequently the agent drove in circles with a radius of 20\u201350 meters around the starting point. Such behavior was actually rewarded by the reinforcement function\n\nYou probably also want to watch this video.\nAnother approach to solving the sparse rewards problem is to learn a reward function from an expert/optimal policy or from demonstrations (inverse reinforcement learning) or to completely avoid using the reward function and simply learn the policy directly from demonstrations (imitation learning).\nNote that I'm not saying that any of these solutions fully solves all your problems. They have advantages (e.g. if done correctly, PBRS can speed the learning process) but also disadvantages (e.g., in the case of IRL, if your expert demonstrations are scarce, then your learned RF may also not be good), which I will not discuss further here (also because I don't currently have much practical experience with none of these techniques).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does ChatGPT create fake code? ChatGPT has been a big thing lately. It also makes a lot of mistakes. For example, it creates fake functions of a package and tells it as it works for real. I was wondering how that works. Why is it creating fake functions of code and not just telling that it doesn't know how to solve the question that was asked?\n\nExample taken from Stack Overflow.\nQuestion\nLink: https://stackoverflow.com/q/74662093/\nTitle:\n\nApp script accessing secret manager to retrieve api token\n\nBody:\n\nI am trying to access secret manager from a small script I built on app script. I need to access and API with with a key but do not want to hardcode it.\nI have already assigned the app to a project. I am just not sure how to query the token.\n\nAnswer (deleted)\nLink: https://stackoverflow.com/a/74682465/1595451\nBody\n\nTo access the Secret Manager from Google App Script, you can use the\nSecretManager.getSecret(secret) method, which takes a secret parameter specifying the name of the secret you want to retrieve. For\nexample:\n // Get the secret named \"my-api-token\"\n var secret = SecretManager.getSecret('my-api-token');\n \n // Use the secret value in your script\n var apiToken = secret.getValue();\n\nNote that this method will throw an error if the specified secret does\nnot exist or if the user does not have permission to access it. You\ncan use a try-catch block to handle these cases gracefully. For\nexample:\n try {\n // Get the secret named \"my-api-token\"\n var secret = SecretManager.getSecret('my-api-token');\n \n // Use the secret value in your script\n var apiToken = secret.getValue();\n } catch (e) {\n Logger.log('Error getting secret: ' + e.message);\n }\n\nAlso note that the getValue() method returns the secret value as a\nstring, so you may need to convert it to the appropriate data type\n(such as a number or boolean) depending on your use case.\nFor more information, see the Secret Manager documentation and\nthe SecretManager class reference.\n\nSecretManager.getSecret(secret) method doesn't exist, and obviously the links returns page not found.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "ChatGPT is a generalised model. It does not understand any code. It does not know it is creating fake functions. It doesn't know that it isn't solving the question asked, because it doesn't know what the question means. All it knows is what sort of words fit together based on its training corpus.\nThis works very well for chat, but is less suited for anything technical, specialised, or in fact non-chat.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it possible to make a 'forked path' neural network? I want to make a network, specifically a CNN for image recognition, that takes an input, processes it the same way for several layers, and then at some point splits before coming to two different outputs. Is it possible to create a network such as this? It would look something like this:\nInput -> Conv -> Pool -> Conv -> Pool ---------> Dense -> Output 1 \n ||\n\n ----> Dense -> Output 2\n\nI.E. it splits off after the second pooling layer into separate fully connected layers. Of course, it has to train to both outputs, so that it is producing minimal error on both separate outputs using these common convolutional layers. Also, I am using Python Keras, and it would help if there was some way to do this using Keras in some way. Thank you! \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Keras Functional APIs can help you define complex models.\nYou can find the documentation here :\nhttps://keras.io/getting-started/functional-api-guide/.\nFor example:\n# prev_layer is the layer you want to be forked\nfork1 = Dense(32, activation='relu')(prev_layer)\nfork2 = Dense(32, activation='relu')(prev_layer)\n\n# you do some operations on fork1 to get output1\n# and on fork2 to get output2\n\nmodel = Model(inputs=input_layer, outputs=[output1, output2])\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there a machine learning algorithm to find similar sales patterns? I have a dataset as follows\n\n(and the table extends to include an extra 146 columns for companies 4-149)\nIs there an algorithm I could use effectively to find similar patterns in sales from the other companies when compared to my company? \nI thought of using k-means clustering, but as I'm dealing with 150 companies here it would likely become a bit of a mess, and I don't think linear regression would work here.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "If I understand correctly you want to find companies with similar patterns to yours. \nI would start with measuring cosine similarity between your company and others. \nIt is really easy with Python, for example:\nIn [21]: from sklearn.metrics.pairwise import cosine_similarity\n\nIn [22]: cosine_similarity([[1,4,2,6], [1,9,5,4]])\nOut[22]:\narray([[1. , 0.84794633],\n [0.84794633, 1. ]])\n\nNote that if size of sale matters to you, this is not the right approach, as cosine similarity is magnitude invariant:\nIn [23]: from sklearn.metrics.pairwise import cosine_similarity\n\nIn [24]: cosine_similarity([[1,4,2,6], [10,90,50,40]])\nOut[24]:\narray([[1. , 0.84794633],\n [0.84794633, 1. ]])\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why can't the XOR linear inseparability problem be solved with one perceptron like this? Consider a perceptron where $w_0=1$ and $w_1=1$:\n\nNow, suppose that we use the following activation function\n\\begin{align}\nf(x)=\n\\begin{cases}\n1, \\text{ if }x =1\\\\\n0, \\text{ otherwise}\n\\end{cases}\n\\end{align}\nThe output is then summarised as:\n\\begin{array}{|c|c|c|c|}\n\\hline\nx_0 & x_1 & w_0x_0 + w_1x_1 & f( \\cdot )\\\\ \\hline\n0 & 0 & 0 & 0 \\\\ \\hline\n0 & 1 & 1 & 1 \\\\ \\hline\n1 & 0 & 1 & 1 \\\\ \\hline\n1 & 1 & 2 & 0 \\\\ \\hline\n\\end{array}\nIs there something wrong with the way I've defined the activation function?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It can be done.\nThe activation function of a neuron does not have to be monotonic. The activation that Rahul suggested can be implemented via a continuously differentiable function, for example $ f(s) = exp(-k(1-s)^2) $ which has a nice derivative $f'(s) = 2k~(1-s)f(s)$. Here, $s=w_0~x_0+w_1~x_1$. Therefore, standard gradient-based learning algorithms are applicable.\nThe neuron's error is $ E = \\frac{1}{2}(v-v_d)^2$,\nwhere $v_d$ - desired output, $v$ - actual output. The weights $w_i, ~i=0,1$ are initialized randomly and then updated during training as follows\n$$w_i \\to w_i - \\alpha\\frac{\\partial E}{\\partial w_i}$$\nwhere $\\alpha$ is a learning rate. We have\n$$\\frac{\\partial E}{\\partial w_i} = (v-v_d)\\frac{\\partial v}{\\partial w_i}=(f(s)-v_d)~\\frac{\\partial f}{\\partial s}\\frac{\\partial s}{\\partial w_i}=2k~(f(s)-v_d)(1-s)f(s)~x_i$$\nLet's test it in Python.\nimport numpy as np \nimport matplotlib.pyplot as plt\n\nFor training, I take a few points randomly scattered around $[0, 0]$, $[0, 1]$, $[1, 0]$, and $[1, 1]$. \nn = 10\nsd = [0.05, 0.05]\n\nx00 = np.random.normal(loc=[0, 0], scale=sd, size=(n,2))\nx01 = np.random.normal(loc=[0, 1], scale=sd, size=(n,2))\nx10 = np.random.normal(loc=[1, 0], scale=sd, size=(n,2))\nx11 = np.random.normal(loc=[1, 1], scale=sd, size=(n,2))\n\nx = np.vstack((x00,x01,x10,x11))\ny = np.vstack((np.zeros((x00.shape[0],1)), \n np.ones((x01.shape[0],1)), \n np.ones((x10.shape[0],1)), \n np.zeros((x11.shape[0],1)))).ravel()\n\nind = np.arange(len(y))\nnp.random.shuffle(ind)\n\nx = x[ind]\ny = y[ind]\nN = len(y)\n\nplt.scatter(*x00.T, label='00')\nplt.scatter(*x01.T, label='01')\nplt.scatter(*x10.T, label='10')\nplt.scatter(*x11.T, label='11')\nplt.legend()\nplt.show()\n\n\nActivation function:\nk = 10\n\ndef f(s):\n return np.exp(-k*(s-1)**2)\n\nInitialize the weights, and train the network:\nw = np.random.uniform(low=0.25, high=1.75, size=(2))\n\nprint(\"Initial w:\", w)\n\nrate = 0.01\nn_epochs = 20\n\nerror = []\nfor _ in range(n_epochs):\n err = 0\n for i in range(N):\n s = np.dot(x[i],w)\n w -= rate * 2 * k * (f(s) - y[i]) * (1-s) * f(s) * x[i]\n err += 0.5*(f(s) - y[i])**2\n err /= N\n error.append(err)\n\nprint('Final w:', w)\n\nThe weights have indeed converged to $w_0=1,~w_1=1$:\nInitial w: [1.5915165 0.27594833]\nFinal w: [1.03561356 0.96695205]\n\nThe training error is decreasing:\nplt.scatter(np.arange(n_epochs), error)\nplt.grid()\nplt.xticks(np.arange(0, n_epochs, step=1))\nplt.show()\n\n\nLet's test it. I create a testing set in the same way as the training set. My test data are different from my training data because I didn't fix the seed.\nx00 = np.random.normal(loc=[0, 0], scale=sd, size=(n,2))\nx01 = np.random.normal(loc=[0, 1], scale=sd, size=(n,2))\nx10 = np.random.normal(loc=[1, 0], scale=sd, size=(n,2))\nx11 = np.random.normal(loc=[1, 1], scale=sd, size=(n,2))\n\nx_test = np.vstack((x00,x01,x10,x11))\ny_test = np.vstack((np.zeros((x00.shape[0],1)), \n np.ones((x01.shape[0],1)), \n np.ones((x10.shape[0],1)), \n np.zeros((x11.shape[0],1)))).ravel()\n\nI calculate the root mean squared error, and the coefficient of determination (R^2 score):\ndef fwd(x,w):\n return f(np.dot(x,w))\n\nRMSE = 0\n\nfor i in range(N):\n RMSE += (fwd(x_test[i],w) - y_test[i])**2\n\nRMSE = np.sqrt(RMSE/N)\n\nprint(\"RMSE\", RMSE)\n\nybar = np.mean(y)\n\nS = 0\nD = 0\nfor i in range(N):\n S += (fwd(x_test[i],w) - y_test[i])**2\n D += (fwd(x_test[i],w) - ybar)**2\n\nr2_score = 1 - S/D\nprint(\"r2_score\", r2_score)\n\nResult:\nRMSE 0.09199468888373698\nr2_score 0.9613632278609362\n\n... or I am doing something wrong? Please tell me.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to shorten the development time of a neural network? I am developing an LSTM for sequence tagging. During the development, I do various changes in the system, for example, add new features, change the number of nodes in the hidden layers, etc. After each change, I check the accuracy using cross-validation on a development dataset.\nCurrently, in each check, I use 100 iterations to train the system, which takes a lot of time. So I thought that, maybe, during development, I can use only e.g. 20 iterations. Then, each check will be faster. After I find the best configuration, I can switch back to 100 iterations to get better accuracy.\nMy question is: is this consideration correct? More specifically, if model A is better than model B with 20 training iterations, is it likely that A will be better than B also with 100 training iterations?\nAlternatively, is there a better way to speed up the development process?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Your scenario is common.\nThe most straightforward approach is to subsample your data randomly. Unless your data or your model has strong bias, your performance to the smaller data set should be comparable. The accuracy might be lower, but the purpose is to do quick sanity check.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why did the openai's gym website close? Openai's gym website redirects to the GitHub repository. Why did the openai's gym website close?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "According to Open AI's Greg Brockman, the Gym website never had a big impact and so was never maintained. This is the reason he gives for shutting down the website. \nA read only export of the site was archived at https://gym.openai.com/read-only.html and if you attempt to access the old website through the url https://gym.openai.com you will be redirected to the Open AI gym github repository. \nFor a while a static copy of the Open AI leader-board was maintained on the below url https://scoreboard-site-1764008611.us-west-2.elb.amazonaws.com/ . However as of present the static site is also unreachable. \nThe Canadian AI startup montreal.ai had offered to maintain the gym website. However this offer was not taken up by open ai. \nThis issue was discussed in depth on the following threads\nhttps://www.reddit.com/r/MachineLearning/comments/6zvlm2/d_openai_closing_down_gym_toolkit_website/?st=jca6ia3n&sh=48a0d8f3\nhttps://github.com/openai/gym/issues/718\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can we prevent AGI from doing drugs? I recently read some introductions to AI alignment, AIXI and decision theory things.\nAs far as I understood, one of the main problems in AI alignment is how to define a utility function well, not causing something like the paperclip apocalypse.\nThen a question comes to my mind that whatever the utility function would be, we need a computer to compute the utility and reward, so that there is no way to prevent AGI from seeking it to manipulate the utility function to always give the maximum reward.\nJust like we humans know that we can give happiness to ourselves in chemical ways and some people actually do so.\nIs there any way to prevent this from happening? Not just protecting the utility calculator physically from AGI (How can we sure it works forever?), but preventing AGI from thinking of it?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is known as reward hacking in the literature; see, e.g., https://medium.com/@deepmindsafetyresearch/designing-agent-incentives-to-avoid-reward-tampering-4380c1bb6cd for discussion and further links.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between out of distribution detection and anomaly detection? I'm currently reading the paper Likelihood Ratios for Out-of-Distribution Detection, and it seems that their problem is very similar to the problem of anomaly detection. More precisely, given a neural network trained on a dataset consisting of classes $A,B,$ and $C$, then they can detect if an input to the neural network is anomalous if it is different than these three classes. What is the difference between what they are doing and regular anomaly detection?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You observation is correct although the terminology needs a little explaining.\nThe term 'out-of-distribution' (OOD) data refers to data that was collected at a different time, and possibly under different conditions or in a different environment, then the data collected to create the model. They may say that this data is from a 'different distribution'.\nData that is in-distribution can be called novelty data. Novelty detection is when you have new data (i.e. OOD) and you want to know whether or not it is in-distribution. You want to know if it looks like the data you trained on.\nAnomaly detection is when you test your data to see if it is different than what you trained the model. Out-of-distribution detection is essentially running your model on OOD data. So one takes OOD data and does novelty detection or anomaly detection (aka outlier detection).\nBelow is a figure from What is anomaly detection?\n\nIn time series modeling, the term 'out-of-distribution' data is analogous to 'out-of-sample' data and 'in-distribution' data is analogous with 'in-sample' data.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can two admissable heuristics not dominate each other? I am working on a project for my artificial intelligence class. I was wondering if I have 2 admissible heuristics, A and B, is it possible that A does not dominate B and B does not dominate A? I am wondering this because I had to prove if each heuristic is admissible and I did that, and then for each admissible heuristic, we have to prove if each one dominates the other or not. I think I have a case that neither dominates the other and I was wondering if maybe I got the admissibility wrong because of that.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is possible. Admissibility only asserts that the heuristic will never overestimate the true cost. With that being said, it is possible for one heuristic in some cases to do better than another and vice-versa. Think of it as a game of rock paper scissors.\nSpecifically, you may find that sometimes $h_1 < h_2$ and in other times $h_2 < h_1$, where $h_1$ and $h_2$ are admissible heuristics. Thus, by definition, neither strictly dominates the other. \nIn fact, there is a way to \"combine\" the two admissible heuristics to get the best of both using:\n$$h_3 = \\max(h_1, h_2)$$\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can CNNs be applied to non-image data, given that the convolution and pooling operations are mainly applied to imagery? When using CNNs for non-image (times series) data prediction, what are some constraints or things to look out for as compared to image data?\nTo be more precise, I notice there are different types of layers in a CNN model, as described below, which seem to be particularly designed for image data.\nA convolutional layer that extracts features from a source image. Convolution helps with blurring, sharpening, edge detection, noise reduction, or other operations that can help the machine to learn specific characteristics of an image.\nA pooling layer that reduces the image dimensionality without losing important features or patterns.\nA fully connected layer also known as the dense layer, in which the results of the convolutional layers are fed through one or more neural layers to generate a prediction.\nAre these operations also applicable to non-image data (for example, times series)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Usually, you need to ensure that your convolutions are causal, meaning that there is no information leakage from the future into the past. You could start by looking at this paper, which compares Temporal Convolutional Networks (TCN) with vanilla RNNs models.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it suitable to find inverse of last layer's activation function and apply it on the target output? I have a neural network with the following structure:\n\nI am expecting specific outputs from the neural network which are the target values for my training. Let's say the target values are 0.8 for the upper output node and -0.3 for the lower output node.\nThe activations function used for the first 2 layers are ReLu or LeakyReLu while the last layer uses atan as an activation function.\nFor back propogation, instead of adjusting values to make the network's output approach 0.8,-0.3. is it suitable if I use the inverse function for atan -which is tan itself- to get \"the ideal input to the output layer multiplied by weights and adjusted by biases\". \nThe tan of 0.8 and -0.3 is 0.01396 and -0.00524 approximately. \nMy algorithm would then adjust weights and biases of the network so that the \"pre-activated output\" of the output layer -which is basically (sum(output_layer_weight*output_layer's inputs)+output_layer_biases)- approaches 0.01396 and -0.00524.\nIs this suitable \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "For the above stated artificial network, these two training scenarios are similar.\n\nTraining to converge to the ideal output vector at the point after the last layer's activation functions are applied\nTraining to converge to the vector formed by applying $tan$ functions to each component of the ideal output vector, when convergence occurs at the point just after the vector-matrix multiplication with the last layer's parameters, prior to the last layer's $atan$ activation functions\n\nDistinctions between them include these.\n\nThe applications of gradients and associated code must be adapted to the modification of the starting point of back propagation to before the final $atan$ activation functions.\nThe slope and curvature of the loss function will differ if the same loss function is used for the two scenarios, so the accuracy, speed, and reliability of convergence will also be different.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Will a CNN that is Group Equivariant always be better than a regular CNN? I am reading this paper about Group Equivariant Convolutional Networks. Basically, it is a CNN whose construction makes the network naturally equivariant to Group transformations (e.g. rotations) of the input.\nThis is, a GE-CNN trained with the Rotations Group in its architecture, will for instance predict correctly the label of a rotated MNIST digit, even though it was never trained on rotated MNIST digits.\nMy question here is, are there any situations in which these GE-CNN will not perform better than a regular CNN? In other words: is the property of being equivariant to any transformation of the input always desirable?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "No, it will very much depend on the specific domain that you're applying the model to, whether or not this type of prior will be good or bad. The same applies to any other prior structure/knowledge you could encode in networks.\nFor example, the basic CNNs implement the prior assumption of shift invariance. Intuitively, you may think of this as saying \"if I can learn to recognise a cat (or anything else) in one location of an image, I can generalise from this and immediately also recognise cats in different locations of images\". This tends to work well, because it is true: cats do look like cats, regardless of where they are in an image.\nThe same reasoning applies to the prior assumption of rotation invariance (or equivariance): whether it is helpful or harmful depends on the domain. I would actually argue that the very same MNIST digit recognition problem that you mention as an example in your question is a problem where you do not want rotation invariance. Just think of the digits 6 and 9: if you rotate one of those upside down, it looks identical to the other. So, a neural network with rotation invariance will never be able to distinguish between sixes and nines!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can reinforcement learning algorithms be applied to computer vision problems? Can reinforcement learning algorithms be applied to computer vision problems? If yes, what are some examples of these applications?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, there are a couple of ways to apply reinforcement learning in computer vision problems. This mainly employs the principle of \"applying the algorithm -> evaluating the outcome -> adopting the best outcome\".\nThe following are a couple of examples that use reinforcement learning in computer vision.\n\nCAD2RL: Real Single-Image Flight Without a Single\nReal Image.\nEnd-to-End Training of Deep Visuomotor\nPolicies\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between local search and global search algorithms? What is the difference between local search and global (or complete) search algorithms?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The difference between a local search algorithm (like beam search) and a complete search algorithm (like A*) is, for the most part, small.\nLocal search algorithms will not always find the correct or optimal solution, if one exists. For example, with beam search (excluding an infinite beam width), it sacrifices completeness for greater efficiency by ordering partial solutions by some heuristic predicting how close a partial solution is to a complete one. Beam search is a greedy algorithm.\nComplete search algorithms will always find the correct or optimal solution if there is one, given enough time. An algorithm like A* uses heuristics to prune the tree as it goes along, but it will not converge to a sub-optimal solution. In a lot of practical cases, this is inefficient, but how much so is problem dependent.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the pros and cons of sparse and dense rewards in reinforcement learning? From what I understand, if the rewards are sparse the agent will have to explore more to get rewards and learn the optimal policy, whereas if the rewards are dense in time, the agent is quickly guided towards its learning goal.\nAre the above thoughts correct, and are there any other pros and cons of the two contrasting settings? On a side-note, I feel that the inability to specify rewards that are dense in time is what makes imitation learning useful.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nWhat are the pros and cons of sparse and dense rewards in reinforcement learning?\n\nIt is unusual to refer to this difference as \"pros and cons\" because that term is often used to make comparisons between difference choices. Assuming you have a specific problem to solve, then whether or not the rewards are naturally sparse or dense is not a choice. You cannot say \"I want to solve MountainCar, I will use a dense reward setting\", because MountainCar has (relatively, for a starting problem) sparse rewards. You can only say \"I won't attempt MountainCar, it is too difficult\".\nIn short however, your assessment is correct:\n\nif the rewards are sparse the agent will have to explore more to get rewards and learn the optimal policy, whereas if the rewards are dense in time, the agent is quickly guided towards its learning goal\n\nThere is not really any other difference at the top level. Essentially, sparser rewards make for a harder problem to solve. All RL algorithms can cope with sparse rewards to some degree, the whole concept of returns and value backup is designed to deal with sparseness at a theoretical level. In practical terms however, it may take some algorithms an unreasonable amount of time to determine a good policy beyond certain levels of sparseness.\n\nOn a side-note, I feel that the inability to specify rewards that are dense in time is what makes imitation learning useful.\n\nImitation learning is one of many techniques available to work around or deal with problems that have sparse reward structure. Others include:\n\nReward shaping, which attempts to convert a sparse reward scheme to a dense one using domain knowledge of the researcher.\n\nEligibility traces, which back up individual TD errors across multiple time steps.\n\nPrioritised sweeping, which focuses updates on \"surprising\" reward data.\n\nAction selection planning algorithms that look ahead from the current state.\n\n\"Curiousity\" driven reinforcement learning that guides exploration to new state spaces independently of any reward signal.\n\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can I create an artificially intelligent aimbot for a game like CS:GO? How can I create an artificially intelligent aimbot for a game like Counter-Strike Global Offensive (CS:GO)?\nI have an initial solution (or approach) in mind. We can train an image recognition model that will recognize the head of the enemy (in the visible area of the player, so excluding the invisible area behind the player, to avoid being easily detected by VAC) and move the cursor to the position of the enemy's head and fire.\nIt would be much more preferable to train the recognition model in real-time than using demos. Most of the available demos you might have might be 32 tick, but while playing the game, it works at 64 tick.\nIt is a very fresh idea in my mind, so I didn't actually think a lot about it. Ignoring facts like detection by VAC for a few moments.\nIs there any research work on the topic? What are the common machine learning approaches to tackle such a problem?\nLater on, this idea can be expanded to a completely autonomous bot that can play the game by itself, but that is a bit too much initially.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Automation of Game-play\nAimbots are indeed designed to provide assistance to the human game player when the complexity of game play escapes full cybernetic autonomy at the current state of technology. There are five basic components in any game player, DNA based or digital.\n\nAcquisition of the current state of the game\nControl over execution of move options\nIntercommunication with other players\nModels related to the game\nExecution engine for applying these\n\nThe models are as follows for a CS:GO aimbot.\n\nModel of game players\nModel of the opposing team\nModel of the game player being assisted\nModel of that player's team\nModel of the opposing team\nModel of the game state\nModel of legal game moves that transition state\nModel of objectives (winning or maintaining a top score)\nModels of game-play strategy involving the first three items in the previous list \n\nLearning all of these is not in the scope of current deep learning strategies but not outside the scope of AI if the following problem analysis and system approaches are taken.\n\nAssumptions are made similar to those of Morgenstern and von Neumann in the later chapters of their Game Theory to mathematically treat the decisioning of game players in a minimalistic way.\nDSP, GPU, network realization hardware, cluster computing, or some other artificial network hardware acceleration is available\nModels programmed in Prolog, DRools, or some other production system and then leveraged by the execution engine in conjunction with other components such as deep learning networks, convolution processing, Markov trees, fuzzy logic, and the application of oversight functions or heuristics as needed\n\nThe two services, (a) the provision of suggestions and (b) the automation of minor tasks, may indeed represent the low hanging fruit from a software engineering perspective, but the problem analysis and system approach above may provide more.\nObjectives in CS:GO\nThe CS:GO (Counter-Strike Global Offensive) game seems to have been written from a Westphalian geopolitical point of view. This is the typical western perspective, somewhat oblivious to the mindset of the true nature of asymmetric warfare1. This answer will focus on the creation of an aimbot for the existing models of game-play rather than a realistic simulation of geopolitical balance in this decade.\nWe have the objective types listed in online resources that provide a game overview, again, narrowed in authenticity by the prevailing western view of asymmetric war1.\n\nTerminating players of the opposing team\nPlanting a bomb toward that end (terrorists only)\nDefend hostages (terrorists only)\nPrevention of bomb casualties (counter-terrorists only)\nRescue of hostages (counter-terrorists only)\n\nBallistic Control\nThe targetting of the body or head of an opponent is within the scope of what image recognition can do in conjunction with a movement model. In military applications, aeronautic devices must be propelled against air friction and the propulsion requires a largely exothermic reaction like combustion. Thus all targets have a heat signature, which can be recognized in an infrared video stream in such a way as to plot an intercept course for the ballistic weapon.\nThe targetting formulation for CS:GO is not as complex and aiming and firing may be fully automated with much less software machinery. A LSTM with sufficient speed can be trained to recognize a head in subsequent frames and terminate opponents even if moving. A simple web search for LSTM will provide a plethora of resources to the novice intending to learn about image recognition.\nOne Ambiguity\nWhether the second objective can be met is dependent on what is meant by the term, \"Viewing angles,\" in the context of image recognition. Can the player see from perspectives other than the location of their eyes? If so, this answer can be adjusted if given a clear picture of what is meant.\nTraining and Re-entrant Learning\nTraining of an artificial neural net to target a head is unnecessary unless the 3D rendering of the game objects and players is distorted by a wide angle virtual lens and trajectories and movements are curved. As mentioned LSTM can be used to locate a head in multiple frames and extrapolate an opposing players trajectory.\nWhere deep learning may be most effective is in the training of how to interact with the player to best assist. Also, if there are other non-targeting techniques that are more discrete, those who play CS:GO well could record their interactions and those recordings can be processed in preparation for use as training data.\nCertainly a re-entrant learning strategy such as reinforcement is useful for game-play especially if the make up of teams changes and players exhibit different behaviors, executing differing strategies over different networks with different latencies and through-puts, and communicating with the game clients through different peripheral devices.\n[DeepMind Lab Test Bed for Reinforcement Technology](https://github.com/deepmind/lab}\nMore than Suggestions\nWith proper architecture, more than suggestive strategies can be provided to the player. Statistical dashboards, identification of a bomb before or after planting, and identification of hostages should be among the aimbot services provided, which might suggest a new name, such as obot for objective bot or asbot for assistive bot.\nIt is not certain that the aimbot interface need be integrated with dashboards or bomb or hostage identifiers. Sometimes independent bots provide a more flexible arrangement for a user. Individual bots can always use the same underlying image recognition components and models.\nEntry Points into Developing Such a System\nRead some of the work on the above concepts and download what code you can find that demonstrates it in Python or Java, install what is necessary, and develop some proficiency with the components discussed above as well as the associated theory. Don't shy away from the math, since success will require some proficiency with feedback signalling and concepts like gradient descent and back-propagation.\nReinforcement in Games\nLSTM Head Locating\nPlaying Atari with Deep Reinforcement Learning, Mnih et al., 2013\nPhased Approach\nThe following phased research and development approach is suggested.\n\nLearn the theory\nPractice the theory in code\nDevelop the image recognition front end\nDevelop the library to control a virtual player\nDevelop at least one of the above models\nCreate the simplest bot to use it\nExpand automation from there\n\n\nFootnotes\n[1] In asymmetric power struggles, there are always at least two factions within each side because didactic legitimacy seeks division. Unity is not practically possible. Each real team usually has a more religious and more secular faction, each of which has economic, philosophic, and historical justifications for their position and agenda. Also, terrorists don't seek the public detonation of bombs or retention of hostages as objective but rather as means, with the total elimination of all not fully adhered to their view of legitimacy as the sole endgame objective. Suicide or high risk bombing is considered by most of those that employ it as the poor man's nukes, so without nuclear strike capability for the counter-terrorists and their allies, the terrorism lacks the important dimension of last resort. The last resort aspect of nuclear strike is missing from the counter-terrorist side too. CS:GO may sell better by glossing over these particular characteristics of asymmetric warfare and such was left out deliberately. There may be some benefit to adding these features in from an educational and anti-propaganda point of view.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the real-life applications of transfer learning? What are the real-life applications of transfer learning in machine learning? I am particularly interested in industrial applications of the concept.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "One application I know of being used in industry is of image classification, by only training the last layer of one of the inception models released by Google, with the desired number of classes. I can't provide specific details. \nTransfer learning is useful when:\n\nYou do not have the resources (time, processing power, etc.) to train a DL model from scratch.\nYou can compromise a bit on accuracy. \n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does using the softmax function in Q learning not defeat the purpose of Q learning? It is my understanding that, in Q-learning, you are trying to mimic the optimal $Q$ function $Q*$, where $Q*$ is a measure of the predicted reward received from taking action $a$ at state $s$ so that the reward is maximised.\nI understand for this to be properly calculated, you must explore all possible game states, and as that is obviously intractable, a neural network is used to approximate this function.\nIn a normal case, the network is updated based on the MSE of the actual reward received and the networks predicted reward. So a simple network that is meant to chose a direction to move would receive a positive gradient for all state predictions for the entire game and do a normal backprop step from there.\nHowever, to me, it makes intuitive sense to have the final layer of the network be a softmax function for some games. This is because in a lot of cases (like Go for example), only one \"move\" can be chosen per game state, and as such, only one neuron should be active. It also seems to me that would work well with the gradient update, and the network would learn appropriately.\nBut the big problem here is, this is no longer Q learning. The network no longer predicts the reward for each possible move, it now predicts which move is likely to give the greatest reward.\nAm I wrong in my assumptions about Q learning? Is the softmax function used in Q learning at all?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nHowever, to me, it makes intuitive sense to have the final layer of the network be a softmax function for some games. This is because in a lot of cases (like Go for example), only one \"move\" can be chosen per game state, and as such, only one neuron should be active.\n\nYou are describing a network that approximates as policy function, $\\pi(a|s)$, for a discrete set of actions.\n\nIt also seems to me that would work well with the gradient update, and the network would learn appropriately.\n\nYes there are ways to do this, based on the Policy Gradient Theorem. If you read it you will probably discover this is more complex to understand than you first thought, the problem being that the agent is never directly told what the \"best\" action is in order to simply learn in a supervised manner. Instead, it has to be inferred from rewards observed whilst acting. This is a bit harder to figure out than the Q learning update rules which are just sampling from the Bellman optimality equation.\nYou can split Reinforcement Learning methods broadly into value-based methods and policy gradient methods. Q learning is a value-based method, whilst REINFORCE is a basic policy gradient method. It is also common to use a value based method within a policy gradient method in order to help estimate likely future return used to drive the polcy gradient updates - this combination is called Actor-Critic where the actor learns a policy function $\\pi(a|s)$ and the critic learns a value function e.g. $V(s)$.\n\nBut the big problem here is, this is no longer Q learning. The network no longer predicts the reward for each possible move, it now predicts which move is likely to give the greatest reward.\n\nThis is true, but it is not a big problem. The main issue is that policy gradient methods are more complex than value based methods. They may or may not be more effective, it depends on the environment you are tryng to create an optimal agent for.\n\nIs the softmax function used in Q learning at all?\n\nI cannot think of any non-contrived environment in which this function would be useful for an action value approximation.\nHowever, it is possible to use a variant of softmax to create a behaviour policy for Q learning. This uses a temperature hyperparameter $T$ to weight the Q values, and provide a probability of selecting an action, as follows\n$$\\pi(a_i|s) = \\frac{e^{Q(s,a_i)/T}}{\\sum_j e^{Q(s,a_j)/T}}$$\nwhen $T$ is high all the probabilities of actions will be similar, when it is low even a small difference in $Q(s,a_i)$ will make a big difference to probability of selecting action $a_i$. This is quite a nice distribution for exploring whilst avoiding previously bad decisions. It will tend to focus the agent on exploring differences between similarly high rated actions. The main issue with it is that it introduces hyperparameters for deciding starting $T$, ending $T$ and how to move between them.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why did a Tesla car mistake a truck with a bright sky? Do we know why Tesla's autopilot mistaken empty sky with a high-sided lorry which resulted in fatal crash involving a car in self-drive mode? Was it AI fault or something else? Is there any technical explanation behind this why this happened?\nThe articles Tesla Driver In First Self-Drive Fatal Crash and Tesla driver killed in crash with Autopilot active, NHTSA investigating talk about this topic, but do not go in detail.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Tesla's technology is assistive, as Alexey points out, so this is not a case of an autonomous system (e.g. an AGI) doing some fatal stunt (the product name AutoPilot is famously misleading). Now on why the car assistance led to this tragic accident, there is some information related to AI technologies.\n\nWarning: I cannot find again the source critical to the next paragraph, and reading again pages over pages, I cannot find similar argument in other reports. I still remember vividly the point below, but please keep in mind it may be incorrect. The rest of the answer is weakly related, so I leave it all, with this warning.\nAn independent report (link needed, I can't find it...) explained that the assistive system was unable to detect the truck due to an exceptionally low contrast (bright sky perceived as white---colour of the truck). The report also said that a human driver would have been unable to make the difference either. In other words, it is possible that car sensors (presumably camera) and the human eye could not have detected an obstacle, and could not have triggered any safety measure. This short graphical explanation sums up the car sensors: Camera, radar, GPS, etc.\nThe assistive sub-system is based on proprietary AI technologies. We can only speculate under some hypothesis. _This is not very useful, honestly, except for illustration purpose. Assuming the assistive system relies on ML technologies to learn about obstacles from a video stream (such systems do exist):\n\nIt may be that the learning data was not \"good enough\" to cover the truck scenario.\nIt may be the technology was not powerful enough yet (lack generalization power, or simply too slow).\nIt may be a hardware problem, notably from the sensors: If the \"car's eyes\" are defective, the \"car's brain\" (the assistive system) is unable to react properly.\n\nWhy those technologies did not work in that case will remain a secret. We can say however that any system---whether built with AI technology or not---has limits. Beyond these limits, the system reaction is unpredictable: It could stop, reset, shutdown. The difficulty here is to define what a \"default behaviour\" is. A machine will basically do whatever it is designed to do, so an AI-based system too.\nWe could speculate even more on what would happen if the assistive system was really autonomous, the elusive AGI, but that is really not the case here.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between imitation learning and classification done by experts? In short, imitation learning means learning from the experts. Suppose I have a dataset with labels based on the actions of experts. I use a simple binary classifier algorithm to assess whether it is good expert action or bad expert action.\nHow is this binary classification different from imitation learning?\nImitation learning is associated with reinforcement learning, but, in this case, it looks more like a basic classification problem to me.\nWhat is the difference between imitation learning and classification done by experts?\nI am getting confused because imitation learning relates to reinforcement learning while classification relates to supervised learning.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Imitation learning is supervised learning applied to the RL setting.\nIn any general RL algorithm (such as Q-learning), the learning is done on the basis of the reward function. However, consider a scenario where you have available the optimal policy in the form of a table, mapping each state to each action. In this scenario you will not care about the rewards received - rather, you'd simply do a table lookup to decide the optimal action. \nThis scenario is impractical in most settings because the table for the optimal policy will be too big. However, if you have enough entries from the table, you can use a general function approximator such as a neural network to find the optimal action. Again, you do not need to look at the rewards, but only at the state $\\rightarrow$ action mappings. I do not know imitation learning in detail beyond this, but I suspect in the case of discrete actions (such as in Chess, Go), it would be trained with a cross-entropy objective as is typical of classification tasks.\nI suspect that the reason this has a different name in the RL setting is because this is different than how the conventional RL algorithms work. Also, much of RL thinking is inspired from everyday interaction / biology. Think of how we learn how to drive, or play sports such as soccer. Typically there is a coach who tells you what actions to take under different conditions, and you imitate those actions. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to add more features to the input of a machine learning algorithm? I am trying to perform a binary classification of tweets using machine learning. \nThe usual way of doing this seems to be putting a hand-classified tweet's words into a big vector, then use that vector as input to an algorithm, which then predicts new tweets based on this data.\nIs there a standard method, or algorithm, that can include other input, such as the location of a tweet, in this process? \nI could just add tweet location at the end of the vector, I suppose, but that would give it a very small weighting. \nAny pointers are much appreciated.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Data pre-processing and feature extraction are by far the most important part of any machine learning algorithm. It's even more important that the model you choose to do the classification. \nUnfortunately, pre-processing and feature extraction are completely different for each type of data. You need to play around with the data yourself to find out what works best with the nature of your data. With experience you start noticing some patterns with different data types. For example, as you are doing, building a word vector is an effective means of feature extraction with text based data. \n\"I could just add tweet location at the end of the vector I suppose, but that would give it a very small weighting.\"\nThis is entirely untrue for any machine learning algorithm I would choose. Your model should not associate weights to the inputs based on their array location. They should be associated based on the explained variance (information gain) it provides. \n\nAfter you do your pre-processing and feature extraction you can then further refine your feature set with some common methods which can be found in libraries such as: principle component analysis (PCA) and linear discriminant analysis (LDA). \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is AI safety so much harder than Isaac Asimov's \"Three Laws of Robotics\"? I understand that AI researchers are trying to create AI designs that allow for desired behavior without undesirable side-effects. A classic example of an attempt is Isaac Asimov's Three Laws of Robotics. This idea seems to have been debunked due to its vague phrasing. In particular, I realize that the exact 3 laws from the stories can't work, but surely there is a set of more robust ones that can limit an AI to good behavior in the same way that people are restricted by law.\nWhy have AI researchers not accepted an idea like the following (just making the laws more specific):\n\nWhat if the UN voted for the country with the fairest laws and all\nutility functions have 2/3 of their points made up of not breaking any\nof those laws. If the ai has a question, it could look at court\nprecedent just like a judge would or ask humans (with two-thirds of\nits points on the line, it should be pretty cautious).\nPeople have been looking for loopholes in law for thousands of years\nand there may not be any catastrophic ones left. (It certainly\nwouldn't be violent)\n\nI must be missing something if this is still an open problem.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The reason this is hard is because it is not trivial to understand what a law means. Many humans still have a hard time understanding laws and thus we have millions of judges and lawyers who study years to be able to even debate whether a law was broken at all.\nMore generally to AI, the problem of understanding laws is a byproduct of the bigger problem that AIs today do not yet have mechanisms to turn input (text, audio, other sensor data) into concepts. This is evident in even the most advanced conversation systems which struggle with dialog which is off of a particular set of subjects.\nHowever, there are promising results with probabilistic logic programming languages that attempt to combine first-order logic with statistical inference ($\\text{LP}^{\\text{MLN}}$ is an example). These languages could provide, in theory, a way for future AI-lawyers (or whatever one should call them) to encode exactly what laws mean. Using this set or encoded laws, a system with a rich enough representation could determine if an action would brake a law or not. This sounds great but the \"rich enough representation\" is beyond what even today's best deep learning systems (or any other architecture) can do. For comparison, today's best deep learning systems don't even have good object permanence, something humans have around 4-7 months old. Asking those deep learning systems to also be able to represent the complexities of laws is profoundly outside of current AI capabilities.\nAnother promising area is only including text data and having artificial judges. This wouldn't immediately mean that AIs would obey laws but it is the start of AIs understanding the word of law.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does the number of required expert demonstrations in Imitation Learning depend on? I just read the following points about the number of required expert demonstrations in imitation learning, and I'd like some clarifications. For the purpose of context, I'll be using a linear reward function throughout this post (i.e. the reward can be expressed as a weighted sum of the components of a state's feature vector)\n\nThe number of expert demonstrations required scales with the number of features in the reward function.\n\nI don't think this is obvious at all - why is it true? Intuitively, I think that as the number of features rises, the complexity of the problem does too, so we may need more data to make a better estimate of the expert's reward function. Is there more to it?\n\nThe number of expert demonstration required does not depend on -\n\nComplexity of the expert\u2019s optimal policy $\\pi^{*}$\nSize of the state space\n\n\nI don't see how the complexity of the expert's optimal policy plays a role here - which is probably why it doesn't affect the number of expert demonstrations we need; but how do we quantify the complexity of a policy in the first place?\nAlso, I think that the number of expert demonstrations should depend on the size of the state space. For example, if the train and test distributions don't match, we can't do behavioral cloning without falling into problems, in which case we use the DAGGER algorithm to repeatedly query the expert and make better decisions (take better actions). I feel that a larger state space means that we'll have to query the expert more frequently, i.e. to figure out the expert's optimal action in several states.\nI'd love to know everyone's thoughts on this - the dependence of the number of expert demonstrations on the above, and if any, other factors. Thank you!\n\nSource: Slide 20/75\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The answer to your question can be found in the original paper that introduced the max-margin and projection imitation learning (IL) algorithms: Apprenticeship Learning via Inverse Reinforcement Learning (by Abbel and Ng, 2004, ICML). Specifically, theorem 1 (section 4, page 4) states\n\nLet an $\\text{MDP} \\setminus R$, features $ \\phi : S \\rightarrow [0, 1]^k$, and any $\\epsilon > 0$ be given. Then the apprenticeship learning algorithm (both max-margin and projection versions) will terminate with $t^{(i)} \\leq \\epsilon$ after at most\n$$n=O\\left(\\frac{k}{(1-\\gamma)^{2} \\epsilon^{2}} \\log \\frac{k}{(1-\\gamma) \\epsilon}\\right)$$\niterations.\n\nHere $k$ is the dimension of the feature vectors, so it's clear that the number of iterations needed for these algorithms to terminate scales with $k$. The proof of this theorem can be found in appendix A of the same paper (and all other terms are defined in the paper, which you should read to understand all the details). Of course, this result holds (only) for these specific IL algorithms (which are the algorithms the author of your slides, Abbel, is referring to). See also theorem 2 and the experiments section (in particular, figure 4, which shows the performance as a function of the number of trajectories) of the same paper.\nThese slides provide a nice overview of the contents of this paper, so I suggest that you read them too.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the derivative of this objective function 0 if the policy is deterministic? In the Berkeley RL class CS294-112 Fa18 9/5/18, they mention the following gradient would be 0 if the policy is deterministic.\n$$\n\\nabla_{\\theta} J(\\theta)=E_{\\tau \\sim \\pi_{\\theta}(\\tau)}\\left[\\left(\\sum_{t=1}^{T} \\nabla_{\\theta} \\log \\pi_{\\theta}\\left(\\mathbf{a}_{t} \\mid \\mathbf{s}_{t}\\right)\\right)\\left(\\sum_{t=1}^{T} r\\left(\\mathbf{s}_{t}, \\mathbf{a}_{t}\\right)\\right)\\right]\n$$\nWhy is that?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Here is the gradient that they are discussing in the video:\n$$\\nabla_{\\theta} J(\\theta) \\approx \\frac{1}{N} \\sum_{i=1}^N \\left( \\sum_{t=1}^T \\nabla_{\\theta} \\log \\pi_{\\theta} (\\mathbf{a}_{i, t} \\vert \\mathbf{s}_{i, t}) \\right) \\left( \\sum_{t = 1}^T r(\\mathbf{s}_{i,t}, \\mathbf{a}_{i, t}) \\right)$$\nIn this equation, $\\pi_{\\theta} (\\mathbf{a}_{i, t} \\vert \\mathbf{s}_{i, t})$ denotes the probability of our policy $\\pi_{\\theta}$ selecting the actions $\\mathbf{a}_{i, t}$ that it actually ended up selecting in practice, given the states $\\mathbf{s}_{i, t}$ that it encountered during the episode that we're looking at.\nIn the case of a deterministic policy $\\pi_{\\theta}$, we know for sure that the probability of it selecting the actions that it did select must be $1$ (and the probability of it selecting any other actions would be $0$, but such a term does not show up in the equation). So, we have $\\pi_{\\theta} (\\mathbf{a}_{i, t} \\vert \\mathbf{s}_{i, t}) = 1$ for every instance of that term in the above equation. Because $\\log 1 = 0$, this leads to:\n\\begin{aligned}\n\\nabla_{\\theta} J(\\theta) &\\approx \\frac{1}{N} \\sum_{i=1}^N \\left( \\sum_{t=1}^T \\nabla_{\\theta} \\log \\pi_{\\theta} (\\mathbf{a}_{i, t} \\vert \\mathbf{s}_{i, t}) \\right) \\left( \\sum_{t = 1}^T r(\\mathbf{s}_{i,t}, \\mathbf{a}_{i, t}) \\right) \\\\\n%\n&= \\frac{1}{N} \\sum_{i=1}^N \\left( \\sum_{t=1}^T \\nabla_{\\theta} \\log 1 \\right) \\left( \\sum_{t = 1}^T r(\\mathbf{s}_{i,t}, \\mathbf{a}_{i, t}) \\right) \\\\\n%\n&= \\frac{1}{N} \\sum_{i=1}^N \\left( \\sum_{t=1}^T \\nabla_{\\theta} 0 \\right) \\left( \\sum_{t = 1}^T r(\\mathbf{s}_{i,t}, \\mathbf{a}_{i, t}) \\right) \\\\\n%\n&= \\frac{1}{N} \\sum_{i=1}^N 0 \\left( \\sum_{t = 1}^T r(\\mathbf{s}_{i,t}, \\mathbf{a}_{i, t}) \\right) \\\\\n%\n&= 0 \\\\\n\\end{aligned}\n(i.e. you end up with a sum of terms that are all multiplied by $0$).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can the policy iteration algorithm be model-free if it uses the transition probabilities? I'm actually trying to understand the policy iteration in the context of RL. I read an article presenting it and, at some point, a pseudo-code of the algorithm is given : \nWhat I can't understand is this line : \n\nFrom what I understand, policy iteration is a model-free algorithm, which means that it doesn't need to know the environment's dynamics. But, in this line, we need $p(s',r \\mid s, \\pi(s))$ (which in my understanding is the transition function of the MDP that gave us the probability of landing in the state $s'$ knowing previous $s$ state and the action taken) to compute $V(s)$. So I don't understand how we can compute $V(s)$ with the quantity $p(s',r \\mid s, \\pi(s))$ since it is a parameter of the environment. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Everything you say in your post is correct, apart from the wrong assumption that policy iteration is model-free. PI is a model-based algorithm because of the reasons you're mentioning. \nSee my answer to the question What's the difference between model-free and model-based reinforcement learning?.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is \"planning\" in the context of reinforcement learning, and how is it different from RL and SL? This is an excerpt taken from Sutton and Barto (pg. 3):\n\nAnother key feature of reinforcement learning is that it explicitly considers the whole problem of a goal-directed agent interacting with an uncertain environment. This is in contrast with many approaches that address subproblems without addressing how they might fit into a larger picture. For example, we have mentioned that much of machine learning research is concerned with supervised learning without explicitly specifying how such an ability would finally be useful. Other researchers have developed theories of planning with general goals, but without considering planning's role in real-time decision-making, or the question of where the predictive models necessary for planning would come from. Although these approaches have yielded many useful results, their focus on\nisolated subproblems is a significant limitation.\n\nI have an idea of supervised learning (SL), but what exactly does the author mean by planning? And how is the RL approach different from planning and SL?\n(Illustration with an example would be nice).\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The concept of \"planning\" is not just related to RL. In general (as the name suggests), planning consists in creating a \"plan\" which you will use to reach a \"goal\". The goal depends on the context or problem. For example, in robotics, you can use a \"planning algorithm\" (e.g. Dijkstra's algorithm) in order to find the path between two points on a map (given e.g. the map as a graph).\nIn RL, planning usually refers to the use of a model of the environment in order to find a policy that hopefully will help the agent to behave optimally (that is, obtain the highest amount of return or \"future cumulative discounted reward\"). In RL, the problem (or environment) is usually represented as a Markov Decision Process (MDP). The \"model\" of the environment (or MDP) refers to the transition probability distribution (and reward function) associated with the MDP. If the transition model (and reward function) is known, you can use an algorithm that exploits it to (directly or indirectly) find a policy. This is the usual meaning of planning in RL. A common planning algorithm in RL is e.g. value iteration (which is a dynamic programming algorithm).\n\nOther researchers have developed theories of planning with general goals, but without considering planning's role in real-time decision- making, or the question of where the predictive models necessary for planning would come from.\n\nPlaning is often performed \"offline\", that is, you \"plan\" before executing. While you're executing the \"plan\", you often do not change it. However, often this is not desirable, given that you might need to change the plan because the environment might also have changed. Furthermore, the authors also point out that planning algorithms often have a few limitations: in the case of RL, a \"model\" of the environment is required to plan.\n\nFor example, we have mentioned that much of machine learning research is concerned with supervised learning without explicitly specifying how such an ability would finally be useful.\n\nI think the authors simply want to say that supervised learning is usually used to solve specific problems. The solutions to supervised problems often are not directly applicable to other problems, so this makes them limited.\n\nAnother key feature of reinforcement learning is that it explicitly considers the whole problem of a goal-directed agent interacting with an uncertain environment.\n\nIn RL, there is the explicit notion of a \"goal\": there is an agent that interacts with an environment in order to achieve its goal. The goal is often to maximize the \"return\" (or \"future cumulative discounted reward\", or, simply, the reward in the long run).\n\nHow is RL different from planning and supervised learning?\n\nRL and planning (in RL) are quite related. In RL, the problem is similar to the one in planning (in RL). However, in RL, the transition model and reward function of the MDP (which represents the environment) are usually unknown. Therefore, the only way of finding or estimating an optimal policy that will allow the agent to (near-optimally) behave in this environment is to interact with the environment and gather some info regarding its \"dynamics\".\nRL and supervised learning (SL) are quite different. In SL, there isn't usually the explicit concept of \"agent\" or \"environment\" (and their interaction), even though it might be possible to describe supervised learning in that way (see this question). In supervised learning, during the training or learning phase, a set of inputs and the associated expected outputs is often provided. Then the \"objective\" is to find a map between inputs and outputs, which generalizes to inputs (and corresponding outputs) that have not been observed during the learning phase. In RL, there isn't such a set of inputs and associated expected outputs. In RL, there is just a scalar signal emitted by the environment, at each time step, which roughly indicates how well the agent is currently performing. However, the goal of the agent is not just to obtain rewards, but to behave optimally (in the long run).\nIn short, in RL, there is the explicit notion of agent, environment and goal, and the reward is the only signal which tells the agent how well it is performing, but the reward does not tell the agent which actions it should take at each time step. In supervised learning, the objective is to find a function that maps inputs to the corresponding outputs, and this function is learned by providing explicit examples of such mappings during the training phase.\nThere are some RL algorithms (like the temporal-difference ones), which could roughly be thought of as self-supervised learning algorithms, where the agent learns from itself (or from the experience it has gained by interacting with the environment). However, even in these cases, the actions that the agent needs to take are not explicitly taught.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Clarifying representation of Neural Nerwork input for Chess Alpha Zero In the Alpha Zero paper (https://arxiv.org/pdf/1712.01815.pdf) page 13, the input for the NN is described. In the beggining of the page, the authors state that:\n\"The input to the Neural Network is an N x X x (MT + L) image stack [...]\"\nFrom this, I understand that (for one training example) each input feature is an 8x8 plane. (Technically speaking, every value of every 8x8 plane is a feature, but for the purpose of the question let's suppose that a plane is an input feature).\nIn the description of the table on top of the image, the following statement is made:\n\"[...] Counts are represented by a single real-valued input; other input features are represented by a one-hot encoding using thespecified number of binary input planes. [...]\"\nI understand how they convert the P1 and P2 pieces to one-hot encodings. My questions are:\n\nWhen they say single real-valued input, since every input feature should be an 8x8 plane, do they mean that they create an 8x8 plane where every entry has the same single-real value? For example, for the 'Total move count' plane, if 10 moves had been played in the game so far, it would look like the one below?\n\n move_count_plane = [[10, 10, 10, 10, 10, 10, 10, 10],\n [10, 10, 10, 10, 10, 10, 10, 10],\n [10, 10, 10, 10, 10, 10, 10, 10],\n [10, 10, 10, 10, 10, 10, 10, 10],\n [10, 10, 10, 10, 10, 10, 10, 10],\n [10, 10, 10, 10, 10, 10, 10, 10],\n [10, 10, 10, 10, 10, 10, 10, 10],\n [10, 10, 10, 10, 10, 10, 10, 10]]\n\n\nFor the 'Repetitions' plane, is it the same case as above? They mean a plane where every value is the number of times a specific board setup has been reached? For example, if a specific position has been reached 2 times, then the repetitions plane for that position would be\n\n # for a specific timestep in the T=8 step history\n repetitions_plane = [[2, 2, 2, 2, 2, 2, 2, 2],\n [2, 2, 2, 2, 2, 2, 2, 2],\n [2, 2, 2, 2, 2, 2, 2, 2],\n [2, 2, 2, 2, 2, 2, 2, 2],\n [2, 2, 2, 2, 2, 2, 2, 2],\n [2, 2, 2, 2, 2, 2, 2, 2],\n [2, 2, 2, 2, 2, 2, 2, 2],\n [2, 2, 2, 2, 2, 2, 2, 2]]\n\n? Also, why do they keep 2 repetitions planes? Is it one for every player? (8 repetition planes for the past T=8 moves for P1, and more 8 repetition planes for the past T=8 moves for P2?)\nThanks in advance.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "For anyone wondering, I believe to have found the answer:\n\nYes, it will be an 8x8 plane where all the entries are the same, the number of moves (or mpves with no progress).\n\nThere are two repetitions planes (for each position from the most recent T=8 positions):\na) The first repetition plane will be a plane where all the entries are 1's if the position is being repeated for the first time. Else 0's.\nb) The second repetition plane will be a plane where all the entries are 1's if the current position is being repeated for the second time. Else 0's.\n\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When to use Value Iteration vs. Policy Iteration Both value iteration and policy iteration are General Policy Iteration (GPI) algorithms. However, they differ in the mechanics of their updates. Policy Iteration seeks to first find a completed value function for a policy, then derive the Q function from this and improve the policy greedily from this Q. Meanwhile, Value Iteration uses a truncated V function to then obtain Q updates, only returning the policy once V has converged.\nWhat are the inherent advantages of using one over the other in a practical setting?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Value Iteration Vs Policy Iteration\nBelow is the list of differences & similarities between value iteration and policy iteration\nDifferences\n\n\n\n\n\nValue Iteration\nPolicy Iteration\n\n\n\n\nArchitecture\nVI Architecture reference\n PI Architecture Reference\n\n\nExecution starts with a\nrandom value function\nrandom policy\n\n\nAlgorithm\nsimpler\ncomplex\n\n\nComputation costs\nmore expensive\ncheaper\n\n\nExecution time\nSlower\nFaster\n\n\nNo of Iterations to converge\nsignificantly more\ntakes fewer iteration to converge\n\n\nGuaranteed to converge\nYes\nYes\n\n\n\n\nSimilarities\n\nboth are dynamic programming algorithms\nboth employ variations of Bellman updates\nBoth exploit one-step look-ahead\nBoth algorithms are guaranteed to converge to an optimal policy in the end\n\nPolicy iteration is reported to conclude faster than value iteration\nUSAGE PREFERENCE\nAs mentioned earlier in the difference, the main advantage for using Policy iteration over value iteration is its ability to conclude faster with fewer iterations thereby reducing its computation costs and execution time.\nREFERENCES\n\nResearch papers\n\nValue iteration and policy iteration\nalgorithms\nfor Markov decision problem\nOn the Complexity of Policy Iteration \n\n\nBook\n\nArtificial Intelligence: A Modern Approach, by Peter Norvig and Stuart J. Russell Chapter 17 Making Complex decisions\n\n\nArchitecture\n\nVI Architecture reference\nPI Architecture Reference\n\n\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "In MCTS, what to do if I do not want to simulate till the end of the game? I'm trying to implement MCTS with UCT for a board game and I'm kinda stuck. The state space is quite large (3e15), and I'd like to compute a good move in less than 2 seconds. I already have MCTS implemented in Java from here, and I noticed that it takes a long time to actually reach a terminal node in the simulation phase.\nSo, would it be possible to simulate games up until a specific depth?\nInstead of returning the winner of the game after running until the max depth, I could return an evaluation of the board (the board game is simple enough to write an evaluation function), which then back propagates.\nThe issue I'm having is in handling the backpropagation. I'm not quite sure what to do here. Any help/resources/guidance is appreciated!\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Famous example is AlphaZero. It doesn't do unrolls, but consults the value network for leaf node evaluation. The paper has the details on how the update is performed afterwards:\n\nThe leaf $s'$ position is expanded and evaluated only once by the network to gene-rate both prior probabilities and evaluation, $(P(s\u2032 , \\cdot),V(s \u2032 )) = f_\\theta(s\u2032 )$. Each edge $(s, a)$ traversed in the simulation is updated to increment its visit count $N(s, a)$, and to update its action value to the mean evaluation over these simulations, $Q(s,a) = \\frac{1}{N(s,a)}\\sum_{s,a\\to s'}V(s')$ , where $s, a\\to s\u2032$ indicates that a simulation eventually reached s\u2032 after taking move a from position s.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the role of the hidden vectors in restricted Boltzmann machines? I'm learning about the restricted Boltzmann machine (RBM), and I just came up with two naive understandings of this model. But it seems these two understandings are so different.\nMy first understanding goes like this.\nThe hidden units are just structural support and we don't care about what those hidden vectors really are. We introduce those hidden units just for RBM to gain more expressive power for a probability distribution.\nLet's say I have only one image, and I transform this image into a binary vector and feed this vector into an RBM with random variables (all the weights and biases are chosen randomly). Then, by turning on the machine, the first hidden vector would be constructed. But this hidden vector does not tell us anything, it would be only used to reconstruct a visible vector.\n(My understanding for this reconstructed visible vector is this vector is a vector encoded in the defined RBM in the first place, we are not really construct something new, but we just happen to sample this vector from the defined RBM).\nAnd we just run this loop of construction and reconstruction for infinitely many times. Finally, what we will get is just the probability distribution encoded in this RBM with random variables.\nMy second understanding goes like this.\nRBM can be used to perform dimensionality reduction, and those hidden vectors are some abstract representations of the raw inputs:\nGiven an RBM, each hidden unit of the RBM would be a classifier, and what it does is to check the input vector lies in which side of the hyperplane defined by these hidden units (by its weights and bias). So, if we input an image into this RBM, the RBM will project this input vector onto many hyperplanes defined by all the hidden units, and thus for an input vector, the corresponding hidden vector is very important. It is some abstract representation. And we can further feed this representation into other learning models.\nWhat is the role of the hidden vectors in restricted Boltzmann machines?\nIf you can answer this question by explaining how RBM is used for MNIST that would be extremely helpful for me.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Generative models\n\nThe hidden units are just structural support and we don't care about what those hidden vectors really are.\n\nGenerative modeling is concerned about $P(X)$, to be able to compute it, we use representation learning (aka deep learning) to identify and disentangle the underlying explanatory factors hidden in the observed data, \nbecause if we could separate them out like this \n$$P(X) = P(X \\mid Z) P(Z),$$\nwhere $Z$ could encode not just the digit identity but the angle that the digit is drawn, the stroke width, and also abstract stylistic properties. \nAny classifier for some task will decide which of those $z$ elements could help him to make a better decision, i.e. just the part that holds the digit identity and ignore the rest, this kind of modeling is called distributed representation, where each element is a simple indicator about some feature.\nNo conditional dependency within a layer\n\n(my understanding for this reconstructed visible vector is this vector is a vector encoded in the defined RBM in the first place, we are not really construct something new, but we just happen to sample this vector from the defined RBM)\n\nRBM is an undirected graphical model and no conditional dependency within a layer. Thus, the conditional distribution over the hidden units $h$ given the input image $v$ factorizes, that is \n$$p(h \\mid v) = \\prod_i p(h_i \\mid v) $$ \nAnd the conditional distribution over the visible units $v$ given the hidden units $h$ also factorize. \n$$p(v \\mid h) = \\prod_j p(v_j \\mid h) $$ \nInference is tractable\nInference in RBM is tractable and we could compute $p(z|x)$, but the tractability of the RBM does not extend to its partition function. \nTo minimize the negative log-likelihood of the data, consider the following equation.\n$$-\\frac{\\partial \\log p(x)}{\\partial \\theta} = \\frac{\\partial \\mathcal{F}(x)}{\\partial \\theta}-\\sum_{\\tilde{x}} p(\\tilde{x}) \\frac{\\partial \\mathcal{F}(\\tilde{x})}{\\partial \\theta}$$\nThe first term $\\frac{\\partial \\mathcal{F}(x)}{\\partial \\theta}$ increases the probability of training data. The second term $\\sum_{\\tilde{x}} p(\\tilde{x}) \\frac{\\partial \\mathcal{F}(\\tilde{x})}{\\partial \\theta}$ decreases the probability of samples generated by the model. \nThe second term is nothing less than an expectation over all possible configurations of the input $x$ (under the distribution $P$ formed by the model). \nMonte Carlo-based algorithms\nSo, we use Monte Carlo based algorithms to replace the expectation with an average sum. Samples of $p(x)$ from the model can be obtained by running a Markov chain to convergence, using Gibbs sampling as the transition operator. \nFor RBMs, the set of visible and hidden units, since they are conditionally independent, one can perform block Gibbs sampling. In this setting, visible units are sampled simultaneously given fixed values of the hidden units. Similarly, hidden units are sampled simultaneously given the visible units. \nA step in the Markov chain is thus taken as follows: \n\n$v$: input values\n$h$: hidden features, latent space, a.k.a $Z$\n$W$: the weight parameters; note that I am using the transposed $W$,\nsince it's an undirected graphical model. \n\nSo, we have the formulas.\n$$h^{(n+1)} \\sim \\operatorname{sigm}\\left(W^{\\prime} v^{(n)}+c\\right)$$\nand \n$$v^{(n+1)} \\sim \\operatorname{sigm}\\left(W h^{(n+1)}+b\\right)$$\nwhere $h^{n+1}$ refers to the set of all hidden units at the $n$th step of the Markov chain. What it means is that, for example, $h^(n+1)_i$ is randomly chosen to be $1$ (versus $0$) with the probability of the sigmoid function and similarly for $v^(n+1)_j$.\nIn theory, each parameter update in the learning process would require running one such chain to convergence. It is needless to say that doing so would be prohibitively expensive. As such, several algorithms have been devised for RBMs, see Contrastive Divergence. \nWe initialize the Markov chain with a training example (i.e., from a distribution that is expected to be close to $p$, so that the chain will be already close to having converged to its final distribution $p$).\nCD does not wait for the chain to converge. Samples are obtained after only $k$-steps of Gibbs sampling. In practice, $k=1$ has been shown to work surprisingly well. \nRBM for dimensionality reduction\n\nRBM can be used to perform dimensionality reduction, and those hidden vectors are some abstract representations of the raw inputs:\n\nAccording to the paper Reducing the Dimensionality of Data with Neural Networks \n\nIn 2006, a breakthrough in feature learning and deep learning took place (Hinton et al., 2006; Bengio et al., 2007; Ranzato et al., 2007), A central idea, referred to as greedy layerwise unsupervised pre-training, was to learn a hierarchy of features one level at a time, using unsupervised feature learning to learn a new transformation at each level\n to be composed with the previously learned transformations; essentially, each iteration of unsupervised feature learning adds one layer of weights to a deep neural network. Finally, the set of layers could be combined to initialize a deep supervised predictor, such as a neural network classifier. \n\n\nSummary\n\nTrain single layer RBM to reconstruct to input and then keep adding layer after layer until we reach some good low-level representation as depicted in the figure below, W1, W2, W3 are the matrices that have some lower dimensionality of the input space.\nTranspose those matrices $W_1, W_2, W_3$ to be the decoder part.\nFine-tune the whole encoder-decoder stack to reconstruct the input. image\n\n\nRBM vs VAE and GAN\nSide note: RBM is now obsolete, see VAE, GAN they are way better at modeling the manifold in which the data is concentrated, yet you could sample from the manifold directly with a single inference step.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "If the current state is $S_t$ and the actions are chosen according to $\\pi$, what is the expectation of $R_{t+1}$ in terms of $\\pi$ and $p$? I'm trying to solve exercise 3.11 from the book Sutton and Barto's book (2nd edition)\n\nExercise 3.11 If the current state is $S_t$ , and actions are selected according to a stochastic policy $\\pi$, then what is the expectation of $R_{t+1}$ in terms of $\\pi$ and the four-argument function $p$ (3.2)?\n\nHere's my attempt.\nFor each state $s$, the expected immediate reward when taking action $a$ is given in terms of $p$ by eq 3.5 in the book:\n$$r(s,a) = \\sum_{r \\in R} r \\, \\sum_{s'\\in S} p(s',r \\mid s,a) = E[R_t \\mid S_{t-1} = s, A_{t-1} = a] \\tag{1}\\label{1}$$\nThe policy $\\pi(a \\mid s)$, on the other hand, gives the probability of taking action $a$ given the state $s$.\nIs it possible to express the expectation of the immediate reward over all actions $A$ from the state $s$ using (1) as\n$$E[R_t \\mid S_{t-1} = s, A] = \\sum_{a \\in A} \\pi(a \\mid s) r(a,s) \\tag{2}\\label{2}$$\n?\nIf this is valid, is this also valid in the next time step\n$$E[R_{t+1} \\mid S_{t} = s, A] = \\sum_{a \\in A} \\pi(a \\mid s) r(a, s) \\tag{3}\\label{3}$$\n?\nIf (2) and (3) are OK, then\n$$E[R_{t+1} \\mid S_{t} = s, A] = \\sum_{a \\in A} \\pi(a \\mid s) \\sum_{r \\in R} r \\, \\sum_{s'\\in S} p(s',r \\mid s,a)$$\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First note that $\\mathbb{E}[R_{t+1} |S_t=s] = \\sum_{s',r}rm(s',r|s)$ where $m(\\cdot)$ is the mass function for the joint distribution of $S_{t+1},R_{t+1}$. \nIf you are currently in state $S_t$ and we condition on taking action $a$ then the expected reward at time $t+1$ is given as follows:\n\\begin{align} \\mathbb{E}[R_{t+1} | S_t = s, A_t=a] & = \\sum_{s',r}rp(s'r|s,a)\\;.\n\\end{align}\nHowever, action $A_t$ is taken according to some stochastic policy $\\pi$ so we need to marginalise this out of our expectation by using the tower law - i.e. we take \n$$\\mathbb{E}_{A_t \\sim \\pi}[\\mathbb{E}[R_{t+1} | S_t = s, A_t=a]|S_t = s] = \\sum_a \\pi(a|s)\\sum_{s',r}rp(s'r|s,a) = \\mathbb{E}[R_{t+1} | S_t = s]\\;.$$\nTo see why this holds we can re-write using some arbitrary mass functions $f(\\cdot),h(\\cdot),g(\\cdot),m(\\cdot)$ as\n$$\\pi(a|s)p(s'r|s,a) = \\frac{f(a,s)}{g(s)} \\times \\frac{h(s',r,a,s)}{f(a,s)} = m(s',r,a|s)\\;,$$\nso when we would end up with (after re-arranging the summations)\n$$\\sum_{s',r}r \\sum_{a}m(s',r,a|s) = \\sum_{s',r}r m(s',r|s) = \\mathbb{E}[R_{t+1}|S_t = s]\\;;$$\nas required. \nNB: what you have done is mostly correct except be careful when going from (2) to (3). They are exactly the same equation except for the time stamps, which means you would have to change the time stamps in your $r(s,a)$. Note that when you are at time step $t$ you take your action $A_t$ from your current $S_t$ to transition into state $S_{t+1}$ and then receive reward $R_{t+1}$ (and the next state). \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does \"hard for AI\" look like? In theoretical computer science, there is a massive categorization of the difficulty of various computational problems in terms of their asymptotic worst-time computational complexity. There doesn't seem to be any analogous analysis of what problems are \"hard for AI\" or even \"impossible for AI.\" This is in some sense quite reasonable, because most research is focused on what can be solved. I'm interested in the opposite. What I do need to prove about a problem to prove that it is \"not reasonably solvable\" by AI?\nMany papers say something along the lines of\n\nAI allows us to find real-world solutions to real-world instances of NP-complete problems.\n\nIs there a theoretical, principled reason for saying this instead of \"... PSPACE-complete problems\"? Is there some sense in which AI doesn't work on PSPACE-complete, or EXPTIME-complete, or Turing complete problems?\nMy idea answer would be a reference to a paper that shows AI cannot be used to solve a particular kind of problem based on theoretical or statistical reasoning. Any answer exhibiting and justifying a benchmark for \"too hard for AI\" would be fine though (bonus points if the benchmark has a connection to complexity and computability theory).\nIf this question doesn't have an answer in general, answers about specific techniques would also be interesting to me.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Nice Question!\nThis is a perennial topic of discussion among AI researchers. The short answer is \"we don't really know which topics are hard in general, but we do know which we haven't got good techniques for yet.\"\nLet's start by explaining why AI is not concerned with notions of computational complexity like NP-Completeness. AI researchers figured out in the 90's that most problems that are computationally hard in theory aren't actually hard in practice at all! For example, Boolean Satisfiability, the canonical NP-Hard problem, is known to have hard instances, but in practice, these almost never show up. Even when they do, we can usually get good approximate solutions with minimal computation time. Since many AI problems are reducible to SAT, whole areas of the field just use these approximation techniques and solvers. There's a good, if a bit old, survey here. Since 2008, things have only gotten better. Basically, NP-Hard stuff just isn't that hard. Worst-case complexity is therefore probably the wrong tool to guess at which problems are hard for AI.\nAt the other end of the scale, we have subjective complexity based on things like how \"large\" the problem is. This has proven to be pretty unreliable. One example is Go, which I was told would \"never be solved by AI\" as late as 2010. Clearly, we were completely wrong. We just didn't know which techniques to use yet. Another example is language. Rule-based AI'ers tried at it for decades with minimal success. Probabilistic methods have achieved essentially human-level performance in less time. If you asked a researcher in the 1970s if language was hard for AI, they'd have said yes, but they'd have been wrong. This has been closely related to the advances in computing hardware: techniques that seemed wasteful and slow 40 years ago are now entirely practical. Sometimes they turn out to solve problems really well.\nPart of this ties into the issue that AI'ers don't really know or agree on what intelligence is, or what it means to solve a problem. Some AI'ers maintain that language really is hard, and that the systems we use now aren't really solving language, they're just making blind guesses that happen to be right a lot. Under that view, language is still hard. Fodor was a strong proponent of this view in the past, and his writings are a good place to read about it, but I've still heard people espouse views like this at AI conferences as recently as 2015.\nSomething this usually considered hard right now is making a good general intelligence, that integrates knowledge across many domains and could plausibly pass something like the Turing test. Yet, there has been some progress here (look at virtual assistants), and some AI'ers reckon this might not be as hard as we thought either. \nSo, basically, we don't know what's hard because we don't know when someone will come up with a new exciting technique that solves problems previously thought to be hard, we know that worst-case complexity isn't a good measurement system for \"intelligence\" requirements, and we don't know what intelligence really is. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When to use the state value function $V(s)$ and when to use the state-action value function $Q(s, a)$? I saw the difference between value function $V(s)$ and $Q(s, a)$. But when do I use each one? When I coded in Matlab I only used $Q(s, a)$ directly (as I was thinking of a tabular approach). So, when is more beneficial than the other? I have a large state space.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The core differences between using $V(s)$ or $Q(s,a)$ are:\n$V(s)$ cannot be used stand-alone to decide a policy.\nYou either need a separate policy function $\\pi(a|s)$ that it is the value function for, or you can derive a policy from it if you have access to the environment's distribution model $p(r,s'|s,a)$ - the probability of receiving reward $r$ and arriving in next state $s'$ given start $s,a$. The derived policy would be deterministic $\\pi(s) = \\text{argmax}_a \\sum_{r,s'} p(r,s'|s,a)(r + \\gamma V(s'))$\nIn comparison, $Q(s,a)$ can be used to derive a policy without reference to any model: $\\pi(s) = \\text{argmax}_a Q(s,a)$. This makes the action value function Q necessary for model-free value-based control methods. Hence Monte-Carlo Control, SARSA, Q-Learning will all use action values.\n$V(s)$ is usually more compact than $Q(s,a)$.\nSpace used by a state value table is $O(|\\mathcal{S}|)$\nSpace used by an action-value table is $O(|\\mathcal{S} \\times \\mathcal{A}|)$\nThese space concerns also apply when you are using approximation - the input domain you need to learn to approximate $Q(s,a)$ is larger than the one you need to learn $V(s)$. Although for large state spaces with lots of dimensions, the relative difference after approximation may be small enough that you don't really care.\nThe smaller space makes $V(s)$ a good choice if you can use it. The benefits are smaller memory footprint, and often faster learning because there are fewer separate values to learn (not always faster, as you still need to explore all actions in all states to learn accurate values).\nTypical scenarios where you can use $V(s)$ instead of $Q(s,a)$\n\nYou have access to the full environment model, as described in the first section, above.\n\nor\n\nYou are working with a separate policy function. In optimal control, this typically occurs in actor-critic methods, which are relatively advanced RL approach, but a popular one, especially when the action space is large. The situation also occurs in prediction problems where the task is not to optimise anything, but to evaluate a fixed policy.\n\nor\n\nYour actions are directly choosing the next state. This is called afterstate representation, and is subtly different to state values $V(s)$, but has similar benefit of smaller space used. It is useful in determining values in board games and similar environments.\n\nIf none of these situations applies, then you will have to use action-value function $Q(s,a)$. You might also choose to use $Q(s,a)$ because it is easier to stick with it in whatever framework you are working in. Sometimes the benefits of using $V(s)$ instead are not large enough to be worth the effort.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to express a fully connected neural network succintly using linear algebra? I'm currently reading the paper Federated Learning with Matched Averaging (2020), where the authors claim:\n\nA basic fully connected (FC) NN can be formulated as: $\\hat{y} = \\sigma(xW_1)W_2$ [...]\nExpanding the preceding expression\n$\\hat{y} = \\sum_{i=1}^{L} W_{2, i \\cdot } \\sigma(\\langle x, W_{1,\\cdot i} \\rangle))$, where $ i\\cdot$ and $\\cdot i$ denote the ith row and column correspondingly and $L$ is the number of hidden units.\n\nI'm having a hard time wrapping my head around how it can be boiled down to this. Is this rigorous? Specifically, what is meant by the ith row and column? Is this formula for only one layer or does it work with multiple layers?\nAny clarification would be helpful.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The equation $$\\hat{y} = \\sigma(xW_\\color{green}{1})W_\\color{blue}{2} \\tag{1}\\label{1}$$ is the equation of the forward pass of a single-hidden layer fully connected and feedforward neural network, i.e. a neural network with 3 layers, 1 input layer, 1 hidden layer, and 1 output layer, where\n\nthe input layer is connected to the hidden layer (all scalar inputs are connected to every neuron in the hidden layer)\nthe hidden layer is connected to the output layer (all neurons in the hidden layer are connected to all neurons in the output layer\n\nAs an example, suppose that we have $N$ real-valued features, there are $L$ hidden units (or neurons) and $M$ output units, then the elements (feature vector and parameters) of equation \\ref{1} would have the following shape\n\n$x \\in \\mathbb{R}^{1 \\times N}$\n$W_\\color{green}{1} \\in \\mathbb{R}^{N \\times L}$\n$W_\\color{blue}{2} \\in \\mathbb{R}^{L \\times M}$\n\n$\\sigma$ is an activation function that is applicable to all elements of the matrix separately (i.e. component-wise). So, $\\hat{y} \\in \\mathbb{R}^{1 \\times M}$.\nThe equation\n$$\n\\hat{y} = \\sum_{\\color{red}{i} = 1}^{L} W_{\\color{blue}{2}, \\color{red}{i} \\cdot} \\sigma(\\langle x, W_{\\color{green}{1}, \\cdot \\color{red}{i}} \\rangle )\\label{2}\\tag{2}\n$$\nis another way of writing equation \\ref{1}.\nBefore going to the explanation, let's try to understand equation \\ref{2} and its components.\n\n$W_{\\color{green}{1}, \\cdot \\color{red}{i}} \\in \\mathbb{R}^N$ is the $\\color{red}{i}$th column of the matrix that connects the inputs to the hidden neurons, so it is a vector of $N$ elements (note that we sum over the number of hidden neurons, $L$).\n\nSimilarly, $ W_{\\color{blue}{2}, \\color{red}{i} \\cdot} \\in \\mathbb{R}^M$ is also a vector, but, in this case, it is a row of the matrix $ W_{\\color{blue}{2}}$ (rather than a column: why? because we use $\\color{red}{i} \\cdot$ instead of $\\cdot \\color{red}{i}$, which refers to the column).\n\nSo, $\\langle x, W_{\\color{green}{1}, \\cdot \\color{red}{i}} \\rangle$ is the dot (or scalar) product between the feature vector $x$ and the $\\color{red}{i}$th column of the matrix that connects the inputs to the hidden neurons, so it's a number (or scalar). Note that both $x$ and $W_{\\color{green}{1}, \\cdot \\color{red}{i}}$ have $N$ elements, so the dot product is well-defined in this case.\n\n$ W_{\\color{blue}{2}, \\color{red}{i}} \\sigma(\\langle x, W_{\\color{green}{1}, \\color{red}{i}} \\rangle))$ is the product between a vector of shape $M$ and a number $\\sigma(\\langle x, W_{\\color{green}{1}, \\cdot \\color{red}{i}} \\rangle )$. This is also well-defined. You can multiply a real-number with a vector, it's like multiplying the real-number with each element of the vector.\n\n$\\sum_{\\color{red}{i} = 1}^{L} W_{\\color{blue}{2}, \\color{red}{i} \\cdot} \\sigma(\\langle x, W_{\\color{green}{1}, \\cdot \\color{red}{i}} \\rangle )$ is thus the sum of $L$ vectors of size $M$, which makes $\\hat{y}$ also have size $M$, as in equation \\ref{1}.\n\n\nNow, the question is: is equation \\ref{2} really equivalent to equation \\ref{1}? This is still not easy to see because $xW_\\color{green}{1}$ is a vector of shape $L$, but, in equation \\ref{2}, we do not have any vector of shape $L$, but we have vectors of shape $N$ and $M$ (and the vectors of shape $M$ are summed $L$ times). First, note that $\\sigma(xW_\\color{green}{1}) = h\\in \\mathbb{R}^L$, so $hW_\\color{blue}{2}$ are $M$ dot products collected in a vector (i.e. $\\hat{y} \\in \\mathbb{R}^M$), where the $j$th element of $\\hat{y}$ was computed as a summation of $L$ elements (a dot product of two vectors is the element-wise multiplication of the elements of the vectors followed by the summation of these multiplications). Ha, still not clear!\nThe easiest way (for me) to see that they are equivalent is to think that $\\sigma(xW_\\color{green}{1})$ is a vector of $L$ elements $\\sigma(xW_\\color{green}{1}) = \\ell = [l_1, l_2, \\dots, l_L]$. Then you know that to multiply this vector with $\\ell$ (from the left), you actually perform a dot product between $\\ell$ and each column $W_\\color{blue}{2}$. A dot product is essentially a sum, and that's why we sum in equation \\ref{2}. So, essentially, in equation \\ref{2}, we first multiple $l_1$ with the first row of $W_\\color{blue}{2}$ (i.e. by all elements of the first row). Then we multiply $l_2$ by the second row of $W_\\color{blue}{2}$. We do this for all $L$ rows, then we sum the rows (to conclude the dot product). So, you can think of equation 2 as first perform all multiplications, then summing, rather than dot product-by-dot product.\nSo, in my head, I have the following picture. To simplify the notation, let $A$ denote $W_\\color{blue}{2}$, so $A_{ij}$ is the element at the $i$th row and $j$th column of matrix $W_\\color{blue}{2}$. So, we have the following initial matrix\n$$\nA = \n\\begin{bmatrix}\nA_{11} & A_{12} & A_{13} & \\dots & A_{1M} \\\\\nA_{21} & A_{22} & A_{23} & \\dots & A_{2M} \\\\\n\\vdots & \\vdots & \\vdots & \\dots & \\vdots \\\\\nA_{L1} & A_{L2} & A_{L3} & \\dots & A_{LM} \\\\\n\\end{bmatrix}\n= \n\\begin{bmatrix}\nW_{\\color{blue}{2}, \\color{red}{1} \\cdot} \\\\\nW_{\\color{blue}{2}, \\color{red}{2} \\cdot} \\\\\n\\vdots \\\\\nW_\\color{blue}{2, \\color{red}{L} \\cdot} \\\\\n\\end{bmatrix}\n$$\nThen, in the first iteration of equation \\ref{2}, we do the following\n$$\n\\begin{bmatrix}\nl_1 A_{11} & l_1 A_{12} & l_1 A_{13} & \\dots & l_1 A_{1M} \\\\\nA_{21} & A_{22} & A_{23} & \\dots & A_{2M} \\\\\n\\vdots & \\vdots & \\vdots & \\dots & \\vdots \\\\\nA_{L1} & A_{L2} & A_{L3} & \\dots & A_{LM} \\\\\n\\end{bmatrix}\n$$\nIn the second, we do the following\n$$\n\\begin{bmatrix}\nl_1 A_{11} & l_1 A_{12} & l_1 A_{13} & \\dots & l_1 A_{1M} \\\\\nl_2 A_{21} & l_2 A_{22} & l_2 A_{23} & \\dots & l_2 A_{2M} \\\\\n\\vdots & \\vdots & \\vdots & \\dots & \\vdots \\\\\nA_{L1} & A_{L2} & A_{L3} & \\dots & A_{LM} \\\\\n\\end{bmatrix}\n$$\nUntil we have\n$$\n\\begin{bmatrix}\nl_1 A_{11} & l_1 A_{12} & l_1 A_{13} & \\dots & l_1 A_{1M} \\\\\nl_2 A_{21} & l_2 A_{22} & l_2 A_{23} & \\dots & l_2 A_{2M} \\\\\n\\vdots & \\vdots & \\vdots & \\dots & \\vdots \\\\\nl_L A_{L1} & l_L A_{L2} & l_L A_{L3} & \\dots & l_L A_{LM} \\\\\n\\end{bmatrix}\n$$\nThen we do a reduce sum across the rows to end the dot product (i.e. for each column we sum the elements in the rows). This is exactly equivalent to first performing the dot product between $\\ell$ and the first column of $W_\\color{blue}{2}$, then the second column, and so on.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is tf.abs non-differentiable in Tensorflow? I understand why tf.abs is non-differentiable in principle (discontinuity at 0) but the same applies to tf.nn.relu yet, in case of this function gradient is simply set to 0 at 0. Why the same logic is not applied to tf.abs? Whenever I tried to use it in my custom loss implementation TF was throwing errors about missing gradients.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "By convention, the $\\mathrm{ReLU}$ activation is treated as if it is differentiable at zero (e.g. in [1]). Therefore it makes sense for TensorFlow to adopt this convention for tf.nn.relu. As you've found, of course, it's not true in general that we treat the gradient of the absolute value function as zero in the same situation; it makes sense for it to be an explicit choice to use this trick, because it might not be what the code author intends in general.\nIn a way this is compatible with the Python philosophy that explicit is better than implicit. If you mean to use $\\mathrm{ReLU}$, it's probably best to use tf.nn.relu if it is suitable for your use case.\n[1] Vinod Nair and Geoffrey Hinton. Rectified Linear Units Improve Restricted Boltzmann Machines. ICML'10 (2010). URL.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a weighted average in a non-stationary k-armed bandit problem? In the book Reinforcement Learning: An Introduction (page 25), by Richard S. Sutton and Andrew G. Barto, there is a discussion of the k-armed bandit problem, where the expected reward from the bandits changes slightly over time (that is, the problem is non-stationary). Instead of updating the Q values by taking an average of all rewards, the book suggests using a constant step-size parameter, so as to give greater weight to more recent rewards. Thus:\n$$ Q_{n+1} = Q_n + \\alpha (R_n - Q_n),$$\nwhere $\\alpha$ is a constant between 0 and 1. \nThe book then states that this a weighted average because the sum of the weights is equal to 1. What does this mean? Why is this true?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The weighted average stands for a linear combination of all values, such that the sum of all weights is 1.\nMore specifically, if you denote the rewards by a vector $X$, the weighted average will be taking the dot product between $X$ and a vector $W$ such that $0 \\le W_i \\le 1$ and the sum of all $W_i$ is 1.\nIf each $W_i = 1/n$ it will be a weighted average (a.k.a the mean). Using the exponential decay $W_i = \\alpha^i/ (\\sum W_i)$ is also a weighted average.\nThen both strategies to compute the Q value use weighted average of previous reward.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why are only neural networks (and not SVMs, for example) used for reinforcement learning? I know that neural networks are the \"universal function approximator\", but they also have a huge number of trainable parameters and are extremely prone to overfitting.\nSo my question is: Why aren't SVMs or Random Forests used as the mediators in decision-making?\nI have read this response, and it highlights very broadly why NNs are not required but are generally good for the job.\nThis does not answer my question, though, as I want to understand why no popular implementations (that I've seen) use anything but neural networks, and why the vast majority of reinforcement learning literature talks about Deep RL and not, for example, \"SVM-RL\" or something like that.\nMy understanding is that this is technically possible - but why is it not being done often or at all?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The biggest problem with SVMs, random forests, gradient boosting and others for reinforcement learning (RL) is that they are not able to learn online, adjusting for new data as it arrives, and equally importantly forgetting older data. These algorithms learn from fixed datasets, and must be re-trained with whole new datasets if the target dataset changes, in scenarios also known as non-stationary problems.\nThis is a major issue in reinforcement learning for control problems (when you want to find an optimal policy). RL control problems always generate non-stationary target data, because they maintain a current policy - or for off-policy approches, current target policy. That current policy then changes over time as the agent improves its estimates (of e.g. the Q table), which means it is necessary to forget older training data and replace with newer.\nSo one requirement in RL is for online learning algorithms that can handle non-stationary data well - both incorporating new data and smoothly forgetting older data. That includes neural networks. There are not many other non-linear approximators that can do so simply.\nIt is possible to compensate for this lack of online learning in various ways. Some of the model classes, such as random forests and support vector machines, can be extended to learn online - although this seems not to be explored much in deep RL, perhaps due to complexity, or limitations that make it still less flexible choice than neural networks (opinion: looking at the recent dates on these papers compared to the longer history of using NNs with RL, there may be an element of intertia too, and possibility for revisiting using these models in a RL context).\nYou could modify the outer algorithm to be more like policy iteration, collecting large amounts of data for the current policy to form a large batch that is then learned from to replace the previous approximate value function and in turn update the policy from that. That would work for most approximators in theory, but may be very slow and introduces hyperparameter of batch size that will have a large impact.\nThere are unwanted side-effect to online learning in RL using approximators, such as the risk of catastrophic forgetting, where a well-trained agent is not able to distinguish bad choices from good ones because it has not experienced a bad decision for many time steps, and has generalised that \"everything is good now\". This would not be fixed in RL by using large batches and non-online algorithms - if anything it could be worse in those cases, because they would effectively be forced to forget everything between batches. The usual fix for catastrophic forgetting in RL is adding some management of the dataset - e.g. keeping some amount of older experience even though it is technically not part of the current policy's generated data.\n\nthey also have a huge number of trainable parameters and are extremely prone to overfitting\n\nOverfitting of approximators can happen, but may be less of an issue in practice with RL compared to smaller fixed datasets, because agents are continuously and actively generating new data. Complex environments with lots of resources used to generate experience behave in a lot of ways like \"big data\" datasets, playing to the strengths of large flexible models.\nIn RL there is commonly an overlap with processing image data (and possibly other sensors with return data that can be structured into some grid or graph). In the problem domains related to image comprehension, neural networks are state of the art, so it is no surprise to see them used for approximating action values in the orginal DQN paper for example - with the right architecture NNs are measurably superior, in terms of error metrics, to SVMs, RFs, boosting et al, when fitting this kind of sensor data.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does the quality of training images affect the accuracy of the neural network? I just got into AI few months ago. I noticed most of the images in training datasets are usually low quality( almost pixelated). \nDoes the quality of training images affect the accuracy of the neural network? \nI tried googling, but I couldn't find an answer.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "For most of the current use cases, where NNs are used in conjunction with images, the image quality (resolution, color depth) can be low.\nConsider image classification for example. The CNN extracts features from the image to tell different types of objects apart. Those features are pretty independent from the quality of the image (in reasonable bounds). Compare it with your own visual experience. Try to reduce the resolution of an image of a car step by step to figure out how little details you need until you can no longer distinguish it from a plane. This is similar to modern CNNs, which can even outperform human vision in some regards.\nThis changes when small details start to matter. Maybe you need to be able to detect small differences in fur patterns to tell different cat breeds apart. As soon as you lose those details, the detection rate will drop significantly.\nSo the answer to your question is, it depends. As long as you do not lose the important features of the image, you'll be fine with low resolution.\n\nIn case you care about the reason for the low quality of images used in machine learning - The resolution is an easy factor you can manipulate to scale the speed of your NN. Decreasing resolution will reduce the computational demands significantly.\nMany CNNs even include pooling layers in their architecture, which artificially reduce the resolution further after certain processing steps. This is usually a good idea as long as you are fine with loosing positional information. You shouldn't do this when teaching the CNN to play a game, because location is highly important, but for image classification this has become an established method to increase performance.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can TD($\\lambda$) be used with deep reinforcement learning? TD lambda is a way to interpolate between TD(0) - bootstrapping over a single step, and, TD(max), bootstrapping over the entire episode length, or, Monte Carlo.\nReading the link above, I see that an eligibility trace is kept for each state in order to calculate its \"contribution to the future\".\nBut, if we use an approximator, and not a table for state-values, then can we still use eligibility traces? If so, how would the loss (and thus the gradients) be calculated? Specifically, I would like to use actor-critic (or advantage actor-critic).\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Eligibility traces is a method of weighting between temporal-difference \"targets\" and Monte-Carlo \"returns\". In practice, for example, instead of using the one-step TD target, $r_t + \\gamma V (s_{t+1})$, as in the temporal difference update $V (s_t) \\leftarrow V (s_t) + \\alpha (r_t + \\gamma V (s_{t+1}) \u2212 V (s_t))$, you use the so-called \"lambda\" ($\\lambda$) target, which is a target that balances between the TD target and the Monte Carlo return. So, in practice and intuitively, eligibility traces is just a way of using a more \"appropriate\" target while learning. In general, you need to perform these updates (e.g., the TD update above) \"online\", i.e. while you explore or exploit the environment.\nIn theory, you could use a deep neural network to represent your value function (or your policy), while using eligibility traces. It would be similar to not using them: you would just use a different target.\nHowever, deep RL (that is, RL which uses deep neural networks to represent e.g. value functions) training needs to be performed using i.i.d. data, in order to prevent overfitting, which often means that they can't be trained online or need to use \"tricks\" like the \"experience replay\" (used in the paper Human-level control through deep reinforcement learning). Note that, in RL, successive states are often very correlated (e.g. two successive frames of a video would be very correlated).\nIn theory and similarly, you would still be able to use eligibility traces with the actor-critic method, but not with the asynchronous advantage actor-critic method. See the section 2.3 of the paper \"Efficient Eligibility Traces for Deep Reinforcement Learning\" (2018) by Brett Daley and Christopher Amato, for more info.\nIn this same paper, an approach is introduced to efficiently combine eligibility traces with deep neural networks. The authors propose DQN($\\lambda$), which is the DQN architecture combined with eligibility traces, where the $\\lambda$ return is computed in an \"efficient\" (and recursive) way, instead of the \"usual\" way. Since they use a DQN, they also use an \"experience replay\" buffer (or memory), where they also store the efficiently computed $\\lambda$ target (in addition to the usual rewards). Furthermore, they also eliminate the need for the \"target\" network used in the standard DQN. You can have a look at algorithm 1 of the same paper to see how they improve the parameters of the network, which represents the Q function, in the case of the DQN($\\lambda$) model. See the section 3.1 of the same paper for more details regarding this model.\nThey also introduce A3C($\\lambda$), which combines asynchronous advantage actor-critic (A3C) with eligibility traces. See the section 3.2 for more details.\nNote that there have been other proposals for combining eligibility traces with deep learning. You can have a look at the literature.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do I design a neural network that breaks a 5-letter word into its corresponding syllables? I am going to design a neural network which will be able to break a 5-letter word into its corresponding syllables (hybrid syllables, I mean it will not strictly adhere to grammatical syllable rules but will be based on some training sets I provide).\nExample: \"train\" -> \"tra\"-\"in\".\nI think of implementing it in terms of some feedforward neural network with 1 input layer, 1 hidden layer and 1 output layer.\nThere will be 5 input nodes in the form of decimals (1/26 = 0.038 for 'A' ; 2/26 = 0.076 for 'B', etc.)\nThe output layer consists of 4 nodes, which corresponds to each gap between two characters in the word.\nAnd fires as follows:\n\nFor \"train\" (\"tra\"-\"in\"), the input is (0.769, 0.692, 0.038, 0.346, 0.538) and the output would be (0, 0, 1, 0).\n\nFor \"boric\" (\"bo\"-\"ri\"-\"c\"), the input is something else, and the output is (0, 1, 0, 1).\n\n\nIs it possible to implement the neural network in the way I am doing? If possible, then how will I decide the number of hidden layers and nodes in each layer?\nIn the book I am reading, the XOR gate problem and its implementation using hidden layer is given. In XOR, we could decide the number of nodes and hidden layers required by seeing the linear separability of XOR using two lines. But here I think such analysis can't be made..\nSo, how do I proceed? Or is it a trial and error process?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I would highly recommend modeling things differently with regard to how letters are presented to the model. While the problem is more natural, perhaps, for a Convolutional or Recurrent Neural Network, there's no problem to try and run this on a feed forward network. However, the way you give letters as input will be very confusing for a network and will make learning very hard. I'd recommend using one hot encoding or even a binary encoding for the letters. If this is for more than playing around I'd try and add some info (encode whether the letter is in \"aeiou\" in a separate bit).\nAs for the hidden layers, try playing around a bit. Two systematic approaches are to start very simple and make the model more complicated, or start complicated and make your model simpler (or just normalize a lot). Look at the performance on the training set and on a separate validation set during training. If the model keeps on improving on the training data but starts to deteriorate on the validation data, you're probably over fitting. In this case you should either make the model simpler (fewer nodes, fewer layers) or regularize (start with l2 normalization on the weights). If the data doesn't perform well on the training data, you may wish to make the model more complex.\nOnce you've tried the feedforward network, really do try CNN or RNNs for this task.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between a language model and a word embedding? I am self-studying applications of deep learning on the NLP and machine translation.\nI am confused about the concepts of \"Language Model\", \"Word Embedding\", \"BLEU Score\".\nIt appears to me that a language model is a way to predict the next word given its previous word. Word2vec is the similarity between two tokens. BLEU score is a way to measure the effectiveness of the language model.\nIs my understanding correct? If not, can someone please point me to the right articles, paper, or any other online resources?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Simplified: Word Embeddings does not consider context, Language Models does.\nFor e.g Word2Vec, GloVe, or fastText, there exists one fixed vector per word.\nThink of the following two sentences:\n\nThe fish ate the cat.\n\nand\n\nThe cat ate the fish.\n\nIf you averaged their word embeddings, they would have the same vector, but, in reality, their meaning (semantic) is very different.\nThen the concept of contextualized word embeddings arose with language models that do consider the context, and give different embeddings depending on the context.\nBoth word embeddings (e.g Word2Vec) and language models (e.g BERT) are ways of representing text, where language models capture more information and are considered state-of-the-art for representing natural language in a vectorized format.\nBLEU score is an algorithm for evaluating the quality of text which has been machine-translated from one natural language to another. Which is not directly related to the difference between traditional word embeddings and contextualized word embeddings (aka language models).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which paper introduced the term \"softmax\"? Nowadays, the softmax function is widely used in deep learning and, specifically, classification with neural networks. However, the origins of this term and function are almost never mentioned anywhere. So, which paper introduced this term?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The paper that appears to have introduced the term \"softmax\" is Training Stochastic Model Recognition Algorithms as Networks can Lead to Maximum Mutual Information Estimation of Parameters (1989, NIPS) by John S. Bridle.\nAs a side note, the softmax function (with base $b = e^{-\\beta}$)\n$$\\sigma (\\mathbf {z} )_{i}={\\frac {e^{-\\beta z_{i}}}{\\sum _{j=1}^{K}e^{-\\beta z_{j}}}}{\\text{ for }}i=1,\\dotsc ,K {\\text{ and }}\\mathbf {z} =(z_{1},\\dotsc ,z_{K})\\in \\mathbb {R} ^{K}$$\nis very similar to the Boltzmann (or Gibbs) distribution\n$$\np_i=\\frac{e^{- {\\varepsilon}_i / k T}}{\\sum_{j=1}^{M}{e^{- {\\varepsilon}_j / k T}}}\n$$\nwhich was formulated by Ludwig Boltzmann in 1868, so the idea and formulation of the softmax function is quite old.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When should we use algorithms like Adam as opposed to SGD? As far as I know, Stochastic Gradient Descent is an optimization algorithm which belongs to the the category of algorithms where hyper-parameters have to be defined beforehand. They are useful in many cases, but there are some cases that the adaptive learning algorithms (like AdaGrad or Adam) might be preferable. \nWhen are algorithms like Adam and AdaGrad preferred over SGD? What are the cons and pros of adaptive algorithms, like Adam, when we compare them with learning algorithms like SGD?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Empirically, I observed that algorithms like Adam and RMSProp tended to give me a final higher performance (in my case, the accuracy) on (the validation dataset) with respect to SGD. However, I also observed that Adam and RMSProp are highly sensitive to certain values of the learning rate (and, sometimes, other hyper-parameters like the batch size) and they can catastrophically fail to converge if e.g. the learning rate is too high. On the other hand, in general, SGD have not led me to the highest performance, but they did not catastrophically fail (at least, as much as Adam and RMSProp) in my experiments (even when using quite different hyper-parameters). I noticed that the learning rate (and the batch size) are the hyper-parameters that mainly affect the performance of all these algorithms.\nIn my experiments, I use SGD without momentum and I used the (PyTorch) default values of Adam and RMSProp. I only compared SGD with Adam and RMSProp, on the relatively simple task of recognising MNIST digits. You can have a look at this repository https://github.com/nbro/comparative-study-between-optimizers, which contains the code I used to perform these experiments. You also have the instructions there to perform the experiments (if you want).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why don't we use auto-encoders instead of GANs? I have watched Stanford's lectures about artificial intelligence, I currently have one question: why don't we use autoencoders instead of GANs?\nBasically, what GAN does is it receives a random vector and generates a new sample from it. So, if we train autoencoders, for example, on cats vs dogs dataset, and then cut off the decoder part and then input random noise vector, wouldn't it do the same job?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Auto-encoders are widely used and maybe even more used than GANs (in fact, auto-encoders are older than GANs, although the main general idea behind GANs is quite old). For example, auto-encoders are used in World Models, for drug design (e.g. see this paper) and many other tasks that involve data compression or generation.\n\nSo, if we train autoencoders, for example, on cats vs dogs dataset, and then cut off the decoder part and then input random noise vector, wouldn't it do the same job?\n\nYes, the encoder part of the auto-encoder produces a vector that represents the input in a compressed form. You may also be interested in denoising auto-encoders, but there are other variations, such as convolutional auto-encoders or variational auto-encoders.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is exploitation necessary during training? I have read many blog articles making all kinds of broad analogies to explain the exploration/exploitation trade-off. However, I still can't fully grasp it. On an extremely abstract level, I understand why you would want to \"try new things to gain information\", but then I don't understand why you would want to \"exploit\" in training. It seems as though it would be better to keep trying as many things as possible to gain the most information.\nWhat is the value of exploitation during training? Intuitively, I would think you would only want to explore during \"training\" and only exploit in \"testing\".\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "An algorithm that chooses to always explore during training is unlikely to find an optimal policy because it will be employing a more random search as opposed to a directed search. During training, the neural network aims to determine the relation between states or state-action pairs and the reward signal through past experience. If the agent is always exploring during training, it will never use the experience gained from past episodes to influence its training policy and therefore will search more randomly.\nExploitation during training allows the neural net to use its past experience to guide its future actions and avoid random search. There can be many states in which there is an obvious optimal action. After some training, the neural network may be able to quickly learn these states and corresponding optimal actions. By primarily exploiting at those states, the agent will not be wasting training time by exploring suboptimal actions at those states, allowing the agent to focus its exploration on other more uncertain, unexplored, or complex parts of the state space.\nFor a practical example, consider the original Super Mario Bros game on NES. Let the reward be the number of pixels traveled to the right before Mario loses a life. If Mario is exploring the whole time, it is unlikely that he makes it very far to the right or over many obstacles, let alone to the flagpole. Since it is more rewarding in general to go to the right, Mario's exploitation action at most states is to run to the right. In this manner, Mario will usually run to the right until he reaches an obstacle (e.g. a pipe, pit, staircase, enemy). At that point, Mario may need to explore to overcome the obstacle, but Mario needed to exploit to be able to reach that obstacle in the first place.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there any artificially intelligent system that really mimics human intelligence? After having read something that Elon Musk said about artificial intelligence and how it could affect our lives, I've been reading about artificial intelligence, deep learning, etc. The recurrent topic is neural networks, which are used for \"recognition tasks\".\nAlthough this is not my main question, can we say the following about neural networks?\n\nNeural networks use the sigmoid function and gradient descent to fine-tune weights.\n\nIn any case, neural networks do not seem to really mimic any of the properties that we associate with intelligent beings, like humans, such as thinking outside the box, being able to observe, reflect and come up with innovations.\nSo, is there any artificially intelligent system that really mimics human intelligence?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As far as emulating an intelligent being, no. There are a few different potential architectures for possible AGI. Many of these are extremely infantile, as the bulk of AI research is in narrow AI, which focuses on creating algorithms that are highly specialized for a specific task.\nWith that being said, here is one supervised learning approach to this problem by Andrej Karpathy: Karpathy Method\nOpenAI, also has a team who works on the AGI problem.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the relationship between robustness and adversarial machine learning? I have been reading a lot of articles on adversarial machine learning and there are mentions of \"best practices for robust machine learning\". \nA specific example of this would be when there are references to \"loss of efficient robust estimation in high dimensions of data\" in articles related to adversarial machine learning. Also, IBM has a Github repository named \"IBM's Adversarial Robustness Toolbox\". \nAdditionally, there is a field of statistics called 'robust statistics' but there is no clear explanation anywhere about its relation to adversarial machine learning. \nI would therefore be grateful if someone could explain what robustness is in the context of Adversarial Machine Learning.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A robust ML model is one that captures patterns that generalize well in the face of the kinds of small changes that humans expect to see in the real world. \nA robust model is one that generalizes well from a training set to a test or validation set, but the term also gets used to refer to models that generalize well to, e.g. changes in the lighting of a photograph, the rotation of objects, or the introduction of small amounts of random noise.\nAdversarial machine learning is the process of finding examples that break an otherwise reasonable looking model. A simple example of this is that if I give you a dataset of cat and dog photos, in which cats are always wearing bright red bow ties, your model may learn to associate bow ties with cats. If I then give it a picture of a dog with a bow tie, your model may label it as a cat. Adversarial machine learning also often includes the ability to identify specific pieces of noise that can be added to inputs to confound a model. \nTherefore, if a model is robust, it basically means that it is difficult to find adversarial examples for the model. Usually this is because the model has learned some desirable correlations (e.g. cats have a different muzzle shape than dogs), rather than undesirable ones (cats have bow ties; pictures containing cats are 0.025% more blue than those containing dogs; dog pictures have humans in them more often; etc.).\nApproaches like GANs try to directly exploit this idea, by training the model on both true data and data designed by an adversary to resemble the true data. In this sense, GANs are an attempt to create a robust discriminator. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Feasibility of generating large images with a convnet I've spent the past couple of months learning about neural networks, and am thinking of projects that would be fun to work on to cement my understanding of this tech.\nOne thing that came to mind last night is a system that takes an image of a movie poster and predicts the genre of the movie. I think I have a good understanding of what'd be required to do this (put together a dataset, augment it, download a convnet trained on imagenet, finetune it on my dataset, and go from there).\nI also thought that it would be pretty cool to run the system backwards at the end, so that I could put in e.g. a genre like 'horror' and have the system generate a horror movie poster. I expect that it will be very bad at this because I'm not a team of expert researchers, but I think I could have some fun hacking on it even if it only ever generated incomprehensible results.\nHere's what I'm having trouble understanding: on the one hand, all the convnets whose architecture I've seen described seem to rely on being given very small, square input images (on the order of 220px by 220px iirc), and movie posters are rectangular, and a generated poster would have to be of a larger size in order for a human to make any sense of it. I've seen several examples of papers where researchers use convnets to generate images, e.g. the adversarial system that generates pictures of birds and flowers, and a system that generates the next few frames of video when given a feed of a camera sweeping across the interior of a room, but all of those generated images seemed to be of the small square size I've been describing.\nOn the other hand, I've seen lots of \"deep dream\" images over the past year or so that have been generated by convnets and are of a much larger size than ~220px by ~220px.\nHere's my question: is it possible for me to build the system I describe, which takes a movie genre and outputs a movie poster of a size like e.g. 400px by 600px? [I'm not asking about whether or not the resulting poster would be any good - I'm curious about whether or not it's possible to use a convnet to generate an image of that size.]\nIf it is possible, how is it possible, given that these systems seem to expect small, square input images?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The way you would recognize images (image -> genre) would be very different from the other way around (genre -> image). For the former you are correct on what would be involved.\nFor the latter, if you want large images then GANs are indeed the way to go. Currently the largest images we can generate are on the order of 220 x 220 pixels, mostly due to memory constraints on the GPU. There is no fundamental problem with having rectangular images, it just so happens that we use squares. You would be able to use identical architectures to train on rectangular data as well.\nThe reason that some generated images you see (e.g. from DeepDream or NeuralStyle) are larger is that it's not a GAN. Both of these are not generative models in a standard sense, even if they do technically \"generate\" images. Instead, they merely modify an existing image by running backprop on a specifically designed loss function.\nTLDR: your movie genre recognition idea is sound. For generation, have a look at things like this (https://github.com/Newmu/dcgan_code), where Alec generated album covers instead of posters. If you have enough data it will do something half sensible.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why not more TD(\ud835\udf06) in actor-critic algorithms? Is there either an empirical or theoretical reason that actor-critic algorithms with eligibility traces have not been more fully explored? I was hoping to find a paper or implementation or both for continuous tasks (not episodic) in continuous state-action spaces.\nThis has been the only related question on SE-AI that I have been able to find Why are lambda returns so rarely used in policy gradients?.\nAlthough I appreciated the dialog and found it useful, I was wondering if there was any further detail or reasoning that might help explain the void.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Theoretically, nothing precludes the use of $\\lambda$-returns in actor-critic methods. The $\\lambda$-return is an unbiased estimator of the Monte Carlo (MC) return, which means they are essentially interchangeable. In fact, as discussed in High-Dimensional Continuous Control Using Generalized Advantage Estimation, using the $\\lambda$-return instead of the MC return can actually help reduce the variance of gradient updates.\nThe above is similar to my answer in the other question you linked, so let me try to answer your question more specifically. Even though we can use $\\lambda$-returns, why are they not too common in practice? I suspect there might be a few reasons:\n\nEmpirically, faster credit assignment might be more desirable than lower variance. Sometimes the learning speed of your algorithm is constrained simply by how quickly you can learn about the consequences of certain actions. In this case, it is faster to use the MC return, even if it theoretically has higher variance than the $\\lambda$-return.\nWhen proposing a new algorithm, adding $\\lambda$-returns to it might give it an \"unfair\" advantage if the other baseline methods do not use them (the reviewers would not like this), so researchers tend to favor simpler 1-step or MC returns for the sake of consistency. I would guess this is why you don't typically see $\\lambda$-returns in papers that propose new actor-critic methods. In some sense, it is generally assumed that you could always add $\\lambda$-returns to them later and probably get better performance.$^*$\nA decent number of deep RL researchers don't know what $\\lambda$-returns are. This is especially true if they come from a pure deep learning background; they may have never read Reinforcement Learning: An Introduction which is where most people are introduced to TD($\\lambda$) and $\\lambda$-returns.\n\n$^*$Exceptions to this are papers like mine (Reconciling $\\lambda$-Returns with Experience Replay) where the contribution is the use of $\\lambda$-returns in methods that previously could not use them. But actor-critic methods are pretty straightforward to combine with $\\lambda$-returns.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the denominator ignored in the Bayes' rule? The na\u00efve Bayes' generative algorithm is often represented by the following formula:\n$$\\text{argmax}_{y} p(y|x) = \\text{argmax}_y \\frac{p(x|y)p(y)}{p(x)} \\approx \\text{argmax}_y p(x|y)p(y)$$\nWhy do we have $p(x)=1$ which allows the approximation $\\text{argmax}_y \\frac{p(x|y)p(y)}{p(x)} \\approx \\text{argmax}_y p(x|y)p(y)$?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The answer from @kiner_shah in the comments has solved it:\n\nThey have eliminated it because in comparing probability for best outcome, it would just introduce additional division and the divisor p(x) is same for all candidates. For example, if I tell you to compare the largest of the following numbers: 3/2, 5/2, 1/2, you will without thinking pick 5/2 since the divisors are same and 5 is greatest of all.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between artificial intelligence and swarm intelligence? Artificial intelligence (AI) refers to the simulation of human intelligence in machines that are programmed to think like humans and mimic their actions. The term may also be applied to any machine that exhibits traits associated with a human mind such as learning and problem-solving.\nAccording to the Wikipedia article on swarm intelligence\n\nSwarm intelligence (SI) is the collective behavior of decentralized, self-organized systems, natural or artificial. The concept is employed in work on artificial intelligence.\nThe application of swarm principles to robots is called swarm robotics, while 'swarm intelligence' refers to the more general set of algorithms.\nSI systems consist typically of a population of simple agents or boids interacting locally with one another and with their environment. The inspiration often comes from nature, especially biological systems.\n\nThese two terms seem to be related, especially in their application in computer science and software engineering. Is one a subset of another? Is one tool (SI) is used to build a system for the other(AI)? What are their differences and why are they significant?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Swarm intelligence (SI) is a sub-field of or an approach to artificial intelligence (AI), where you have multiple individuals (for example, artificial ants), which collectively can produce what we (or most of us) would intuitively call intelligent behaviour.\nSI is sometimes categorized as a sub-field of evolutionary computation (which also includes evolutionary algorithms, such as genetic algorithms, genetic programming, evolution strategies, and so on), which is often considered a sub-field of AI or techniques to produce artificial intelligence, because all these techniques are often based on the use of multiple individuals/solutions (that either compete or collaborate with each other).\nOne of the most commonly used SI techniques is ant colony optimization algorithms (by M. Dorigo et al.), which have been successfully applied to solve the travelling salesman problem. There are other SI techniques, which are somehow similar to ACO algorithms, such as particle swarm optimization.\nOccasionally, SI may also be categorised as a sub-field of computational intelligence, which often refers to specific techniques to create artificially intelligent systems (i.e. programs that exhibit what we would call intelligence) that are more based on or inspired by the biology, such as neural networks, genetic algorithms, or, in fact, SI algorithms, such as ACO algorithms. However, CI can also be considered a sub-field of AI, given that it studies techniques to produce artificial intelligence, so, in the end, as I said above, SI is an approach to AI, which includes other approaches, such as evolutionary algorithms, rule-based systems, deep learning or other machine learning techniques.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it better to make neural network to have hierchical output? i'm quite new to neural network and i recently built neural network for number classification in vehicle license plate. It has 3 layers: 1 input layer for 16*24(382 neurons) number image with 150 dpi , 1 hidden layer(199 neurons) with sigmoid activation function, 1 softmax output layer(10 neurons) for each number 0 to 9. \nI'm trying to expand my neural network to also classify letters in license plate. But i'm worried if i just simply add more classes into output, for example add 10 letters into classification so total 20 classes, it would be hard for neural network to separate feature from each class. And also, i think it might cause problem when input is one of number and neural network wrongly classifies as one of letter with biggest probability, even though sum of probabilities of all number output exceeds that.\nSo i wonder if it is possible to build hierchical neural network in following manner:\nThere are 3 neural networks: 'Item', 'Number', 'Letter'\n\n'Item' neural network classifies whether input is numbers or letters.\nIf 'Item' neural network classifies input as numbers(letters), then input goes through 'Number'('Letter') neural network.\nReturn final output from Number(Letter) neural network.\n\nAnd learning mechanism for each network is below:\n\n'Item' neural network learns all images of numbers and letters. So there are 2 output.\n'Number'('Letter') neural network learns images of only numbers(letter).\n\nWhich method should i pick to have better classification? Just simply add 10 more classes or build hierchical neural networks with method above?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Item network should be recogniting regional register number standards and typical places of numbers on those standards. Otherwise your 'Item' phase has equal task than the whole system, because 'Letter' and 'Number' do not differ in plates so much you could right away choose between the two without first evaluating the exact object on each case.\nSide note: correct me if that is not true on your local plate system\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is a Sobel filter for edge detection a type of Cellular Neural Network? I have implemented a Sobel filter for edge detection in Matlab without using its toolbox. I am a bit confused: \nIs a Sobel filter a type of Cellular Neural Network?\nBoth Sobel and Cellular Neural Network calculate output via its neighborhood cells.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You're right about the basic arrangement of the inputs, but there are a number of differences:\n\nArtificial neural networks typically use exemplar data as inputs for the purpose of training, or adjusting the weights of its internal connections, to accurately classify them within a certain error range. The network is then applied to unknown data to classify them. Edge detection filters are just blind operators that transform input data regardless of how it can be classified. There is no training, so any intelligence exists only in the mind of the filter developer.\nA CNN could be trained to be an effective Sobel (edge detection) filter, as described in this paper, but a Sobel filter couldn't be an effective learning algorithm.\nTraining neural networks is more non-deterministic, with outputs depending on what data they are trained with and potentially even the operational computations that are used for classification. Applying filters is typically deterministic, i.e. they will transform the same data exactly the same way if applied twice.\n\nOne succinct way of expressing the biggest difference is: a cellular neural network is looking for a function, while a Sobel filter is a function.\nNote that there are types of neural networks called Convolutional Neural Networks, which can use Sobel and other filters in their input layers, as described here. Though, these are neither of the things you are asking about. :)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why are GRU and LSTM better than standard RNNs? It seems that older RNNs have a limitation for their use cases and have been outperformed by other recurrent architectures, such as the LSTM and GRU.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "These newer RNNs (LSTMs and GRUs) have greater memory control, allowing previous values to persist or to be reset as necessary for many sequences of steps, avoiding \"gradient decay\" or eventual degradation of the values passed from step to step. LSTM and GRU networks make this memory control possible with memory blocks and structures called \"gates\" that pass or reset values as appropriate.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does ChatGPT type slowly on purpose or is it computing? When you give ChatGPT a prompt, does it\nA) generate the entire response instantly (at least on the server), but then \"buffers\" it slowly to the end user (for whatever reason)\nor\nB) it's actually generating words (and sometimes entire sentences at once) one by one, and using (server) computational power all that while?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The model infers in an autoregressive way. That is, it needs the previous output to produce the next one, so it's slow because it computes. More details.\nIt also depends on the language. The model was trained primarily on the English corpus and typically generates one or two tokens for each word. But for other languages, it might not be as efficient and can generate a token for each symbol\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the state space and the state transition function in AI? I'm studying for my AI final exam, and I'm stuck in the state space representation. I understand initial and goal states, but what I don't understand is the state space and state transition function. Can someone explain what are they with examples?\nFor example, one of the questions was this on my previous exam:\n\nGiven $k$ knights on an infinite (in all directions) chessboard and k selected squares of the board. Our task to move the knights to these selected squares obeying the following simple rules:\n\nAll knights move parallel, following their movement rule (L-shape jump)\nNo knights can move to a square on which a knight stood anytime before\n\nGive the state space of the problem, the starting and goal states, and the state transition function!\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Initial state\nHow things are at first.\nIn your particular example, it would be where your k knights are placed on the board initially. Your problem doesn't precisely state this, so you could either place them at the bottom or at random.\nGoal state\nThe board with the k knights placed on the target squares.\nState transition function\nA function that takes actions (bound presumably by rules) and returns a new state.\nIn the k knight problem, the legal actions are moving parallel and in L shape movements, after which the knight will be in a new position and the board in a new state.\nState space\nThe set of all states reachable from the initial state by any sequence of actions.\nSo, in the case of the k knight problem, your state space would start at the top with your initial state followed down by each individual movement of the k knights and the resulting new state. A graph where lines are actions and nodes are new states or a table are common representations of state space.\n\nReference\nArtificial Intelligence: A Modern Approach, by S. Russell and P. Norvig.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does A* search work given there are multiple goal states? When I have read through the fundamentals of AI, I saw a situation (i.e., a search space) which is illustrated in the following picture.\n\nThese are the heuristic estimates:\nh(B)=9\nh(D)=10\nh(A)=2\nh(C)=1\n\nIf we use the A* algorithm, the node $B$ will be expanded first because $f(B)=1+9=10$, while node $A$ having $f(A)=9+2=11$ and $f(B) B -> D -> G2. Will the search go on to also find the goal state G1?\nKindly let me know the order of the search if I am wrong.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Question 1: First of all, you state that that the goal G2 will be found first by relying on the expansion order R, B, D, G2.\nThis is wrong. It is extremely easy to see that this is wrong, because A* is a search algorithm that guarantees to find an optimal solution given that only admissible heuristics are used. (A heuristic is being admissible if it never over-estimates the optimal goal distance. This is the case in your example.) Since the true cost for reaching G1 is 11 and the true cost for reaching G2 is 13, clearly G1 must be found first.\nThus, your expansion order is wrong as well. Let us first give the f-values for all nodes:\nf(A)=11, f(B)=10, f(C)=11, f(D)=13\nAssuming that h(G1)=h(G2)=0 (i.e, the heuristic is \"goal-aware\"), we get f(G1)=11 and f(G2)=13.\nBecause A* expands search nodes by lowest f-values of the search nodes in the open list (the search nodes not yet expanded), we get the following expansion order:\nR, B, A, C, G1\nYou very-likely did a mistake that is done extremely often: after heaving expanded D, you add G2 to the open list. Because G1 is a goal node and you are already \"seeing\" it, you return it as a solution. But this is wrong! Goal nodes are not returned when being created, but when being selected for expansion! So, although the expansion of D generates G2, you are not allowed to return G2 as solution, because it has not been selected for expansion.\nQuestion 2:\nCan G2 be found as well?\nAs NietzscheanAI pointed out, you can simple continue search. That is, after heaving expanded R, B, A, C, G1, A* will expand D, G2.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Would convolutional NN recognize patterns in encoded images? I have a set of images that I already trained a CNN to classify successfully. I wonder if it would be possible to encode the images (using XOR in combination with a key of the same length as the image) and train a new net on them. \nThinking logically, the features still exist in the same relation to each other, just in a different form (encoded). Considering that neural networks are incredible at pattern recognition, I assume that it would still be doable.\nFor people, who cannot imagine how a xor-encoded image would look like:\n\nFor a human, it may look like rubbish, but the information is definitely there.\nWould love to read your opinion.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First you should give it a try, because anyone's guess could be off, as there isn't really a complete high level analytic model of how neural networks behave on real data. Most results with neural networks are informed by theory, but involve a whole lot of experimental testing.\nI suspect your network might at least learn something from the new images, but would struggle to get anything like the same accuracy as without the noise, because the CNN filters rely on being able to detect similar features at different positions. In your scrambled image, there will not be any meaningful and consistent edges/corners etc that a single learned feature detector could learn to match (and therefore present to the next layer).\nA fully-connected network would not have this limitation, and would learn just as well on a set of binary features that have been xor'd identically in each position for each example, as it did on the original copy (i.e. only if the picture was 1 bit depth). It would learn less well if each feature was a scaled 8-bit pixel value that was xor'd with the same 8 bit random number in each pixel position, because that would introduce many more non-linear mappings between input and output. Of course a fully-connected network will generally not learn image tasks as well as CNNs in the first place . . . but if it could learn anything useful at all for your image problem, then it will probably out-perform CNNs after the scrambling effect.\nAs a CNN usually has a few fully-connected layers, then it may be possible to get something from your scrambled images.\n\nThinking logically, the features still exist in the same relation to each other, just in a different form (encoded)\n\nIn terms of being recognisable in the way that a CNN filter extracts them, then the features do not exist. That is a problem.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the loss for policy gradients with continuous actions? I know with policy gradients used in an environment with a discrete action space are updated with $$\n\\Delta \\theta_{t}=\\alpha \\nabla_{\\theta} \\log \\pi_{\\theta}\\left(a_{t} \\mid s_{t}\\right) v_{t}\n$$\nwhere $v_t$ could be many things that represent how good the action was. And I know that this can be calculated by performing cross entropy loss with the target being what the network would have outputted if it were completely confident in its action (zeros with the index of the action chosen being one). But I don\u2019t understand how to apply that to policy gradients that output the mean and variance of a Gaussian distribution for a continuous action space. What is the loss for these types of policy gradients?\nI tried keeping the variance constant and updating the output with mean squared error loss and the target being the action it took. I thought this would end up pushing the mean towards actions with greater total rewards but it got nowhere in OpenAI\u2019s Pendulum environment.\nIt would also be very helpful if it was described in a way with a loss function and a target, like how policy gradients with discrete action spaces can be updated with cross entropy loss. That is how I understand it best but it is okay if that is not possible.\nEdit: for @Philipp. The way I understand it is that the loss function is the same with a continuous action space and the only thing that changes is the distribution that we get the log-probs from. In PyTorch we can use a Normal distribution for continuous action space and Categorical for discrete action space. The answer from David Ireland goes into the math but in PyTorch, that looks like log_prob = distribution.log_prob(action_taken) for any type of distribution. It makes sense that for bad actions we would want to decrease the probability of taking the action. Below is working code for both types of action spaces to compare them. The continuous action space code should be correct but the agent will not learn because it is harder to learn the right actions with a continuous action space and our simple method isn't enough. Look into more advanced methods like PPO and DDPG.\nimport torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torch.distributions.categorical import Categorical #discrete distribution\nimport numpy as np\nimport gym\nimport math\nimport matplotlib.pyplot as plt\n\nclass Agent(nn.Module):\n def __init__(self,lr):\n super(Agent,self).__init__()\n self.fc1 = nn.Linear(4,64)\n self.fc2 = nn.Linear(64,32)\n self.fc3 = nn.Linear(32,2) #neural network with layers 4,64,32,2\n\n self.optimizer = optim.Adam(self.parameters(),lr=lr)\n\n def forward(self,x):\n x = torch.relu(self.fc1(x)) #relu and tanh for output\n x = torch.relu(self.fc2(x))\n x = torch.sigmoid(self.fc3(x))\n return x\n\nenv = gym.make('CartPole-v0')\nagent = Agent(0.001) #hyperparameters\nDISCOUNT = 0.99\ntotal = []\n\nfor e in range(500): \n log_probs, rewards = [], []\n done = False\n state = env.reset()\n while not done:\n #mu = agent.forward(torch.from_numpy(state).float())\n #distribution = Normal(mu, SIGMA)\n distribution = Categorical(agent.forward(torch.from_numpy(state).float()))\n action = distribution.sample()\n log_probs.append(distribution.log_prob(action))\n state, reward, done, info = env.step(action.item())\n rewards.append(reward)\n \n total.append(sum(rewards))\n\n cumulative = 0\n d_rewards = np.zeros(len(rewards))\n for t in reversed(range(len(rewards))): #get discounted rewards\n cumulative = cumulative * DISCOUNT + rewards[t]\n d_rewards[t] = cumulative\n d_rewards -= np.mean(d_rewards) #normalize\n d_rewards /= np.std(d_rewards)\n\n loss = 0\n for t in range(len(rewards)):\n loss += -log_probs[t] * d_rewards[t] #loss is - log prob * total reward\n\n agent.optimizer.zero_grad()\n loss.backward() #update\n agent.optimizer.step()\n\n if e%10==0:\n print(e,sum(rewards)) \n plt.plot(total,color='blue') #plot\n plt.pause(0.0001) \n\n\ndef run(i): #to visualize performance\n for _ in range(i):\n done = False\n state = env.reset()\n while not done:\n env.render()\n distribution = Categorical(agent.forward(torch.from_numpy(state).float()))\n action = distribution.sample()\n state,reward,done,info = env.step(action.item())\n env.close()\n\nAbove is the discrete action space code for CartPole and below is the continuous action space code for Pendulum. Sigma (variance or standard deviation) is constant here but adding it is easy. Just make the final layer have two neurons and make sure sigma is not negative. Again, the pendulum code won't work because most environments with continuous action spaces are too complicated for such a simple method. Making it work would probably require a lot of testing for hyper parameters.\nimport torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torch.distributions.normal import Normal #continuous distribution\nimport numpy as np\nimport gym\nimport math\nimport matplotlib.pyplot as plt\nimport keyboard\n\nclass Agent(nn.Module):\n def __init__(self,lr):\n super(Agent,self).__init__()\n self.fc1 = nn.Linear(3,64)\n self.fc2 = nn.Linear(64,32)\n self.fc3 = nn.Linear(32,1) #neural network with layers 3,64,32,1\n\n self.optimizer = optim.Adam(self.parameters(),lr=lr)\n\n def forward(self,x):\n x = torch.relu(self.fc1(x)) #relu and tanh for output\n x = torch.relu(self.fc2(x))\n x = torch.tanh(self.fc3(x)) * 2\n return x\n\nenv = gym.make('Pendulum-v0')\nagent = Agent(0.01) #hyperparameters\nSIGMA = 0.2\nDISCOUNT = 0.99\ntotal = []\n\nfor e in range(1000): \n log_probs, rewards = [], []\n done = False\n state = env.reset()\n while not done:\n mu = agent.forward(torch.from_numpy(state).float())\n distribution = Normal(mu, SIGMA)\n action = distribution.sample().clamp(-2.0,2.0)\n log_probs.append(distribution.log_prob(action))\n state, reward, done, info = env.step([action.item()])\n #reward = abs(state[1])\n rewards.append(reward)\n \n total.append(sum(rewards))\n\n cumulative = 0\n d_rewards = np.zeros(len(rewards))\n for t in reversed(range(len(rewards))): #get discounted rewards\n cumulative = cumulative * DISCOUNT + rewards[t]\n d_rewards[t] = cumulative\n d_rewards -= np.mean(d_rewards) #normalize\n d_rewards /= np.std(d_rewards)\n\n loss = 0\n for t in range(len(rewards)):\n loss += -log_probs[t] * d_rewards[t] #loss is - log prob * total reward\n\n agent.optimizer.zero_grad()\n loss.backward() #update\n agent.optimizer.step()\n\n if e%10==0:\n print(e,sum(rewards)) \n plt.plot(total,color='blue') #plot\n plt.pause(0.0001)\n if keyboard.is_pressed(\"space\"): #holding space exits training\n raise Exception(\"Exited\")\n\n\ndef run(i): #to visualize performance\n for _ in range(i):\n done = False\n state = env.reset()\n while not done:\n env.render()\n distribution = Normal(agent.forward(torch.from_numpy(state).float()), SIGMA)\n action = distribution.sample()\n state,reward,done,info = env.step([action.item()])\n env.close()\n\nDavid Ireland also wrote this on a different question I had:\n\nThe algorithm doesn't change in this situation. Say your NN outputs the mean parameter of the Gaussian, then log\u03c0(at|st) is just the log of the normal density evaluated at the action you took where the mean parameter in the density is the output of your NN. You are then able to backpropagate through this to update the weights of your network.\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This update rule can still be applied in the continuous domain.\nAs pointed out in the comments, suppose we are parameterising our policy using a Gaussian distribution, where our neural networks take as input the state we are in and output the parameters of a Gaussian distribution, the mean and the standard deviation which we will denote as $\\mu(s, \\theta)$ and $\\sigma(s, \\theta)$ where $s$ shows the dependancy of the state and $\\theta$ are the parameters of our network.\nI will assume a one-dimensional case for ease of notation but this can be extended to multi-variate cases. Our policy is now defined as\n$$\\pi(a_t | s_t) = \\frac{1}{\\sqrt{2\\pi \\sigma(s_t, \\theta)^2}} \\exp\\left(-\\frac{1}{2}\\left(\\frac{a_t - \\mu(s_t, \\theta)}{\\sigma(s_t, \\theta)}\\right)^2\\right).$$\nAs you can see, we can easily take the logarithm of this and find the derivative with respect to $\\theta$, and so nothing changes and the loss you use is the same. You simply evaluate the derivative of the log of your policy with respect to the network parameters, multiply by $v_t$ and $\\alpha$ and take a gradient step in this direction.\nTo implement this (as I'm assuming you don't want to calculate the NN derivatives by hand) then you could do something along the lines of the following in Pytorch.\nFirst you want to pass your state through your NN to get the mean and standard deviation of the Gaussian distribution. Then you want to simulate $z \\sim N(0,1)$ and calculate $a = \\mu(s,\\theta) + \\sigma(s, \\theta) \\times z$ so that $a \\sim N( \\mu(s, \\theta), \\sigma(s, \\theta))$ -- this is the reparameterisation trick that makes backpropagation through the network easier as it takes the randomness from a source that doesn't depend on the parameters of the network. $a$ is your action that you will execute in your environment and use to calculate the gradient by simply writing the code torch.log(normal_pdf(a, \\mu(s, \\theta), \\sigma(s, \\theta)).backward() -- here normal_pdf() is any function in Python that calculates the pdf of a normal distribution for a given point and parameters.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does Lucas's argument work? In Minds, Machines and G\u00f6del (1959), J. R. Lucas shows that any human mathematician can not be represented by an algorithmic automaton (a Turing Machine, but any computer is equivalent to it by the Church-Turing thesis), using G\u00f6del's incompleteness theorem.\nAs I understand it, he states that since the computer is an algorithm and hence a formal system, G\u00f6del's incompleteness theorem applies. But a human mathematician also has to work in a formal axiom system to prove a theorem, so wouldn't it apply there as well?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, it applies. If a statement cannot be derived in a finite number of steps, then it doesn't matter if the person trying to prove it is a human or a computer. \nThe mathematician has one advantage over a standard theorem proving algorithm: the mathematician can \"step out of the system\" (as Douglas Hofstadter called in G\u00f6del, Escher, Bach), and start thinking about the system. From this point of view, the mathematician may find that the derivation is impossible.\nHowever, an AI for proving theorems could be programmed to recognize patterns in the derivation, just like our hypothetical mathematician, and start reasoning about the formal system to derive properties of the formal system itself.\nBoth the AI and the mathematician would still be bound by the laws of mathematics, and not be able to prove a theorem if it was mathematically improvable.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What techniques are used to make MDP discrete state space manageable? Generating a discretized state space for an MDP (Markov Decision Process) model seems to suffer from the curse of dimensionality.\nSupposed my state has a few simple features:\n\nFeeling: Happy/Neutral/Sad\nFeeling: Hungry/Neither/Full\nFood left: Lots/Some/Low/Empty\nTime of day: Morning/Afternoon/Evening/Night\nLocated: Home/Work/Library/Shops\nMoney in wallet: \\$0, \\$0-\\$50, \\$51-\\$200, \\$200-\\$1000, \\$1000+\n\nThis is a relatively compact set of information however since the number of states multiplies out, the corresponding MDP state space is 3 x 3 x 4 x 4 x 4 x 5 = 2880.\nFor a non-trivial problem with a greater number of choices per factor, the state space quickly becomes unmanageably large.\nIt seems to me that the usefulness of MDPs with large complex problems would be very limited.\nIs that the case, or are there ways of keeping the state space manageable for more complex problems?\nIn general, what is a manageable number of states for an MDP to have, considering the need to generate the transition matrix and reward matrix?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "tl:dr\nRead chapter 9 of an Introduction of Reinforcement Learning\nThere is definitely a problem (a curse if you will) when the dimensionality of a task (MDP) grows. For fun, lets extend your problem to a much harder case, continuous variables, and see how we deal with it.\nMood: range [-1, 1] // 1 is Happy, 0 is Neutral, -1 is Sad\n\nHunger: range [0, 1] // 0 is Very Hungry, 1 is Full\n\nFood: range [0, 100] // amount of food, capping at 100 for numbers sake\n\nTime of day: [0, 23] // Hours, 9.5 would be 9:30 am\n\nPosition x: range [-10, 10] // assuming the area the agent stays in is 10x10 km\n\nPosition y: range [-10, 10]\n\nMoney: range [0, 2000]\n\nNow its impossible to even count the number of states the agent could be in. An example of one state would be:\nMood, Hunger, Food, Time, PosX, PosY, Money\n.5, .3, 67.4, 4.5, 0, 0, 5\n\nThis would mean that our agent has a neutral mood, is kind of hungry, has 67.4% food, the time is 4:30 am, they are in the center of the city (0,0), and have 5 dollars. Which has happened to me once or twice before too so this is reasonable. If we we still wanted to generate a transition matrix and a reward matrix we would have to represent this state uniquely from other possibly similar states such as if the time was 5 pm with all other things equal.\nSo now how would we approach this?\nFirst lets discretize or breakup each range into little chunks. Then we could have an array of 0s representing our chunks and assign a 1 to the index of the chunk we are in. Lets call this array our feature array. \nIf we did this for each dimension of our state information, we would end up with some state similar to what you originally proposed. I've chosen some arbitrary numbers to break up the state space and lets see what it does to the example state.\nIf we broke the Mood range up into 8 chunks of .25 we would have these ranges:\nm = Mood\n\n-1.0 \u2264 m < -.75\n-.75 \u2264 m < -.50\n-.50 \u2264 m < -.25\n-.25 \u2264 m < 0.0\n0.0 \u2264 m < .25\n.25 \u2264 m < .50\n.50 \u2264 m < .75\n.75 \u2264 m < 1.0\n\nIf we took the mood from the example state (.5), it would land in the 7th range, so then our feature vector for mood would look like:\n[0,0,0,0,0,0,1,0] <- represents a mood of .5\n\nLets do the same for hunger by splitting it into 8 chunks of .125:\n[0,0,1,0,0,0,0,0] <- represents a hunger of .3\n\nWe could then do something similar for each other state variable and break each state variable's range up into 8 chunks of equal sizes as well. Then after calculating their feature vectors, we would concatenate them all together and have a feature vector that is 56 elements long (7 state variables * 8 chunks each).\nAlthough this would give us 2^56 different combinations of feature vectors, it actually doesn't represent what we wanted to represent. We need features that activate (are 1) when events happen together. We need a feature that is 1 when we are hungry AND when we have food. We could do this by doing a cross product of our 56 element feature vector with itself.\nNow we have a 3136 element feature vector that has features like:\n 1 if its 3pm and am happy\n 1 if am full and out of food\n 1 if at coordinate -3, 4 (Position x, Position y)\nThis is a step in the right direction but still isn't enough to represent or original example state. So lets keep going with the cross products!\nIf we do 6 cross products we would have 30,840,979,456 features and only 1 of them would be on when our agent has a neutral mood, is kind of hungry, has 67.4% food, the time is 4:30 am, they are in the center of the city (0,0), and have 5 dollars.\nAt this point you are probably like \"Well.. thats a bit much\", to which I would agree. This would be the curse of dimensionality, and is the reason transition tables stop being fun (if they ever were).\nInstead lets take a different approach, rather than trying to represent an individual state with an individual feature and saying whether that feature is good, lets go back to our nice 56 element feature vector. From here lets instead give a weight (w_i) to each of our 56 features. We have now entered the world of linear function approximation. Although I could explain it here, I think its better explained in Chapter 9 of the Introduction of Reinforcement Learning.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is random initialization of the weights the only choice to break the symmetry? My knowledge\nSuppose you have a layer that is fully connected, and that each neuron performs an operation like\na = g(w^T * x + b)\n\nwere a is the output of the neuron, x the input, g our generic activation function, and finally w and b our parameters.\nIf both w and b are initialized with all elements equal to each other, then a is equal for each unit of that layer.\nThis means that we have symmetry, thus at each iteration of whichever algorithm we choose to update our parameters, they will update in the same way, thus there is no need for multiple units since they all behave as a single one.\nIn order to break the symmetry, we could randomly initialize the matrix w and initialize b to zero (this is the setup that I've seen more often). This way a is different for each unit so that all neurons behave differently.\nOf course, randomly initializing both w and b would be also okay even if not necessary.\nQuestion\nIs randomly initializing w the only choice? Could we randomly initialize b instead of w in order to break the symmetry? Is the answer dependent on the choice of the activation function and/or the cost function?\nMy thinking is that we could break the symmetry by randomly initializing b, since in this way a would be different for each unit and, since in the backward propagation the derivatives of both w and b depend on a(at least this should be true for all the activation functions that I have seen so far), each unit would behave differently. Obviously, this is only a thought, and I'm not sure that is absolutely true.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Randomising just b sort of works, but setting w to all zero causes severe problems with vanishing gradients, especially at the start of learning. \nUsing backpropagation, the gradient at the outputs of a layer L involves a sum multiplying the gradient of the inputs to layer L+1 by the weights (and not the biases) between the layers. This will be zero if the weights are all zero.\nA gradient of zero at L's output will further cause all earlier layers(L-1, L-2 etc all the way back to layer 1) to receive zero gradients, and thus not update either weights or bias at the update step. So the first time you run an update, it will only affect the last layer. Then the next time, it will affect the two layers closest to the output (but only marginally at the penultimate layer) and so on.\nA related issue is that with weights all zero, or all the same, maps all inputs, no matter how they vary, onto the same output. This also can adversely affect the gradient signal that you are using to drive learning - for a balanced data set you have a good chance of starting learning close to a local minimum in the cost function.\nFor deep networks especially, to fight vanishing (or exploding) gradients, you should initialise weights from a distribution that has an expected magnitude (after multiplying the inputs) and gradient magnitude that neither vanishes nor explodes. Analysis of values that work best in deep networks is how Xavier/Glorot initialisation were discovered. Without careful initialisation along these lines, deep networks take much longer to learn, or in worst cases never recover from a poor start and fail to learn effectively.\nPotentially to avoid these problems you could try to find a good non-zero fixed value for weights, as an alternative to Xavier initialisation, along with a good magnitude/distribution for bias initialisation. These would both vary according to size of the layer and possibly by the activation function. However, I would suspect this could suffer from other issues such sampling bias issues - there are more weights, therefore you get a better fit to desired aggregate behaviour when setting all the weight values randomly than you would for setting biases randomly.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Do Vision Transformers handle arbitrary sequence lengths the same way as normal Transformers? Does ViT do handle arbitrary sequence lengths using masking the same way the normal Transformer does?\nThe ViT paper doesn't mention anything about it, so I assume it uses masking like the normal Transformer.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, they can handle sequences with arbitrary length sequence, but with some remarks.\nIn the paper Training data-efficient image transformers & distillation through attention authors train models in the resolution 224x224 (1 + 14x14 tokens) and then finetune to the 384x384 (1 + 28x28 tokens).\nWeights to produce queries, keys, values, as well as feedforward layers, operate only on a single token and are agnostic to the sequence length.\nHowever, the size of the sequence is required in the positional embeddings, where one has a specific weight for each location of the token.\nIn order to make this construction work for inputs of other sizes, one needs to transform this positional embedding in a certain way. Bicubic interpolation of positional embeddings, used in DeiT, works pretty well.\nOne can use simpler Bilinear or Nearest interpolation - but it seems like this harms accuracy.\nIn my own experience, when I took the DeiT-tiny with base accuracy of 72.2% after several epochs of finetuning gave accuracy of 77.0%.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it possible to create LLM using NEAT or its variations? While researching neuroevolutionary algorithms, neural networks performed well on a variety of tasks, creating complex systems. But when I needed something more complex, trying to create a GenAI for text or a simple translator between two languages, I ran into serious problems. After almost a year of trying, it seems to me that neither NEAT nor its variations (HyperNEAT, CoDeepNEAT, etc.) can handle this, but I'm not sure. So is it possible to create generative models or at least translators using neuroevolutionary algorithms?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "No, this is not possible. Or more precisely, it is not practical.\nEvolutionary algorithms are a very general optimisation process that perform semi-random and local searches in a parameter space (the \"genome\") that must be converted into some expression (the \"phenotype\"), evaluated and selected.\nThis process, and any evolutionary algorithm based on it, is conceptually simple and very robust, but it is also very slow when faced with complex searches. When evaluation is slow, or when solutions require large numbers of tuned parameters, using an evolution-inspired algorithm becomes impossibly slow.\nLLMs, which typically have billions of paramaters, and where training consists of processing billions of input/output pairs, are large scale in both aspects (number of parameters and amount of evaluation), and are many orders of magnitude out of reach of gradient-free learning algorithms like NEAT.\nEvolution built human brains in the real world, but the underlying mechanics and scale of the system that allowed this is very different from anything we can perform on a computer. We don't fully understand it, but we can say that something like the NEAT model is a very different kind of system. For example, mammalian genomes don't have very many tunable parameters (maybe 100,000? There are an estimated 20,000 protein-coding genes for example in the human genome*), but the phenotype expression and evaluation are beyond anything related to current computation limits - it's not really computationally feasible to simulate a single cell on a computer to the level where a true-to-life evolution could occur. And that's before we consider parallel processing involving massive numbers of indvividuals over millions of years.\nWhen we can design a system based on function approximation, are able to describe example inputs and outputs, and can take advantage of gradient-based algorithms, this makes LLM training feasible. There is no known practical gradient-free method to training models at the scale of LLMs.\n\n* Equating a gene expressed in DNA to a \"tunable parameter\" is probably wrong, but it's not important. We cannot replicate biological systems in that much detail on a computer anyway.\nI would also add that successfully processing the genetics and physical development of a simulated human would lead to a \"blank slate\" system that in the real world takes years to learn useful language skills. We don't understand which layers of the system can be shortcut and don't need to be simulated down to the atomic level\n...\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the goal of weight initialization in neural networks? This is a simple question. I know the weights in a neural network can be initialized in many different ways like: random uniform distribution, normal distribution, and Xavier initialization. But what is the weight initialization trying to achieve?\nIs it trying to allow the gradients to be large so it can quickly converge? Is it trying to make sure there is no symmetry in the gradients? Is it trying to make the outputs as random as possible to learn more from the loss function? Is it only trying to prevent exploding and vanishing gradients? Is it more about speed or finding a global maximum? What would the perfect weights (without being learned parameters) for a problem achieve? What makes them perfect? What are the properties in an initialization that makes the network learn faster?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nIs it trying to make sure there is no symmetry in the gradients?\n\nThe aim of weight initialization is to make sure that we don't converge to a trivial solution. That's why we have different kinds of initialization depending on the dataset type. So, Yes it is trying to avoid symmetry.\n\nIs it trying to allow the gradients to be large so it can quickly converge?\n\nThe time it takes to converge, is I think a property of the optimizer and not of the weights initialization. Of course, the manner in which we initialize our weights matters but I think Optimization Algorithms contribute more towards convergence\n\nWhat are the properties in an initialization that makes the network learn faster?\n\nGlorot and Bengio believed that Xavier weight initialization would maintain the variance of activations and back-propagated gradients all the way up or down the layers of a network. Incidentally, when they trained deeper networks that used ReLUs, it was found that a 30-layer CNN using Xavier initialization stalled completely and didn\u2019t learn at all. Thus, it depends on the particular problem at hand.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Current limitations to artificial consciousness With some knowledge of machine learning and deep learning, it seems very unlikely for AI to develop into the consciousness that we imagine.\nTo me, consciousness requires a new framework that is very different from what we have today, as current forms of learning seem to be very 'shallow'.\nWhat are the current limitations to artificial consciousness and sentience? Also is there a difference between artificial consciousness and sentience?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It may be helpful to think of consciousness, like intelligence, as a spectrum. The Stanford Encyclopedia of Philosophy, under the section \"Creature Consciousness\" (2.1) defines sentience as:\n\nSentience. It may be conscious in the generic sense of simply being a sentient creature, one capable of sensing and responding to its world (Armstrong 1981). Being conscious in this sense may admit of degrees, and just what sort of sensory capacities are sufficient may not be sharply defined. Are fish conscious in the relevant respect? And what of shrimp or bees? Stanford Encyclopedia of Philosophy, 2.1 \"Creature Consciousness\"\n\nIt seems clear that AI possesses the most basic form of consciousness in terms of \"sensing and responding to its world\". I might liken this level of consciousness to that of microorganisms, able to interact with their environments but possessing none of the higher functions of humans, or even higher-order animals.\nWe don't really understand the true nature of higher consciousness and human-level sentience, which doesn't necessarily mean that an automata with sufficient complexity couldn't achieve it. But there is a deeper problem relating to validation (i.e. how would be know the system is truly self-aware, and not simulating self-awareness. [See Searle's Chinese Room, but also McCarthy's Refutation] \nIn his paper Making Robots Conscious of their Mental\nStates McCarthy states:\n\nConscious knowledge and other information is distinguished from\nunconscious information by being observable, and its observation results\nin conscious knowledge about it. We call this introspective knowledge.\nA robot will need to use introspective knowledge in order to operate\nin the common sense world and accomplish the tasks humans will give\nit.\nMany features of human consciousness will be wanted, some will\nnot, and some abilities not possessed by humans have already been\nfound feasible and useful in limited domains.\nWe give preliminary fragments of a logical language a robot can\nuse to represent information about its own state of mind.\nA robot will often have to conclude that it cannot decide a question\non the basis of the information in memory and therefore must seek\ninformation externally.\nPrograms with much introspective consciousness do not yet exist.\nMaking Robots Conscious of their Mental\nStates, Abstract\n\nThis still seems to be the case, however, McCarthy seems hopeful about the \"computationalist\" approach:\n\nThinking about consciousness with a view to designing it provides\na new approach to some of the problems of consciousness studied by\nphilosophers. One advantage is that it focusses on the aspects of\nconsciousness important for intelligent behavior. If the advocates of\nqualia are right, it looks like robots won\u2019t need them to exhibit any\nbehavior exhibited by humans.ibid.\n\nThe continual increase in memory, processing and algorithmic sophistication may well yield Artificial General Intelligence.\nEven if this proves to be the case, I suspect the debate over artificial consciousness will rage on.\n\nSee also: Artificial Consciousness\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do my rewards reduce after extensive training using D3QN? I am running a drone simulator for collision avoidance using a slight variant of D3QN. The training is usually costly (runs for at least a week) and I have observed that reward function gradually increases during training and then drastically drops. In the simulator, this corresponds to the drone exhibiting cool collision avoidance after a few thousand episodes. However, after training for more iterations it starts taking counterintuitive actions such as simply crashing into a wall (I have checked to ensure that there is no exploration at play over here).\nDoes this have to do with overfitting? I am unable to understand why my rewards are falling this way.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It is not 100% clear, but this seems like an instance of catastrophic forgetting. This is something that often impacts reinforcement learning.\nI have answered a very similar question on Data Science stack exchange, and reproduce the same answer here.\n\nThis is called \"catastrophic forgetting\" and can be a serious problem in many RL scenarios.\nIf you trained a neural network to recognise cats and dogs and did the following:\n\nTrain it for many epochs on a full dataset until you got a high accuracy.\n\nContinue to train it, but remove all the cat pictures.\n\n\nThen in a relatively short space of time, the NN would start to lose accuracy. It would forget what a cat looks like. It would learn that its task was to switch the dog prediction as high as possible, just because on average everything in the training population was a dog.\nSomething very similar happens in your DQN experience replay memory. Once it gets good at a task, it may only experience success. Eventually, only successful examples are in its memory. The NN forgets what failure looks like (what the states are, and what it should predict for their values), and predicts high values for everything.\nLater on, when something bad happens and the NNs high predicted value is completely wrong, the error can be high. In addition the NN may have incorrectly \"linked\" features of the state representation so that it cannot distinguish which parts of the feature space are the cause of this. This creates odd effects in terms of what it learns about values of all states. Often the NN will behave incorrectly for a few episodes but then re-learn optimal behaviour. But it is also possible that it completely breaks and never recovers.\nThere is lots of active research into catastrophic forgetting and I suggest you search that term to find out some of the many types of mitigation you could use.\nFor Cartpole, I found a very simple hack made the learning very stable. Keep aside some percentage of replay memory stocked with the initial poor performing random exploration. Reserving say 10% to this long term memory is enough to make learning in Cartpole rock solid, as the NN always has a few examples of what not to do. The idea unfortunately does not scale well to more complex environments, but it is a nice demonstration. For a more sophisticated look at similar solutions you could see the paper \"The importance of experience replay database composition in deep reinforcement learning\"\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to write a C decompiler using AI? I would like to learn more about whether it is possible and how to write a program that decompiles executable binary (an object file) to the C source. I'm not asking exactly 'how', but rather how this can be achieved.\nGiven the following hello.c file (as example):\n#include \nint main() {\n printf(\"Hello World!\");\n}\n\nThen after compilation (gcc hello.c) I've got the binary file like:\n$ hexdump -C a.out | head\n00000000 cf fa ed fe 07 00 00 01 03 00 00 80 02 00 00 00 |................|\n00000010 0f 00 00 00 b0 04 00 00 85 00 20 00 00 00 00 00 |.......... .....|\n00000020 19 00 00 00 48 00 00 00 5f 5f 50 41 47 45 5a 45 |....H...__PAGEZE|\n00000030 52 4f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |RO..............|\n00000040 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 |................|\n00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|\n00000060 00 00 00 00 00 00 00 00 19 00 00 00 d8 01 00 00 |................|\n00000070 5f 5f 54 45 58 54 00 00 00 00 00 00 00 00 00 00 |__TEXT..........|\n$ wc -c hello.c a.out \n 60 hello.c\n8432 a.out\n\nFor the learning dataset, I assume I'll have to have thousands of source code files along with its binary representation, so the algorithm can learn about moving parts on certain changes.\nHow would you tackle this problem?\nMy concerns (and sub-questions) are:\n\nDoes my algorithm need to be aware of the header file, or it's \"smart\" enough to figure it out?\n\nIf it needs to know about the header, how do I tell my algorithm \"here is the header file\"?\n\nWhat should be input/output mapping (whether some section to section or file to file)?\n\nDo I need to divide my source code into some sections?\n\nDo I need to know exactly how decompilers work or AI can figure it out for me?\n\nShould I have two neural networks, one for header, another for body it-self?\n\nor more separate neural networks, each one for each logical component (e.g. byte->C tag, etc.)\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In-between your input and desired output, there's obviously a huge space to search. The more relevant domain information you include as features, the higher chance that the Deep Learning (DL) algorithm can find the desired mapping.\nAt this early stage in DL research, there aren't so many rules of thumb to tell you what features to explicitly encode - not least because it depends on the size of your training corpus. My suggestion would be: obtain (or generate) a large corpus of C code, train on that with the most naive feature representation that you think might work, then repeatedly gather data and add more feature preprocessing as necessary.\nThis following paper describes a DL approach to what is almost the 'reverse problem' to yours - generating the source code for a program described in natural language.\nI found the strength of the results reported in this paper surprising, but it does give me some hope that what you are asking might be possible.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Formal definition of the Object Detection problem For many problems in computer science, there is a formal, mathematical problem defition.\nSomething like: Given ..., the problem is to ...\nHow can the Object Detection problem (i.e. detecting objects on an image) be formally defined?\nGiven a set of pixels, the task is to decide\n\nwhich pixels belong to an object at all,\nwhich pixels belong to the same object.\n\nHow can this be put into a formula?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is just an idea\nGiven a set of pixels, the task is to decide:\n\nWhich pixel is the center of an object?\nWhat is the size of the bounding boxes with the center is the pixel in part 1?\n\nFormula, consider this is a 2D image, call $(x,y)$ is the horizontal and vertical coordinate and $(w_i,h_i)$ is the size of bouding box of object $i$:\n$\\text{For }m \\in[x,x+w_i] \\text{ and } n\\in[y,y+h_i]$\n$c_i(m,n) = \\begin{cases}\n 1, \\text{if pixel at position (m,n) is belongs to object i,}\\\\\n 0, \\text{else}\n\\end{cases}$\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does AI rely on determinism? I don\u2019t believe in free will, but most people do. Although I\u2019m not sure how an act of free will could even be described (let alone replicated), is libertarian freewill something that is considered for AI? Or is AI understood to be deterministic?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I'm going to assume that by free will, you mean something like the philosophical concept of libertarian free will, which is defended by philosophers like Robert Kane. In Libertarian Free Will, individuals have some capability to make choices about their actions. The classic way to argue this is by assuming some kind of spirit-stuff (e.g. a soul) that exists outside the material world, and that this spirit-stuff constitutes the consciousness of a person. Kane tries some mental gymnastics to avoid this, but then concedes something like it in a footnote. I'm not aware of any serious work that doesn't make some kind of non-physical assumption to justify this view. If someone can point at one, I'll update the answer.\nBy determinism, I'm going to assume you mean the usual notion of philosophical determinism: since people's decisions depend on what happened in the past, and where they are in the present, they don't really have a choice in any meaningful sense. Philosopher's like Dennett adopt a slightly softer view (compatibilism, essentially: you don't get to make big choices, but you do get to make small ones). Appeals to Quantum Mechanics are common to justify that view. In this context, free action means something more like \"did something we couldn't predict exactly\". An example might be: you are pre-destined to put a can of campbell's brand tomato soup in your shopping cart, but \"make a choice\" about exactly which of the dozens of cans you will put in. Since small choices can have large impacts (maybe that can will give you food poisoning, and the others wouldn't), this can make all sorts of things impossible to predict exactly. \nI think most AI researchers don't worry too much about these issues, but Turing actually addresses them in his paper right at the start of the field, Computing Machinary and Intelligence. The deterministic/compatibilist view point is introduced as Lady Lovelace's objection: Computers only know how to do what we tell them to, so they can't be called intelligence.\nTuring's counterargument uses two prongs. First, Turing notes that computers can probably be made to learn (he was right!). If they can learn, they can do things that we don't expect, just like children do. Second, Turing notes that computers already do all sorts of things we don't expect: they have bugs. Anytime a computer exhibits a bug, it did something that was unexpected. Since we cannot generally rule out bugs in programs, computers will always do surprising things. Therefore, computers satisfy the deterministic notion of free will.\nTuring also addresses the libertarian notion of free will, which is part of what he calls the \"Theological Objection\". The objection is that intelligence requires some kind of divine spark (like free will). Turing argues that we can't detect sparks like this right now (he actually thought we would be able to one day, and spent a lot of time looking at supernatural phenomena too). However, there's no reason to suppose that computers with the right programs won't be endowed with them. A divine creator could decide that anytime you build something brain-like, it gets a spark. If we build a program that's brain-like, maybe it gets a spark too. In the absence of some way to detect souls, it seems like we ought to just agree to treat things that seem intelligent as though they had these souls, since otherwise we don't have a really clear way to decide who is and isn't intelligent. The only remaining way is to say \"only things made of human meat have souls and are intelligent\". While a lot of people do actually say things like this (e.g. animals have no souls), this is a pretty arbitrary view, and I think there's no hope arguing against it. Turing suggests the \"Anthropic Principal\": we shouldn't assume that we're special, because the earth isn't in a special place in the galaxy, or in the universe, and we have pretty compelling evidence that we're an evolved version of other animals around us, but some groups (e.g. biblical literalists) find this unconvincing. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "If vanishing gradients are NOT the problem that ResNets solve, then what is the explanation behind ResNet success? I often see blog posts or questions on here starting with the premise that ResNets solve the vanishing gradient problem.\nThe original 2015 paper contains the following passage in section 4.1:\n\nWe argue that this optimization difficulty is unlikely to\nbe caused by vanishing gradients. These plain networks are\ntrained with BN, which ensures forward propagated\nsignals to have non-zero variances. We also verify that the\nbackward propagated gradients exhibit healthy norms with\nBN. So neither forward nor backward signals vanish. In\nfact, the 34-layer plain net is still able to achieve competitive accuracy, suggesting that the solver works\nto some extent.\n\nSo what's happened since then? I feel like either it became a misconception that ResNets solve the vanishing gradient problem (because it does indeed feel like a sensible explanation that one would readily accept and continue to propagate), or some paper has since proven that this is indeed the case.\nI'm starting with the initial knowledge that it's \"easier\" to learn the residual mapping for a convolutional block than it is to learn the whole mapping. So my question is on the level of: why is it \"easier\"? And why does the \"plain network\" do such a good job but then struggle to close the gap to the performance of ResNet. Supposedly if the plain network has already learned reasonably good mappings, then all it has left to learn to close the gap is \"residual\". But it just isn't able to.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "They explained in the paper why they introduce residual blocks. They argue that it's easier to learn residual functions $F(x) = H(x) - x$ and then add them to the original representation $x$ to get hidden representation $H(x) = F(x) + x$ than it is to learn hidden representation $H(x)$ directly from original representation. That's the main reason and empirical results show that they might be right. Better gradient propagation might be an additional bonus but that's not why they originally introduced the idea.\n\"Normal\" networks work too but, at some point, they become too deep and start working worse than shallower versions (they empirically showed that in the paper). Again, they argue that the reason for that might be that at deeper layers hidden representations become approximately similar $H_n \\approx H_{n+1}$ because representation is already well learned and you only need some slight adjustments. That would mean that transformation for deeper layers is similar to identity transformation and that ordinary layers might have trouble learning that, while for residual blocks it would be easy to learn slight modification and add that to the already existing representation from the previous layer.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why don't we train highly specialized, highly polished, single knowledge LLMs? LLMs are trained on astronomical amounts of data, but it doesn't appear to have occurred to anyone to train highly specialized, highly polished, single knowledge LLMs, such as the ones listed below, orchestrated as a series of micro-services, which together \"become greater then the sum of its parts\", ultimately forming Artificial General Intelligence? Why isn't it modular? Why isn't it being used like this?\nPhysics/Astronomy\n\nTheoretical physicist\nAstrophysicist\nCosmologist\n\nBiology/Life Sciences\n\nAstrobiologist\nExobiologist\nNeuroscientist\nEvolutionary biologist\n\nMathematics/Computer Science\n\nMathematician (pure/applied)\nComputer scientist\nAI/ML researcher\nCryptographer/information theorist\n\nLinguistics/Communication\n\nLinguist (especially computational or theoretical)\nSemiotician\nCommunication theorist\n\nEngineering\n\nAerospace engineer\nSystems engineer\nElectrical/computer engineer\n\nMedicine/Health Sciences\n\nPhysician (infectious disease, immunology)\nPublic health expert\nBiomedical researcher\n\nSocial Sciences\n\nAnthropologist (cultural/linguistic)\nCognitive scientist\nPsychologist\nSociologist\n\nHumanities\n\nPhilosopher (especially philosophy of mind, ethics, logic)\nHistorian (civilizational history)\n\nLaw/Policy\n\nInternational law specialist\nDiplomatic studies\nPolicy analyst\n\nInterdisciplinary\n\nScience and Technology Studies (STS)\nCognitive science (often blends psych, CS, linguistics, philosophy)\nBioethics\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nLLMs are trained on astronomical amounts of data, but it doesn't appear to have occurred to anyone to train highly specialized, highly polished, single knowledge LLMs, such as the ones listed below, orchestrated as a series of micro-services, which together \"become greater then the sum of its parts\"\n\nWhat you described sounds a lot like the routing method coupled with MoE (mixture of experts) which GPT 5 uses, among others. In other words, the idea is already in use in one form or another.\n\nultimately forming a higher, Artificial General Intelligence?\n\nLLMs in their current form don\u2019t have what it takes to become any real version of AGI. The only hope it has is to use extremely large models and hope for emergent capabilities that resemble AGI (this has not happened yet). That aside, the technology isn\u2019t really there, as energy problems rear their ugly heads; it\u2019s too expensive and unrealistic to train such a large model with current technology. Even so, there is also the problem of having enough data to train such a large model; the bigger the model the more data you can need per the scaling law for LLMs. In other words, the proposed method would be highly unlikely to produce an AGI model because the component models don\u2019t reach the necessary size (assuming LLMs can really reach AGI)\nHope this helps!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the \u201cHello World\u201d problem of Unsupervised Learning? As a followup to this question, I'm interested in what the typical \"Hello World\" problem (first easy example problem) is for unsupervised learning.\nA quick Google search didn't find any obvious answers for me.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I disagree with the context that MNIST is the \"hello world\" of supervised learning. It is definitely, though, the \"hello world\" of image classification, which is a very specific sub-field of supervised learning.\nI'd consider the Iris dataset a better candidate for the \"hello world\" of supervised learning, with other close candidates such as the Wine, Wisconsin breast cancer or Pima indians datasets. However, as an even simpler and more alternative choice, a lot of people prefer generating their own 2-dimensional datasets so that can more intuitively understand what the different algorithms are doing. An example of this is TensorFlow playground.\nEquivalently, in unsupervised learning there are a lot of different tasks. I personally think that clustering is probably the task that is easier for people to understand and as such the most common intro to unsupervised learning. Here there are, as well, two options:\n\nUsing an already established dataset, e.g. Iris (without the labels).\nGenerating your own synthetic 2-dimensional data, to better understand how the algorithms work. An example is this.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How is the gradient of the loss function in DQN derived? In the original DQN paper, page 1, the loss function of the DQN is\n$$\nL_{i}(\\theta_{i}) = \\mathbb{E}_{(s,a,r,s') \\sim U(D)} [(r+\\gamma \\max_{a'} Q(s',a',\\theta_{i}^{-}) - Q(s,a;\\theta_{i}))^2]\n$$\nwhose gradient is presented (on page 7)\n$$\\nabla_{\\theta_i} L_i(\\theta_i) = \\mathbb{E}_{s,a,r,s'} [(r+\\gamma \\max_{a'}Q(s',a';\\theta_i^-) - Q(s,a;\\theta_i))\\nabla_{\\theta_i}Q(s,a;\\theta_i)] $$\nBut why is there no minus (-) sign if $-Q(s,a;\\theta_i)$ is parameterized by $\\theta_i$ and why is the 2 from power gone?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In general, if you have a composite function $h(x) = g(f(x))$, then $\\frac{dh}{dx} = \\frac{d g}{df} \\frac{d f}{dx}$. In your case, the function to differentiate is\n$$L_{i}(\\theta_{i}) = \\mathbb{E}_{(s,a,r,s') \\sim U(D)} \\left[ \\left(r+\\gamma \\max_{a '} Q(s',a',\\theta_{i}^{-}) - Q(s,a;\\theta_{i}) \\right)^2 \\right]$$\nSo, we want to calculate $\\nabla_{\\theta_i} L_{i}(\\theta_{i})$, which is equal to\n$$\\nabla_{\\theta_i} \\mathbb{E}_{(s,a,r,s') \\sim U(D)} \\left[ \\left(r+\\gamma \\max_{a '} Q(s',a',\\theta_{i}^{-}) - Q(s,a;\\theta_{i}) \\right)^2 \\right] \\label{2} \\tag{2} $$\nFor clarity, let's ignore the iteration number $i$ in \\ref{2}, which can thus more simply be written as\n$$\\nabla_{\\theta} \\mathbb{E}_{(s,a,r,s') \\sim U(D)} \\left[ \\left(r + \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - Q(s,a; \\theta ) \\right)^2 \\right] \\label{3} \\tag{3} $$\nThe subscript of the expected value operator $\\mathbf{e}=(s,a,r,s') \\sim U(D)$ means that the expected value is being taken with respect to the multivariate random variable, $\\mathbf{E}$ (for experience), whose values (or realizations) are $\\mathbf{e}=(s,a,r,s')$, and that follows the distribution $U(D)$ (a uniform distribution), that is, $\\mathbf{e}=(s,a,r,s')$ are uniformly drawn from the experience replay buffer, $D$ (or $\\mathbf{E} \\sim U(D)$). However, let's ignore or omit this subscript for now (because there are no other random variables in \\ref{3}, given that $\\gamma$ and $a'$ should not be random variables, thus it should not be ambiguous with respect to which random variable the expectation is being calculated), so \\ref{3} can be written as\n$$\\nabla_{\\theta} \\mathbb{E} \\left[ \\left(r + \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - Q(s,a; \\theta ) \\right)^2 \\right] \\label{4} \\tag{4} $$\nNow, recall that, in the case of a discrete random variable, the expected value is a weighted sum. In the case of a continuous random variable, it is an integral. So, if $\\mathbf{E}$ is a continuous random variable, then the expectation \\ref{4} can be expanded to\n$$\n\\int_{\\mathbb{D}} {\\left(r + \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - Q(s,a; \\theta )\\right)}^2 f(\\mathbf{e}) d\\mathbf{e}\n$$\nwhere $f$ is the density function associated with $\\mathbf{E}$ and $\\mathbb{D}$ is the domain of the random variable $\\mathbf{E}$.\nThe derivative of an integral can be calculated with the Leibniz integral rule. In the case the bounds of the integration are constants ($a$ and $b$), then the Leibniz integral rule reduces to\n$${\\displaystyle {\\frac {d}{dx}}\\left(\\int _{a}^{b}f(x,t)\\,dt\\right)=\\int _{a}^{b}{\\frac {\\partial }{\\partial x}}f(x,t)\\,dt.}$$\nObserve that the derivative is taken with respect to the variable $x$, while the integration is taken with respect to variable $t$.\nIn our case, the domain of integration, $\\mathbb{D}$, is constant because it only represents all experience in the dataset, $\\mathcal{D}$. Therefore, the gradient in \\ref{4} can be written as\n\\begin{align}\n\\nabla_{\\theta} \\int_{\\mathbb{D}} \\left(r + \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - Q(s,a; \\theta )\\right)^2 f(\\mathbf{e}) d\\mathbf{e} \n&= \\\\\n\\int_{\\mathbb{D}} \\nabla_{\\theta} \\left( \\left( r + \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - Q(s,a; \\theta )\\right)^2 f(\\mathbf{e}) \\right) d\\mathbf{e}\n&=\\\\\n\\mathbb{E} \\left[ \\nabla_{\\theta} { \\left(r + \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - Q(s,a; \\theta) \\right)}^2 \\right] \\label{5}\\tag{5}\n\\end{align}\nRecall that the derivative of $f(x)=x^2$ is $f'(x)=2x$ and that the derivative of a constant is zero. Note now that the only term in \\ref{5} that contains $\\theta$ is $Q(s,a; \\theta)$, so all other terms are constant with respect to $\\theta$. Hence, \\ref{5} can be written as\n\\begin{align}\n\\mathbb{E} \\left[ \\nabla_{\\theta} {(r + \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - Q(s,a; \\theta))}^2 \\right] \n&=\\\\\n\\mathbb{E} \\left[ 2 {(r + \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - Q(s,a; \\theta))} \\nabla_{\\theta} \\left( {r + \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - Q(s,a; \\theta)} \\right) \\right] \n&=\\\\\n\\mathbb{E} \\left[ 2 {(r + \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - Q(s,a; \\theta))} \\left( {\\nabla_{\\theta} r + \\nabla_{\\theta} \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - \\nabla_{\\theta} Q(s,a; \\theta)} \\right) \\right] \n&=\\\\\n\\mathbb{E} \\left[ - 2 {(r + \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - Q(s,a; \\theta))} {\\nabla_{\\theta} Q(s,a; \\theta)} \\right] \n&=\\\\\n-2 \\mathbb{E} \\left[ {(r + \\gamma \\max_{a'} Q(s',a',\\theta^{-}) - Q(s,a; \\theta))}{\\nabla_{\\theta} Q(s,a; \\theta)} \\right] \n\\end{align}\nThe $-2$ disappears because it can be absorbed by the learning rate.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Interesting examples of discrete stochastic games SGs are a generalization of MDPs to multiple agents. Like this previous question on MDPs, are there any interesting examples of zero-sum, discrete SGs\u2014preferably with small state and action spaces? I'm hoping to use such examples as benchmarks, but couldn't find much in the literature. One example I can think of is a pursuit-evasion game on a graph.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Some of the domains in the International Probabilistic Planning Competition, such as the Wildlife Preserve benchmark, fit quite well the constraints you have given. Note that the problems are modeled with a high-level declarative language, RDDL. This means that you can define problems as big or as small as your heart desires with relative ease, since you can parametrize state description in terms of functions describing properties of an arbitrary number of objects.\nThere's also a quite useful project that allows to instance OpenAI gym environments from the declarative description of the environment, states and actions.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does the uniform-cost search algorithm work? What is the uniform-cost search (UCS) algorithm? How does it work? I would appreciate seeing a graphical execution of the algorithm. How does the frontier evolve in the case of UCS?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Uniform Cost Search is also called the Cheapest First Search. For an example and entire explanation you can directly go to this link: Udacity - Uniform Cost Search.\nIn this answer I have explained what a frontier is. To put it in simple words, you can describe the UCS algorithm as 'expanding the frontier only in the direction which will require the minimum cost to travel from initial point among all possible expansions, i.e. adding a point on the graph (which can be reached from the frontier without going through any other point) that has the shortest route from the initial point. We keep on doing this until a path has explored the goal frontier: this path is the cheapest path from the initial point.\nI strongly suggest you check out both the links for examples and a better understanding.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Reward interpolation between MDPs. Will an optimal policy on both ends stay optimal inside the interval? Say I've got two Markov Decision Processes (MDPs):\n$$\\mathcal{M_0} = (\\mathcal{S}, \\mathcal{A}, P, R_0),\\quad\\text{and}\\quad\\mathcal{M}_1 = (\\mathcal{S}, \\mathcal{A}, P, R_1)$$\nBoth have the same set of states and actions, and the transition probabilities are also the same. The only difference is in the reward functions $R_0$ and $R_1$. Suppose that we've found an optimal deterministic policy $\\pi^*_0$ for the problem $\\mathcal{M}_0$ and we've checked that this policy is also optimal for $\\mathcal{M}_1$\n$$\\pi_0^*(s) = \\arg\\max\\limits_a Q^*_0(s,a)\\qquad Q_1^*(s,\\pi_0^*(s)) = \\max\\limits_a Q^*_1(s,a)$$\nNow, given the two MDPs one can build a whole family of MDPs interpolating between them:\n$$\\mathcal{M}_\\alpha = (\\mathcal{S}, \\mathcal{A}, P, \\alpha R_0 + (1-\\alpha) R_1)$$\nWhere $\\alpha\\in[0,1]$ is the interpolation parameter between the two problems - the rewards are linearly changing from $R_0$ to $R_1$ with this parameter. My question is - in general. will $\\pi_0^*$ be optimal for all MDPs in the middle of interpolation interval?\n$$Q_\\alpha(s,\\pi_0^*(s))\\stackrel{?}{=}\\max\\limits_aQ^*_\\alpha(s,a),\\; \\forall\\alpha\\in[0,1]$$\nI feel like this could be generally true due to linearity of the dependence and convexity of the optimization problem. But I cannot neither prove it, nor find a counterexample.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I believe the claim is true. Here is my attempt at a proof.\nLet us consider the optimal infinite horizon value function $V_\\alpha^*$ of $\\mathcal{M}_\\alpha$ at an arbitrary state $s \\in S$.\nThe value $V_\\alpha^*(s)$ is the expected sum of discounted rewards under an optimal policy $\\pi_\\alpha^*$, i.e.,\n\\begin{equation}\n V_\\alpha^*(s) = \\mathbb{E}_{\\rho_\\alpha}\\left[\\sum\\limits_{t=0}^{\\infty}\\gamma^t\\left( \\alpha R_0(s_t,\\pi_\\alpha^*(s_t)) + (1-\\alpha)R_1(s_t, \\pi_\\alpha^*(s_t)) \\right)\\middle| s_0 = s, \\right],\n\\end{equation}\nwith the expectation taken with respect to the steady state distribution $\\rho_\\alpha$ of states under $\\pi_\\alpha^*$.\nIn the following, I drop the condition $s_0=s$ for conciseness, but you can assume it's in each expectation.\nNow, break up the sum:\n\\begin{equation}\n V_\\alpha^*(s) = \\mathbb{E}_{\\rho_\\alpha}\\left[ \\alpha\\sum\\limits_{t=0}^{\\infty}\\gamma^t R_0(s_t,\\pi_\\alpha^*(s_t)) + (1-\\alpha)\\sum\\limits_{t=0}^{\\infty}\\gamma^t R_1(s_t,\\pi_\\alpha^*(s_t)) \\right].\n\\end{equation}\nThen, by linearity of expectation:\n\\begin{equation}\n V_\\alpha^*(s) = \\alpha\\mathbb{E}_{\\rho_\\alpha}\\left[ \\sum\\limits_{t=0}^{\\infty}\\gamma^t R_0(s_t,\\pi_\\alpha^*(s_t)) \\right] + (1-\\alpha)\\mathbb{E}_{\\rho_\\alpha}\\left[ \\sum\\limits_{t=0}^{\\infty}\\gamma^t R_1(s_t,\\pi_\\alpha^*(s_t)) \\right].\n\\end{equation}\nNote that the first expectation term is the value of $\\pi_\\alpha^*$ in $\\mathcal{M}_0$, and the second expectation term is the value of $\\pi_\\alpha^*$ in $\\mathcal{M}_1$.\nWe already know that $\\pi_0^*(s)$ is optimal in $\\mathcal{M}_0$ with reward function $R_0$, and $\\pi_1^*(s)$ is likewise optimal in $\\mathcal{M}_1$ with $R_1$. Further, as per your assumption, $\\pi_0^*(s) = \\pi_1^*(s)$.\nSo $\\pi_\\alpha^*$ can be at most as good as $\\pi_0^*$ with reward function $R_0$ (resp., with $R_1$):\n\\begin{equation}\n V_\\alpha^*(s) \\leq \\alpha\\mathbb{E}_{\\rho_0}\\left[ \\sum\\limits_{t=0}^{\\infty}\\gamma^t R_0(s_t,\\pi_0^*(s_t)) \\right] + (1-\\alpha)\\mathbb{E}_{\\rho_0}\\left[ \\sum\\limits_{t=0}^{\\infty}\\gamma^t R_1(s_t,\\pi_0^*(s_t)) \\right].\n\\end{equation}\nNote that we know take the expectation under the steady state distribution $\\rho_0$ of $\\pi_0^*$ instead.\nThus, we have shown that $V_\\alpha^*(s) \\leq \\alpha V_0^*(s) + (1-\\alpha)V_1^*(s)$.\nNow it remains to argue that the case with a strict less than relation is not possible.\nSuppose this were the case, and we would have $V_\\alpha^*(s) < \\alpha V_0^*(s) + (1-\\alpha)V_1^*(s)$.\nBut then $\\pi_0^*$ would attain a higher value than $\\pi_\\alpha^*$ in $\\mathcal{M}_\\alpha$, which is a contradiction (because we assumed that $\\pi_\\alpha^*$ is an optimal policy for $\\mathcal{M}_\\alpha$).\nThus, $V_\\alpha^*(s) = \\alpha V_0^*(s) + (1-\\alpha)V_1^*(s)$ and furthermore, acting according to $\\pi_0^*$ is optimal also in $\\mathcal{M}_\\alpha$.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which nodes are expanded in the expansion phase of MCTS? I'm confused regarding a specific detail of MCTS.\nTo illustrate my question, let's take the simple example of tic-tac-toe.\nAfter the selection phase, when a leaf node is reached, the tree is expanded in the so-called expansion phase. Let's say a particular leaf node has 6 children. Would the expansion phase expand all the children and run the simulation on them? Or would the expansion phase only pick a single child at random and run simulation, and only expand the other children if the selection policy arrives at them at some later point?\nAlternatively, if both of these are accepted variants, what are the pros/cons of each one?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "By far the most common (and likely also the most simple / straightforward) implementation is to expand exactly one node in the Expansion Phase; specifically, the node corresponding to the very first state selected (semi-)randomly by the Play-Out Phase. This is also pretty much the bare minimum you have to do if you want any form of tree growing at all (which you do).\n\nOther variants are possible too, but are much less common. The variant you suggest in the question is to expand all the children of the final node encountered during the Selection Phase, and run a Play-Out for all of them. I am not familiar with any literature on such a strategy really, never tried that myself. Intuitively, I would expect it to perform very similarly, perhaps slightly worse. Essentially what this would do is that it moves the \"behaviour\" of the search algorithm slightly more towards Breadth-First Search behaviour, rather than Best-First search behaviour. You spend a bit less of your computation time in the Selection Phase, because every Selection Phase is followed up by for example 6 (or whatever branching factor you have) Play-Outs instead of just a single one. On average I'd expect this to be slightly worse, because the Selection Phase is the primary source of the \"Best-First Search\" behaviour of the algorithm. I certainly don't expect a change like this to cause a large difference in performance though, if any. It will also likely be domain-dependent; worse in some cases, better in other cases.\n\nA different variant that I did once use myself is to expand every node in the complete line of play followed by the Play-Out phase. You can visualize this as a very \"thin\", but \"deep\" expansion, whereas your suggestion discussed above would be visualized as a \"shallow\" but \"wide\" expansion (and the conventional expansion strategy of a single node would be \"thin\" and \"shallow\").\nFor this strategy, it is much easier to clearly define the advantages and disadvantages that it has in comparison to the standard strategy. The main advantage is that you retain more information from your Play-Outs, you throw less information away. This is because the Backpropagation phase, after the Play-Out terminates, can only store information in nodes that exist. If you immediately expand the complete line of play followed in the Play-Out Phase, you can store the result (the evaluation in the terminal state) in all of those nodes. If you don't expand the complete Play-Out (e.g. only expand the very first node), you'll have to \"skip\" all of those nodes which you didn't expand yet (they don't exist), and you can't store results in there yet.\nThe main disadvantage of this approach is that it requires more memory, the tree grows a lot more quickly.\nI would personally recommend this approach if you have very strict limitations on computation time, if you expect to be able to only run very few iterations of the MCTS algorithm. For example, I personally used this in my General Video Game AI agent; this is a real-time game where you have to make decisions every ~40 milliseconds. In such a low amount of time, you cannot run many MCTS simulations. This means that:\n\nYou do not expect to run out of memory, even if you grow your tree very quickly, so the increased memory requirements become a non-issue.\nDue to the low expected number of iterations, it is extremely important to retain as much information as possible, not throw any information away. If we can't run many simulations, we want to make sure to squeeze every little bit of information we can out of each of them.\n\nFor contrast, if you're developing an agent to play a board game, and it has in the order of multiple minutes of thinking time per turn, the standard approach of only expanding a single node per Expansion Phase becomes a lot more appealing. If you're capable of running tens of thousands of iterations or more, it really doesn't hurt if you \"forget\" about a little bit of information deep down in the tree. The risk of running out of memory also becomes a lot more serious if you're running many iterations, so you don't want to grow the tree too quickly.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Given enough computational resources, do we currently have any algorithms which could achieve AI? Hypothetically, assume that you have access to infinite computing power. Do we have designs for any brute-force algorithms that can find an AI capable of passing traditional tests (e.g. Turing, Chinese Room, MIST, etc.)? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "What 'infinite' means here could possibly be debated at some length, but that notwithstanding, here are two conflicting answers:\n'Yes': Simulate all possible universes. Stop when you get to one containing a flavor of intelligence that passes whatever test you have in mind. Steven Wolfram has suggested something broadly along these lines. Problem: the state of computational testing for intelligence e.g. Winograd schema would then be the bottleneck. In the limit, testing for intelligence requires intelligence and creativity on behalf of the questioner.\n'No': It may be that, even with infinite ability to simulate, there may be some missing aspect of our simulation that is necessary for intelligence. For example, AFAIK quantum gravity (for which we lack an adequate theory) is involved in Penrose's \"Quantum Microtubules\" theory of consciousness (*). What if that was needed, but we didn't know how to include it in the simulation?\nThe reason for talking in terms of such incredibly costly computations as 'simulate all possible universes' (or at least a brain-sized portion of them) is to deliberately generalize away from the specifics of any techniques currently in vogue (DL, neuromorphic systems etc). The point is that we could be missing something essential for intelligence from any of these models and (as far as we know from our current theories of physical reality) only empirical evidence to the contrary would tell us otherwise.\n(*) No-one knows if consciousness is required for Strong AI, and physics can't distinguish a conscious entity from a Zombie.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the differences in scope between statistical AI and classical AI? What are the differences in scope between statistical AI and classical AI?\nReal-world examples would be appreciated.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Statistical AI, arising from machine learning, tends to be more concerned with inductive thought: given a set of patterns, induce the trend.\nClassical AI is the branch of artificial intelligence research that concerns itself with attempting to explicitly represent human knowledge in a declarative form, i.e given a set of constraints, deduce a conclusion.\nAnother difference is that C++, Python, and R tend to be a favorite language for statistical AI, while LISP and PROLOG dominate in classical AI.\nA system can't be more intelligent without displaying properties of both inductive and deductive thought. This leads many to believe that, in the end, there will be some kind of synthesis of statistical and classical AI.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What exactly are partially observable environments? I have trouble understanding the meaning of partially observable environments. Here's my doubt.\nAccording to what I understand, the state of the environment is what precisely determines the next state and reward for any particular action taken. So, in a partially observable environment, you don't get to see the full environment state.\nSo, now, consider the game of chess. Here, we are the agent and our opponent is the environment. Even here we don't know what move the opponent is going to take. So, we don't know the next state and reward we are going to get. Also, what we can see can't precisely define what is going to happen next. Then why do we call chess a fully observable game?\nI feel I am wrong about the definition of an environment state or the definition of fully observable, partially observable. Kindly correct me.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First, note that the current state does not determine the next state. What determines the next state are the dynamics of the environment, which, in the context of reinforcement learning and, in particular, MDPs, are encoded in the probability distribution $p(s', r \\mid s, a)$. So, if the agent is in a certain state $s$, it could end up in another state $s'$, but this is not only determined by being just in $s$, but also by $a$ (the action that you take in $s$) and $p$ (the dynamics of the environment).\nNow, in their 3rd edition of the AIMA book, Russell and Norvig define fully observable environments as follows.\n\nFully observable vs. partially observable: If an agent's sensors give it access to the complete state of the environment at each point in time, then we say that the task environment is fully observable. A task environment is effectively fully observable if the sensors detect all aspects that are relevant to the choice of action; relevance, in turn, depends on the performance measure. Fully observable environments are convenient because the agent need not maintain any internal state to keep track of the world. An environment might be partially observable because of noisy and inaccurate sensors or because parts of the state are simply missing from the sensor data\u2014for example, a vacuum agent with only a local dirt sensor cannot tell whether there is dirt in other squares, and an automated taxi cannot see what other drivers are thinking. If the agent has no sensors at all then the environment is unobservable.\n\nThis definition is also the common definition used in reinforcement learning. So, to determine whether an environment is fully or partially observable, you need to determine whether you have or not full access to a (Markovian) state or what constitutes a state in your case. You can consider chess fully observable because you have access to the configuration of the board, so, in theory, you can take optimal action by considering all possible moves of the opponent (but, of course, in practice, not even AlphaZero does this). See figure 2.6, p. 45, of the AIMA book (3rd edition) for more examples of fully and partially observable environments.\nA partially observable MDP (POMDP) is a mathematical framework that can be used to model partially observable environments, where you maintain a probability distribution over the possible current (or next) state that the agent may be in.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the advantages of the Kullback-Leibler over the MSE/RMSE? I've recently encountered different articles that are recommending to use the KL divergence instead of the MSE/RMSE (as the loss function), when trying to learn a probability distribution, but none of the articles are giving a clear reasoning why the first is better than the others.\nCould anyone give me a strong argument why the KL divergence is suitable for this?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In the context of Variational Inference (VI): the KL allows you to move from the unknown posterior $p(z \\mid x)$, to the known joint $p(z,x)=p(x|z)p(z)$ and optimize only the ELBO. You cannot do this with L2.\n$p(z|x)$ is the desired posterior, of which you cannot calculate the evidence (i.e., using Bayes formula we can set: $p(z|x) = \\frac{p(x|z)p(z)}{\\int_z p(x|z)p(z)dz}$, and you can't calculate the integral in the denominator [also denoted by $p(x)$] due to it's intractability).\nNow suppose $q$ is a Variational distribution (e.g. a family of Gaussians which you can control), VI tries to approximates $p(z|x)$ by $q$ by minimizing their KL divergence.\n$$KL(q(z)||p(z|x)) = \\int_z q(z) \\log \\frac{q(z)}{p(z|x)}dz = \\mathbb E_q[\\log q(z)]-\\mathbb E_q[\\log \\frac{p(x|z)p(z)}{p(x)}] =$$\n$$ -\\mathbb E_q[\\log p(x|z)p(z)] + \\mathbb E_q[\\log q(z)] + \\mathbb E_q[\\log p(x)] = -ELBO(q) + \\log p(x)\n$$\nSince you're only optimizing $q$ (it's the only thing you can control), you can discard the unknown and difficult to compute normalizing constant $p(x)$.\nIf you would use the (squared) L2 norm you would get:\n$$\\int_z [q(z)-p(z|x)]^2dz = \\int_z [q^2(z)-2q(z)p(z|x)+p^2(z|x)]dz $$\nWhile the 3rd term doesn't depend on q, the 2nd term does, and it also requires $p(x)$ to compute.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do I know when to use which Monte Carlo method? I'm a bit confused with extensive number of different Monte Carlo methods such as:\n\nHamiltonian/Hybrid Monte Carlo (HMC),\nDynamic Monte Carlo (DMC),\nMarkov chain Monte Carlo (MCMC),\nKinetic Monte Carlo (KMC),\nDynamic Monte Carlo (DMC)\nQuasi-Monte Carlo (QMC),\nDirect Simulation Monte Carlo (DSMC),\nand so on.\n\nI won't ask for the exact differences, but why are all of them called Monte Carlo? What do they all have in common? Can they all be used for AI? E.g. which one can be used for gaming (like Go) or image recognition (resampling)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "They are all called Monte Carlo because all of them are a different version of the canonical Monte Carlo algorithm.\nThe canonical version of Monte Carlo algorithm is a stochastic algorithm to determine an action based in a tree representation. The differences among all these version are their exploration and exploitation mechanisms, and it is necessary to analyse each of them to define which one fits in your case. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can this tic tac toe program be considered AI? I coded a tic tac toe program, but I don't know if I can call it artificial intelligence.\nHere's what I did.\nThere is a random player, which always makes random valid moves.\nAnd then there is the AI player, which will receive input before every move, that input is the state of the board, and all the posibilities.\nThe AI, will try any move that it hasn't tried before. But if it knows every possibility, it will select the one that has the higher value.\nThis value is assigned by the outcome of the match, if the match was won ,+1, 0 for draw, -1 for lose.\nEvery move, will be stored in a database, or updated if it's known.\nEventually it will know every possible move.\nI also added a threshold to compare the best moves, so it really select the best move. Example, two moves with a value of 100, the AI will keep trying them both, randomly until one has surpased the other by the threshold, say 50.\nIt takes about 20.000 games to make the AI perfect, it never loses a game, just draws and wins.\nI'm new to AI, and I'm wondering, could this be really considered Artificial Intelligence?\nAnd how is this different from a Neural Network approach? (I'm been reading about it, but I still don't quite get it.)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This is basically reinforcement learning. The state space contains your moves, and the value function are the value you store at the end. And your rewards are the end results. And you have episodic game. It is an AI method. Consider looking at value iteration, policy iteration, SARSA, Q-learning. The difference between neural network method and yours is you are not doing function approximation with neural network for the value function, you are doing tabular method.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the effect of parallel environments in reinforcement learning? Do parallel environments improve the agent's ability to learn or does it not really make a difference? Specifically, I am using PPO, but I think this applies across the board to other algorithms too.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nDo parallel environments improve the agent's ability to learn or does it not really make a difference?\n\nYes they can make a difference. There are two ways improvement is seen:\n\nCollecting data from multiple trajectories at once reduces correlation in the dataset. This improves convergence for online learning systems like neural networks, which work best with i.i.d. data.\n\nData collection is faster overall, which improves clock time to obtain the same result. This may make better use of other resources too.\n\n\nOf the two, the first improvement is important for stability, although it can be emulated by running multiple episodes - or restarting from multiple starting points - between batch learning updates.\n\nSpecifically, I am using PPO, but I think this applies across the board to other algorithms too.\n\nIt does apply to PPO, but the first improvement does not apply across the board. These things need to be true for environment run in paralell to be help with stability:\n\nUsing an on-policy method, or where experience replay is not an option.\n\nUsing a function approximator for policy and/or value function.\n\n\nA lot of policy gradient methods match this, including PPO, A3C, REINFORCE. However, for an off-policy method like DQN, the main benefit will be faster data collection.\nThese effects are discussed in sections 1 and 4 of the paper Asynchronous Methods for Deep Reinforcement Learning which introduced A3C - thanks to DeepQZero for that reference.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What algorithm to use for completely randomized pokemon battles? I'm currently playing around with a pokemon battle simulator where the pokemon's stats & abilities and movesets are completely randomized. Each move itself is also completely randomized (meaning that you can have moves with 100 power, 100 accuracy, aswell as a trickroom and other effects). You can imagine the moves as huge vectors with lots of different features (power, accuracy, is trickroom toggles?, is tailwind toggled?, etc.). So there are theoretically an infinite amount of moves (accuracy is a real number between 0 and 1), but each pokemon only has 4 moves it can choose from. I guess it's kind of a hybrid between a continous and discrete action space.\nI'm trying to write a reinforcement learning agent for that battle simulator. I researched Q-Learning and Deep Q-Learning but my problem is that both of those work with discrete action spaces. For example, if I actually applied tabular Q-Learning and let the agent play a bunch of games it would maybe learn that \"move 0 is very strong\". But if I started a new game (randomize all pokemon and their movesets anew), \"move 0\" could be something entirely different and the agent's previously learned Q-values would be meaningless... Basically, every time I begin a new game with new randomized moves and pokemon, the meaning and value of the availabe actions would be completely different from the previously learned actions.\nIs there an algorithm which could help me here? Or am I applying Q-Learning incorrectly?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Tabular Q Learning would not work for your project, but deep Q learning or similar would work.\nAn action in reinforcement learning (RL) is only defined by the direct controllable choices available to the agent, not the attributes associated with those actions. If some value - e.g. the accuracy of a pokemon's attack - cannot be controlled by the agent then it is not part of the action. It's a consequence of the action, and in general part of the environment.\nSo how should you model the differences between the randomised moves? They should be part of the state, along with any other general and current attributes of each pokemon. This is still going to be a large space for the agent to explore, but it is part of the state space, not the action space. The large state space will be too much for tabular Q learning, but deep Q learning should be fine.\nIt will take a lot of trials to learn this task due to all the possible variations. Your modelling choices for the move descriptions will make an impact on this, but figuring out what will work best will take some extended experimentation.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the probability of selecting the greedy action in a 0.5-greedy selection method for the 2-armed bandit problem? I'm new to reinforcement learning and I'm going through Sutton and Barto. Exercise 2.1 states the following:\n\nIn $\\varepsilon$-greedy action selection, for the case of two actions and $\\varepsilon=0.5$, what is the probability that the greedy action is selected?\n\nThey describe the $\\varepsilon$-greedy method on pages 27-28 as follows:\n\n...behave greedily most of the time, but every once in a while, say with small probability $\\varepsilon$, instead select randomly from among all the actions with equal probability...\n\nThe above method makes the agent select an action randomly \"every once in a while\" from the action space uniformly with probability $\\varepsilon$. I find the question imprecise since we don't know the \"once in a while\" in this exercise (i.e. is it once every $50$ timesteps? every time step?). If it's for every timestep, isn't it like a Bernouli problem where the parameter is $0.5$? I'd say that the agent has a $0.5$ chance to select a greedy action but I'm not sure at all.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I read section 2.2 of Sutton and Barto, and I understand your confusion: the $\\epsilon$-greedy algorithm is not defined precisely on page 27-28. Selecting an action randomly \"every once in awhile\" with probability $\\epsilon$ means selecting an action randomly with probability $\\epsilon$ at each timestep and selecting an action greedily with probability $1-\\epsilon$ at each timestep. This definition is standard and will be clear as you progress through the book and other relevant literature. For reference, the $\\epsilon$-greedy algorithm is used in the pseudocode on page 32 of Sutton and Barto.\nThe key distinction in this problem is that it's asking for the probability that the greedy action is selected, NOT the probability that an action is selected greedily. Specifically, the greedy action can be selected when the agent selects an action randomly because the greedy action is in the action space and the entire action space is sampled uniformly when selecting an action randomly.\nSince $\\epsilon=0.5$, the agent will select an action greedily 50% of the time, which will 100% of the time be the greedy action. The agent will select an action randomly the other 50% of the time. Since there are two actions in the action space, the greedy action will be selected 50% of the time when the agent selects an action randomly. Therefore, the probability that the greedy action is selected at any single timestep is as follows:\n\\begin{align}\n &p(\\mbox{greedy action}) \\\\\n=\\ &p(\\mbox{greedy action AND greedy selection}) + p(\\mbox{greedy action AND random selection})\\\\\n=\\ &p(\\mbox{greedy selection}) \\cdot p(\\mbox{greedy action}\\ |\\ \\mbox{greedy selection}) \\\\ \n&\\hspace{1em}+ p(\\mbox{random selection})\\cdot p(\\mbox{greedy action}\\ |\\ \\mbox{random selection})\\\\\n=\\ &(1-\\epsilon) \\cdot p(\\mbox{greedy action}\\ |\\ \\mbox{greedy selection}) + \\epsilon \\cdot p(\\mbox{greedy action}\\ |\\ \\mbox{random selection})\\\\\n=\\ &0.5 \\cdot p(\\mbox{greedy action}\\ |\\ \\mbox{greedy selection}) + 0.5 \\cdot p(\\mbox{greedy action}\\ |\\ \\mbox{random selection})\\\\\n=\\ &0.5 \\cdot 1 + 0.5 \\cdot 0.5 \\\\ \n=\\ &0.5+ 0.25 \\\\ \n=\\ &0.75.\n\\end{align}\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between policy and action in reinforcement learning? I'm confused with the two terminology - action and policy - in Reinforcement Learning. As far as I know, the action is:\n\nIt is what the agent makes in a given state.\n\nHowever, the book I'm reading now (Hands-On Reinforcement Learning with Python) writes the following to explain policy:\n\nwe defined the entity that tells us what to do in every state as policy.\n\nNow, I feel that the policy is the same as the action. So what is the difference between the two, and how can I use them apart correctly?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A policy is a function that maps states to a probability distribution over all possible actions. \nSo, in a typical Atari game, there might just be a handful of actions, represented by the keys that are used to play the game. In this context, the policy of a reinforcement learner might be represented by a pretty complex neural network that gets pixels as input and gives action probabilities as output. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does a neural network exist that can learn every possible training data? The universal approximation theorem states, that a feed-forward network with a single hidden layer containing a finite number of neurons can approximate continuous functions on compact subsets of $R^n$.\nMichael Nielsen states\n\nNo matter what the function, there is guaranteed to be a neural network so that for every possible input, $x$, the value $f(x)$ (or some close approximation) is output from the network.\n\nSo, for continuous functions, this seems plausible. Interestingly, in the same article, Nielsen mentioned \"any function\".\nLater, he writes\n\nHowever, even if the function we'd really like to compute is discontinuous, it's often the case that a continuous approximation is good enough.\n\nThe last statement leaves open a gap, to ask how well an approximation practically can be.\nLet's ignore contradictory input/output training pairs like $f(0)=0$ and $f(0)=1$, which actually don't event represent a function anyway.\nFurthermore, assume that the training data is generated randomly, which would practically result in a discontinuous function.\nHow does a neural network learn such data? Will a learning algorithm always be able to find a neural network that approximates the function represented by the input-output pairs?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The branch of AI research that answers questions like this is called computational learning theory.\nFor the specific question you have asked, the universal approximation theorem does indeed prove that any function can be modeled by a sufficiently wide neural network. The definition of a function includes the requirement that each input be mapped to exactly one output, so contradictory labels in training data are excluded explicitly.\nHere is a rough sketch that can provide an intuition behind why this is true. This is not a proper proof, but it gives you an idea of the power of \"finite number of neurons\" in a hidden layer:\n\nA single neuron can essentially learn to draw a straight line across the space of input features. It outputs a value arbitrarily close to 1 for things on one side of the line, and arbitrarily close to 0 for things on the other side of the line.\nFor any given datapoint, it is possible to enclose the hyper-volume containing that datapoint, and no others by drawing a series of lines in the input space, and defining one side of each line as \"inside\" the hyper-volume, and the other side as \"outside\". In 2-d space, this corresponds to drawing the 4 sides of a square around a point.\nAn output neuron learns to draw lines across the outputs of the hidden layer neurons. It can therefore decide to output 1 only when, say, 4 other neurons are all simultaneously active. \n\nIt should seem natural then that a sufficiently wide neural network can memorize all of an input pattern. Since memorization is sufficient for \"learning\" to fit a pattern this should give you an intuition for the ability of neural networks to fit things.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there a logical method of deducing an optimal batch size when training a Deep Q-learning agent with experience replay? I am training an RL agent using Deep-Q learning with experience replay. At each frame, I am currently sampling 32 random transitions from a queue which stores a maximum of 20000 and training as described in the Atari with Deep RL paper. All is working fine, but I was wondering whether there is any logical way to select the proper batch size for training, or if simply using a grid search is best. At the moment, I\u2019m simply using 32, for its small enough that I can render the gameplay throughout training at a stunning rate of 0.5fps. However, I\u2019m wondering how much of an effect batch size has, and if there is any criteria we could generalize across all Deep Q-learning tasks.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is no special calculation you can do to determine the optimal batch size for any situation, so you kinda have to do a bit of testing to determine what batch size will work best. But there are some common trends you can take into account to make your testing easier.\n\nHow to choose your batch size\nAccording to the paper Accelerated Methods for Deep Reinforcement Learning you get the best performance from DQNs (on average) with a batch size of 512. The problem with this is that is is much slower than the usual batch size of 32 and most of the time the performance improvement doesn't warrant it.\n\nIf you are just trying to test out your agents it is generally best to stick with a batch size of 32 or 64 so that you can train the agent quickly yet still get an idea of what it is capable of. But if getting the best performance is your top priority and waiting longer isn't a problem, then you should go for a batch size of 512 (higher can actually lead to worse performance) or something near that.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which situation will helpful using encoder or decoder or both in transformer model? I have some questions about using (encoder / decoder / encoder-decoder) transformer models, included (language) transformer or Vision transformer.\nThe 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, for what purpose do model designers use only encoders, only decoders, or both?\nI already knew that encoders in transformers are as known as taking in a sequence of input data and generates a fixed-length representation of it. This representation can then be fed into the decoder to generate an output sequence.\nIn other words, the encoder can be thought of as a kind of compression that extracts features from the data. And the decoder can be thought of as playing a role in returning the compressed information in the encoder to its original state.\nSo I'm wondering why some models work without having both an encoder and a decoder.\nFew days ago, I think use only encoders are useful to classifying classes. Because DOSOVITSKIY, Alexey, et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020. paper shows only encoder to classification images. Decoders are useful in generative things, because WANG, Jianfeng, et al. Git: A generative image-to-text transformer for vision and language. arXiv preprint arXiv:2205.14100, 2022. paper using encoder to encode the visual information from the input image into a representation that can be used by the text decoder to generate text. Then, to generate text, they give the 'encoder's output and the text' as the decoder's input.\nBut, I am sure about that my think are wrong because of BERT and GPT. BERT using encoder and does not have a decoder. GPT uses decoder and does not have a encoder. A typical user thinks that BERT and GPT equally answer the question asked by the user. So they think BERT and GPT provide the same service. However, in terms of model structure, BERT and GPT are completely different.\nSo, I have two questions about each functional part that makes up the transformer.\n\nwhat does encoder and decoder do in transformer? The transformer referred to here can be text or image.\nFor what purpose do model designers use only encoders, only decoders, or both encoders and decoders?\n\nThank you.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The original transformer paper 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 encoder or only of a decoder. That's fine as long as you know what exactly is going on.\n(I would say that the distinctive feature of the transformer model is the attention layer.)\nFor example, as you mentioned, Generative Pretrained Transformer (GPT) is a decoder-only model, and Vision Transformer (ViT) is an encoder-only model.\nI feel like your question already contains the answer :)\nYes, encoders are used exactly for that - encoding (or compressing) the input. Note that the output sequence from the encoder has the same length as the input sequence. This is why encoder-only models cannot be used for tasks where the output sequence has a different length or unknown length, e.g. machine translation, text summarization. In these cases you need the decoder.\nEncoder-only models like ViT and BERT will encode the input sequence and produce an output sequence of the same length. Then for classification they will use only the first element of the output sequence.\n\nAs I said, encoder-only models cannot be used for generating an output sequence of different (or unknown) length, i.e. BERT cannot be used for machine translation or generative question answering. BERT can only be used for question answering on SQuAD-type datasets, i.e. your answer is a continuous segment from the input and the model only outputs and to mark it.\nFor generation tasks you need a decoder. The decoder is actually an auto-regressive model. It will generate the elements of the output sequence one-by-one until it decides that the sequence is ready and then it generates the final token. See here.\nPreviously people used an encoder-decoder architecture to solve these sequence-to-sequence tasks (e.g. T5). You want the encoder to encode your input sequence and the decoder to decode it and produce the output sequence. However, it turns out that you can use a decoder-only model. You simply concatenate your source and target sentences and treat the task as a language modelling task. Now there are pros and cons to this approach, but the main takeaway is that you can do it if you want to.\nYou can checkout these papers to read more about encoder-decoder vs decoder-only models for sequence to sequence tasks:\nhttps://arxiv.org/pdf/2304.04052.pdf\nhttps://aclanthology.org/2022.aacl-main.43.pdf\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "In NEAT, is it a good idea to give the same ID to node genes created from the same connection gene? Do I have to prevent nodes created from the same connection gene to have different IDs/innovation number? In this example, the node 6 is created from the connection going from node 3 to node 4:\n\nIn the case where that specific node was already globally created, is it useful to give it the same ID for crossover? Because the goal of NEAT is to do meaningful crossover by doing historical marking. The paper from Kenneth O. Stanley says at page 108:\n\n[...] by keeping a list of the innovations that occurred in the current generation, it\n is possible to ensure that when the same structure arises more than once through independent mutations in the same generation, each identical mutation is assigned the\n same innovation number.\n\nWhy don't we do that for node genes too?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In NEAT, the innovation of a node does not affect the evolution directly. Only the connection genes and their innovation will matter. So you can simply have whole numbers as IDs under each Genome / Network.\n--EDIT-- (Complete reasoning)\nIn the original paper, it is clearly stated that the nodes from the better genome is taken during crossover and then only the connections are cross-over'ed (in some method) and hence the innovation numbers for the connections. NEAT is connection-centric and does not care much about evolving nodes.\nAdding to that from basic neural networks theory, the nodes will never matter in a neural network because all the calculation and the learning happens in the connections. Think about a regular feed-forward network. You only care about the weight matrix which is a property of the connections instead of the nodes though both are present. Similarly in a NEAT generated network, the nodes will not matter, as all the learning takes place in the way these nodes are connected and the weights of the network.\nFurther, the nodes list can easily be derived from the connection list and hence marking the connections, are enough.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the formula used to calculate the loss in the FaceNet model? The FaceNet model returns the loss of the predictions and ground-truth classes. How is this loss calculated?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The loss function used is the triplet loss function. \n\nLet me explain it part by part.\nNotation\nThe $f^a_i$ means the anchor input image. The $f^p_i$ means the postive input image, which corresponds to the same people as the anchor image. The $f^n_i$ corresponds to the negative sample, which is a different person(input image) then the anchor image. \nThe formula explained step by step\nThe first part, $||f^a_i - f^p_i||^2_2$ basically calculates the distance between the anchor image output features and the postive image output features, which you want the distance to be as small as possible as the input is the same person. For the second part, $||f^a_i - f^n_i||^2_2$ , it calculates the distance of the output features of the anchor image and the negative image. You wnat the distance to be as large as possible as they are not the same person. Finally, the $\\alpha$ term is a constant(hyperparameter) that adds to the loss to prevent negative loss. \nHow it works\nThe loss function optimizes for the largest distance between the anchor and negative sample and the smallest distance of the positive and anchor sample. It cleverly combines both metrics into one loss function. It can optimize for both case simultaneously in one loss function. If there is no negative sample, the model will not be able to differciate different person and vice versa.\nHope I can help you and have a nice day!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why are neural networks preferred to other classification functions optimized by gradient decent Consider a neural network, e.g. as presented by Nielsen here. Abstractly, we just construct some function $f: \\mathbb{R}^n \\to [0,1]^m$ for some $n,m \\in \\mathbb{N}$ (i.e. the dimensions of the input and output space) that depends on a large set of parameters, $p_j$. We then just define the cost function $C$ and calculate $\\nabla_p C$ and just map $p \\to p - \\epsilon \\nabla_p C$ repeatedly.\nThe question is why do we choose $f$ to be what it is in standard neural networks, e.g. a bunch of linear combinations and sigmoids? One answer is that there a theorem saying any suitably nice function can be approximated using neural networks. But the same is true of other types of functions $f$. The Stone-Weierstrass theorem gives that we could use polynomials in $n$ variables: $$f(x) = c^0_0 + (c^1_1 x_1 + c^1_2 x_2 + \\cdots + c^1_n x_n) + (c^2_{11}x_1 x_1 + c^2_{12} x_1x_2 + \\cdots + c^2_{1n} x_1 x_2 + c^2_{21} x_2x_1 + c^2_{22} x_2x_2 + \\cdots) + \\cdots,$$\nand still have a nice approximation theorem. Here the gradient would be even easier to calculate. Why not use polynomials?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You can indeed fit a polynomial to your labelled data, which is known as polynomial regression (which can e.g. be done with the function numpy.polyfit). One apparent limitation of polynomial regression is that, in practice, you need to assume that your data follows some specific polynomial of some degree $n$, i.e. you assume that your data has the form of the polynomial that you choose, which may not be true.\nWhen you use a neural network to solve a classification or regression problem, you also need to choose the activation functions, the number of neurons, how they are connected, etc., so you also need to limit the number and type of functions that you can learn with neural networks, i.e. the hypothesis space.\nNow, it is not necessarily a bad thing to limit the hypothesis space. In fact, learning is generally an ill-posed problem, i.e. in simple terms, there could be multiple solutions or no solutions at all (and other problems), so, actually, you often need to limit the hypothesis space to find some useful solutions (e.g. solutions that generalise better to unseen data). Regularisations techniques are ways of constraining the learning problem, and the hypothesis space (i.e. the set of functions that your learning algorithm can choose from), and thus making the learning problem well-posed.\nNeural networks are not preferred over polynomial regression because they are theoretically more powerful. In fact, both can approximate any continuous function [1], but these are just theoretical results, i.e. these results do not give you the magical formula to choose the most appropriate neural network or polynomial that best approximates the desired unknown function.\nIn practice, neural networks have been proven to effectively solve many tasks (e.g. translation of natural language, playing go or atari games, image classification, etc.), so I would say that this is the main reason they are widely studied and there is a lot of interest in them. However, neural networks typically require large datasets to approximate well the desired but unknown function, it can be computationally expensive to train or perform inference with them, and there are other limitations (see this), so neural networks are definitely not perfect tools, and there is the need to improve them to make them more efficient and useful in certain scenarios (e.g. scenarios where uncertainty estimation is required).\nI am not really familiar with research on polynomial regression, but it is possible that this and other tools have been overlooked by the ML community. You may want to have a look at this paper, which states that NNs are essentially doing polynomial regression, though I have not read it, so I don't know the details about the main ideas and results in this paper.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does AI 'see' the images it generates- from what perspective? I've been using AI image generation for a while now, and I've noticed how profoundly AI doesn't seem to see the image as a whole, sometimes generating an image with parts of fingers floating near objects supposed to be being held, VERY warped perspective, and of course, extra fingers and occasionally legs. I also notice that by negative prompting 'extra/distorted limbs' (or similar)it often solves the problem, so it appears that there must be some sort of awareness of what is happening in the image. Stable Diffusion being open source and thus available for analysis, why would AI specifically have this as a common problem?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Let's start from the problem associated with generating details in images, probably as old as computer vision itself.\nConsider an image of a person of classic size 512x512 pixels, one finger in that image will probably consists only of 10 of those pixels. Whatever loss you might use, the contribution coming from the reconstruction of 10 pixels will be most of the time irrelevant compare to the contribution coming from other elements in the image. Let's also remember that most architectures today rely on convolutions, meaning that those 10 pixels will be averaged together trough some pooling operation, making them count even less. This should give the overall idea about way in general even state of the art models fails with high details.\nDiffusion models add even more complexity to the overall picture because they start from random noise and they iteratively subtract a different noise distribution learned during training to produce something that make sense. So not only they have the hard task to learn details, they also have to learn to distinguish between noise that's actual noise to remove, and details that sometimes do resemble noise but that we want to keep.\nTo understand the connection between noise and details it useful to know that in the literature image details are often referred to as high frequency functions. It's actually an on point definition rather than just an analogy. The frequency of a wave relates to its wavelength, basically how much space it need to complete a full cycle, in an image you can think of the frequency of an element exactly the same way, i.e. how much space in the image the element need to end or repeat itself (I know it more complicated than this, but we care about the gist). This very nice paper shows how it become suddenly easy for simple architectures to reconstruct high details when random Fourier transformation are used for feature extraction (basically high frequency random functions). The image below is taken from the paper. This unfortunately comes with huge increase in computational power and it not a real feasible solution for large models like stable diffusion.\n\nOne last consideration should be done about the negative prompts. Unlike purely visual models, text to image models try to learn a semantic latent space, i.e. they try to associate specific latent vectors with elements that the output image have (during training) or should have (during inference). Moreover, this latent space for the most part have nice geometric properties, like vectors of word of opposite meaning have opposite direction. Now, stating that something should be in the generated image gives absolutely total freedom to a model about extra elements that could be potentially present. The weights of a model are always used all at once, the text prompt simply causes some weight vectors in the latent space to have more impact than others. This is why negative prompt are an easy solution to remove artefacts (to some extent), you're just constraining the model more. The model has already learned that most of the times a hand has 5 finger, but since a hand it's a rather detailed element to generate and because it's not explicitly sated in the prompt that we want 5 fingers, a model has more than enough space for random manoeuvre to end up generating aberrations.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to detect frauds in advertising business using machine learning? I am very beginner to this world. I still learning the basics of Machine learning and AI but i have a problem at hand and i am not sure which technique or Algorithm can be applied on it.\nI am working on Click-Fraud detection in advertising. I need to predict fraud and learn new frauds with ML.\nThe dataset I have is the view and click logs from adserver(Service Provider). This data have some fields few of them are listed below:\n\"auction_log_bid_id\": null, \n\"banner\": 9407521, \n\"browser\": 0, \n\"campaign\": 2981976, \n\"city\": 94965, \n\"clickword\": null, \n\"content_unit\": 4335438, \n\"country\": 1, \n\"external_profiledata\": {}, \n\"external_user_id\": null, \n\"flash_version\": null, \n\"id\": 6665230893362053181, \n\"ip_address\": \"80.187.103.98\", \n\"is_ssl\": true, \n\"keyword\": \"string\"\n\"mobile_device\": -1, \n\"mobile_device_class\": -1, \n\"network\": 268, \n\"new_user_id\": 6665230893362118717, \n\"operating_system\": 14, \n\"profile_data\": {}, \n\"referrer\": null, \n\"screen_resolution\": null, \n\"server_id\": 61, \n\"state\": 7, \n\"target_url\": \"string\"\n\"timestamp\": 1551870000, \n\"type\": \"CLICK_COMMAND\", \n\"user_agent\": \"Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16D57\", \n\"user_id\": null, \n\"view_log_id\": null\n\nThere are other fields.\nI need to analyse these logs to find patterns for possible frauds but i am not sure where to start and which technique to use. e.g. Supervised, Unsupervised Semi-Supervised or Reinforcement Learning.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I could give you my $0.02 on fraud detection.\n\nRead everything you can on the Equifax breach and seek to secure your data\nBenfords Law would be a good place to start\nIf you can isolate log activity that is inhumanly consistant, if you \"ip_address\", \"id\" and/or \"timestamp\" all show a constant 3 second gap between activity or its always a random choice between 3 and 6 seconds between them.\n\nIf you plan on investing the time and resources that ML or Ai require, you will need to isolate \"good data\" as training data and train your model on that. Perhaps you could get the IP address of your known top 10 customers and include that.\nThen begin training with that as your sample data, with keeping your test data seperate.\nI'm sure there is alot more but I would need to know context of the info provided in terms of what kind of fraud you are looking for, what you have tried or why they think there is fraud to be found.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does the notation $\\mathcal{N}(z; \\mu, \\sigma)$ stand for in statistics? I know that the notation $\\mathcal{N}(\\mu, \\sigma)$ stands for a normal distribution.\nBut I'm reading the book \"An Introduction to Variational Autoencoders\" and in it, there is this notation:\n$$\\mathcal{N}(z; 0, I)$$\nWhat does it mean?\npicture of the book:\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It means that $z$ has a (multivariate) normal distribution with 0 mean and identity covariance matrix. This essentially means each individual element of the vector $z$ has a standard normal distribution.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is it called back-propagation? While looking at the mathematics of the back-propagation algorithm for a multi-layer perceptron, I noticed that in order to find the partial derivative of the cost function with respect to a weight (say $w$) from any of the hidden layers, we're just writing the error function from the final outputs in terms of the inputs and hidden layer weights and then canceling all the terms without $w$ in it as differentiating those terms with respect to $w$ would give zero. \nWhere is the back-propagation of error while doing this? This way, I can find the partial derivatives of the first hidden layer first and then go towards the other ones if I wanted to. Is there some other method of going about it so that the Back Propagation concept comes into play? Also, I'm looking for a general method/algorithm, not just for 1-2 hidden layers. \nI'm fairly new to this and I'm just following what's being taught in class. Nothing I found on the internet seems to have proper notation so I can't understand what they're saying.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Have a look at the following article Principles of training multi-layer neural network using backpropagation. It was very useful to me. \nYou can also see here an example of backpropagation in Matlab. It effectively solves the XOR problem. You can also play around with the cost function or the learning rate. You may get surprising results! Does this answer your question?\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "DQN arXiv 10-year anniversary: What are the outstanding problems being actively researched in deep Q-learning since 2019? Background\nAs of today (12-19-2023), the arXiv submission of the original deep Q-learning approach to achieve superhuman performance on ATARI games has turned a decade old. The original approach, sometimes referred to as vanilla DQN (2013), was the focus of numerous research investigations and improvements throughout the ensuing 5 years (2014-2018), as evidenced by the following problems and examples:\n\nEstimation: Double DQN (DDQN, 2015) decouples action selection and estimation to prevent overestimation in the Q-values. Dueling DQN (2015) decouples the deep Q-network into separate state-value and action-value functions to achieve better policy evaluation in the presence of many similar-valued actions. Distributional DQN (2017) attempts to learn a value distribution to better model multimodal and nonstationary policies.\n\nEfficiency: Prioritized experience replay (PER, 2015) samples important transitions more frequently to increase learning speed. Learning from multi-step bootstrap targets such as in A3C (2016) was performed in RAINBOW DQN (2017) to help propagate newly observed rewards faster to earlier visited states, again for increased learning speed.\n\nGeneralization: Certain environmental additions such as sticky actions (2018) prevent the agent from memorizing trajectories and require some basic level of generalization. Techniques from standard deep learning such as batch normalization and regularization (2018) have shown to improve the agent's ability to generalize.\n\nParallelism: General Reinforcement Learning Architecture DQN (Gorila, 2015) presented the first massively distributed architecture for DQN, which reduced wall-clock training time. Ape-X DQN (2018) is a distributed algorithm that incorporates other DQN improvements such as prioritized experience replay to again lessen training time.\n\nMemory: Incorporating recurrent architectures such as LSTMs in deep recurrent Q-networks (DRQN, 2015) improves the agent's ability to learn and test on partially-observable environments. Recurrent replay distributed DQN (R2D2, 2018) incorporates an LSTM in a distributed architecture and presents training strategies to mitigate representational drift and recurrent state staleness caused by RNN architectures.\n\nExploration: Noisy networks (2017) inject stochasticity into the agent's policy to more efficiently explore. Random network distillation (RND, 2018) provides an exploration bonus based on the novelty of a state through its prediction error on a randomly-distilled predictor network that is continually trained on incoming states using a fixed target network for its target values.\n\n\n\nQuestion: What are the outstanding problems being actively researched in deep Q-learning throughout the past 5 years (2019-2023)?\nTo keep this question within the on-topic guidelines and reduce possible subjectivity, please cite relevant sources and briefly summarize the sources (e.g. with a cause-and-effect structure as in the above paragraphs). Also, only discuss sources that involve Q-learning.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Regarding estimation and sample efficiency:\n\nREDQ (2021): using a large ensemble of Q-functions can reduce the overestimation bias (likewise Double DQN) so much that it enables to update the Q-networks more often than the environment interactions (i.e., high update-to-data ratio), therefore achieving high sample-efficiency.\nDroQ (2022): improves over REDQ by also increasing the computational efficiency, thanks to the use of a small ensemble. This is possible by \"dropout Q-networks\", which use Dropout as an efficient way to introduce uncertainty in the Q-networks.\n\nThe concept of ensemble Q-functions is also useful in offline RL, where the goal is to learn a policy from a fixed dataset of experience:\n\nThis paper (2021) says that the uncertainty of the ensemble can be used to penalize the policy towards predicting actions that are out-of-distribution (OOD), due to an erroneously large Q-value.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why would someone use NEAT over other machine learning algorithms? Why would someone use a neuroevolution algorithm, such as NEAT, over other machine learning algorithms? What situation would only apply to an algorithm such as NEAT, but no other machine learning algorithm?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The main difference leading to strengths and weaknesses of NEAT algorithm, is that it does not use any gradient calculations. That means for NEAT, neither the cost function, nor the activation functions of the neurons are required to be differentiable. In some circumstances - e.g. where agents directly compete, and you can select them for next generation if they win versus one or more opponents - you may not even need a cost function to optimise. Quite often the cost function can be a simple number generated from a complex evaluation of the network. \nTherefore, NEAT can be used in situations where the formula for a cost function, in terms of single feed-forward runs of the network, is not very clear. It can also be used to explore activation functions such as step functions or stochastic firing neurons, where gradient based methods are difficult to impossible to apply.\nNEAT can perform well for simple control scenarios, as a policy network that outputs actions given some sensor inputs. For example, it is popular to use it to create agents for racing games or simulated robotics controllers. When used as a policy-based controller, NEAT is in competition with Reinforcement Learning (RL), and has basic similarities with policy gradient methods - the nature of the controller is similar and often you could use the same reward/fitness function.\nAs NEAT is already an evolution-inspired algorithm, it also fits well with a-life code as the \"brains\" of simulated creatures.\nThe main disadvantage of NEAT is slow convergence to optimal results, especially in complex or challenging environments. Gradient methods can be much faster, and recent advances in Deep RL Policy Gradients (algorithms like A3C and DDPG) means that RL can tackle much more complex environments than NEAT. \nI would suggest to use NEAT when:\n\nThe problem is easy to assess - either via a measurement of performance or via competition between agents - but might be hard to specify as a loss function\nA relatively small neural network should be able to approximate the target function\nThere is a goal to assess a non-differentiable activation function\n\nIf you are looking at a sequential control problem, and could use a standard feed-forward neural network to approximate a policy, it is difficult to say in advance whether NEAT or some form of Deep RL would be better. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Emulating human brain - with analogous NN chips Considering the answers of this question, emulating a human brain with the current computing capacity is currently impossible, but we aren't very far from it.\nNote, 1 or 2 decades ago, similar calculations had similar results.\nThe clock frequency of the modern CPUs seem to be stopped, currently the miniaturization (-> mobile use), the RAM/cache improvement and the multi-core paralellization are the main lines of the development.\nOk, but what is the case with the analogous chips? In case of a NN, it is not a very big problem, if it is not very accurate, the NN would adapt to the minor manufacturing differences in its learning phase. And a single analogous wire can substitute a complex integer multiplication-division unit, while the whole surface of the analogous printed circuit could work parallel.\nAccording to this post, \"software rewirable\" analogous circuits, essentially \"analogous FPGAs\" already exist. Although the capacity of the FPGAs is highly below the capacity of the ASICs with the same size, maybe analogous chips for neural networks could also exist.\nI suspect, if it is correct, maybe even the real human brain model wouldn't be too far. It would still require a massively parallel system of costly analogous NN chips, but it seems to me not impossible.\nCould this idea work? Maybe there is even active research/development into this direction?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I'm not sure about \"emulating the brain\" per-se, but in a more general sense there has been some thought given to using analog computing for AI/ML. It seems clear that analog computers do have certain advantages over digital computers. For one, they can (depending on the application) be faster, albeit at the cost of some loss of precision. But that's OK, because I don't think anybody believes the human brain is calculating floating point math using digital computing techniques either. The human brain appears, at least superficially, to be largely probabilistic and able to tolerate some \"slop\" numerically. \nThe downside to analog computers, as I understand it, is that they're not as flexible... you basically hardwire a circuit to do one specific \"thing\" and that's really all it can do. To change the \"programming\" you have to literally solder in a new component! Or, I suppose, adjust a potentiometer or adjustable capacitor, etc. Anyway, the point is that digital computers are supremely flexible, which is one big reason they came to dominate the world. But I can see where there could be room for going analog for discrete functions that make up some or all of an intelligent system.\nAs for research in the area, you might look into whatever DARPA was / is doing. There was an article in Wired a while back, talking about some DARPA initiatives related to analog computing. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why doesn't SiLU suffer from a worse version of a \"dying ReLU\" problem? Unlike ReLU, the derivative of SiLU is non-zero everywhere except at the global minimum. However, intuitively it seems like having a negative gradient when the input is very negative should be even worse than having a zero gradient, since the gradient update steps would go the wrong way. Why is this not a problem in practice?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Due to the definition of SiLU activation function, only slightly negative gradients in regions near $0$-valued input can cause weight updates that seem to be moving in the \"wrong\" direction.\nHowever, due to their generally small magnitudes, intuitively these updates are usually not large enough to drastically impact the optimization process. Moreover, the usual SGD optimization introduces a lot of noise into the gradient updates where the above occasional small wrong updates are usually overwhelmed by the noise and the model continues to learn effectively.\nAdditionally with batch normalization techniques, inputs are more likely to hover around zero, and the distribution of positive and negative gradients is balanced. This balance minimizes the negative impact of slightly negative gradients together with its everywhere-smooth property and increased computational cost compared to ReLU.\nFinally some level of oscillation in parameter updates can actually act as a form of (implicit) regularization, preventing the model from overfitting to a specific direction in the gradient landscape. This can help the model explore a broader region of the parameter space. In modern deep learning, overparameterization helps to absorb slight perturbations caused by negative gradients whose flexibility allows it to learn complex patterns even when some updates are counter-intuitive.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When should one prefer using Total Variational Divergence over KL divergence in RL In RL, both the KL divergence (DKL) and Total variational divergence (DTV) are used to measure the distance between two policies. I'm most familiar with using DKL as an early stopping metric during policy updates to ensure the new policy doesn't deviate much from the old policy.\nI've seen DTV mostly being used in papers giving approaches to safe RL when placing safety constraints on action distributions. Such as in Constrained Policy Optimization and Lyapunov Approach to safe RL.\nI've also seen that they are related by this formula:\n$$\nD_{TV} = \\sqrt{0.5 D_{KL}}\n$$\nWhen you compute the $D_{KL}$ between two polices, what does that tell you about them, and how is it different from what a $D_{TV}$ between the same two policies tells you?\nBased on that, are there any specific instances to prefer one over the other?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I did not read those two specified linked/cited papers and I am not currently familiar with the total variation distance, but I think I can answer some of your questions, given that I am reasonably familiar with the KL divergence.\n\nWhen you compute the $D_{KL}$ between two polices, what does that tell you about them\n\nThe KL divergence is a measure of \"distance\" (or divergence, as the name suggests) between two probability distributions (i.e. probability measures) or probability densities. In reinforcement learning, (stochastic) policies are probability distributions. For example, in the case your Markov decision process (MDP) has a discrete set of actions, then your policy can be denoted as $$\\pi(a \\mid s),$$which is the conditional probability distribution over all possible actions, given a specific state $s$. Hence, the KL divergence is a natural measure of how two policies are similar or different.\nThere are 4 properties of the KL divergence that you always need to keep in mind\n\nIt is asymmetric, i.e., in general, $D_{KL}(q, p) \\neq D_{KL}(p, q)$ (where $p$ and $q$ are p.d.s); consequently, the KL divergence cannot be a metric (because metrics are symmetric!)\nIt is always non-negative\nIt is zero when $p = q$.\nIt is unbounded, i.e. it can be arbitrarily large; so, in other words, two probability distributions can be infinitely different, which may not be very intuitive: in fact, in the past, I used the KL divergence and, because of this property, it wasn't always clear how I should interpret the KL divergence (but this may also be due to my not extremely solid understanding of this measure).\n\n\nand how is it different from what a $D_{TV}$ between the same two policies tells you?\n\n$D_{TV}$ is also a measure of the distance between two probability distributions, but it is bounded, specifically, in the range $[0, 1]$ [1]. This property may be useful in some circumstances (which ones?). In any case, the fact that it lies in the range $[0, 1]$ potentially makes its interpretation more intuitive. More precisely, if you know the maximum and minimum values that a measure can give you, you can have a better idea of the relative difference between probability distributions. For instance, imagine that you have p.d.s $q$, $p$ and $p'$. If you compute $D_{TV}(q, p)$ and $D_{TV}(q, p')$, you can have a sense (in terms of percentage) of how much $p'$ and $p$ differ with respect to $q$.\nThe choice between $D_{TV}$ and $D_{KL}$ is probably motivated by their specific properties (and it will probably depend on a case by case basis, and I expect the authors of the research papers to motivate the usage of a specific measure/metric). However, keep in mind that there is not always a closed-form solution not even to calculate the KL divergence, so you may need to approximate it (e.g. by sampling: note that the KL divergence is defined as an expectation/integral so you can approximate it with a sampling technique). So, this (computability and/or approximability) may also be a parameter to take into account when choosing one over the other.\nBy the way, I think that your definition of the total variational divergence is wrong, although the DTV is related to the DKL, specifically, as follows [1]\n\\begin{align}\nD_{TV} \\leq \\sqrt{\\frac{1}{2} D_{KL}}\n\\end{align}\nSo the DTV is bounded by the KL divergence. Given that the KL divergence is unbounded (e.g. it can take very big values, such as 600k, this bound should be very loose).\nTake a look at the paper On choosing and bounding probability metrics\n (2002, by Alison L. Gibbs and Francis Edward Su) or this book for information about $D_{TV}$ (and other measures/metrics).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How are afterstate value functions mathematically defined? In this answer, afterstate value functions are mentioned, and that temporal-difference (TD) and Monte Carlo (MC) methods can also use these value functions. Mathematically, how are these value functions defined? Yes, they are a function of the next state, but what's the Bellman equation here? Is it simply defined as $v(s') = \\mathbb{E}\\left[ R_t \\mid S_t = s, A_t = a, S_{t+1} = s' \\right]$? If yes, how can we define it in terms of the state, $v(s)$, and state-action, $q(s, a)$, value functions, or as a Bellman (recursive) equation?\nSutton & Barto's book (2nd edition) informally describe afterstate value functions in section 6.8, but they don't provide a formal definition (i.e. Bellman equation in terms of reward or other value functions), so that's why I am asking this question.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Based on this and this resources, let me give an answer to my own question, but, essentially, I will just rewrite the contents of the first resource here, for reproducibility, with some minor changes to the notation (to be consistent with Sutton & Barto's book, 2nd edition). Note that I am not fully sure if this formulation is universal (i.e. maybe there are other ways of formulating it), but the contents of the first resource seem to be consistent with the contents in the second resource.\nSetup\nLet's assume that we have an infinite-horizon MDP\n$$\\mathcal{M} = (\\mathcal{S}, \\mathcal{Y}, \\mathcal{A}, \\mathcal{T}, \\mathcal{R}, \\gamma),$$\nwhere\n\n$\\mathcal{S}$ is the set of states\n$\\mathcal{Y} \\subseteq \\mathcal{S}$ is the set of afterstates (aka post-decision states or \"end of period\" states [1], which can also be written as after-states)\n$\\mathcal{A}$ is the set of actions\n$\\mathcal{T}$ is the transition function\n$\\mathcal{R}$ is the reward function\n$\\gamma$ is a discount factor\n\nLet\n\n$y \\in \\mathcal{Y}$ be an afterstate\n$f: \\mathcal{S} \\times \\mathcal{A} \\rightarrow \\mathcal{Y}$ be a deterministic function (from state-action pairs to afterstates), so we have $f(s, a) = y$\n\nThe transition function $\\mathcal{T}$ for $\\mathcal{M}$ is defined as\n\\begin{align}\n\\mathcal{T}(s, a, s^{\\prime}) \n&\\doteq P ( s^{\\prime} \\mid f(s, a)) \\\\\n&= P ( s^{\\prime} \\mid y)\n\\end{align}\nA transition is composed of 2 steps\n\na deterministic step, where we apply the deterministic function $f(s, a) = y$, which depends on an action $a$ taken in the state $s$, followed by\na stochastic step, where we apply the probability distribution $P (s^{\\prime} \\mid y)$, which does not depend on the action $a$ anymore, but only on $y$\n\nSo, I have denoted afterstates with a different letter, $y$, because afterstates are reached with a deterministic function $f$, while other states, $s$ or $s'$, are reached with $P$.\nAfter having taken the action $a$ in the state $s$, we get a reward (i.e. we get a reward in step 1), but we do not get a reward after the stochastic step (given that no action is taken).\nSo, we can define the reward function $\\mathcal{R}$ for this MDP as follows\n$$\n\\mathcal{R} (s, a, s^{\\prime} ) \\doteq \\mathcal{R}(s, a)\n$$\nThe situation is illustrated by the following diagram\n\nSo, here, $P$ is the stochastic transition function (i.e. a probability distribution) as used above. Note that, here, $r_t$ is a specific realization of $R_t$ (the random variable) in the formulas below.\nState value function\nLet's recall the definition of the state value function $v_\\pi(s)$ for a given policy $\\pi$ (as defined in Sutton & Barto, section 3.5)\n\\begin{align}\nv_{\\pi}(s) \n&\\doteq \n\\mathbb{E}_{\\pi}\\left[G_{t} \\mid S_{t}=s\\right] \\\\\n&=\n\\mathbb{E}_{\\pi}\\left[\\sum_{k=0}^{\\infty} \\gamma^{k} R_{t+k+1} \\mid S_{t}=s\\right],\n\\end{align}\nfor all $s \\in \\mathcal{S}$ and\n\\begin{align}\nG_{t} \n&\\doteq \n\\sum_{k=0}^{\\infty} \\gamma^{k} R_{t+k+1} \\\\\n&=\nR_{t+1} + \\gamma R_{t+2} + \\gamma^{2} R_{t+3}+ \\cdots \\\\\n&=\n\\mathcal{R}(s_t, a_t) + \\gamma \\mathcal{R}(s_{t+1}, a_{t+1})+\\gamma^{2} \\mathcal{R}(s_{t+2}, a_{t+2}) +\\cdots,\n\\end{align}\nwhere $\\pi(s_t) = a_t$ and $\\mathcal{R}(s_t, a_t) = R_{t+1}$, for $t=0, 1, 2, \\dots$. (So, note that $\\mathcal{R} \\neq R_t$: the first is the reward function, while the second is a random variable that represents the reward received after having taken action $a_t$ in step $s_t$)\nThe optimal state value function is defined as\n$$\nv_{*}(s) \\doteq \\max _{\\pi} v_{\\pi}(s)\n$$\nAfterstate value function\nSimilarly, we will define the afterstate value function, but we will use the letter $w$ just to differentiate it from $v$ and $q$.\n\\begin{align}\nw_{\\pi}\\left(y\\right)\n&\\doteq \n\\mathbb{E}_{\\pi}\\left[G_{t+1} \\mid Y_{t}=y\\right] \n\\\\\n&=\n\\mathbb{E}_{\\pi}\\left[\\sum_{k=0}^{\\infty} \\gamma^{k} R_{t+k+2} \\mid Y_{t}=y\\right] \n\\\\\n&=\n\\mathbb{E}_{\\pi}\\left[\nR_{t+2} + \\gamma R_{t+3}+\\gamma^{2} R_{t+4} + \\cdots\n \\mid Y_{t}=y\\right] \n\\\\\n&=\n\\mathbb{E}_{\\pi}\\left[\n\\mathcal{R}(s_{t+1}, a_{t+1})+\\gamma \\mathcal{R}(s_{t+2}, a_{t+2}) + \\gamma^{2} \\mathcal{R}(s_{t+3}, a_{t+3}) + \\cdots\n \\mid Y_{t}=y\\right] ,\n\\end{align}\nwhere $\\mathcal{R}(s_{t+1}, a_{t+1}) = R_{t+2}$, for all $t$.\nIn other words, the value of an afterstate $y$ (at time step $t$, i.e. given $Y_t = y$) is defined as the expectation of the return starting from the state that you ended up in after the afterstate $y$.\nThis seems reasonable to me and is similar to my proposal for the definition of the afterstate value function in the question, although I was not considering any deterministic functions in a potential formulation, and I was also not thinking of afterstates as intermediate states, reached by a deterministic step, between the usual states.\nSimilarly to the optimal state value function, we also define the optimal afterstate value function\n$$\nw_{*}(y) \\doteq \\max _{\\pi} w_{\\pi}(y)\n$$\nAfterstate value function defined in terms of the state value function\nWe can define the afterstate value function in terms\n$$\nw_{*}(y) \n= \n\\sum_{s^{\\prime}} P (s^{\\prime} \\mid y ) v_{*} ( s^{\\prime} )\n$$\nIn other words, $w_{*}(y)$ is defined as an expectation over the value of next possible states $s'$ from the afterstate $y$.\nThis seems to be correct and consistent with the above definitions.\nMore equations\nIn this and this resources, the state value function is also defined in terms of afterstate value function as follows\n$$v_{*}(s)=\\max_{a}\\left(\\mathcal{R}(s, a)+\\gamma w_{*}(f(s, a))\\right)$$\nThe Bellman equation for afterstate value function (from which an update rule can be derived) is given by\n$$\nw_{*}(y)\n=\n\\sum_{s^{\\prime}} \nP(s^{\\prime} \\mid y ) \n\\max_{a} ( \n\\mathcal{R} (s^{\\prime}, a)\n+\n\\gamma \nw_{*}(f ( s^{\\prime}, a ))),\n$$\nwhich is really similar to the Bellman equation for the state value function.\nFinally, we can also express the state-action value function in terms of the afterstate value function\n$$\nq_\\pi(s_t, a_t)\n=\n\\mathcal{R}\\left(s_{t}, a_{t}\\right)+\\gamma w_{\\pi}\\left(f\\left(s_{t}, a_{t}\\right)\\right)\n$$\nGiven that this answer is already quite long, see the resource for more details (including an algorithm based on the afterstate Bellman equation).\nImplementation\nIf you are the type of person that understands the concepts by looking at the code, then this Github project, which implements a Monte Carlo method that uses afterstates to play tic-tac-toe, may be useful. Afterstates are useful in tic-tac-toe because it is a 2-player game, where two agents take actions in turn, so we can estimate the action that you should take deterministically (as if it was the $f$ above) before the other agent takes an action (probabilistically), at least, this is my current interpretation of the usefulness of afterstates in this game (and similar games/problems).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the intuition behind variational inference for Bayesian neural networks? I'm trying to understand the concept of Variational Inference for BNNs. My source is this work. The aim is to minimize the divergence between the approx. distribution and the true posterior\n$$\\text{KL}(q_{\\theta}(w)||p(w|D) = \\int q_{\\theta}(w) \\ log \\frac{q_{\\theta}(w)}{p(w \\mid D)} \\ dw$$\nThis can be expanded out as $$- F[q_{\\theta}] + \\log \\ p(D)$$ where $$F[q_{\\theta}] = -\\text{KL}(q_{\\theta}(w) || p(w)) + E[\\log p(D \\mid w)]$$\nBecause $log \\ p(D)$ does not contain any variational parameters, the derivative will be zero. I really would like to summarize the concept of VI in words.\nHow can one explain the last formula in words intuitive and with it on the fact that one approximates a function without really knowing it / able to compute it?\nMy attempt would be: Minimizing the KL between the approximate distribution and the true posterior boils down in minimizing the KL between the approximate distribution and the prior (?) and maximizing the log-likelihood that the parameters of the approximate distribution resulted in the data. Is this somehow correct?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Your description of what is going on is more or less correct, although I am not completely sure that you have really understood it, given your last question.\nSo, let me enumerate the steps.\n\nThe computation of the posterior is often intractable (given that the evidence, i.e. the denominator of the right-hand side of the Bayes' rule, might be numerically expensive to approximate/compute or there's no closed-form solution)\n\nTo address this intractability, you cast the Bayesian inference problem (i.e. the application of Bayes' rule) as an optimization problem\n\nYou assume that you can approximate the posterior with another simpler distribution (e.g. a Gaussian), known as the variational distribution\n\nYou formulate this optimization problem as the minimization of some notion of distance (e.g. the KL divergence) between the posterior and the VD\n\nHowever, the KL divergence between the posterior and the VD turns out to be intractable too, given that, if you expand it, you will find out that there's still an evidence term\n\nTherefore, you use a tractable surrogate (i.e. equivalent, up to some constant) objective function, which is known as the evidence lower bound (ELBO) (which is sometimes known as the variational free energy), which is the sum of 2 terms\n\nKL divergence between the VD and the prior\nthe likelihood of the parameters given the data\n\n\n\n\n\nTo address your last doubt/question, the ELBO does not contain the posterior (i.e. what you really want to find), but only the variational distribution (you choose this!), the prior (which you also define/choose), and the likelihood (which, in practice, corresponds to the typical usage of the cross-entropy; so the only thing that you need more, with respect to the traditional neural networks, is the computation of the KL divergence): in other words, you originally formulate the problem as the minimization of the KL divergence between the posterior and the VD, but this is just a formulation.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it possible for an AI to learn how to speak from books as training sets? I want to know something more about it. Are there any github repo or an open source project?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It is possible\nThe Recurrent Neural Network architectures help in building efficient NLP algorithms, which can identify semantics and their relations across long pieces of text.\nWith very minor tuning, they can be made generative too. So, here is an excellent article on RNNs which I highly recommend, which also talks about how an RNN was trained on Shakespere's texts and wrote one itself.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can artificial intelligence (including deep learning algorithms) find suspicious patterns in the body\u2019s biochemistry? It has been suggested that machine learning algorithms (also Watson) can help with finding disease in patient images and optimize scans. Also that deep learning algorithms show promise for every type of digital imaging.\nHow does exactly deep learning algorithms exactly can find suspicious patterns in the body\u2019s biochemistry?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I wouldn't focus only on \"deep learning\" unless you have some specific reason for doing so. There may be other techniques which could be as effective, or more effective. \nOne approach I've seen used for something similar was Inductive Logic Programming. For one example of using ILP to reason about elements of biochemistry, see this paper\nThat's not exactly about detecting disease, but it does sort of illustrate the broad idea of reasoning about states and reactions involving metabolic pathways in biochemistry, using ILP. Possibly the basic idea could be adapted more towards detecting disease. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the mean used to compute the expectation in the GAN loss? From Goodfellow et al. (2014), we have the adversarial loss:\n$$ \\min_G \\, \\max_D V (D, G) = \\mathbb{E}_{x\u223cp_{data}(x)} \\, [\\log \\, D(x)] + \\, \\mathbb{E}_{z\u223cp_z(z)} \\, [\\log \\, (1 \u2212 D(G(z)))] \\, \\text{.} \\quad$$\nIn practice, the expectation is computed as a mean over the minibatch. For example, the discriminator loss is:\n$$\n\\nabla_{\\theta_{d}} \\frac{1}{m} \\sum_{i=1}^{m}\\left[\\log D\\left(\\boldsymbol{x}^{(i)}\\right)+\\log \\left(1-D\\left(G\\left(\\boldsymbol{z}^{(i)}\\right)\\right)\\right)\\right]\n$$\nMy question is: why is the mean used to compute the expectation? Does this imply that $p_{data}$ is uniformly distributed, since every sample must be drawn from $p_{data}$ with equal probability?\nThe expectation, expressed as an integral, is:\n$$\n\\begin{aligned}\nV(G, D) &=\\int_{\\boldsymbol{x}} p_{\\text {data }}(\\boldsymbol{x}) \\log (D(\\boldsymbol{x})) d x+\\int_{\\boldsymbol{z}} p_{\\boldsymbol{z}}(\\boldsymbol{z}) \\log (1-D(g(\\boldsymbol{z}))) d z \\\\\n&=\\int_{\\boldsymbol{x}} p_{\\text {data }}(\\boldsymbol{x}) \\log (D(\\boldsymbol{x}))+p_{g}(\\boldsymbol{x}) \\log (1-D(\\boldsymbol{x})) d x\n\\end{aligned}\n$$\nSo, how do we go from an integral involving a continuous distribution to summing over discrete probabilities, and further, that all those probabilities are the same?\nThe best I could find from other StackExchange posts is that the mean is just an approximation, but I'd really like a more rigorous explanation.\nThis question isn't exclusive to GANs, but is applicable to any loss function that is expressed mathematically as an expectation over some sampled distribution, which is not implemented directly via the integral form.\n(All equations are from the Goodfellow paper.)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It seems your question is concerned with how an empirical mean works.\nIt is indeed true that, if all $x^{(i)}$ are independent identically distributed realisations of a random variable $X$, then $\\lim_{n \\rightarrow \\infty} \\frac{1}{n}\\sum_{i=1}^n f(x^{(i)}) = \\mathbb{E}[f(X)]$. This is a standard result in statistics known as the law of large numbers.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are methods human actors use to imitate robots? Robot technology is usually thought from an engineering perspective. A human programmer writes a software this executed in a robot who is doing a task. \nBut what would happen, if the project is started with the opposite goal? The idea is, that the human becomes the robot by himself. That means, the human is using makeup to make his face more mechanically, buys special futuristic clothing which mirrors the light and imitates in a roleplay the working of a kitchen robot.\nWhat are methods human actors use to imitate robots?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The great acting teacher Stella Adler wrote about mannerisms being a powerful tool for actors. Method acting in general focuses on natural performances based roughly on understanding the mindset of the character portrayed. \nIt's possible actors who have portrayed androids have observed industrial robots to inform their physicality, and many performances convey the idea, via movement, of a mechanical inner structure. (It is often said that an \"actor's body is their instrument\".)\nWhat is more interesting is actors trying to convey the cognitive structure of the androids. \nWith Arnold, and Terminator robots in general, the baseline performance is decidedly robotic, to convey their inhumanity. But the more advanced Terminators are able to mimic naturalistic human mannerisms, and even established human characters, to trick humans. \nLieutenant Data often used head motions, such as cocking his head slightly, to convey computation. Here the character arc involved working to become more human, as this character draws heavily on Pinocchio, the wooden puppet that became a boy. Overall Data's performance conveyed a lack of emotion, a definite reference to the logic-oriented Mr. Spock, although I recall episodes where Data experimented with \"emotional circuits\" and \"humor circuits\", where the output was intentionally inconsistent with natural human behavior.\nBlade Runner, where the Tyrell Corporation's motto was \"More Human than Human\", presented the cutting edge Nexus-6 androids as having emotions, but, due to their artificially short life-spans, were portrayed as childlike in trying to reconcile extremely powerful feelings. The Voight-Kampff Test, a form of Turing Test, used in the film to identify androids, relied on the emotional response to questions. \nThe key plot point of Do Androids Dream of Electric Sheep, the novel the film was based on, utilized what would be formalized as evolutionary game theory to hypothesize that empathy is a natural function of intelligence sufficiently advanced. Deckard, who may or may not have been an android, and Rachel, who definitely was, are both capable of love. This capacity informed their performances, to the extent that the androids came off as more human than the actual humans, due to the depth of their emotion. This is also reflected in Blade Runner 2049 via the girlfriend-bot Joi, who us the most limited android, but the most human character in the film per her capacity to love (or at least simulate it.)\nIn the recent HBO Westworld reboot, the Androids replicate natural human mannerisms when playing their designated roles, but reset to more mechanical mannerisms when acting under their own agency. This is reflected in Ex Machina, where the android mimics human emotions to pass a Turing Test and trick the human subject, only to revert to purely alien mannerisms after the android is free. (\"Alien\" here used in the sense of non-human--it's possible the android is sentient as it seems to convey some degree of emotion in regarding the simulated human skin it will wear.)\nThe most interesting recent android performance may come from the recent Alien: Covenant where Michael Fassbender plays two identical androids, David and Walter, which have two distinct neural structures. (David has the capacity to be creative, where Walter cannot. In the film it is mentioned that David made people uncomfortable, so the creative functions were removed from subsequent models.) The key difference in the performance seems to be that David demonstrates passion, and even emotions, where Walter is more clearly \"robotic\".\n\nIn general, the underlying approach of actors seems to have been to show the androids being distinct from humans, drawing a clear, though sometimes subtle, contrast. \nActors portraying androids have typically utilized robotic mannerisms to convey an artificial entity.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "In the Manifold Hypothesis applied to LLMs, are text sequences points or paths on the manifold? The Manifold Hypothesis makes a ton of sense to me for images. Images are points in high dimensional space, where each dimension corresponds to the intensity value of a single pixel. For example, we can think about the 28x28 pixel grayscale MNIST images as points lying on some manifold in 28x28=784 dimensional space.\nWhen we jump to language modeling however, I know that each word is mapped to a vector using various embedding approaches. In this sense, each word is a point in a high dimensional space, that I imagine sweep out some manifold in that space. However, the examples LLMs learn from are of course sequences of words, and as far as I know that when transformers are applied to images, it's done by making images into pixel sequences. From this perspective I'm wondering if sequences of text are better thought of as points on a high dimensional manifold?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "When transformers process sequences, they learn to generate contextual embeddings for each word. However, often for downstream tasks, these word-level embeddings are combined (e.g., using pooling or attention mechanisms) into a single fixed-length vector that represents the entire sequence. Thus a sequence of text can indeed be thought of as a point in an even higher-dimensional space than each word's semantic embedding space where each dimension corresponds to one of the input features across all words or more general tokens. Just like in images where the nearby pixels are related and constrained by the rules of natural scenes, in text words within sequences are contextually related. Not every possible sequence of words makes sense in a given language which follows specific syntactic and semantic rules, so only a subset lower-dimensional manifold of the high-dimensional space is occupied by meaningful sequences.\nOf course there's nothing wrong to alternatively view text sequences as paths sweeping out some manifold in the word embedding space, but since word embeddings of a generic text sequence are not continuously varying geometrically speaking it's hard to leverage this view to make any substantive conclusion.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do all states appear identical under the function approximation in the Short Corridor task? This is the Short Corridor problem taken from the Sutton & Barto book. Here it's written:\n\nThe problem is difficult because all the states appear identical under the function approximation\n\nBut this doesn't make much sense as we can always choose states as 0,1,2 and corresponding feature vectors as\nx(S = 0,right) = [1 0 0 0 0 0]\nx(S = 0 , left) = [0 1 0 0 0 0]\nx(S = 1,right) = [0 0 1 0 0 0]\nx(S = 1 , left) = [0 0 0 1 0 0]\nx(S = 2,right) = [0 0 0 0 1 0]\nx(S = 2 , left) = [0 0 0 0 0 1]\\\nSo why is it written that all the states appear identical under the function approximation?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You can choose those states, but is the agent aware of the state it is in? From the text, it seems that the agent cannot distinguish between the three states. Its observation function is completely uninformative.\nThis is why a stochastic policy is what is needed. This is common for POMDPs, whereas for regular MDPs we can always find a deterministic policy that is guaranteed to be optimal.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to calculate the distance between the camera and an object using Computer Vision? I want to create a Deep Learning model that measures the distance between the camera and certain objects in an image. Is it possible? Please, let me know some resources related to this task.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In general, calculation of distance between camera and object is impossible if you don't have further scene dependent information.\nTo my knowledge you have 3 options:\nStereo Vision\nIf you have 2 cameras looking at the same scene from a different point of view you can calculate the distance with classical Computer Vision algorithms. This is called stereo vision, or also multiview geometry.\nStereo Vision is the reason why humans can infer the distance to objects around them (because we have 2 eyes).\nStructure from Motion\nYou move your camera and therefore change your viewpoint and can essentially do stereo mapping over time. Structure from Motion\nScene Understanding\nWhy is it then still possible for a one-eyed person to infer depth to some extent? Because humans have lots of scene dependent understanding. If you see a rubber duck that takes half of your field of view, you know it's pretty close because you know a rubber duck is not big. If you don't know the size of rubber ducks it is impossible to know whether you see a big rubber duck that is far away or a small rubber duck that is really close.\nThis is where Deep Learning based models come into play. A recent overview over monocular\ndepth estimation can be found in Zhao2020\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the major differences between cost, loss, error, fitness, utility, objective, criterion functions? I find the terms cost, loss, error, fitness, utility, objective, criterion functions to be interchangeable, but any kind of minor difference explained is appreciated.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "They are not all interchangeable. However, all these expressions are related to each other and to the concept of optimization. Some of them are synonymous, but keep in mind that these terms may not be used consistently in the literature.\nIn machine learning, a loss function is a function that computes the loss/error/cost, given a supervisory signal and the prediction of the model, although this expression might be used also in the context of unsupervised learning. The terms loss function, cost function or error function are often used interchangeably [1], [2], [3]. For example, you might prefer to use the expression error function if you are using the mean squared error (because it contains the term error), otherwise, you might just use any of the other two terms.\nIn genetic algorithms, the fitness function is any function that assesses the quality of an individual/solution [4], [5], [6], [7]. If you are solving a supervised learning problem with genetic algorithms, it can be a synonym for error function [8]. If you are solving a reinforcement learning problem with genetic algorithms, it can also be a synonym for reward function [9].\nIn mathematical optimization, the objective function is the function that you want to optimize, either minimize or maximize. It's called the objective function because the objective of the optimization problem is to optimize it. So, this term can refer to an error function, fitness function, or any other function that you want to optimize. [10] states that the objective function is a utility function (here).\nA utility function is usually the opposite or negative of an error function, in the sense that it measures a positive aspect. So, you want to maximize the utility function, but you want to minimize the error function. This term is more common in economics, but, sometimes, it is also used in AI [11].\nThe term criterion function is not very common, at least, in machine learning. It could refer to the function that is used to stop an algorithm. For example, if you are executing a computationally expensive procedure, a stopping criterion might be time. So, in this case, your criterion function might return true after a certain number of seconds have passed. However, [1] uses it as a synonym for the objective function.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does Brooks mean by \"representation\"? For a class, I'm reading Brooks' \"Intelligence without representation\". The introduction is dedicated to slating representation as a focus for AI development.\nI've read that representation is the problem of representing information symbolically, in time for it to be useful. It's related to the reasoning problem, which is about reasoning about symbolic information.\nBut I don't feel like I really understand it at any practical level. I think the idea is that when an agent is given a problem, it must describe this problem in some internal manner that is efficient and accurately describes the problem. This can then also be used to describe the primitive actions that can be taken to reach the solution. I think this then relates to Logic Programming (e.g. Pascal?),\nIs my understanding of representation correct? Just what does representation look like in practice? Are there any open-source codebases that might make a good example?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First, Pascal is not a logic programming language. Logic programming refers to languages like Prolog where you have a declarative style of programming compared to a imperative style like you have in Pascal. Maybe you mean if-statements which are typical for imperative languages.\nSecond, representation means a certain level of abstraction. For instance, a model represents a certain part of the reality. Imagine a cup on a table. If the agent has a representation of this situation, it has a symbol table and a symbol cup which represents the things in the real world. Now it can have a relation on(cup, table) which represents the situation that the cup is on the table. This type of abstraction can be easily represented in a logic language like first order logic. Therefore, one uses logic programming languages like Prolog or other types of languages like OWL to represent knowledge and perform reasoning. So the important term to which Brooks refers is Knowledge Representation and Reasoning.\nThird, if your agent only have sensor data like video or sonar data, then it knows only distances or pixels from the real world. That is not meant with representation. Brooks' Creatures have only this information and calculate with this data directly to perform an action without reasoning. In that sense also artificial neural networks have no representation.\nFinally, for an open source project to understand representation I would recommend the above mentioned OWL. You can look at the Prot\u00e9g\u00e9 editor for working with OWL. In an OWL ontology you can represent relations between things and reason about them.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is PyTorch's `grad_fn` for a non-differentiable function that function's inverse? What is grad_fn for a non-differentiable function like slicing (grad_fn=), view (grad_fn=), etc.? Is grad_fn simply the function's inverse operation?\nWhere in the source code can I see the implementation of SliceBackward0, ViewBackward0, etc.? I assume it's in their backward() static methods somewhere.\nrelated: \"Does it make sense for a computational graph to have entirely non-differentiable functions?\"\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Non-differentiable node is not inverted during backward(), but is simply treated as constants. The backpropagated gradient stops at that node so any parameter whose only connection to the loss is via the said non-differentiable node cannot receive gradient updates. So the grad_fn objects you listed are not inverse of the forward operations (e.g., differentiable slicing and view operations), instead, it's an object of a subclass of PyTorch's internal Function class that holds the logic for how to compute the gradients in the backward pass.\nThe functions such as your are implemented here and is generated at the location like torch/csrc/autograd/generated/Functions.cpp or a related file in a local source build since PyTorch's autograd engine is implemented primarily in C++ with code generation for many fuctions.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can a crossover result in a node with no outgoing connections? I'm currently implementing the original NEAT algorithm in Swift.\nLooking at figure 4 in Stanley's original paper, it seems to me there is a chance that node 5 will have no (enabled) outgoing connection if parent 1 is assumed the fittest parent and the connection is randomly picked from parent 2.\nIs my understanding of the crossover function correct and can it indeed result in a node with no outgoing connections?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The disabled/enabled bit in a connection gene indicates whether or not it should be expressed in the calculation of the network.\nHere's an example:\n\nThis is a neural network and its corresponding connection genes which represent the layout of the network among other things.\nThe top connection gene going from 1 -> 3 that has a weight of 0.1 is expressed in the calculation of the network.\nThe bottom connection gene going from 2 -> 3 that has a weight of 0.4 is not expressed in the calculation of the network.\nCalculating the network:\n\n1633 * 0.1 = 163.3\nGiven the weights in the example the output of this network is 163.3\n\nHypothetically, if both connection genes had their enabled bit set to true (which can happen in the future, to quote the paper: \"The disabled genes may become enabled again in future generations\") then the output of the network would be:\n\n(1633 * 0.1) + (10 * 0.4) = 167.3\n\nTo answer your question, the connection between two nodes still exists in the network regardless of whether the bit in the gene is enabled or disabled, but, if the bit in the gene is disabled it is not used when the output of the network is being calculated as I've shown above.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a beam? For example, faster-whisper's transcribe function takes an argument\nbeam_size: Beam size to use for decoding.\n\nWhat does \"beam\" mean?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Beam search\nThe beam search is a algorithm to find probable output sequences for an input sequence, so it has been used for decoding in the context of sequence-to-sequence tasks, like machine translation. It's an alternative to a greedy search, which just samples the most likely token at every step (which is not guaranteed to find the most likely sequence, though), that can keep a set of solutions.\nI think I first encountered this algorithm a few years ago while reading this important paper, which refers to this Alex Graves' paper, which actually contains a description and the pseudocode of a beam search, but I had forgotten about it, so I decided to review it :)\nA good description can be found here (section 7.2.3) or here.\nIf you're familiar with search algorithms like breadth-first search (BFS), think of beam search as a similar search algorithm, where nodes are the tokens from some vocabulary and the edges are the probabilities of selecting a certain token given the previously selected tokens (important!). In fact, it can be viewed as a generalization of BFS (exhaustive search) - if you set the beam size equal to the vocabulary size, you get BFS.\nThe following image (taken from here, which provides a nice explanation) should give you the intuition\n\nWhat is a beam? Just a guess\nNow, I don't know the origin of the term beam in this context or why it's called beam search. In some papers I've come across (example), the beam acts like an object that has properties like the size (beam size).\nHowever, it could refer to the paths or the polygon formed by the external nodes at each layer from the first to the last, which is kind of similar to or could remind us of a light beam (image taken from here).\n\nThe terminology is not very important, unless you're only interested in the history of the algorithm, which I assume not\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is Statistical relational learning? I have gone through the wikipedia explanation of SRL. But, it only confused me more:\n\nStatistical relational learning (SRL) is a subdiscipline of artificial intelligence and machine learning that is concerned with domain models that exhibit both uncertainty (which can be dealt with using statistical methods) and complex, relational structure.\n\nCan someone give a more dumbed down explanation of the same, preferably with an example?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The University of Maryland published some slides (PDF) from an introductory presentation on this topic.\nThe fourth page explains why SRL is interesting. \"Traditional statistical machine learning approaches\" process one sort of thing in which there is some uncertaintly. Image identification is a good example of that. \"Traditional ILP/relational learning approaches\" use several kinds of information to produce hypotheses about the data set, but apparently allow for no noise in the data.\nStatistical relational learning models are intended to work with data sets that have several types of objects connected to each other via various links (hence \"relational\"). They also are meant to deal with uncertainty (hence \"statistical\").\nSkipping past some slides that aren't really useful without a transcript of what was said over them, we come to slide 17, which has comprehensible definitions and examples:\n\n\nObject classification\n\nPredicting the category of an object based on its attributes and its links and attributes of linked objects\ne.g., predicting the topic of a paper based on the words used in the paper the topics of papers it cites the used in the paper, the topics of papers it cites, the research interests of the author\n\nObject type prediction\n\nPredicting the type of an object based on its attributes and its links and attributes of linked objects\ne.g., predict the venue type of a publication (conference, journal, workshop) based on properties of the paper\n\n\n\nAs you can see, these models can keep track of several things and the interactions between them. The next slide talks about link prediction, the ability to predict several attributes of connections between objects, like the importance/quality of a citation. As previously mentioned, these models don't require 100% accurate data to give interesting results; academic citation lists might occasionally be less than comprehensive, and the importance of a citation is challenging to quantify.\nLike ILP, SLP will hopefully be able to \"see\" new kinds of links between \"entities\", as with the presentation's example of identifying research communities.\nPast slide 20, the presentation goes into some serious mathematics. It does have a much less technical conclusion starting at slide 198. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do weak learners become strong in boosting? Boosting refers to a family of algorithms which converts weak learners to strong learners. How does it happen?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As @desertnaut mentioned in the comment\n\nNo weak learner becomes strong; it is the ensemble of the weak learners that turns out to be strong\n\nBoosting is an ensemble method that integrates multiple models(called as weak learners) to produce a supermodel (Strong learner).\n\nBasically boosting is to train weak learners sequentially, each trying to correct its predecessor. For boosting, we need to specify a weak model (e.g. regression, shallow decision trees, etc.), and then we try to improve each weak learner to learn something from the data.\nAdaBoost is a boosting algorithm where a decision tree with a single split is used as a weak learner. Also, we have gradient boosting and XG boosting.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Examples of ontologies made with AI I'm looking for more or less successful artificial intelligence usage examples to build an ontology or rationale why it can't be done. I found a lot of articles on how to use ontologies for AI, but not succeded vice versa.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Ontology learning is a relatively new field that aims to automatically (or semi-automatically) learn or create ontologies (using machine learning, text mining, knowledge representation and reasoning, information retrieval and natural language processing techniques) from some text or corpus.\nOntology learning can be divided into different phases or tasks\n\nthe acquisition of terms that refer to specific concepts (named-entity\nrecognition)\nthe recognition of synonyms among these terms\nthe identification of taxonomic relations (such as the \"is-a\" relation)\nthe establishment of non-hierarchical relations\nthe derivation of new knowledge, i.e. knowledge that is not explicitly\nencoded by the ontology.\n\nSee also Ontology Learning from Text: An Overview (2003) and A survey of ontology learning techniques and applications (2018) for more details.\nIn the paper Ontology Learning with Deep Learning: a case study on Patient Safety using PubMed (2016), the authors investigate how continuous bag-of-words (CBOW) and skip-gram (two language models based on artificial neural networks) can be used to aid ontology development for patient safety, using PubMed citations as a corpus.\nLatent Dirichlet allocation (LDA) has also been used for ontology learning, for example, in the paper Terminological ontology learning and population using latent Dirichlet allocation. (2014).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which neural network can count the number of objects in an image? 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.\nI already found articles about crowd counting. I'm looking for articles about different types of objects.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "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 through it. For example, in the pytorch code for YOLO,(source:https://github.com/eriklindernoren/PyTorch-YOLOv3)\nYou can add a nn.Linear and use cross entropy loss to classify the number of images. You can also change the architecture completely. Maybe you can try adding layers to reset or other classifying network to count the number of objects. Hope this can help you and have a nice day!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Where can I find pre-trained language models in English and German? Where can I find (more) pre-trained language models? I am especially interested in neural network-based models for English and German.\nI am aware only of Language Model on One Billion Word Benchmark and TF-LM: TensorFlow-based Language Modeling Toolkit.\nI am surprised not to find a greater wealth of models for different frameworks and languages.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Of course now there has been a huge development:\nHuggingface published pytorch-transformers, a library for the so successful Transformer models (BERT and its variants, GPT-2, XLNet, etc.), including many pretrained (mostly English or multilingual) models (docs here). It also includes one German BERT model. SpaCy offers a convenient wrapper (blog post).\nUpdate: Now, Salesforce published the English model CTRL, which allows for use of \"control codes\" that influence the style, genre and content of the generated text.\nFor completeness, here is the old, now less relevant version of my answer:\n\nSince I posed the question, I found this pretrained German language model:\nhttps://lernapparat.de/german-lm/\nIt is an instance of a 3-layer \"averaged stochastic descent weight-dropped\" LSTM which was implemented based on an implementation by Salesforce.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are neurons in layer $l$ only affected by neurons in the previous layer? Are artificial neurons in layer $l$ only affected by those in layer $l-1$ (providing inputs) or are they also affected by neurons in layer $l$ (and maybe by neurons in other layers)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It depends on the architecture of the neural network. However, in general, no, neurons at layer $l$ are not only affected by neurons at layer $l-1$.\nIn the case of a multi-layer perceptron (or feed-forward neural network), only neurons at layer $l-1$ directly affect the neurons at layer $l$. However, neurons at layers $l-i$, for $i=2, \\dots, l$, also indirectly affect the neurons at layer $l$.\nIn the case of recurrent neural networks, the output of neuron $j$ at level $l$ can also affect the same neuron but at a different time step.\nIn the case of residual networks, the output of a neuron at a layer $l-i$, for $i=2, \\dots, l$, can directly affect the neurons at layer $l$. These non-neighboring connections are called skip connections because they skip layers.\nThere are probably other combinations of connections between neurons at different layers or the same layer. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Neural networks of arbitrary/general topology? Usually neural networks consist from layers, but is there research effort that tries to investigate more general topologies for connections among neurals, e.g. arbitrary directed acyclic graphs (DAGs).\nI guess there can be 3 answers to my question:\n\nevery imaginable DAG topology can be reduced to the layered DAGs already actively researched, so, there is no sense to seek for more general topologies;\ngeneral topologies exist, but there are fundamental restrictions why they are not used, e.g. maybe learning is not converging in them, maybe they generate chaotic osciallations, maybe they generate bifurcations and does not provide stability;\ngeneral topologies exist and are promising, but scientists are not ready to work with them, e.g. maybe they have no motivation, standard layered topologies are good enough.\n\nBut I have no idea, which answer is the correct one. Reading the answer on https://stackoverflow.com/questions/46569998/calculating-neural-network-with-arbitrary-topology I start to think that answer 1 is the correct one, but there is no reference provided.\nIf answer 3 is correct, then big revolution can be expected. E.g. layered topologies in many cases reduces learning to the matrix exponentiation and good tools for this are created - TensorFlow software and dedicated processors. But there seems to be no software or tools for general topologies is they have some sense indeed.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The simplistic neural networks that have been given away for free after they prove insufficient by themselves in field use consist solely of two orthogonal dimensions.\n\nLayer width \u2014 the number of ordinal numbers or floating point numbers that represent the signal path through any given layer comprise of an array of layer elements\nNetwork depth \u2014 the number of layers in the primary signal path, which is the number of activation function arrays or convolution kernels or whatever other elements Usually neural networks consist from layers\n\nHowever, in large corporations that have AI pipelines, this is not the case. We are beginning to see more interesting topologies in open source. We see this in generative systems for images, text, and speech. We see this in robotic control of robots. The truth is that these more sophisticated topologies have been in play for years, but were just not appearing in the open source community because they were company confidential. Enough academic work, releasing of portions of corporate IP, and the accumulation of independent OSS work has occurred to start to see these topologies in GIT repos.\nCyclic Not Acyclic\nArtificial network topologies are generally cyclic, not acyclic in terms of their causality or their signal pathways, depending on how you depict them theoretically. These are three basic examples from among dozens in the literature and in the open source repositories.\n\nBack-propagation represents the introduction of a deliberate cycle in signal paths in a basic multilayer perceptron, making that topology a sequence of layers represented by vertices, connected sequentially by a set of directed edges representing forward propagation, and a set of directed edges in the reverse direction to distribute the corrective error determined at the network output according to the principle of gradient descent. For efficiency, the corrective signal is distributed recursively backward through the layers to the $N - 1$ matrices of parameters attenuating the signals between $N$ layers. Back propagation requires the formation of these $N - 1$ cycles for convergence to occur.\nIn a generative adversarial network (GAN), we have the signal path of each of the two networks feeding the training criteria of the other. Such a topological arrangement is like negative feedback in a stable control system in that an equilibrium is formed between the generative network and discriminative network. The two directed edges, (a) the one that causally affects G with Ds result, and (b) the one that causally affects D with Gs result, create a cycle on top of the cycles in each of G and D.\nIn attention based networks being touted as theoretically advantageous over LSMT (which has been dominating over CNNs) has a much more complex topology and more cycles above those in supervisory layer than those in GANs.\n\nAnalysis of Answer One of Three\nIt is true that every directed graph can be realized in an arbitrarily large RNN because they are Turing complete, but that doesn't mean they are a great topology for all finite algorithms.\nTuring was aware that his punched tape model was not the best general purpose, high speed computing architecture. He was not intending to prove anything about computing speed but rather what could be computed. His Turing machine had a trivial topology deliberately. He wanted to illustrate his completeness theorem to others and resurrect the forward movement of rationalism after G\u00f6del disturbed it with his two incompleteness theorems.\nSimilarly, John von Neumann proposed his computing architecture, with a central processing unit (CPU) and unified data and instruction bus, to reduce the number of relays or vacuum tubes, not to maximize parallel algorithm execution. That topology as a directed graph has the instruction controller and the arithmetic unit in the center and everything else branching out from the data and address bus leading from them.\nThat a topology can accomplish a task is no longer a justification for persisting in the use of that topology, which is why Intel acquired Nirvana, which deviates from traditional von Neumann architecture, DSP architecture, and the current CUDA core architecture that NVidia GPUs use and offer for artificial network realization through C libraries that can be called via integrated Java and Python adapters.\nThere is definitely sense to seek for more general topologies, if they are fit for the purpose, just as with Turing's or von Neuman's.\nAnalysis of Answer Two of Three\nGeneral topologies exist, the most economically viable of which is the CUDA cores begun by NVidia, which can be configured for MLPs, CNNs, RNNs, and general 2D and 3D video processing. They can be configured with or without cycles depending on the characteristics of the parallelism desired.\nThe realization of topologies unlike the Cartesian arrangements of activation functions in artificial networks or the kernel cells in convolution engines do have barriers to use, but they are not fundamental restrictions. The primary barrier is not one of hardware or software. It is one of linguistics. We don't think topologically because we don't talk topologically. That's what is great about this question's challenge.\nFORTRAN began to dominate over LISP during the time when general purpose programming began to emerge in many corporations. That is not surprising because humans communicate in orthogonal ways. It is cultural. When a child scribbles, teachers are indoctrinated to say nice things but respond by drawing a shape. If the child draws a square, the teacher smiles. The child is given blocks. The books are rectangular. Text is justified into rectangles.\nWe can see this in building architecture dating back to Stonehenge. Ninety degree angles are clearly dominant in artificial things, whereas nature doesn't seem to have that bias.\nAlthough directed graphs were easy to implement and traverse in recursive structure and were commonplace in the LISP community. FORTRAN with its realization of vectors and matrices in one and two dimensional arrays respectively were easier to grasp by those with less theoretical background in data structures.\nThe result is that even if learning EMMASCRIPT (JavaScript) which has its seed from the LISP community and is not biased toward orthogonal data structures, people tend to proceed from HelloWorld.js to something with a basic loop in it, with an underlying array through which the loop iterates.\nThere are three wonderfully inquisitive and insightful phrases in answer two of three.\n\nMaybe learning is not converging in them \u2014 Interestingly an algorithm cannot learn without a cycle. Directly applying a formula or converging using a known convergent series of terms does not qualify as learning. Gradient descent relies entirely on the cyclical nature of a corrective action at the end of each sample processing or batch of them.\nMaybe they generate chaotic [oscillations] \u2014 This gets into chaos theory and control theory's concept of stability. They can do so, but so can a basic multilayer perceptron if the learning rate is set to high.\nMaybe they generate bifurcations \u2014 Now we have fully entered the realm of chaos, which is arguably closely related to creativity. Mendelbrot proposed the relationship between new forms of order and the apparent chaotic behavior arising from the appropriate level of feedback in a system with signal path components that cannot be modelled with a first degree equation. Since then, we find that most phenomena in nature are actually strange attractors. The plot of the training of a network from a continuous feed of consistently distributed data in phase space will reveal ... you guessed it ... a strange attractor. When purtibations are deliberately injected into a training epoch from a pseudo-random number generator, the specific purpose is a bifurcation, so that the global optimization can be found when the training gets stuck in a local optimization.\n\nAnalysis of Answer Three of Three\nGeneral topologies exist and are promising and researchers are ready to work with them. It is enthusiasts that can have a dismissive attitude. They don't yet understand the demos they've downloaded and painstakenly tweaked to run on their computer, they're about to launch their AI carrier amidst the growing demand from all the media hype, and now someone is introducing something interesting and not yet implemented in code. The motivational direction is generally to either dismiss or resist the creative proposals.\nIn this case, Google, CalTech, IBM, MIT, U Toronto, Intel, Tesla, Japan, and a thousand other governments, institutions, corporations, and open source contributors will solve that problem, provided people keep talking about topology and the restrictions inherent in purely Cartesian thinking.\nMisunderstanding Topology to Mean Dimensionality or Topography\nThere has been some confusion in terms. The SO reference in the question is an example of thinking that changing an array dimension is changing the topology. If such were so, then there would be no change one could make to the geometry of an AI system that would not be topological. Topology can only have meaning if there are features that are not topological. When one draws a layer, they don't need to increase the height of the rectangle representing it if the number of activitations, the width of the layer, is changed from 100 to 120.\nI've also seen academic papers that called the texture or roughness of an error surface its topology. That completely undermines the concept of topology. They meant to use the term topography. Unfortunately neither the publisher nor the editor noticed the error.\nSoftware or Tools\nMost programming languages support directed graphs in recursive hashmaps. LISP and its derivatives supported them at a more machine instruction efficient level, and that's still the case. Object oriented databases and graph libraries exist and are in use. Google uses them extensively in web indexing and lookup. FaceBook's API is called the Graph API, because it is a query and insert API into the graph that is FaceBook's user data store.\nThe explosion is here in global software giants. There is open source for it. The revolution that is missing is among those who are not yet educated as to the meaning of topology, the difference between a hierarchy and a network or the role of feedback in any learning system.\nRegarding Java and Python there are many barriers to the revolution in thinking, primarily these.\n\nThere are now key words in either Java or Python to directly deal with directed graphs other than the idea of a class with references to instances of other classes, which is quite limited. None of these languages can add edge types with a single simple language construct.\nThere is no mapping to hardware yet, although Nirvana allegedly developed one, and Intel acquired Nirvana, so that barrier may evaporate soon.\nThe bias still exists in preschool, kindergarten, and first grade\nHilbert spaces are not generally taught in calculus\n\nGraphviz and other graphing software that auto-generates diagrams from unconstrained directed or bidirectional graph representations have done much to bust through the barriers because the generated images are visible across the web. It may be through visual representations of graphs that linguistic representations, thought, hardware, and software begin to emerge representing the paradigm shift the question investigates.\nIt is not that constraints are not useful. Only some patterns and paradigms produce results, but since the results from the human brain demand attention, and the human brain is\n\nNot at all orthogonal,\nNot implemented using Cartesian neural patterns, and\nNot topologically a box,\n\nOne can all but conclude that those are not particularly well chosen constraints. Neither is the acyclic criteria. Nature is cyclic, and intelligence probably requires it in many ways and at many levels.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are calculus and differential geometry required for building neural networks? I've been studying geometry and linear algebra for months with the goal to build neural networks. But now I'm reading that perceptrons require fitting curves, and curves are not expressed as linear functions. So, I might need to study differential geometry and calculus for building good fitting curves in perceptrons.\nI already know how to code and was hoping to get my hands dirty by coding a few neural networks. But should I study calculus and differential geometry before coding?\nFrom this video, I understand that the least squares approximation can be used to fit a curve through a set of points, so maybe linear algebra is enough for building good neural networks?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Neural networks are essentially just repeated matrix multiplications and applications of an activation function, so you really don't need a great deal of linear algebra to construct a simple neural network \u2014 if you understand how to multiply matrices, that's probably sufficient.\nThe harder bit is the training process which is typically done through backpropagation. You need a bit of calculus, but differential geometry is overkill. There are some interesting topics in differential geometry for machine learning, but it's far beyond what is needed to implement backpropagation.\nTo understand backpropagation you just need to know about the gradient of a function and what this means intuitively; you should also have a good knowledge of the chain rule. That's really all you need, and any course on \"multivariable calculus\" or something similar would give you more than enough to get started.\nOf course, it never hurts to know more, but fortunately neural networks are simple\nenough that you don't need to struggle for years before you can implement a basic neural network; try to get started as soon as you have the basics, and learn the rest as you go.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to make convnets aware what the image actually is, not what is depicted on it? I've uploaded a picture to Wolfram's ImageIdentify of graffiti on the wall, but it recognized it as 'monocle'. Secondary guesses were 'primate', 'hominid', and 'person', so not even close to 'graffiti' or 'painting'.\nIs it by design, or there are some methods to teach a convolutional neural network (CNN) to reason and be aware of a bigger picture context (like mentioned graffiti)? Currently it seems as if it's detecting literally what is depicted in the image, not what the image actually is.\n\nThis could be the same problem as mentioned here, that DNN are:\n\nLearning to detect jaguars by matching the unique spots on their fur while ignoring the fact that they have four legs.2015\n\nIf it's by design, maybe there is some better version of CNN that can perform better?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Wolfram's image id system is specifically meant to figure out what the image is depicting, not the medium. \nTo get what you want you'd simply have to create your own system where the training data is labeled by the medium rather than the content, and probably fiddle with it to pay more attention to texture and things as such as that. The neural net doesn't care which we want - it has no inherent bias. It just knows what it's been trained for.\nThat's really all there is to it. It's all to do with the training labels and the focus of the system (e.g. a system that looks for edge patterns that form shapes, compared to a system that checks if the lines in the image are perfectly computer-generated straight and clean vs imperfect brush strokes vs spraypaint).\nNow, if you want me to tell you how to build that system, I'm not the right person to ask haha\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Should the policy parameters be updated at each time step or at the end of the episode in REINFORCE? REINFORCE is a Monte Carlo policy gradient algorithm, which updates weights (parameters) of policy network by generating episodes. Here's a pseudo-code from Sutton's book (which is same as the equation in Silver's RL note):\n\nWhen I try to implement this with my own problem, I found something strange. Here's implementation from Pytorch's official GitHub:\ndef finish_episode():\n R = 0\n policy_loss = []\n returns = []\n for r in policy.rewards[::-1]:\n R = r + args.gamma * R\n returns.insert(0, R)\n returns = torch.tensor(returns)\n returns = (returns - returns.mean()) / (returns.std() + eps)\n for log_prob, R in zip(policy.saved_log_probs, returns):\n policy_loss.append(-log_prob * R)\n optimizer.zero_grad()\n policy_loss = torch.cat(policy_loss).sum()\n policy_loss.backward()\n optimizer.step()\n del policy.rewards[:]\n del policy.saved_log_probs[:]\n\nI feel like there's a difference between the above two. In Sutton's pseudo-code, the algorithm updates $\\theta$ for each step $t$, while the second code (PyTorch's one) accumulate loss and update $\\theta$ with the summation, i.e. after each episode. \nI tried to search other implementation of REINFORCE, and I found that most of the implementations follow the second form, update after each generated episodes. \nTo check whether both give the same result, I changed the second code as \ndef finish_episode():\n R = 0\n policy_loss = []\n returns = []\n for r in policy.rewards[::-1]:\n R = r + args.gamma * R\n returns.insert(0, R)\n returns = torch.tensor(returns)\n returns = (returns - returns.mean()) / (returns.std() + eps)\n for log_prob, R in zip(policy.saved_log_probs, returns):\n optimizer.zero_grad()\n loss = -log_prob * R\n loss.backward()\n optimizer.step()\n\n...\n\nand run it, which gives different result (if my code has no problem). \nSo they are not the same, and I think the last one is more close to the original pseudo-code of REINFORCE. What am I missing now? Is it okay because the results are approximately same? (I'm not sure about this claim)\nHowever, in some sense, I think Pytorch's implementation is the right version of REINFORCE. In Sutton's pseudo-code, episode is generated first, so I think $\\theta$ shouldn't be updated at each step and should be updated after the total loss is computed. If $\\theta$ is updated at each step, then such $\\theta$ might be different with the original $\\theta$ that used to generate the episode. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The essence of your observation is that Sutton's version of REINFORCE is taking into consideration all of the trajectory to compute the returns, while in the pytorch version only the future is taken into consideration, hence going in reverse to sum the future rewards and ignore the previous rewards. The consequence is that future actions are not punished for early mistakes. The guys at OpenAI refer to this as reward-to-go, but, personally, I find that it resembles Monte Carlo On Policy Control without Exploring Starts or First Visit from Sutton's book.\nYou can find more on REINFORCE and Policy Gradient in Spinning Up RL: Part3: Intro to policy gradient - Don't let the past distract you.\nAlso, something to note is that even in Sutton's version, the whole trajectory is unrolled, i.e. the episode completes, and then the weights get updated. Otherwise it stops being a Monte Carlo Method and it becomes a TD method. In addition, you can't make a change on a single point because sampling is a non differentiable operation, instead, the gradient is estimated by collecting a lot of trajectories.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why not use the MSE instead of the current logistic regression? When watching the machine learning course on Coursera by Andrew Ng, in the logistic regression week, the cost function was a bit more complex than the one for linear regression, but definitely not that hard. \nBut it got me thinking, why not use the same cost function for logistic regression? \nSo, the cost function would be $\\frac{1}{2m} \\sum_{i}^m|h(x_i) - y_i|^2$, where $h(x_i)$ is our hypothesis $\\text{function}(\\text{sigmoid}(X * \\theta))$, $m$ is the number of training examples and $x_i$ and $y_i$ are our $ith$ training example?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The mean squared error (MSE), $J(\\theta) = \\frac{1}{2m}\\sum_{i=1}^m(h_\\theta(x_i)-y_i)^2$, is not as appropriate as a cost function for classification, given that the MSE makes assumptions about the data that are not appropriate for classification. Though, as an optimization objective, it is still possible to attempt to minimize MSE even in a classification problem, and thus still learn parameters $\\theta$.\nThe new cost function has better convergence characteristics as it is more inline with the objective.\nSee link for the precise mathematical formulation that explains these loss functions from a probabilistic perspective. \nNote that the absolute value is redundant because $\\forall x:x^2\\geq0$.\nI hope this clarifies the matter.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are the model implementations in Hugging Face\u2019s transformers library created by the original model authors or by Hugging Face? I've been exploring the implementation of models like Llama in Hugging Face\u2019s transformers library, for example:\nHugging Face's Llama model implementation.\nI\u2019m curious about how these implementations work:\n\nAre the model codes in Hugging Face\u2019s transformers library (e.g., for Llama) written directly by the creators of the models, or is it Hugging Face\u2019s attempt to reproduce the functionality based on documentation or papers released by the model's original creators?\nHow closely do these implementations follow the specifications or official codebases (if available) provided by the model authors?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You can actually see the author of this code if you look at the first few lines of the file.\nTo save you clicking the link again:\n# coding=utf-8\n# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.\n#\n# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX\n# and OPT implementations in this library. It has been modified from its\n# original forms to accommodate minor architectural differences compared\n# to GPT-NeoX and OPT used by the Meta AI team that trained the model.\n#\n\nSo this file is not written by meta.\nYou can find code written by the meta team that implements llama inference here: https://github.com/Meta-Llama/llama and https://github.com/meta-llama/llama/blob/main/llama/model.py\nThe main difference between these two implementations is that the EleutherAI/Huggingface implementation is built on top of the transformers API (which I will point out does use pytorch), whereas the meta implementation is written just on top of pytorch. If you are familiar with the transformers API, the EleutherAI/Huggingface implementation may be a little bit more convenient to use.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Variable Number of Inputs to Neural Networks So suppose that you have a real estate appraisal problem. You have some structured data, and some images exterior of home, bedrooms, kitchen, etc. The number of pictures taken is variable per observational unit, i.e. the house.\nI understand the basics of combining an image processing neural net with tabular data for a single image. You chop off the final layer and feed in the embeddings of the image to your final model.\nHow would one deal with variable number of images? Where your unit of observation can have between zero and infinity images (theoretically no upper bound on number of images in observation)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "We can generalize both problem and solution by removing the specifics of housing.\nRepresenting Forward Propagation\nWe have a function $f$ we wish to obtain via the training of an artificial network that produces a scalar result $s$, the sole dependent variable and the generalization of market price.\n$s = f(s_1, s_2, ..., s_k, c_1, c_2, ..., c_v)$\nThe independent scalar variables $s_1$ through $s_k$ are the generalization of a constant number $k$ of property features from the tax authority, assessor's office, or inspection document. The question calls this structured data, however it is questionable whether $k$ is truly effectively constant. In normal practice, some of $s_i$ will be unassigned. Since the question overlooks the additional complexity of missing scalars, so will this answer.\nThe independent cube variables $c_1$ through $c_v$ are the generalizations of a variable number $v$ of property images from Google photography, real estate agents, buyers, sellers, and other potential sources. The dimensions of each cube are horizontal and vertical positions and pixel structure element number.\nIt is unlikely that the resolution values for each cube are uniform between samples in real life, which the question did not mention, so this answer will overlook that complexity and focus on the variability of $v$, the quantity of cubes representing images for a given example. Since $v$ cannot meaningfully be either negative or infinite, we can assume $v$ to be a non-negative integer.\nTerminology\nThe observational unit should not be considered the house or the property but an image of it, which may be a member of a camera location and orientation category relative to the elements of the property. Each image capture is an observation, distinct in both Bergsonian and clock time. Each item under evaluation is an example from the sample of all items, in this case, all properties in the region for which prediction is attempted.\nDesign of a Solution\nEach of the $v$ cubes demonstrate zero or more additional features of the item being evaluated, real properties in the question's specific case.\nIt may be reasonable to assume that such features may either positively or negative affect the example's label corresponding to the result $s$, but not both positively and negatively affect it. If that is the case, we can aggregate the features across the set of cubes for each example under the reasonable assumption that there are no points of inflection. Such may be reasonable because, for instance, a feature regarding the uniformity of paint coverage, lawn care, or roofing material may have no inflection point. Such aspects of the property cannot be too uniform. That makes the substitution straightforward.\nA reasonably versatile way to generalize the aggregation of directionally consistent function is using a substitution, which may be what the question meant by feed in the embeddings of the image to your final model.\n$s = f = f'(s_1, s_2, ..., s_k, v, h\\big(v, \\sum_{j = 1}^v g(c_j)\\big)$\nNote the elements of this substitution.\n\n$h$ is a vector function that normalizes the distribution of each feature found in the feature vector before using it as a set of inputs to $f'$.\n$g$ is a generalization of the cube, with the input (independent variable) being a cube representing the image and with the output (dependent variable) being a vector of features extracted.\n$v$, the number of cubes (visual observations) is fed along with extracted features into the function $f'$, which can be realized through the convergence of a multilayer perceptron.\n\nIf the images are grouped in terms of the location of the camera, then this principle can be applied iteratively, where $o$ is the number of distinct categories of camera orientation. In this case, the pairs $(v_z, h_z)$ represent the cube quantity and feature aggregations for image camera location category $z$.\n$s = f = f'(s_1, s_2, ..., s_k, v_1, h_1, v_2, h_2, ... v_o, h_o)$\nGiven sensible models $h$ and $g$, training for prediction is straightforward.\nImage feature extraction can be realized through ConvNet approaches such as OverFeat1, AlexNet2, CaffeNet3, GoogLeNet4, VGG 65 or PatreoNet6. Tuning such models produces $g$.\nThe nature of function $h$ may be homogeneous or heterogeneous across dimensions. Each component of the feature vector arising from extraction can have applied to it a function such as any of these or others, where $q$ is the feature index, $p_{qi}$ is learning parameter i.\n\n$h_q(x) = x$\n$h_q(x) = \\large{x^{p_{q1} + p_{q2} v}}$\n$h_q(x) = \\log (x + p_{q1} v + p_{q2})$\n$h_q(x) = \\large{\\epsilon^x}$\nOthers\n\nScalar function 1 is best when the designer wishes the convergence during the training of $f'$ in such a way that normalization is accomplished in the net. It is a good choice for features where its frequency of occurrence and magnitude are across the entire set of images for a given example item is roughly proportional to the resulting value of that item.\nFunction 2 presents flexibility in normalization curvature with respect to the number of cubes. Function 3 presents attenuation of the frequency of feature occurrence. Function 4 presents compounding of feature effect with recurrence in the images of the same example.\nThe key is then the selection of how to deal with the substitution in the training in terms of procedure and wiring of corrective signaling. Procedurally, there are three options.\n\nTrain both the ConvNet function $g$ and the multilayer perceptron function $f'$ together, extending the applicable principles of back-propagation and gradient descent.\nExtract features first, tuning the ConvNet corresponding to $g$ prior to training the network corresponding to $f'$. The advantage of this approach is manual control over and interim evaluation of feature extraction.\nUse something similar to the mini-batch approach to find a balance between the above two extremes.\n\n\u2014\u2014\u2014\nFootnotes\n[1] P. Sermanet, D. Eigen, X. Zhang, M. Mathieu, R. Fergus, Y. LeCun, Overfeat: Integrated recognition, localization and detection using convolutional networks, arXiv preprint arXiv:1312.6229v4\n[2] A. Krizhevsky, I. Sutskever, G. E. Hinton, Imagenet classification with deep convolutional neural networks, in: Neural Information Processing Systems, 2012, pp. 1106\u20131114\n[3] Y. Jia, E. Shelhamer, J. Donahue, S. Karayev, J. Long, R. Girshick, S. Guadarrama, T. Darrell, Caffe: Convolutional architecture for fast feature embedding, arXiv preprint arXiv:1408.5093\n[4] C. Szegedy, W. Liu, Y. Jia, P. Sermanet, S. Reed, D. Anguelov, D. Erhan, V. Vanhoucke, A. Rabinovich, Going deeper with convolutions, arXiv preprint arXiv:1409.4842\n[5] K. Simonyan, A. Zisserman, Very deep convolutional networks for large-scale image recognition, arXiv preprint arXiv:1409.1556\n[6] K. Nogueira, W. O. Miranda, J. A. Dos Santos, Improving spatial feature representation from aerial scenes by using convolutional networks, in: Graphics, Patterns and Images (SIBGRAPI), 2015 28th SIBGRAPI Conference on, IEEE, 2015, pp. 289\u2013296.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is a \"batch\" in batch normalization? I'm working on an example of CNN with the MNIST hand-written numbers dataset. Currently I've got convolution -> pool -> dense -> dense, and for the optimiser I'm using Mini-Batch Gradient Descent with a batch size of 32.\nNow this concept of batch normalization is being introduced. We are supposed to take a \"batch\" after or before a layer, and normalize it by subtracting its mean, and dividing by its standard deviation.\nSo what is a \"batch\"? If I feed a sample into a 32 kernel conv layer, I get 32 feature maps. \n\nIs each feature map a \"batch\"? \nAre the 32 feature maps the \"batch\"? \n\nOr, if I'm doing Mini-Batch Gradient Descent with a batch size of 64,\n\nAre 64 sets of 32 feature maps the \"batch\"? So in other words, the batch from Mini-Batch Gradient Descent, is the same as the \"batch\" from batch-optimization?\n\nOr is a \"batch\" something else that I've missed?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The \"batch\" is same as in mini-batch gradient descent. The mean in batch-norm here would be the average of each feature map in your batch (in your case either 32 or 64 depending on which you use)\ngenerally batch is used quite consistently in ML right now, where it refers to the inputs you send in together for forward/backward pass.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What's the optimal policy in the rock-paper-scissors game? A deterministic policy in the rock-paper-scissors game can be easily exploited by the opponent - by doing just the right sequence of moves to defeat the agent. More often than not, I've heard that a random policy is the optimal policy in this case - but the argument seems a little informal.\nCould someone please expound on this, possibly adding more mathematical details and intuition? I guess the case I'm referring to is that of a game between two RL agents, but I'd be happy to learn about other cases too. Thanks!\nEDIT: When would a random policy be optimal in this case?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "For this, we will need game theory.\nIn game theory, an optimal strategy is one that cannot be exploited by the opponent even if they know your strategy.\nLet's say you want a strategy where your move selection is not based on what happened before (so you are not trying to model your opponent, or trick them into believing you will always play scissors and then throw them off, anything like that).\nA strategy will look like $(P, S, R)$, where $P, S, R \\in [0, 1], P+S+R = 1$. You select paper with probability $P$, scissors with probability $S$, rock with probability $R$.\nNow, if your probabilities are a bit uneven (for example $(0.5, 0.2, 0.3)$) an opponent can abuse that strategy. If your opponent plays with probabilities $(p, s, r)$, their expected reward (counting +1 for win, -1 for loss, 0 for draw) would be $0.5(s - r) + 0.2(r - p) + 0.3(p - s) = 0.1p + 0.2s - 0.3r$. If they wish to maximize their wins, they would play scissors all the time against you, and expect to have a distinct advantage over you.\nIn general, for a strategy $(P, S, R)$ for you and $(p, s, r)$ for your opponent, your opponent's winnings would be $P(s - r) + S(r - p) + R(p - s) = p(R-S) + s(P-R) + r(S - P)$. If all the partial derivatives of this, with respect to $p$, $s$ and $r$ are 0, the opponent has no way to maximize his winnings; they would have no incentive to play a particular move over any other move.\nThis occurs when $P = S = R = \\frac13$.\nThat's basically how to approach game theory: find a strategy so your opponent has no incentive to choose one action over another. The approach seems a bit counter-intuitive at first (you're trying to find the optimal strategy for your opponent instead of for yourself) but it works for many similar problems.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What's the difference between a \"perceptron\" and a GLM? In a comment to this question user nbro comments:\n\nAs a side note, \"perceptrons\" and \"neural networks\" may not be the same thing. People usually use the term perceptron to refer to a very simple neural network that has no hidden layer. Maybe you meant the term \"multi-layer perceptron\" (MLP).\n\nAs I understand it, a simple neural network with no hidden layer would simply be a linear model with a non-linearity put on top of it. That sounds exactly like a generalized linear model (GLM), with the non-linearity being the GLM's link function.\nIs there a notable difference between (non-multi-layer) perceptrons and GLMs? Or is it simply another case of two equivalent methods having different names from different researchers?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The perceptron uses the Heaviside step (or sign) function as the activation function (so you are not free to use any activation function), while a GLM is a generalization of linear regression, where the link function can be, for example, the logit (which leads to the logistic regression), identity function (which leads to linear regression), and so on. The sign function has the role in the perceptron as the sigmoid in logistic regression.\nSo, GLM models have a probabilistic interpretation (i.e. you assume that the response variable follows some distribution), while perceptrons do not, even though, for example, the perceptron and logistic regression can both be used for classification.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to replicate legacy systems with machine learning? Let's suppose that we have a legacy system in which we don't have the source code and this system is on a mainframe written in Cobol. Is there any way using machine learning in which we can learn from the inputs and outputs the way the executables work? Doing this analysis could lead to develop some rest / soap webservice that can substitute the legacy system in my opinion. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Let's assume from the outset that the space of inputs is too large to allow exhaustive tabulation.\nThe essential issues when applying ML are that the program being modelled is likely in general to:\n\nBe discrete, i.e. operate (at least in part) on integer, boolean or categorical variables.\nContain various conditional/looping constructs (if/while/for etc).\nHave side-effects that affect other parts of the program (e.g. non-local variables) or world state (e.g. writing to a file).\n\nThese pose obstacles for ML methods such as ANN. The ML approach which is most immediately compatible with these issues is Genetic Programming (GP).\nA recent specialisation of GP that is specifically concerned with the transformation of existing software systems is Genetic Improvement (GI).\nHowever neither GP/GI (nor any other current ML technique) is a 'silver bullet' here:\n\nDespite decades of research, GP still works best at synthesizing relatively small functions, certainly not entire legacy programs.\nBecause it is only possible to train on a very small subset of a program's input space, there is little guarantee that the program will generalize to inputs it hasn't been trained on.\nHow will the success of side effects be formally determined for training purposes?\n\nSome of these issues could be addressed to some degree if the program has a comprehensive test suite, but replacing an entire nontrivial program is not likely anytime soon. Replacing smaller parts of the program that have good unit tests is more realistic goal.\nHere is a case study showing how GI was successfully used to fix errors in the implementation of Apache Hadoop, by operating only on the program binary.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What does 'democratizing AI' exactly mean? In my AI literature research, I often notice authors use the term 'democratizing AI', especially in the AutoML area. For example in the abstract (last sentence) of this paper:\n\nLEAF therefore forms a foundation for democratizing and improving AI, as well as making AI practical in future applications.\n\nI think I have an idea of what this means, but I would like to ask you for some more specific answers.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In this particular context, \"Democratize\" means to make more accessible to people.\nThus, \"Democratizing AI\" means to make AI softwares and AI programming available, accessible and easy to use for the vast majority of people.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can we prove that an autoassociator network will continue to perform if we zero the diagonal elements of a weight matrix? How can we prove that an auto-associator network will continue to perform if we zero the diagonal elements of a weight matrix that has been determined by the Hebb rule? In other words, suppose that the weight matrix is determined from $W = PP^T- QI$, where $Q$ is the number of prototype vectors. \nI have been given a hint: show that the prototype vectors continue to be eigenvectors of the new weight matrix.\nThis is a question from Neural Network Design (2nd Edition) book by\nMartin T. Hagan, Howard B. Demuth, Mark H. Beale, Orlando De Jesus .\nResource : E7.5 p 224-225\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As we have an autoassociative network prototype vectors are both input and output vectors. So , we have that :\n\\begin{equation}\n T = P\n\\end{equation}\n\\begin{equation}\n W = PP^T - QI = TP^T - QI = \\sum_{q=1}^Q p_q p_q^T - QI\n\\end{equation}\nApplying a prototype vector as input :\n\\begin{equation}\n \\alpha = W \\cdot p_k = \\sum_{q=1}^Q p_k p_q p_q^T - QIp_k\n\\end{equation}\nBecause they are orthogonal we have :\n\\begin{equation}\n \\alpha = p_k(p_k^T\\cdot p_k) - Q \\cdot I \\cdot p_k = p_k (p_k^T\\cdot p_k - Q \\cdot I ) = p_k (\\textbf{R - Q $\\cdot$ I})\n\\end{equation}\nwhere $R-Q\\cdot I$ is the length of vectors\nSo since ,\n\\begin{equation}\n W \\cdot p_k= (R - Q \\cdot I) \\cdot p _k\n\\end{equation}\nprototype vectors\ncontinue to be eigenvectors of the new weight matrix .\nIt is often the case that for auto-associative nets, the diagonal weights (those which connect an input component to the corresponding output component) are set to 0. There are papers that say this helps learning. Setting these weights to zero may improve the net's\nability to generalize or may increase the biological\nplausibility of the net. In addition, it is necessary if we use iterations (iterative nets) or the delta rule is used\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which function $(\\hat{y} - y)^2$ or $(y - \\hat{y})^2$ should I use to compute the gradient? The MSE can be defined as $(\\hat{y} - y)^2$, which should be equal to $(y - \\hat{y})^2$, but I think their derivative is different, so I am confused of what derivative will I use for computing my gradient. Can someone explain for me what term to use?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The derivative of $\\mathcal{L_1}(y, x) = (\\hat{y} - y)^2 = (f(x) - y)^2$ with respect to $\\hat{y}$, where $f$ is the model and $\\hat{y} = f(x)$ is the output of the model, is \n\\begin{align}\n\\frac{d}{d \\hat{y}} \\mathcal{L_1}\n&= \\frac{d}{d \\hat{y}} (\\hat{y} - y)^2 \\\\\n&= 2(\\hat{y} - y) \\frac{d}{d \\hat{y}} (\\hat{y} - y) \\\\\n&= 2(\\hat{y} - y) (1) \\\\\n&= 2(\\hat{y} - y) \n\\end{align}\nThe derivative of $\\mathcal{L_2}(y, x) = (y - \\hat{y})^2 = (y - f(x))^2$ w.r.t $\\hat{y}$ is\n\\begin{align}\n\\frac{d}{d \\hat{y}} \\mathcal{L_2}\n&= \\frac{d}{d \\hat{y}} (y - \\hat{y})^2 \\\\\n&= 2(y -\\hat{y}) \\frac{d}{d \\hat{y}} (y -\\hat{y}) \\\\\n&= 2(y - \\hat{y})(-1)\\\\\n&= -2(y - \\hat{y})\\\\\n&= 2(\\hat{y} - y)\n\\end{align}\nSo, the derivatives of $\\mathcal{L_1}$ and $\\mathcal{L_2}$ are the same.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "In reinforcement learning, does the optimal value correspond to performing the best action in a given state? I am confused about the definition of the optimal value ($V^*$) and optimal action-value (Q*) in reinforcement learning, so I need some clarification, because some blogs I read on Medium and GitHub are inconsistent with the literature.\nOriginally, I thought the optimal action value, $Q^*$, represents you performing the action that maximizes your current reward, and then acting optimally thereafter.\nAnd the optimal value, $V^*$, being the average $Q$ values in that state. Meaning that if you're in this state, the average \"goodness\" is this.\nFor example:\nIf I am in a toy store and I can buy a pencil, yo-yo, or Lego.\nQ(toy store, pencil) = -10\nQ(toy store, yo-yo) = 5\nQ(toy store, Lego) = 50\n\nAnd therefore my $Q^* = 50$\nBut my $V^*$ in this case is:\nV* = -10 + 5 + 50 / 3 = 15\n\nRepresenting no matter what action I take, the average future projected reward is $15$.\nAnd for the advantage of learning, my baseline would be $15$. So anything less than $0$ is worse than average and anything above $0$ is better than average.\nHowever, now I am reading about how $V^*$ actually assumes the optimal action in a given state, meaning $V^*$ would be 50 in the above case.\nI am wondering which definition is correct.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nI am wondering which definition is correct.\n\nThe asterisk * in both the definitions stands for \"optimal\" in the sense of \"value when following the optimal policy\"\nSo this one is correct:\n\n$V^*$ actually assumes the optimal action in a given state, meaning $V^*$ would be $50$ in the above case\n\nHowever, you have got the definition of Q slightly wrong.\nI think this is because you are omitting the parameters.\nThe state value function uses the state as a parameter, $V_{\\pi}(s)$, it returns the value of being in state $s$ and following a fixed policy $\\pi$. The * is used to denote following an optimal policy.\nThe action value function has two parameters - a state and an action that is possible in that state, $Q_{\\pi}(s, a)$, it returns the value of being in state $s$, taking action $a$ (regardless of whether it is the best action or not) and following the policy $\\pi$ after that point.\nYour assertion in the question:\n\nAnd therefore my $Q^* = 50$\n\nis wrong, or rather not meaningful, as you have not stated the parameters. You already list all the possible values of Q with the parameters. You could say $\\text{max}_a Q(\\text{toy store}, a) = 50$, or to choose the best action $\\pi(\\text{toy store}) = \\text{argmax}_a Q(\\text{toy store}, a) \n= \\text{Lego}$\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to set the target for the actor in A2C? I did a simple Actor-Critic implementation in Keras using 2 networks where the critic learns the Q-Values of every action, and the actor predicts probabilities for choosing each action. In training, the target probabilities for the actor was a one-hot vector with 1.0 in the maximum Q-Value prediction position and 0.0 in all the rest, and simply used fit method on the actor model with mean squared error loss function.\nHowever, I'm not sure what to set as the target when switching to A2C. In all the guides I saw it's mentioned that the critic now learns one value per state, not one value per action in the action space. \nThis change makes it unclear on how to set the target vector for the actor. The guides/SE questions I went over did not explain this point and simply said that we can calculate the advantage value using the value function (here, here and here) for the current and next state, which is fine, except we can only do that for the specific action taken and not for every action in the action-space because we don't the value for every next state for every action.\nIn other words, we only know A(s,a) for our memorized a, and we know nothing about the advantage of other actions.\nOne of my guesses was that you still calculate the Q-Values, because after all, the value function is defined by the Q-Values. The value function is the sum over every action a of Q(s,a)*p(a). So does the critic need to learn the Q-Values and sum their multiplications with the probabilities generated by the policy network (actor), and calculate the advantages of every action?\nIt's even more confusing because in one of the guides they said that the critic actually learns the advantage values, and not the value function (like all the other guides said), which is strange because you need to use the critic to predict the value function of the state and the next state. Also, the advantage function is per-action and in the implementations I see the critic has one output neuron.\nI think that what's being done in the examples I saw was to train the actor to fit a one-hot vector for the selected action (not the best action by the critic), but modify the loss-function value using the advantage value (possibly to influence the gradient). Is that the case?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In short, my last sentence was the correct answer. The \"target\" is a one-hot with the selected action, but there's a trick.\n\nA2C Loss Function\nA very crucial part of A2C implementation that I missed is the custom loss function that takes into account the advantage. The loss function multiplies the advantage with the negative log of the current probability to select the action that was selected.\nThe trick is that if the advantage is negative, the loss function will switch sign, so the gradients will be applied to the opposite direction.\nIn one dimension it's easier to understand. Let's say my target prediction is 1 and my actual prediction is 0.6. A simple loss would be defined as target - prediction, or in this case 0.4 and future predictions will be closer to one. If my prediction was 1.4, then the loss would be -0.4. A negative loss would mean predicting a lower result in the future, and a positive result would mean predicting a higher result in the future.\nIf the sign of the loss function is switched, the prediction will actually move away from 1.\nThe same thing happens when you multiply the advantage in the loss function. A negative advantage would mean that this action is worse than the value of the state so we need to avoid it, and a positive advantage means that the action is encouraged.\n\nIn Keras (Tensorflow 2.0):\nHere's the custom loss function:\ndef custom_actor_loss(y_true, y_prediction, advantage):\n prediction = K.clip(y_prediction, 1e-8, 1 - 1e-8)\n log_probabilities = y_true * K.log(prediction)\n\n return K.sum(-log_probabilities*advantage)\n\nThe values are clipped because log of 0 is undefined.\nAnd the rest of the network building:\ninput_layer = Input(shape=self._state_size, name='state_in')\nadvantage = Input(shape=[1], name='advantage')\ntarget_prediction = Input(shape=self._actions_num, name='target')\n\ninner_layer = Dense(units=layer_size, activation='relu')(input_layer)\nactor_out = Dense(units=self._actions_num, activation='softmax', name='actor_out')(inner_layer)\n\nself._actor = Model([input_layer, target_prediction, advantage], actor_out, name='actor')\nself._actor.add_loss(custom_actor_loss(actor_out, target_prediction, advantage))\nself._actor.compile(optimizer=Adam(learning_rate=actor_learning_rate))\n\nAnd in the training loop (where future_rewards_prediction and critic_prediction are the outputs from the critic for the current and next state (except for the terminal state where the future_rewards_prediction is set to 0):\n# Train actor\ntarget_probabilities = np.zeros([1, self._actions_num])\ntarget_probabilities[0][memory[step_idx].action] = 1.0\nadvantage = memory[step_idx].reward + future_rewards_prediction * self._future_discount - critic_prediction\nself._actor.fit((memory[step_idx].state, target_probabilities, advantage), verbose=0)\n\n*Notice how I don't really specify a y in my fit call. This is because of an issue I had when trying to implement a custom loss function in Keras which was solved by this answer.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to parse conjunctions in natural language processing? Is there an accepted way in NLP to parse conjunctions (and/or) in a sentence?\nBy following the example below, how would I parse\n\nI drink orange juice if its the weekend or if it's late and I'm tired.\n\ninto\n\nit's the weekend\n\nand \n\nit's late\n\nand \n\nI'm tired\n\n?\nImplying an action will be taken when one of the above elements at the 1st level of depth is true.\nI know when I hear the sentence that it means \"its the weekend\" OR (\"it's late\" AND \"I'm tired\"), but how could this be determined computationally?\nCan an existing python/other library do this?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This seems not easy for NLP. I doubt that state-of-the-art NLP tools can reliably determine the correct hierarchical structure of independent clauses. Examples below.\nThe Berkeley parser gets it basically right in the sense that it can put its late and I'm tired on parallel, and they together on parallel with the weekend. But still not perfect (the weekend should be in the same subtree with It's rather than if its late and I'm tired)\n\nThe Stanford parser, which is available in Python (NLTK), incorrectly parsed I\\'m tired to the same level of I drink orange juice.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "While fine-tuning a decoder only LLM like LLaMA on chat dataset, what kind of padding should one use? While fine-tuning a decoder only LLM like LLaMA on chat dataset, what kind of padding should one use?\nMany papers use Left Padding, but is right padding wrong since transformers gives the following warning if using right padding \" A decoder-only architecture is being used, but right-padding was detected! For correct generation results, please set padding_side='left' when initializing the tokenizer.\"\nThe attention mask will anyways ignore the padding tokens.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I got an answer to this question, probably a correct explanation.\nIn decoder-only model architectures, the output of the model is a continuation of the model input.\nFor example, input: I love apple [pad] [pad]. The output of the model will contain the input and add additional output information.\nFor example, output: I love apple [pad] [pad],because it is delicious.\nThis would result in [pad] being stuck in the middle of the text. It is very bad for the model to process text. If we use left-padding, the output of this model will be\noutput : [pad] [pad] i love apple,because it is delicious.\nSuch complete semantic information is continuous.\nref:https://github.com/huggingface/transformers/issues/18388#issuecomment-1204369688\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does IBM Watson use machine learning? I was reading an article on Medium and wanted to make it clear whether a bot created on IBM Watson is an intelligent one or unintelligent.\n\nSimply put, there are 2 types of chatbots\u200a\u2014\u200aunintelligent ones that act using predefined conversation flows (algorithms) written by developers building them and intelligent ones that use machine learning to interact with users.\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, it does and at many parts of the solution. For one of the core components - intent detection - Intento did a benchmark comparing IBM Watson and other similar products.\nOutside of intent detection, there are other areas where AI techniques help - e.g. disambiguation, bootstrapping a bot from chat logs etc. Specifically for IBM Watson, you can learn more here.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How many weights does the max-pooling layer have? How many weights does the max-pooling layer have?\nFor example, if there are 10 inputs, a pooling filter of size 2, stride 2, how many weights, including bias, does a max-pooling layer have?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A max-pooling layer doesn't have any trainable weights. It has only hyperparameters, but they are non-trainable. The max-pooling process calculates the maximum value of the filter, which consists of no weights and biases. It is purely a way to downscale the data to a smaller dimension.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Should the prediction of the body temperature given a camera image be modelled as classification or regression? I am fairly new to deep learning in general and I am currently facing a problem I want to solve using neural networks and I am unsure if it is a classification or regression problem. I am aware that classification problems are about classifying whether an input belongs to class A or class B (or class C ...) and regression problems are about mapping the input to some sort of continuous output (just like the house pricing problem).\nI basically want to measure the body temperature of a person using a simple video camera. To me, this seems like more of a regression type of issue rather than classification, because of the actual continuous result values I want the neural network to produce from the input video frames, e.g. 39\u00b0Celsius. But a question that came to my mind was: What if I use every integer value in the range from 35\u00b0C to 42\u00b0C as a possible output class? This would make it a classification problem, am I right? What would be the correct approach here and why? Classification or regression?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I think it depends on you application and what data you have available. \nIf the prediction of body temperature itself doesn't have to be accurate and classes like COLD, NORMAL, and HOT will suffice, you should stay with a classification. There isn't a cut off but as you increase the number of classes that represent numbers on the same scale, it may become more difficult to interpret the result as there will be a distribution across the classes.\nIf you choose regression on the other hand, you are not restricted by your classes anymore and may be able to tell the difference between 36.5 and 36C which (according to wikipedia) can be the difference between normal and cold. This is something classes may not be able to capture. \nAnother thing to consider is what your training data looks like and how accurately you want to predict the temperature. If you have pictures of people and a temperature reading, where was the reading taken and how accurate is the reading? If it isn't accurate (+- 1 degree) you may not be able to give as accurate predictions as you would like and may only be able to do 3 different classes like above. \nIf you don't have a data set, then that is another problem altogether and might require another question as it depends on your application. \nI think that your problem is interesting and I hope this can help you to understand how best to apply deep learning to it. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Understanding the equation of TD(0) in the paper \"Learning to predict by the methods of temporal differences\" In the paper Learning to predict by the methods of temporal differences (p. 15), the weights in the temporal difference learning are updated as given by the equation\n$$\n\\Delta w_t\n= \\alpha \\left(P_{t+1} - P_t\\right) \\sum_{k=1}^{t}{\\lambda^{t-k} \\nabla_w P_k}\n\\tag{4}\n\\,.$$\nWhen $\\lambda = 0$, as in TD(0), how does the method learn? As it appears, with $\\lambda = 0$, there will never be a change in weight and hence no learning. \nAm I missing anything?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nWhen lambda = 0 as in TD(0), how does the method learn? As it appears, with lambda = 0, there will never be a change in weight and hence no learning. \n\nI think the detail that you're missing is that one of the terms in the sum (the final \"iteration\" of the sum, the case where $k = t$) has $\\lambda$ raised to the power $0$, and anything raised to the power $0$ (even $0$) is equal to $1$. So, for $\\lambda = 0$, your update equation becomes\n$$\\Delta w_t = \\alpha \\left( P_{t+1} - P_t \\right) \\nabla_w P_t,$$\nwhich is basically a one-step update (just like Sarsa).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Type of artificial neural network suitable for learning and then predicting forest growth I'm trying to use an ANN to learn from a large amount of forest measurement data obtained from sampling plots across Ontario, Canada and associated climate data provided by regional climate modelling in this province. \nSo the following are the inputs to the ANN:\n\nLocation (GPS coordinates)\nMeasurement year and month\nTree species\nAge\nSoil type\nSoil moisture regime\nSeasonal or monthly average temperature\nSeasonal or monthly average precipitation\nSome more data are available to select\n\nAnd the targets include:\n- Average total tree height\n- Average tree diameter at breast height\nFor each sampling plot, the trees have been measured for 1-4 times. \nSo my question is what type of ANN can best used to learn from the data and then it can be used for predicting with a set of new input data?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "My suggestion is not to use an ANN, but instead to use a simpler regression algorithm. The main reason for this is that ANNs take a long time to train, and work better when a lot of data is used. They also require a lot of expertise in parameter tuning to apply well. Since you say you don't have a lot of data, and also don't have a lot of experience using them, I think you will be better off applying something else first. If the other techniques don't work at all, then you might think about using ANNs, but again, they tend to want a lot of data.\nIf you have tried ordinary least squares regression, and found it does not work well, my next choice would be a Classification And Regression Tree. These models can make good decisions with small amounts of data, and do not require a lot of time to train. They can handle real-valued outputs like the height and width of a tree. Weka's REPTree might be a good starting place.\nIf Trees don't work out, my next suggestion would be to try regression using a Support Vector Machine. SciKitLearn's SVR is a good choice for this. SVRs can sometimes be very effective when data is limited, because they make assumptions about how to handle data-poor regions that seem to be generally applicable. An SVM can also report low confidence when estimating in those regions. They also train fairly fast when using small amounts of data, and can learn non-linear functions from the data.\nIf you really want to use an ANN, I would start with a simple Multi-layer perceptron. This model has few parameters to play with, and can probably fit well to your regression. It may make strange decisions in regions with less data however. \nHope this helps!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Can neural networks with a sigmoid as the activation function of the output layer approximate continuous functions? Neural networks are commonly used for classification tasks, in fact from this post it seems like that's where they shine brightest. \nHowever, when we want to classify using neural networks, we often have the output layer to take values in $[0,1]$; typically, by taking the last layer to be the sigmoid function $x \\mapsto \\frac{e^x}{e^x +1}$. \nCan neural networks with a sigmoid as the activation function of the output layer approximate continuous functions? Is there an analogue to the universal approximation theorem for this case? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As far as I know, the sigmoid is often used as the activation function of the output layer mainly because it is a convenient way of producing an output $p \\in [0, 1]$, which can be interpreted as a probability, although that can be misleading or even wrong (if you interpret it as an uncertainty too).\nYou may require the output of the neural network to be a probability, for example, if you use a cross-entropy loss function, although you could in principle produce only $0$s or $1$s. The probability $p$ can then be used to decide the class (or label) of the input. For example, if $p > \\alpha$, then you purposedly decide that the input belongs to class $1$, otherwise, it belongs to class $0$. The parameter $\\alpha$ is called the classification (or decision) threshold. The choice of this threshold can actually depend on the problem and it is one of the reasons people use the AUC metric, i.e. to avoid choosing this classification threshold.\n\nCan neural networks with a sigmoid as the activation function of the output layer approximate continuous functions? Is there an analogue to the universal approximation theorem for this case?\n\nThe most famous universal approximation theorem for neural networks assumes that the activation functions of the units of the only hidden layer are sigmoids, but it does not assume that the output of the network will be squashed to the range $[0, 1]$. To be more precise, the UAT (theorem 2 of Approximation by Superpositions of a Sigmoidal Function, 1989, by G. Cybenko) states\n\nLet $\\sigma$ be any continuous sigmoidal function. Then finite sums of the\n$$G(x) = \\sum_{j=1}^N \\alpha_j \\sigma (y_j^T x + \\theta_j)$$\nare dense in $C(I_n)$.\nIn other words, given any $f \\in C(I_n)$ and $\\epsilon > 0$, there is a sum, $G(x)$, of the above form, for which\n$$|G(x) - f(x)| < \\epsilon $$\n\nHere, $f$ is the continuous function that you want to approximate, $G(x)$ is a linear combination of the outputs of $N$ (which should be arbitrarily big) units of the only hidden layer, $I_n$ denotes the $n$-dimensional unit cube, $[0, 1]^n$, $C(I_n)$ denotes the space of continuous functions on $I_n$, $x \\in I_n$ (so the assumption is that the input to the neural network is an element of $[0, 1]^n$, i.e. a vector $x \\in \\mathbb{R}^n$, whose entries are between $0$ and $1$) and $y_j$ and $\\theta_j$ are respectively the weights and bias of the $j$ unit. The assumption that $f$ is a real-valued function means that $f$ can take any value on $\\mathbb{R}$ (i.e. $f: [0, 1]^n \\rightarrow \\mathbb{R}$). You should note that $G(x)$ is the output of the neural network, which is a combination (where the coefficients are $\\alpha_j$) of the outputs of the units in the only hidden layer, so there's no restriction on the output of $G(x)$, unless you restrict $\\alpha_i$ (but, in this theorem, there's no restriction on the values $\\alpha_j$ can take).\nOf course, if you restrict the output of the neural networks to the range $[0, 1]$, you cannot approximate all continuous functions of the form $f: [0, 1]^n \\rightarrow \\mathbb{R}$ (because not all of these functions will have the codomain $[0, 1]$)! However, the sigmoid has an inverse function, i.e. the logit, so you can reverse the output of such a neural network. So, in this sense (i.e. by reversing the output of the sigmoid), a neural network with a sigmoid as the activation function of the output layer can potentially approximate any continuous function too.\nThe UAT above only states the existence of $G(x)$ (i.e. it's an existence theorem). It doesn't tell you how you can find $G(x)$. So, if you use a sigmoid as the activation function of the output layer or not is a little bit orthogonal to the universality of neural networks.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Snake game: snake converges to going in the same direction every time This is a q-learning snake using a neural network as a q function aproximator and I'm losing my mind here the current model it's worst than the initial one.\nThe current model uses a 32x32x32 MLPRegressor from scikit-learn using relu as activation function and the adam solver.\nThe reward function is like following:\n\ndeath reward = -100.0\nalive reward = -10.0\napple reward = 100.0\n\nThe features extracted from each state are the following:\n\nwhat is in front of the snake's head(apple, empty, snake)\nwhat is in the left of the snake's head\nwhat is in the right of the snake's head\neuclidian distance between head and apple\nthe direction from head to the apple measured in radians\nlength of the snake\n\nOne episode consists of the snake playing until it dies, I'm also using in training a probability epsilon that represent the probability that the snake will take a random action if this isn't satisfied the snake will take the action for which the neural network gives the biggest score, this epsilon probability gradually decrements after each iteration.\nThe episode is learned by the regressor in reverse order one statet-action at a time.\nHowever the neural network fails too aproximate the q function, no matter how many iterations the snake takes the same action for any state.\nThings I tried:\n\nchanging the structure of the neural network\nchanging the reward function\nchanging the features extracted, I even tried passing the whole map to the network\n\nCode (python): https://pastebin.com/57qLbjQZ\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are two problems here.\n\nThe code you posted doesn't incrimentally train your multilayer perceptron. Instead, it effectively re-randomizes the weights, and then re-fits the model each time you call .fit() at lines 35 & 54. Using SKLearn's _fit() function with Incremental=true might solve this, or you can package up the data into a larger batch, and train on that offline instead after several episodes.\nYour reward function makes it painful to be alive, and doesn't give enough benefits through the Apples to make up for this. There are 100 squares that could contain the apple. On average, the apple will spawn about 5 squares from the snake in each direction. Since the snake can't move diagonally, that's 10 moves (5 left/right, 5 up/down). That means that if the snake plays perfectly, then on average, it might be able to get zero reward total. In practice, the snake will not play perfectly. This means living gives negative expected reward.\n\nIn contrast, if the snake can kill itself, it will stop getting negative rewards. The reward function you've used is maximized by getting big enough to run into your own tail as fast as possible. The snake should be able to do this after eating 3 apples I think. There is some incentive to hunt for food well, but not much compared with hitting your own tail as soon as possible.\nIf you want the snake to learn to hunt for the food, reduce the penalty for being alive to -1, or even -0.1. The snake will be much more responsive to signals from the food.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are examples of approaches to dimensionality reduction of feature vectors? Given a pre-trained CNN model, I extract feature vector of images in reference and query dataset with several thousands of elements.\nI would like to apply some augmentation techniques to reduce the feature vector dimension to speed up cosine similarity/euclidean distance matrix calculation.\nI have already come up with the following two methods in my literature review:\n\nPrincipal Component Analysis (PCA) + Whitening\nLocality Search Hashing (LSH)\n\nAre there more approaches to perform dimensionality reduction of feature vectors? If so, what are the pros/cons of each perhaps?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Dimensionality reduction could be achieved by using an Autoencoder Network, which learns a representation (or Encoding) for the input data. While training, the reduction side (Encoder) reduces the data to a lower-dimension and a reconstructing side (Decoder) tries to reconstruct the original input from the intermediate reduced encoding. \nYou could assign the encoder layer output ($L_i$) to a desired dimension (lower than that of the input). Once trained, $L_i$ could be used as a alternative representation of your input data in a lower feature-space, and can be used for further computations.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is symbolic AI not so popular as ANN but used by IBM's Deep Blue? Everybody is implementing and using DNN with, for example, TensorFlow or PyTorch.\nI thought IBM's Deep Blue was an ANN-based AI system, but this article says that IBM's Deep Blue was symbolic AI.\nAre there any special features in symbolic AI that explain why it was used (instead of ANN) by IBM's Deep Blue?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "ANNs as used today need 1. a lot of data 2. a lot of computational power. Before we had any of the above two, we didn't really know how to properly build ANNs since we didn't quite have the means to train the network, and thus couldn't evaluate it.\n\"Symbolic AI\" on the other hand, is very much just a bunch of if-else/logical conditions, much like regular programming. You don't need to think too much about the whole \"symbolic\" part of it. The main/big breakthrough is that you had a lot of clever \"search algorithms\" and a lot of computation power relative to before.\nPoint being, is just that symbolic AI was the main research program at the time, and people didn't really bother with \"connectionist\" methods.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which linear algebra book should I read to understand vectorized operations? I am reading Goodfellow's book about neural networks, but I am stuck in the mathematical calculus of the back-propagation algorithm. I understood the principle, and some Youtube videos explaining this algorithm shown step-by-step, but now I would like to understand the matrix calculus (so not basic calculus!), that is, calculus with matrices and vectors, but especially everything related to the derivatives with respect to a matrix or a vector, and so on.\nWhich math book could you advise me to read?\nI specify I studied 2 years after the bachelor in math school (in French: math\u00e9matiques sup\u00e9rieures et sp\u00e9ciales), but did not practice for years.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "If you already have two years of a bachelor's of mathematics, I recommend part I of the book that you're mentioning. That part of the book reviews the main mathematics used in the optimization of neural nets (in part 1), and then actually goes through the various models in detail in the later parts. The review is done at a level that is suitable for someone who has already studied these topics, but needs a refresher.\nThe book Matrix Differential Calculus with Applications in Statistics and Econometrics covers more advanced topics, which might also be what you are looking for. There is also the related Wikipedia article.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the effect of mislabeled training data? Collecting and labeling training data for supervised learning tasks is incredibly time-consuming and costly.\nFor instance, let's say you wrote a script that went on Google images and got you 5000 pictures for each of 10 classes. You then use an unsupervised algorithm to cluster them. Then, you train a supervised algorithm using the labels from the scraper as ground truth. Obviously, your network will perform more poorly than one with perfectly labeled data, but is there a way to guesstimate how much?\nPerhaps there are 50 mislabeled images in each class. That would most likely be better than 500 mislabeled images, but I'm wondering if there is a way to predict how much (even if it is by someone's rules of thumb or something like that).\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I think the crucial point here is what you precisely mean by mislabelled. Google's image classifier will likely do a 'pretty good' job of retrieving images with the given subject included, but how strict or lenient your class requisites are is quite important. For example, if one of your classes is 'dog' there may be hundreds of images procured from scraping that could display (examples off the top of my head, but you can get even more creative): \n\nAncient canine fossils\nWolves\nStuffed animal dogs\nHard mode dogs (i.e. partially occluded, variable lighting schemas, background color variation, intraclass/species variation)\n\nAdditionally, your computational tool will impact this. If you're using a neural network, the above issues can to some extent be accounted for, but a linear classifier would likely have difficulty adopting a broader/flexible view of your class. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there any resource that describes in detail a naive example-based machine translation algorithm? I'm looking to develop a machine translation tool for a constructed language. I think that the example-based approach is the most suitable because the said language is very regular and I can have a sufficient amount of parallel translations.\nI already know the overall idea behind the example-based machine translation (EBMT) approach, but I can't find any resource that describes a naive EBMT algorithm (or model) that would allow me to easily implement it.\nSo, I'm looking for either:\n\na detailed description,\npseudocode or\na sufficiently clear open-source project (maybe a GitHub one)\n\nof a naive EBMT algorithm. So, I'm not looking for a software library that implements this, but I'm looking for a resource that explains/describes in detail a naive/simple EBMT algorithm, so that I am able to implement it.\nNote that there are probably dozens of variations of EBMT algorithms. I'm only looking for the most naive/simple one.\nI have already looked at the project Phrase-based Memory-based Machine Translator, but, unfortunately, it is not purely based on examples but also statistical, i.e. it needs an alignment file generated by, for example, Giza++ or Moses.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I have not found any simple implementation of a naive EBMT system, but I found some articles, papers and books that may be helpful (although I haven't read them, apart from the first and last one), so I will list them below.\nThe web article Example-based machine translation provides a decent high-level explanation of example-based machine translation. \nThe paper Example-Based Machine Translation: A New Paradigm (2002) by Chunyu Kit et al. also seems to provide a detailed description of the EBMT approach, so this paper should provide you with details you need to implement an EBMT system.\nThe paper A framework of a mechanical translation between Japanese and English by analogy principle (1984) by Makoto Nagao introduced the example-based machine translation approach, so it will be at least historically relevant. \nAdditionally, the paper Example-Based Machine Translation of the Basque Language and the book Recent Advances in Example-Based Machine Translation (2003), which is not apparently freely available online, could also be useful.\nFinally, the article Machine Translation. From the Cold War to Deep Learning gives a nice high-level overview of the main machine translation approaches, so that you can understand the differences between EBMT and other approaches (especially, in case you are not able to distinguish between EBMT and other MT, e.g. those that use a parallel corpus, such as the supervised statistical machine translation approaches).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is the 'direction' considered, when determining the branching factor in bidirectional search? If I am correct, the branching factor is the maximum number of successors of any node.\nWhen I am applying bidirectional search to a transition graph like this one below\n\nIf 11 is the goal state and I start going backwards, is 10 considered as a successor of 5? Even if it does not leads me further to my start state 1?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nIf I am correct, the branching factor is the maximum number of successors of any node\n\nYou are correct, they should also be the immediate ones:\n\n\nIf 11 is the goal state and I start going backwards, is 10 considered as successor of 5? Even if it do not leads me further to my start state 1?\n\nNo, there is also a bit of misunderstanding of bidirectional search: In bidirectional search you run 2 simultaneous searches, one forward from the initial state, and another one backwards from the goal(hoping they meet in the middle and save you steps), if actions are reversible ( going from node to node), the successor nodes become predecessors in one search and vice versa, and your goal becomes your initial state, in your case:\n\nReference/source\nArtificial Intelligence: A Modern Approach, by S. Russell and P. Norvig.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does the variational auto-encoder use the reconstruction loss? VAE is trained to reduce the following two losses.\n\nKL divergence between inferred latent distribution and Gaussian.\n\nthe reconstruction loss\n\n\nI understand that the first one regularizes VAE to get structured latent space. But why and how does the second loss help VAE to work?\nDuring the training of the VAE, we first feed an image to the encoder. Then, the encoder infers mean and variance. After that, we sample $z$ from the inferred distribution. Finally, the decoder gets the sampled $z$ and generates an image. So, in this way, the VAE is trained to make the generated image to be equal to the original input image.\nHere, I cannot understand why the sampled $z$ should make the original image, since the $z$ is sampled, it seems that the $z$ does not have any relationship between the original image.\nBut, as you know, VAE works well. So I think I miss something important or understand it in a totally wrong way.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The VAE uses the ELBO loss, which is composed of the KL term and the likelihood term. The ELBO loss is a lower bound on the evidence of your data, so if you maximize the ELBO you also maximize the evidence of the given data, which is what you indirectly want to do, i.e. you want the probability of your given data (i.e. the data in your dataset) to be high (because you want to use the VAE for the generation of inputs similar to the ones in your dataset). So, the idea is that you optimize both the KL term and the reconstruction (or likelihood) term jointly (i.e. the ELBO). Why? Because, as I just said, the ELBO is the Evidence Lower BOund on the given data, so, by maximizing it, you are also maximizing the evidence of your data. In other words, if you maximize the ELBO, you are finding a decoder that will have a high probability of reconstructing your inputs (i.e. the likelihood term), but, at the same time, you want your encoder to be constrained (i.e. KL term). Please, read this answer for further details.\n\nHere, I cannot understand why the sampled $z$ should make the original image, since the $z$ is sampled, it seems that the $z$ does not have any relationship between the original image.\n\nThe relationship is that you will be maximizing the ELBO, which implies (and you can see this implication only if you are familiar with the ELBO loss) you will be minimizing the KL divergence between your posterior and the prior to generate the samples $z$ (i.e. minimizing because there will be a minus in front of the KL term in the ELBO loss) and maximizing the probability of the reconstructed input. More precisely, $z$ is used to reconstruct the input (i.e. the decoder does this), which is then used to calculate the reconstruction loss. \nIn the mathematical formulations, you will see that the likelihood term of the ELBO is $p(x \\mid z)$, i.e. the likelihood of the input $x$ given $z$. The $z$ is the input to the decoder, which produces a reconstruction of $x$. In practice, people will e.g. use the cross-entropy to then calculate the \"reconstruction loss\" (e.g. see this PyTorch implementation), which should correspond to this likelihood term $p(x \\mid z)$. Why does the cross-entropy correspond to a likelihood? Because you can actually prove that the cross-entropy is equivalent to the negative log-likelihood. (Also, note that, in the ELBO loss, $p(x \\mid z)$ does not appear, but the logarithm of $p(x \\mid z)$ appears, but, for simplicity, I have used $p(x \\mid z)$ rather than $\\log p(x \\mid z)$ above.)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What part of the game is the value network trained to predict a winner on? The Alpha Zero (as well as AlphaGo Zero) papers say they trained the value head of the network by \"minimizing the error between the predicted winner and the game winner\" throughout its many self-play games. As far as I could tell, further information was not given.\nTo my understanding, this is basically a supervised learning problem, where, from the self-play, we have games associated with their winners, and the network is being trained to map game states to the likelihood of winning. My understanding leads me to the following question:\nWhat part of the game is the network trained to predict a winner on? \nObviously, after only five moves, the winner is not yet clear, and trying to predict a winner after five moves based on the game's eventual winner would learn a meaningless function. As a game progresses, it goes from tied in the initial position to won at the end. \nHow is the network trained to understand that if all it is told is who eventually won?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nTo my understanding, this is basically a supervised learning problem, where from the self play we have games associated with their winners, and the network is being trained to map game states to likelihood of winning.\n\nYes, although the data for this supervised learning problem was provided by self-play. As AlphaZero learned, the board evaluations of the same positions would need to change, so this is a non-stationary problem, requiring that the ML forgot the training for older examples over time.\n\nWhat part of the game is the network trained to predict a winner on?\n\nPotentially all of it, including the starting empty board. I am not sure if the empty board was evaluated in this way, but it is not only feasible, but can be done accurately in practice for simpler games (Tic Tac Toe and Connect 4 for example), given known player policies.\n\nObviously after only five moves, the winner is not yet clear, and trying to predict a winner after five moves based on the game's eventual winner would learn a meaningless function.\n\nNot at all. This is purely a matter of complexity and difficultly. In practice at such an early stage, the value network will output something non-committal, such as $p=0.51$ win chance for player 1. And it will have learned to do this, because in its experience during self-play similar positions at the start of the game lead to almost equal numbers of player 1 and player 2 winning.\nThe function is not meaningless either, it can be used to assess results of look-ahead searches without needing to play to the end of the game. It completely replaces position-evaluation heuristics as used in more traditional game tree searches. In practice, very early position data in something as complex as chess or go is not going to be as useful as later position evaluations, due to ambivalent predictions. However, for consistency it can still be learned and used in the game algorithms.\n\nHow is the network trained to understand that, if all it is told is who eventually won?\n\nIf a supervised learning technique is given the same input data $X$ that on different examples predicts the labels $A, B, B, B, A, A, B, B$, then it should learn $p(B|X) = 0.625$. That would minimise a cross-entropy loss function, and is what is going on here.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is \"Computational Linguistics\"? It's not clear to me whether or not someone whose work aims to improve an NLP system may be called a \"Computational Linguist\" even when she/he doesn't modify the algorithm directly by coding.\nLet's consider the following activities:\nAnnotation for Machine Learning: \nanalysis of Morphology, Syntax, POS tagging\nAnnotation, analysis, and annotation of entities (NER) and collocations; supporting content categorization; chunking; word sense disambiguation.\nRecording of technical issues of the annotation tool to improve its reliability.\nRecording of linguistic and logical particular rules adopted by the research team who develops the NLP algorithm to improve consistency between annotation and criteria previously adopted to train the NLP.\nMay be these activities considered \"Computational Linguistics\"? If not, which is their professional category and how should they be included in the resume in a word which synthesizes them?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "(Disclosure: I am a researcher and lecturer in Computational Linguistics)\nIt is true that annotation and debugging work with existing tools without modification can be considered Computational Linguistics.\nAnd yet, most Computational Linguists program on a daily basis, since they actively develop tools. Just to give you some context, at major Computational Linguistics conferences such as ACL or EMNLP (the biggest ones), most authors did the coding themselves.\nTo say that coding is an unimportant side aspect of being a Computational Linguist, as claimed in another answer, is a slight misrepresentation.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does L2 regularization make weights smaller? I'm learning logistic regression and $L_2$ regularization.\nThe cost function looks like below.\n$$J(w) = -\\displaystyle\\sum_{i=1}^{n} (y^{(i)}\\log(\\phi(z^{(i)})+(1-y^{(i)})\\log(1-\\phi(z^{(i)})))$$\nAnd the regularization term is added. ($\\lambda$ is a regularization strength)\n$$J(w) = -\\displaystyle\\sum_{i=1}^{n} (y^{(i)}\\log(\\phi(z^{(i)})+(1-y^{(i)})\\log(1-\\phi(z^{(i)}))) + \\frac{\\lambda}{2}\\| w \\|$$\nIntuitively, I know that if $\\lambda$ becomes bigger, extreme weights are penalized and weights become closer to zero. However, I'm having a hard time to prove this mathematically.\n$$\\Delta{w} = -\\eta\\nabla{J(w)}$$\n$$\\frac{\\partial}{\\partial{w_j}}J(w) = (-y+\\phi(z))x_j + \\lambda{w_j}$$\n$$\\Delta{w} = \\eta(\\displaystyle\\sum_{i=1}^{n}(y^{(i)}-\\phi(z^{(i)}))x^{(i)} - \\lambda{w_j})$$\nThis doesn't show the reason why incrementing $\\lambda$ makes weight become closer to zero. It is not intuitive.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Here is my take.\nThe larger the $\\lambda$, the more the corresponding regularization term for a coefficient will be big, so when minimizing the cost function, the coefficient will be reduced by a bigger factor, you can see this effect in the derivation of the update rule for gradient descent for example:\n\\begin{align*} \\theta_j := \\theta_j - \\alpha\\ \\left[ \\left( \\frac{1}{m}\\ \\sum_{i=1}^m (h_\\theta(x^{(i)}) - y^{(i)})x_j^{(i)} \\right) + \\frac{\\lambda}{m}\\theta_j \\right] &\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ j \\in \\lbrace 1,2...n\\rbrace\\newline & \\end{align*}\n\\begin{align*} \\theta_j := \\theta_j (1- \\alpha \\frac{\\lambda}{m})\\left( \\frac{\\alpha}{m}\\ \\sum_{i=1}^m (h_\\theta(x^{(i)}) - y^{(i)})x_j^{(i)} \\right) &\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ j \\in \\lbrace 1,2...n\\rbrace\\newline & \\end{align*}\nFrom this derivation, it is clear that at every update the coefficients get reduced by a factor that is usually a little less than 1 and directly proportional to $\\lambda$, so, as $\\lambda$ gets bigger, the weights get reduced more and more; eventually, for very big values of $\\lambda$, we risk to totally underfit the data, since only the regularization term will remain in the cost function and all the weights will go to zero.\nThis is for linear regression, but it is essentially the same logic also for logistic regression.\nThis is taken from Andrew Ng's course on Coursera. A more mathematical precise (and complex) traction of the problem can be found in the Bloomberg machine learning course material.\nPS: in the derivation of the update rule for gradient descent, the $\\lambda$ should be divided by the number of training examples, this is important in choosing the right $\\lambda$ because we want this relationship to be inversely proportional, otherwise the coefficient won't be decreased.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the relationship between fuzzy logic and objective bayesian probability? I understand fuzzy logic is a variant of formal logic where, instead of just 0 or 1, a given sentence may have a truth value in the [0..1] interval. Also, I understand that logical probability (objective bayesian) understands probability as an extension of logic, where uncertainity is taken into account. To me they sound rather similar (they both extend formal logic by modelling truth as a continuos interval between 0 and 1).\nMy question is, what is the relationship between these two concepts?. What is the difference, and what are the differences in AI approaches based upon these two formal systems?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This was a somewhat hotly debated question in the 1980s. The debate was more-or-less ended with papers like Cheeseman's In Defense of Probability.\nThe short answer is that Fuzzy Logic does not just assign a continuous value to sentences, what it does is assign degrees of membership in different fuzzy sets. These degrees of membership range between 0 and 1.\nIn contrast, probability says: Among the set of values this variable could take on, what fraction of them are in a certain set? This fraction also ranges between 0 and 1.\nThis might seem like a semantic distinction, but it has deep implications if you try to use these systems to reason about uncertainty.\nFor example, consider the question \"Will it rain tomorrow?\". A probabilistic approach would try to determine the fraction of days like tomorrow that have had rain. A fuzzy logic approach will try to determine whether tomorrow is like a rainy day. The distinction becomes obvious if we then ask whether it will not rain tomorrow. The probabilistic approach will try to find the fraction of days like tomorrow where it did not rain. The chance of it raining or not raining will sum to 1. The fuzzy logic approach will try to determine whether tomorrow is like a non-rainy day. Note that tomorrow may be both like a stereotypical rainy day and not like one. There is no firm requirement that these sets be disjoint. This reflects Cheeseman's critique of Fuzzy Sets: they implicitly reject the additive axiom of probability theory, which (as denoted by the name axiom) is something that is fairly unreasonable to reject.\nWhile there are various approaches to make memberships in fuzzy sets more probabilistic in nature, that's the root distinction. \nI think the dominant modern view is that fuzzy sets are a great tool when you need to reason about membership in a fuzzy concept. Whether rice is \"done\" or not isn't a question of something being true or false. It's a degree of membership in the set \"done\". On the other hand, whether the object in front of a self-driving car is a person or not is either true or false. It is not necessarily a good idea to reason about this in terms of whether the object is partially in the person set or plastic bag set. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there a way to perform pattern recognition without a labeled training set? I have a 10GB file of a time series 1D signal. I want to find some patterns within this signal, I know CNN's are great for this but the problem is I don't have any training data.\nNow, I could, of course, spend an entire week slowly making 100 versions of a certain pattern to train the CNN with. But maybe there is some other way?\nMaybe there is a way for the neural network to work out patterns on its own and simply categorize them? Like this is pattern A, this is pattern B.\nMy ultimate goal is to look at any size data and find the occurrences of patterns within the data.\nDoes anyone have any idea how this problem could be solved? I am just starting with machine learning, so I am slowly learning what's possible in this field.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You should look into unsupervised learning, which is machine learning without a human-labeled training set.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is dialogue a hard problem in natural language processing? I've just started learning natural language processing from Dan Jurafsky's videos lectures. In that video, minute 4:56, he is stating that dialogue is a hard problem in natural language processing (NLP). Why?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Dialogue is a hard problem because it requires pretty advanced cognitive functions. Leaving aside all the lower levels of language analysis (phonology if dealing with speech, morphology and syntax), you quickly run into interpretation problems that require a lot of world knowledge.\nSimple question and answer is fine, and restricted domains are somewhat easier as well. As soon as you get into a normal conversation, you will refer back to things you said before, so an NLP system would have to recognise that and resolve the reference accordingly. Typically in a conversation you would use variations of reference terms: the first time you mention an object you might describe it fully, but subsequently you will use shorter terms to refer to it.\nThere is also a structure to conversation. This is typically modelled as conversational moves, and usually moves will have corresponding response-moves. For example, a common sequence would be greeting - greeting. Then you might have question - response - feedback. This sounds fairly easy, but once you try to annotate a dialogue with such moves you will find that it is pretty hard. As far as I am aware, there is no 'grammar' equivalent of describing the structure of conversations.\nOften, pragmatic meaning is interfering with the 'surface' meaning of utterances. A statement can actually function as a question, or a question can be a command (or a statement). The pragmatics of utterances depend on the context and also the relationship between the interlocutors. If I talk to my manager, I will use language differently than when I talk to my children.\nDialogue/conversations are hard to analyse. Because of that, descriptive frameworks are still fairly limited. You need to keep track of what has said before, as that can change the way an utterance has to be interpreted. Grammatical analysis is a fairly solved problem, and word sense disambiguation as well. But pragmatics and conversational structure are still on the bleeding edge of linguistic research; at least they were when I was still teaching Discourse Analysis at university a few years ago.\nFor that reason, chatbots are generally not very good. Sometimes they can fool people into believing they are human speakers, but this is usually done through trickery (\"smoke and mirrors\") rather than competent handling of conversational structures. It's all in the little box in nbro's answer labelled \"DM\"...\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Use ConvNet to predict bitmap I want to build a classifier which takes an aerial image and outputs a bitmap. The bitmap is supposed to be 1 at every pixel where the aerial image has water. For this process I want to use a ConvNet but I am unsure about the output layer. I identified two approaches:\n\nHave an output layer with exactly 2 nodes which specify wether or not the center pixel of the aerial image corresponds to water or not.\nHave an output layer with one node for every pixel. So for a 64x64 image I would have 4096 nodes.\n\nWhat approach would be preferred and why?\nAnother thing that is unclear to me is how to get the actual bitmap with only zeros and ones from the output of the ConvNet. Assuming we used a approach 2 then for each pixel our ConvNet would give us a probability between 0 and 1 that the this pixel corresponds to water. How do I decide that this probability is high enough to set the value in my bitmap to 1? Do I just define a threshold, say 0.5, and if the value exceeds that threshold I set the pixel to 1 or is there a more sophisticated approach?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Your first approach doesn't make any sense to me. After all, you are not just interested in the centre pixel are you? And if you have two nodes for every pixel, what are those two nodes encoding? For the probability of water you just need one. \nSo clearly approach two. I would just use 0.5 as cutoff. Using a higher or lower cutoff only makes sense, if either false positives or false negatives are for some reason more problematic. Using some additional heuristic to adjust the given probabilities would just do what the ConvNet should already have done.\nIf 4096 output nodes is too expensive you can always make it a bit fuzzier, for example by predicting the probability that at least one of four pixels shows water, reducing the number of nodes to 1024. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is the research on artificial intelligence at this stage all researching on a separate ability? Why is the research on artificial intelligence at this stage all researching on a separate ability? For example, train the visual ability of the computer alone, train the speech recognition ability alone, and train the natural language understanding ability alone. Why not train these abilities together at the same time? Does anyone think this will lead to better AI?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is a large field of AI that indeed does this. It is called multi modal learning. It is a very active research area, especially in the last few years.\nFor more information see:\nhttps://en.m.wikipedia.org/wiki/Multimodal_learning\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do LLMs tokenize python (significant whitespace) I was learning about tokenization (WordPiece) and how there is a normalization step prior to that that will remove consecutive whitespace from the input text, since these are not significant normally.\nBut that got we wonder\n\nhow do LLMs still understand Python and other programming languages whose blocking is done by indentation?\n\nhow do LLMs still understand ASCII art?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "While some tokenizers like WordPiece normalize whitespace by collapsing tabs to single space, modern LLM tokenizers such as BPE or other byte-level tokenization often retain whitespace structure to handle code and art from their vast training corpus, and they're getting better for newer models via smarter compression.\n\nWasteful Whitespace: Indentation in Python can be tokenized as individual spaces, bloating up sequences and making code harder for the LLM to understand. Newer tokenizers are getting better at this!... BPE is the algorithm behind most modern tokenizers. It works by finding common pairs of bytes in your training data and compressing them into single tokens. This creates a balance between vocabulary size and efficiency, allowing LLMs to process text more effectively.\n\n\nThis tokenizer inefficiency can be observed when constrasting tokenizers. Let\u2019s take a Python FizzBuzz script... We observe it in the tiktokenizer tool with the GPT-2 encoder set: Note it generates a token count of 149. Now if we select the cl100k_base (which is the tokenizer for GPT-4), and notice that for the exact same string the token count drops significantly to 77.\n\nFurthermore, LLMs track token order via positional encoding, so even if spaces are individual tokens, the model knows their sequential position. This helps reconstruct indentation levels and ASCII art layouts.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to detect a full-fledged self-aware AI? The premise: A full-fledged self-aware artificial intelligence may have come to exist in a distributed environment like the internet. The possible A.I. in question may be quite unwilling to reveal itself.\nThe question: Given a first initial suspicion, how would one go about to try and detect its presence? Are there any scientifically viable ways to probe for the presence of such an entity? In other words, how would the Turing police find out whether or not there's anything out there worth policing?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This question should probably be moved to worldbuilding.stackexchange \u2026\nThat being said, in the context of a story, I would look at something like the neural correlates of consciousness. In this book by Stanislas Dehaene the experiments are described that led to the realisation that conscious perception requires information integration in certain parts of the prefrontal cortex. Basically the brain processes many different interpretations of a percept in parallel. To become conscious of the percept this interpretations have to be collapsed into a single \"truth\" which is propagated to a specific part of the brain. \nIn your story you could have a researcher of consciousness stumble upon a chart of information flow in a part of the internet and realise that the same kind of information integration is going on. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is there a neural network with a varying number of neurons? Is there some type of neural network that changes the number of neurons while training? \nUsing this idea, the network can increase or decrease the number of neurons when the complexity of the inputs increases or decreases.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes, NEAT (NeuroEvolution of Augmenting Topologies) increases the number of neurons during training. More specifically, NEAT uses evolution to introduce new neurons and connections during training, and - just as evolution - if the mutation performs poorly, gets eliminated after a few generations. This way overall performance increases over time while it keeps your network size (and computing power to run it) minimal. There's also a way to add convolution to this algorithm.\nIn the paper that introduced NEAT, the authors mention a completely different algorithm they tried, optimizing network hyper-parameters by choosing reasonable random values and training it multiple times. That could decrease that number as well.\nAlso, there is a trick to temporarily turn off specific parts of a network, which supposedly helps with overfitting.\nA ReLU+backpropagation based network can \"turn off\" parts of the network during training, because constant 0's derivative is constant 0. In practice, you decrease the number of neurons (that is considered bad though, that's when leaky ReLU and PReLU is used instead).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does text classification reduce manpower costs? (I apologize for the title being too broad and the question being not 'technical')\nSuppose that my task is to label news articles. This means that given a news article, I am supposed to classify which category that news belong to. Eg, 'Ronaldo scores a fantastic goal' should classify under 'Sports'.\nAfter much experimentation, I came up with a model that does this labeling for me. It has, say, 50% validation accuracy. (Assume that it is the best)\nAnd so I deployed this model for my task (on unseen data obviously). Of course, from a probabilistic perspective, I should get roughly 50% of the articles labelled correctly. But how do I know that which labels are actually correct and which labels need to be corrected? If I were to manually check (say, by hiring people to do so), how is deploying such a model better than just hiring people to do the classification directly? (Do not forget that the manpower cost of developing the model could have been saved.)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are several advantages:\n\nSome text classification systems are much more accurate than 50%. For example, most spam classification systems are 99.9% accurate, or more. There will be little value to having employees review these labels.\nMany text classification systems can output a confidence as well as a label. You can selectively have employees review only the examples the model is not confident about. Often these will be small in number.\nYou can usually test a text classification model by having it classify some unseen data, and then asking people to check the work. If you do this for a small number of examples, you can make sure the system is working. You can then confidently use the system on a much large set of unlabeled examples, and be reasonably sure about how accurate it is. \nFor text, it is also important to measure how much different people agree on the ratings. You are unlikely to do better than this, because this gives you a notion of the subjectivity of the specific problem you are working on. If people disagree 50% of the time anyway, maybe you can accept a 50% failure rate from the automated system, and not bother checking its work.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Trying to understand VGG convolution neural networks architecture Trying to understand the VGG architecture and I have these following questions.\n\nI 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 in the VGG architecture, the filter size remained same when vgg was max pooling from 14x14 to 7x7 image size, the filter size remained same at 512x512. Why wasn\u2019t there the need to increase filter size there?\nAlso few consecutive layers, in the end, was constructed with both same filter and image size, those layers were built just to increase accuracy? (experimentation?)\nAnd I couldn\u2019t wrap around that visualization at final filters have the entire face as the feature as I understood through convolution visualizing (Matt Zieler video explanation). But max pooling causes us to see only a subset part of the image right? When filter size is 512x512 (face as the filter/feature) the image size as 7x7, so how does entire face as a filter will work on images when we are moving over small subset of the image pixels?\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Good questions. Let me reply one by one.\n1- Filter size can be increased. There is no limit for it. However, think two cases:\n\nDNN 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. Overfitting and inference/training speed.\nSparsity. You can implement 1024 features at 5th conv block and train the network and check the accuracy to see if increased feature count will make any impact or not.\n\nSo, to decide the number of con layers, it is a good practice to check sparsity of feature layers. \n2- If I did not understand your question wrong, those layers are DNN classifier as a fully connected layer.\n3- Maxpooling is not causing us to see a subset of the image. It is just an algorithm to resizing. What you see in that video is the filter response to some objects exist in the image. In deeper level, do not expect to have visual shape like in shallow layers. You may even get single white pixel at deepest layer and it may be a response to an object like human face. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How do we test if an model or algorithm is AI-complete? How do we test if a model or algorithm is AI-complete?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "According to the Wikipedia definition, a problem is said to be AI-complete if it requires generalized, human-level intelligence, that is, requires strong AI. The Turing test and its variants are the best ways we have of measuring this. See, for example, Turing Test as a Defining Feature of AI-Completeness.\nAs suggested in this paper, in order for the Turing test to be meaningful, the interrogator has a responsibility to ask questions which are both deep and meaningful. \nIt, therefore, seems likely that testing for strong AI is in itself an AI-complete task.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What kind of algorithm is used by StackGAN to generate realistic images from text? What kind of algorithm is used by StackGAN to generate realistic images from text? How does StackGAN work?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The paper StackGAN: Text to Photo-realistic Image Synthesis\nwith Stacked Generative Adversarial Networks should provide the answers to your questions.\nHere's an excerpt from the abstract of the paper.\n\nSynthesizing photo-realistic images from text descriptions is a challenging problem in computer vision and has many practical applications. Samples generated by existing text-to-image approaches can roughly reflect the meaning of the given descriptions, but they fail to contain necessary details and vivid object parts. In this paper, we propose stacked Generative Adversarial Networks (StackGAN) to generate photo-realistic images conditioned on text descriptions. The Stage-I GAN sketches the primitive shape and basic colors of the object based on the given text description, yielding Stage-I low resolution images. The\nStage-II GAN takes Stage-I results and text descriptions as inputs, and generates high resolution images with photorealistic details. The Stage-II GAN is able to rectify defects and add compelling details with the refinement process.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why exactly was previously believed that the deterministic policy gradient did not exist? I'm reading the paper Deterministic Policy Gradient Algorithms, David Silver et al.\nFirst of all, in the introduction, the author says that\n\nIt was previously believed that the deterministic policy gradient did not exist\n\nBut, I wonder why it is. The general version of the policy gradient theorem does not have restrictions about the policy $\\pi$. So, if we choose the policy $\\pi$ as a Dirac measure, that is, $\\pi(\\cdot | s) = \\delta_{a}$ for some $a \\in \\mathcal{A}$, then it is exactly the notion of deterministic policy, so we can apply the usual gradient descent theorem.\nIndeed, in theorem 2, they showed that deterministic policy gradient theorem and usual gradient theorem matches when it comes to zero variance. (In fact, I can't understand the statement rigorously, because the policy is something about probability \"measure\", and the variance is something about \"random variable\".) However, my below computation shows some contradiction.\nLet $\\pi(\\cdot | s) = \\delta_a$, a Dirac measure for some atom $a \\in \\mathcal{A}$. Following the notation of the paper DPG, a policy gradient theorem says\n$$\\nabla_{\\theta}J(\\pi_{\\theta}) = \\mathbb{E}_{s, a}[\\nabla_{\\theta}\\log \\pi_{\\theta}(a | s) * Q^{\\pi}(s, a)] $$\nA definition of integral shows $$\\nabla_\\theta J(\\pi_{\\theta}) = \\int_{\\mathcal{S}, \\mathcal{A}} \\pi_{\\theta}(da|s) \\rho^{\\pi}{(ds)} \\nabla_\\theta \\log \\pi_\\theta(a|s) * Q^{\\pi}(s,a).\n$$\nBut since $\\pi_\\theta$ has only an atom at generic element $a \\in \\mathcal{A}$, so it is same with $$\\int_\\mathcal{S} \\rho^{\\pi}(s) \\nabla_\\theta \\log \\pi_\\theta(a | s) * Q^{\\pi}(s, a) = \\mathbb{E}_s[\\nabla_\\theta \\log \\pi_\\theta(a|s) * Q^{\\pi}(s, a)].$$\n(NOTE : the last term seems the same with the first line of the equation, but we get rid of $a$ from the expectation, by fixing $a$ corresponding to the atom of $s$.) However, note that $\\log\\pi_\\theta(a|s) = 1$, since $\\pi_\\theta(a|s) = \\delta_a(\\{a\\}) = 1$ as we defined! Thus, $\\nabla_\\theta \\log \\pi_\\theta(a | s) = \\nabla_\\theta 1 = 0$ so we reached that gradient vanishes..\nHowever, clearly not.\nCan anyone help me?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Actually, your result that the gradient is 0 is correct given your formulation. Indeed, that is why one might have believed that the deterministic policy gradient didn't exist.\nThe term $\\nabla_{\\theta}\\log \\pi(a \\, | \\, s)$\nis a type of gradient estimator known as a likelihood ratio, and it assumes that the support of $\\pi$ does not depend on $\\theta$. In other words there must be some non-zero probability of choosing all the possible actions $\\mathcal{A}$, and $\\theta$ encodes those probabilities. In your idea, $\\mathcal{A}$ is a single action, and therefore the parameters don't do anything at all. You always have probability 1 of choosing that action. We can't let different parameters choose different actions, as that violates the assumptions of the likelihood ratio and will lead to a biased gradient.\nBut why can't we let the support of a likelihood ratio depend on $\\theta$? I won't prove this in a rigorous way here but you can consider\n\\begin{align*} \n\\mathbb{E}_{y} [ \\nabla_{\\theta}\\, \\log p_{\\theta}(y)] = \\mathbb{E}_{y} \\left[ \\underset{\\epsilon \\rightarrow 0}{\\lim} \\dfrac{\\log p_{\\theta+\\epsilon}(y) - \\log p_{\\theta}(y)}{\\epsilon}\\right]\n\\end{align*}\nand see that if $p_{\\theta + \\epsilon}(y) = 0$, then $\\log p_{\\theta+\\epsilon}(y) = -\\infty$.\nI think a more instructive example is to consider what can go wrong if we just go ahead and let the support depend on $\\theta$ anyway. Let's consider $\\nabla_{\\theta} \\, \\mathbb{E} [u]$ where $u \\sim \\text{Uniform}(0, \\theta)$ (so $\\theta$ is a scalar, and $u$ has support on $[0, \\theta ]$). We know $\\mathbb{E} [u] = \\frac{1}{2}\\theta$ so $\\nabla_{\\theta}\\mathbb{E} [u] = \\frac{1}{2}$. You should work out for yourself that the gradient estimator (using a likelihood ratio) gives the utterly wrong result of $\\mathbb{E}[\\nabla_\\theta \\log p(u)] = -1/\\theta$\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why Are the Standard and Markov Chain Derivations of the Policy Gradient Theorem Equivalent? While studying the proof of the Policy Gradient Theorem, I have come across two different approaches.\nThe first seems to be a more standard approach involving \"unrolling\" across every time step. A good resource discussing this method is section 3.1 of this overview. It begins by writing the objective as the expected state value over the initial state distribution $p_0(s)$ $$J(\\theta)=\\mathbb E_{s\\sim p_0}[V^{\\pi_\\theta}(s)]=\\sum_{s\\in \\mathcal S}p_0(s)\\sum_{a\\in\\mathcal A}\\pi_\\theta(a|s)Q^{\\pi_\\theta}(s,a),$$and ends with the standard result\n$$ \\begin{aligned}\\nabla_\\theta J(\\theta)&=\\eta\\sum_{s\\in \\mathcal S}d^{\\pi_\\theta}(s)\\sum_{a\\in \\mathcal A}\\nabla_\\theta\\pi_\\theta(a|s)Q^{\\pi_\\theta}(s,a)\\\\[8pt]&=\\eta\\mathbb E_{s\\sim d^{\\pi_\\theta},a\\sim\\pi_\\theta}\\left[\\nabla_\\theta\\log\\pi_\\theta(a|s)Q^{\\pi_\\theta}(s,a)\\right],\\end{aligned}$$for some constant $\\eta$.\nThe second approach (discussed in this blog post) views the system as a Markov chain in which each vertex represents a state-action pair. This allows us to express the objective in terms of the Markov chain's transition matrix $\\Pi_\\theta$ $$J(\\theta)=\\sum_{t=0}^\\infty p^0\\Pi_\\theta^tr,$$ where $r$ is a column vector such that $r_i$ is the reward of state-action $i$ and $p^0$ is a row vector representing the initial state-action distribution (note that this is slightly different to the initial state distribution $p_0(s)$ mentioned earlier). The proof concludes with $$\\nabla_\\theta J(\\theta)=d\\nabla_\\theta\\Pi_\\theta q,$$ where $d$ is a row vector of the visitation frequencies of each state-action under the policy $\\pi_\\theta$, and $q$ is a column vector giving all the action values $Q^{\\pi_\\theta}(s,a)$.\nMy question is this: why are these two results equivalent? More specifically, can you give a step by step proof that $$d\\nabla_\\theta\\Pi_\\theta q=\\eta\\sum_{s\\in \\mathcal S}d^{\\pi_\\theta}(s)\\sum_{a\\in \\mathcal A}\\nabla_\\theta\\pi_\\theta(a|s)Q^{\\pi_\\theta}(s,a),$$ making use of the definitions of $\\Pi_\\theta$ and $d^{\\pi_\\theta}(s)$?\nWhat I have tried so far:\nI omit all references to $\\theta$ for brevity (e.g. $\\pi=\\pi_\\theta$).\nLet each state-action pair have its individual state and action indexed with a superscript (i.e. the state-action corresponding to row/column $i$ of $\\Pi$ has state $s^i$ and action $a^i$). Let the state and action at time step $t$ be indexed with subscripts (e.g. $a_t$, $s_t$). Let $\\gamma$ be the discount rate (possibly $1$). Then, we have\n$$\n\\begin{aligned}\n\\Pi_{ij}&=\\gamma\\mathbb P(s^j\\mid s^i,a^i)\\pi(a^j|s^j)\\\\\n\\implies\\nabla\\Pi_{ij}&=\\gamma\\mathbb P(s^j\\mid s^i,a^i)\\nabla\\pi(a^j|s^j)\\\\\nd_i&=\\sum_{t=0}^\\infty\\gamma^t\\mathbb P(s_t,a_t=s^i,a^i)\\\\\n\\implies d\\nabla\\Pi q&=\\sum_i\\sum_jd_i\\nabla\\Pi_{ij}q_j\\\\\n&=\\sum_i\\sum_j\\sum_t\\gamma^t\\mathbb P(s_t,a_t=s^i,a^i)\\gamma\\mathbb P(s^j\\mid s^i,a^i)\\nabla\\pi(a^j|s^j)q_j\\\\\n&=\\sum_j\\sum_t\\gamma^{t+1}\\left(\\sum_i\\mathbb P(s_t,a_t,s_{t+1}=s^i,a^i,s^j)\\right)\\nabla\\pi(a^j|s^j)q_j\\\\\n&=\\sum_j\\sum_t\\gamma^{t+1}\\mathbb P(s_{t+1}=s^j)\\nabla\\pi(a^j|s^j)q_j\\\\\n&=\\sum_j\\tilde d(s^j)\\nabla\\pi(a^j|s^j)q_j\\\\\n&=\\sum_{(s,a)\\in\\mathcal S\\times\\mathcal A}\\tilde d(s)\\nabla\\pi(a|s)Q^\\pi(a|s)\\\\\n&=\\sum_{s\\in\\mathcal S}\\tilde d(s)\\sum_{a\\in\\mathcal A}\\nabla\\pi(a|s)Q^\\pi(a|s)\n\\end{aligned}\n$$\nThis is almost exactly what I want. The problem is\n$$\nd^\\pi(s)=(1-\\gamma)\\sum_{t=0}^\\infty\\gamma^t\\mathbb P(s_t=s)\\not\\propto\\sum_{t=0}^\\infty\\gamma^{t+1}\\mathbb P(s_{t+1}=s)=\\tilde d(s).\n$$\nMultiplying $d$ by $\\nabla\\Pi$ effectively \"shifts everything along by one\" which means that I lose the first term of the series ($t=0$).\nWhere am I going wrong? Is there a small detail I'm neglecting, or a fundamental misunderstanding? Any help would be greatly appreciated!\nOther resources I've read:\n\nhttps://lilianweng.github.io/posts/2018-04-08-policy-gradient/\nI found some Reddit discussion of the Markov approach involving the original post's author.\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Indeed the shift in the MC derivation occurs because the transition matrix $\\Pi_{ij}=\\gamma\\mathbb \\pi(a^j|s^j)P(s^j | s^i,a^i)$ multiplies the transition probability by $\\gamma$ at every step, which means that the gradient contributions computed via this chain begin with a factor of $\\gamma$ so they \u201cstart\u201d at the second time step, effectively skipping a direct contribution from the initial pair $(s^0,a^0)$. While in the standard unrolling derivation the policy gradient contribution from the initial state $s^0$ is not skipped.\nThis inherent \u201cshift\u201d explains your noted difference between the unrolling derivation using the normalized stationary state visitation frequency $d^\\pi(s)$ and the MC derivation using an unnormalized stationary state visitation frequency $\\tilde d(s)$. They differ by a constant factor $\\tilde d(s) = \\frac{\\gamma}{1-\\gamma}d^\\pi(s)$, which can be absorbed into the overall learning rate scaling of the policy gradient during gradient ascent similar to the scaling constant $\\eta$ in the standard unrolling derivation.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Should we fear an AGI if it will be equivalent to a human? It seems to me that the first AGIs ought to be able to perform the same sort and variety of tasks as people, with the most computationally strenuous tasks taking an amount of time compared to how long a person would take. If this is the case, and people have yet to develop basic AGI (meaning it's a difficult task), should we be concerned if AGI is developed? It would seem to me that any fears about a newly developed AGI, in this case, should be the same as fears about a newborn child.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are basically two worries:\nIf we create an AGI that is a slightly better AGI-programmer than its creators, it might be able to improve its own source code to become even more intelligent. Which would enable it to improve its source code even more etc. Such a selfimproving seed AI might very quickly become superintelligent. \nThe other scenario is that intelligence is such a complicated algorithmic task, that when we finally crack it, there will be a significant hardware overhang. So the \"intelligence algorithm\" would be human level on 2030 hardware, but we figure it out in 2050. In that case we would immediately have superintelligent AI without ever creating human level AI. This scenario is especially likely because development often requires a lot of test runs to tweak parameters and try out different ideas. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can I apply reinforcement learning to solve this asteroid game? Introduction\nAn attractive asteroid game was described in the paper Learning Policies for Embodied Virtual Agents through Demonstration (2017, Jonathan Dinerstein et al.):\n\nIn our first experiment, the virtual agent is a spaceship pilot, The pilot's task is to maneuver the spaceship through random asteroid fields\n\nIn theory, this game can be solved with reinforcement learning or, more specifically, with a support vector machine (SVM) and epsilon-regression scheme with a Gaussian kernel. But it seems that this task is harder than it looks like, as the authors of the same paper write\n\nAlthough many powerful AI and machine learning techniques exist, it remains difficult to quickly create AI for embodied virtual agents.\n\n\nit is quite challenging to achieve natural-looking behavior since these aesthetic goals must be integrated into the fitness function\n\nQuestions\nI really want to understand how reinforcement learning works. I built a simple game to test this. There are squares falling from the sky and you have the arrow keys to escape.\n\nHow could I code the RL algorithm to solve this game? Can I do this manually in Javascript according to what I think should happen? How can I do this without having to map the positions of the rectangles and mine, just giving the agent the keyboard arrows to interact and three information:\n\nPlayer life\nSurvival time\nMaximum survival time\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "A closely related question and a minimal implementation written in Python.\nThat program implements the reinforcement learning technique 'Q-Learning'.\nThe idea is for the program to take in an observation of the environment (which could be a screenshot if learning a computer game, or sensor data for a robot) and output a decision in the form of a vector of values. Each cell in that output vector corresponds to a possible action (left, right, shoot, etc) and the highest valued cell shows the action that the agent/player should take. The values in that output vector are called the Q-Values, and it is the mapping from the input data to the vector of Q-Values that we are trying to learn.\nIn your case, the function that takes in an observation of the environment and spits out a vector of decision choices is your SVM.\nThe question linked above contains a description of the training algorithm. It boils down to playing the game multiple times while storing the input vector, output vector and output decision for each step until you reach a termination condition (ie hitting an asteroid) and receiving a score (in this case a negative score since you want to avoid the asteroids). Then, going backwards through the the output vectors, assigning a slowly reducing amount of the output score to the particular cell in each output vector corresponding to the decision that was made at that step of the game.\nThe array of input vectors from the game, and the array of output decision vectors that you have just created become the training data for your machine learning system. Once you have completed a training run, play the game again with your trained system and keep repeating until it is a good as you need it to be, or it stops getting any better.\nTo address your question directly, I don't think that you are going to be able to train your system without giving it information about the position of the asteroids (assuming that they are positioned at random). However, you could try just having a very simple input vector such as 3 integer values where each value corresponds to the presence (1) or absence (0) of an asteroid in the 3 squares to the above left, above and above right of the player. That might be enough to encourage it to dodge away from falling rocks... \nThere are some Support Vector Machines implemented in JavaScript, although I have never used them, but since SVMs are basically two-class classifiers you would have to check that the library can easily support multi-class SVMs. In your case the SVM would be trying to classify each input into a particular player choice (left, right, shoot, etc).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can I avoid overfitting when doing parameter tuning? I very often applied a grid search to tune the parameters of my supervised model. I have the feeling that parameter tuning will eventually (very often) lead to overfitting? Is this crazy to say?\nIs there a way that we can apply grid search in such a way that it will not overfit?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Yes. Usually you would use cross validation to avoid overfitting during parameter tuning. If your dataset is large enough, and you don't try too many parameter combinations, this will work well, because to \"get lucky\" and overfit, a parameter combination will need to work very well on many variations of the problem, which is less likely than working well on just one set of data.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does the input layer of a neural network have bias and are there bias neurons? I have seen two different representations of neural networks when it comes to bias. Consider a \"simple\" neural network, with just an input layer, a hidden layer and an output layer. To compute the value of a neuron in the hidden layer, the weights and neurons from the input layer are multiplied, shifted by a bias and then activated by the activation function. To compute the values in the output layer, you may choose not to have a bias and have an identity activation function on this layer, so that this last calculation is just \"scaling\".\nIs it standard to have a \"scaling\" layer? You could say that there is a bias associated with each neuron, except those in the input layer correct (and those in the output layer when it is a scaling layer)? Although I suppose you could immediately shift any value you're given. Does the input layer have a bias?\nI have seen bias represented as an extra unchanging neuron in each layer (except the last) having value 1, so that the weights associated with the connections from this neuron correspond to the biases of the neurons in the next layer. Is this the standard way of viewing bias? Or is there some other way to interpret what bias is that is more closely described by \"a number that is added to the weighted sum before activation\"?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The purpose of the input layer is just to conceptually represent the input and, in case it is necessary, define the dimensions of the input that the neural network expects. In fact, some neural networks, such as multi-layer perceptrons, expect a fixed-size input, but not all of them: fully convolutional networks can deal with inputs of different dimensions.\nThe input layer doesn't contain neurons (although in the diagrams that you will come across they are usually represented as circles, like the neurons, and that's probably why you are confused!), so it also does not contain biases, linear transformations, and non-linearities. In fact, in the context of neural networks, you could define a neuron as some unit/entity that performs a linear or non-linear transformation (to which you can add a bias). Note that the hidden and output layers can contain biases because they contain neurons that perform a linear or non-linear transformation.\nHowever, although I have never seen it (or I don't recall having seen it), I would not exclude the existence of an input layer that transforms or augments the inputs before passing them to the next layer. For example, one could implement a neural network that first scales the input to a certain range, and the input layer could do this, although, in practice, this is typically done by some object/class that does not belong to the neural network (e.g. tf.data.Dataset).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it possible to separately evolve a part of the population? In a classic example of a genetic algorithm, you would have a population and a certain amount of simulation time to evaluate it and breeding. Then proceed to the next generation.\nIs it possible, during the simulation process, to have an isolated and small part of the population and keep it evolving in their own little island for some time while the rest of the population continues to evolve normally? \nAfter that, they could be reunited with the rest of the population and the end of the simulation would go through. After that, breed the population and continue. \nThis is a super important part of natural evolution and probably some know if it actually works with genetic programming?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There have been extensive studies within evolutionary computation in the area of island models and niching for doing exactly this.\nThe advantages of this approach include greater population diversity (which is particularly useful when the problem is multiobjective) and the potential for concurrent execution of each separate population.\nSee also the answers to the question What is the niching scheme?.\nWith specific reference to genetic programming, here is a recent paper that uses a parallel island model.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can I generate \"what\", \"why\" and \"who\" types of questions from question templates? I was wondering if in any way it is possible to generate $n$ questions based on gap-fill-in type questions.\nFor example, the following template\n\n______ is a process in which plants generate energy.\n\ncould lead to the generation of the following specific question\n\nWhat is the process in which plants generate energy called?\n\nIf so, how can I achieve this?\nI am familiar with and used natural language processing techniques, and have no problem with implementing an algorithm for this, but I do not know where to start with this.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "This seems tricky. It seems that any \"surface level\" transformation wouldn't give adequate results and any working solution would need to properly capture the sentence structure, and generate a gramatically correct transformed sentence.\nOne possible option is to use a \"traditional pipeline\" - e.g. you run a NLP pipeline up to syntactic parsing, which for general domain english is quite accurate (you'd need some special handling for the gap \"____\" part though), then implement some heuristic rules to transform the syntax tree, and regenerate a sentence from the transformed tree. There are a lot of publications about similar transformations in machine translation domain, used as a way to preprocess data before running statistical machine translation for language pairs with very different word(or sentence part) ordering.\nA second option that may work is to look into the field of controlled natural languages, or something like http://www.grammaticalframework.org/ that can be used as a toolkit to help generating new sentences.\nCurrent fashion also suggests a very different option that might work - you could train a character-level recurrent neural network with an attention mechanism (look into recent neural machine translation publications for details) to do this transformation, but I'm not sure of how much training data it will need for decent accuracy.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why are neural networks so data hungry? Stephen Wolfram published an interesting long post on machine learning this week.\nHe illustrates a function approximation application with the following target function, piecewise flat with three regions.\n\nI understand one can describe such a function with five parameters, the three constant levels (initially low, high in the middle and mid on the right) and the two discontinuity points.\nAs a network architecture, the following picture is given.\n\nIf my count is right, there are 19 weights (4+12+3 arrows) and 8 biases (count of all neurons but the input one, 4+3+1), totalling 27 parameters. The activation function is said to be ReLU for all neurons.\nWith this frame, we have 27 parameters in the model to estimate a 5 parameter function.\nThe following image illustrates how the model fits the function as the number of examples grows.\n\nFrom 10 thousand examples to 10 milion examples. The magnitude of data required is much higher than the complexity of the target function and the approximating network.\n\nHow should this (dis)proportion of data to problem parameters be understood?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "One example or sample is basically a pair of data $(x_i, y_i)$ with $x_i$ randomly picked from x axis and $y_i$ from the piecewise function. As you can see, it doesn't provide a lot information to calculating the weighting factors. By 10,000,000 randomly samples, one may capture the turning points. But if it is not randomly sampled, I would guess the number of sample can be less. The process is different from calculating model parameters from the piecewise function parameter as the neural net doesn't know it is a piecewise function as a priori. The function it expects is a general function, which can be very complex.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What applications of smooth manifold theory exist to Artificial Intelligence? What applications of smooth manifold theory exist to Artificial Intelligence?\nI have some knowledge of smooth manifold theory, and was wondering how I could apply it to a project on Artificial Intelligence. In particular, I know a bit of each of the following fields:\n\nGeneral differentiation and integration theory on manifolds (e.g. The Rank Theorem, Stoke's Theorem).\nRiemmanian Manifolds.\nSymplectic Manifolds.\nInfinite dimensional manifolds i.e. modelled in Hilbert, Banach, or Topological Vector Spaces.\n\nI often hear about Computer Science concepts (e.g. the Manifold Hypothesis) which use the notion of a manifold, but it remains unclear to me how the specifics of manifold theory may be used in these areas of research, and I was hoping someone here may point me in the right direction.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The Manifold Hypothesis posits that high-dimensional data such as images and text embeddings often lies on low-dimensional smooth manifolds embedded in the ambient space. This principle underpins many dimensionality reduction unsupervised manifold learning algorithms such as t-SNE, UMAP, and autoencoders, enabling efficient nonlinear feature extraction by mapping to lower-dimensional latent spaces. You may further refer this survey.\n\nManifold learning (ML), known also as non-linear dimension reduction, is a set of methods to find the low dimensional structure of data. Dimension reduction for large, high dimensional data is not merely a way to reduce the data; the new representations and descriptors obtained by ML reveal the geometric shape of high dimensional point clouds, and allow one to visualize, de-noise and interpret them. This survey presents the principles underlying ML, the representative methods, as well as their statistical foundations from a practicing statistician's perspective. It describes the trade-offs, and what theory tells us about the parameter and algorithmic choices we make in order to obtain reliable conclusions.\n\nIf model parameters are constrained to lie on manifolds, optimization algorithms tailored for manifold structures may be employed. These algorithms extend classical first order gradient-based methods to curved spaces, utilizing tools from differential geometry to navigate the manifold effectively. For example. you can use the Fisher information metric which is a Riemannian metric to optimize parameters in statistical manifolds as some form of natural gradient descent, improving convergence in deep learning. Interestingly even hyperbolic geometry can be applied to transformers with much more efficient hierarchical semantics embedding space due to its intrinsic branching geometry compared to the usual Euclidean embedding space.\n\nIn order to learn a latent representation, spectral clustering is formulated in terms of a loss minimization problem over a smooth manifold known as Grassmannian. Such minimization problem cannot be tackled by one of traditional gradient-based learning algorithms, which are only suitable to perform optimization in absence of constraints among parameters... In this paper, we extend classical gradient-based learning algorithms on parameter spaces (from classical gradient descent to adaptive momentum) to curved spaces (smooth manifolds) by means of tools from manifold calculus.\n\n\nIn information geometry, the Fisher information metric is a particular Riemannian metric which can be defined on a smooth statistical manifold, i.e., a smooth manifold whose points are probability distributions. It can be used to calculate the distance between probability distributions. The metric is interesting in several aspects. By Chentsov\u2019s theorem, the Fisher information metric on statistical models is the only Riemannian metric (up to rescaling) that is invariant under sufficient statistics... Considered purely as a matrix, it is known as the Fisher information matrix. Considered as a measurement technique, where it is used to estimate hidden parameters in terms of observed random variables, it is known as the observed information.\n\nSymplectic geometry which deals with structures on manifolds that arise in Hamiltonian systems has applications in AI areas such as robotics and control systems. For instance, modeling the phase space of mechanical systems as symplectic manifolds allows for the application of geometric methods in control and planning algorithms. It can stabilize continuous-depth models in NeuroODEs by preserving energy-like Hamiltonian quantities during training and Hamiltonian Monte Carlo is a well-known sampling method for probabilistic models that leverages symplectic integrators to efficiently explore high-dimensional parameter spaces.\n\nCompared to using a Gaussian random walk proposal distribution in the Metropolis\u2013Hastings algorithm, Hamiltonian Monte Carlo reduces the correlation between successive sampled states by proposing moves to distant states which maintain a high probability of acceptance due to the approximate energy conserving properties of the simulated Hamiltonian dynamic when using a symplectic integrator. The reduced correlation means fewer Markov chain samples are needed to approximate integrals with respect to the target probability distribution for a given Monte Carlo error.\n\nFinally neural networks are often represented as infinite-dimensional manifolds in Hilbert or Banach functional spaces via manually picked Reproducing Kernel Hilbert Spaces (RKHS) or network induced Neural Tangent Kernels (NTK) as the layer width approaches to infinity where learning occurs via kernel regression and the norm of functions often represent their effective complexity.\n\nThe NTK is a specific kernel derived from a given neural network; in general, when the neural network parameters change during training, the NTK evolves as well. However, in the limit of large layer width the NTK becomes constant, revealing a duality between training the wide neural network and kernel methods: gradient descent in the infinite-width limit is fully equivalent to kernel gradient descent with the NTK. As a result, using gradient descent to minimize least-square loss for neural networks yields the same mean estimator as ridgeless kernel regression with the NTK. This duality enables simple closed form equations describing the training dynamics, generalization, and predictions of wide neural networks.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does policy evaluation work for continuous state space model-free approaches? How does policy evaluation work for continuous state space model-free approaches?\nTheoretically, a model-based approach for the discrete state and action space can be computed via dynamic programming and solving the Bellman equation. \nLet's say you use a DQN to find another policy, how does model-free policy evaluation work then? I am thinking of Monte Carlo simulation, but that would require many many episodes. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nHow does policy evaluation work for continuous state space model-free approaches? ... Let's say you use a DQN to find another policy, how does model-free policy evaluation work then? \n\nPolicy evaluation is the process of determining state-value $v_{\\pi}(s)$ or action-value $q_{\\pi}(s, a)$ functions for the current policy. In the context of continuous state and action spaces without a model of the environment, policy evaluation must incorporate the agent's past experience instead of the model dynamics and will generally use a function approximator such as a neural network to estimate the action-values. Many popular approaches apply online updates to the function approximator; e.g., DQN combines Temporal-Difference targets and gradient descent to change the weights of the neural network and the resultant action-value estimates. Since \n\nwe gradually change the weights of the neural network at each gradient descent step,\nthe estimated action-values are solely dependent on the weights of the neural network,\nthe current policy is solely dependent on the estimated action-values (e.g. DQN takes the action with largest action-value),\n\nthen policy evaluation (updating the estimated action-value function to better match the true action-value function under the current policy) and policy improvement (greedily changing the current policy based on the new estimated action-value function) occur simultaneously at each gradient descent step. In DQN, a gradient descent step occurs at each time step.\n\nI am thinking of Monte Carlo simulation, but that would require many many episodes. \n\nAfter changing the action-value function, we may get a new policy. We assume that the action-value function of the old policy is similar to that of the new policy (although it is not guaranteed) because the change in weights of the neural network was small. Therefore, we use the estimated action-value function of the old policy as an initial estimate of the action-value function of the new policy. Specifically, we use the same neural network with the same weights as the initial approximation. This is computationally convenient, as it prevents the need to start the next policy evaluation update from scratch (e.g. with a Monte Carlo simulation over a painfully large number of episodes). \n\nTheoretically, a model-based approach for the discrete state and action space can be computed via dynamic programming and solving the Bellman equation.\n\nThis same technique of using the estimated action-values of the old policy as the initial estimates for the action-values of the new policy is employed by some Dynamic Programming methods such as value iteration, albeit with known dynamics. Generalized Policy Iteration (GPI) is the notion of letting policy evaluation and policy iteration interact on whatever granularity deemed necessary for the problem at hand. A consequence of adopting the GPI paradigm is the choice to halt policy evaluation before convergence of the action-value function. Many deep reinforcement learning algorithms take this to an extreme and perform policy evaluation and policy improvement simultaneously during a single gradient descent step. For reference, Chapter 4 of Sutton and Barto provides a brief summary of these ideas.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Shouldn't G\u00f6del's incompleteness theorems disprove the physical symbol system hypothesis? According to the Wikipedia page of the physical symbol system hypothesis (PSSH), this hypothesis seems to be a vividly debated topic in philosophy of AI. But, since it's about formal systems, shouldn't it be already disproven by G\u00f6del's theorem?\nMy question arises specifically because the PSSH was elaborated in the 1950s, while G\u00f6del came much earlier, so at the time the Incompleteness theorems were already known; in which way does the PSSH deal with this fact? How does it \"escape\" the theorem? Or, in other words, how can it try to explain intelligence given the deep limitations of such formal systems?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The PSSH is often attacked via either Godel's theorems or Turing's incomputability theorem.\nHowever, both attacks have an implicit assumption: that to be intelligent is to be able to decide undecidable questions. It's really not clear that this is so.\nConsider what Godel's theorems say, in essence:\n\n\"powerful\" formal systems cannot prove, using only techniques from within the system, that they are self-consistent.\nThere are statements that are true that cannot be proven within a given \"powerful\" formal system.\n\nSuppose that we allow both of those facts. The missing step in the argument is the following statements:\n\nYou need to be able to prove the consistency of your own reasoning system to be considered intelligent.\nYou need to be able to correct reason out a proof of all true statements to be considered intelligent.\n\nThe main problem is, under this definition, humans are probably not considered intelligent! I certainly have no way to prove that my reasoning is sound and self-consistent. Moreover, it is objectively not so! I frequently believe contradictory things at the same time.\nI also am not able to reason out proofs of all the statements that appear to be true, and it seems entirely plausible that I cannot do so because of the inherent limitations of the logical systems I'm reasoning with.\nThis is a contradiction. The overall argument was that one of these 4 statements is false:\n\nGodel's theorems say symbol systems lack some important properties.\nIntelligent things have the properties that Godel says symbol systems lack.\nHumans are intelligent.\nHumans can't do the things Godel says symbol systems can't do.\n\nSome authors (like John Searle) might argue the false premise is 4. Most modern AI researchers would argue that the false premise is 2. Since intelligence is a bit nebulous, which view is correct may rely on metaphysical assumptions, but most people agree on premises 1 & 3.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the meaning of the square brackets in ant colony optimization? I'm studying the paper \"Minimizing Total Tardiness on a Single Machine Using Ant Colony Optimization\" which has proposed to use Ant colony optimization to SMTWTP.\nAccording to this paper:\n\nEach artificial ant iteratively and independently decides which job to\nappend to the sub-sequence generated so far until all jobs are\nscheduled, Each ant generates a complete solution by selecting a job $j$\nto be on the $i$-th position of the sequence. This selection process is\ninfluenced through problem-specific heuristic information called\nvisibility and denoted by $\\eta_{ij}$ as well as pheromone trails denoted by $\\tau_{ij}$. The former is an indicator of how good the choice of that job\nseems to be and the latter indicates how good the choice of that job\nwas in former runs. Both matrices are only two dimensional as a\nconsequence of the reduction in complexity\n\nThey have proposed this formula for the probability that job $j$ be selected to be processed on position $i$ (page 9 of the linked paper):\n$$\n\\mathcal{P}_{i j}=\\left\\{\\begin{array}{cl}\n\\frac{\\left[\\tau_{i j}\\right]^{\\alpha}\\left[\\eta_{i j}\\right]^{\\beta}}{\\sum_{h \\in \\Omega}\\left[\\tau_{i h}\\right]^{\\alpha}\\left[\\eta_{i h}\\right]^{\\beta}} & \\text { if } j \\in \\Omega \\\\\n0 & \\text { otherwise }\n\\end{array}\\right.\\tag{1}\\label{1}\n$$\nbut I can't understand what $[]$ surrounding $\\eta_{ij}$ and $\\tau_{ij}$ indicates. Does it show that these values are matrices?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The square brackets $[]$ in $[\\tau_{ij}]^\\alpha$ and $[\\eta_{ij}]^\\beta$ may be just a way of emphasing that the elements $\\tau_{ij} \\in \\mathbb{R}$ and $\\eta_{ij} \\in \\mathbb{R}$ of respectively the matrices $\\mathbf{\\tau} \\in \\mathbb{R}^{n \\times n}$ and $\\mathbf{\\eta} \\in \\mathbb{R}^{n \\times n}$ (where $n$ is the number of nodes in the graph) are respectively raised to $\\alpha$ and $\\beta$, so they could have used also other type of brackets, for example, $()$. It may also be a way of indicating that $[\\tau_{ij}]$ and $[\\eta_{ij}]$ are $1 \\times 1$ matrices or vectors that contain respectively the scalars $\\tau_{ij}$ and $\\eta_{ij}$, so you are multiplying matrices or vectors (dot product). \nThis notation is also used in the paper that introduced the ant colony system (ACS) (and it is probably used in many other papers related to ant colony optimization). See equation 1 of Ant Colony System: A Cooperative Learning Approach to the Traveling Salesman Problem (1997) by Dorigo and Gambardella.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the difference between DQN and AlphaGo Zero? I have already implemented a relatively simple DQN on Pacman.\nNow I would like to clearly understand the difference between a DQN and the techniques used by AlphaGo zero/AlphaZero and I couldn't find a place where the features of both approaches are compared. \nAlso sometimes, when reading through blogs, I believe different terms might in fact be the same mathematical tool which adds to the difficulty of clearly understanding the differences. For example, variations of DQN e.g. Double DQN also uses two networks like alpha zero.\nHas someone a good reference regarding this question ? Be it a book or an online ressource.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "DQN and AlphaZero do not share much in terms of implementation.\nHowever, they are based on the same Reinforcement Learning (RL) theoretical framework. If you understand terms like MDP, reward, return, value, policy, then these are interchangeable between DQN and AlphaZero. When it comes to implementation, and what each part of the system is doing, then this is less interchangeable. For instance two networks you have read about in AlphaZero are the policy network and value network. Whilst double DQN alternates between two value networks.\nProbably the best resource that summarises both DQN and AlphaZero, and explains how they extend the basic RL framework in different ways is Sutton & Barto's Reinforcement Learning: An Introduction (second edition) - Chapter 16 sections 5 and 6 cover the designs of DQN Atari, AlphaGo and AlphaZero in some depth.\nIn brief:\nDQN Atari\n\nIs model-free\nUses an action value estimator for $Q(s,a)$ values, based on a Convolutional Neural Network (CNN)\nUses experience replay and temporarily frozen target network to stabilise learning process\nUses a variety of tricks to simplify and standardise the state description and reward structure so that the exact same design and hyperparameters work across multiple games, demonstrating that it is a general learner.\n\nAlphaZero\n\nIs model based (although some of the learning is technically model-free, based on samples of play)\nUses a policy network (estimating $\\pi(a|s)$) and a state value network (estimating $V(s)$), based on CNNs. In practice for efficiency the NN for these share many layers and parameters, so how many \"networks\" there are depends how you want to count them.\n\nThe earlier AlphaGo version had 4 separate networks, 3 variations of policy network - used during play at different stages of planning - and one value network.\n\n\nIs designed around self-play\nUses Monte Carlo Tree Search (MCTS) as part of estimating returns - MCTS is a planning algorithm critical to AlphaZero's success, and there is no equivalent component in DQN\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to calculate the advantage in policy gradient functions? From my understanding of the REINFORCE policy gradient method, we gently nudge the probabilities of actions based on the advantages. More specifically, the positive advantages increase the probabilities, negative advantages reduce the probabilities.\nSo, how do we compute the advantages given the real discounted rewards (aggregated rewards from the episode) and a policy network that only outputs the probabilities of actions?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "First let us note the definition of the advantage function: \n$$A(s,a) = Q(s,a) - V(s) \\; ,$$\nwhere $Q(s,a)$ is the action-value function and $V(s)$ is the state-value function. In theory you could represent these by two different function approximators, but this would be quite inefficient. However, note that \n$$Q(s,a) = \\sum_{s',r} \\mathbb{P}(s',r|s,a)(r + V(s') = \\mathbb{E}[r + V(s')|a,s]\\;,$$\nso we can actually use a single function approximation, for $V(s)$, to completely represent the advantage function. To optimise this function approximator you would use the returns at each step of the episode as in e.g. the REINFORCE algorithm like you mentioned. \n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does the clipped surrogate objective work in Proximal Policy Optimization? In Proximal Policy Optimization Algorithms (2017), Schulman et al. write\n\nWith this scheme, we only ignore the change in probability ratio when it would make the objective improve, and we include it when it makes the objective worse.\n\nI don't understand why the clipped surrogate objective works. How can it work if it doesn't take into account the objective improvements?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Ok, so I think I have a better understanding of this now.\nFirstly, let's remind the main idea of the PPO : staying close to the previous policy. It's the same idea than in TRPO, but the L function is improved.\nSo, you wanna make \"small but safe steps\". With clipped surrogate objective, you don't give too much importance to promising actions. You learn that bad actions are bad, so you decrease their probability according to \"how bad\" they are. But for good actions, you only learn that they are \"a little bit good\", and their probability will be just slightly increased.\nThis mechanism allows you to perform small but relevant updates of your policy.\nhope this will help someone :)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Machine learning applied to space-time diagrams of cellular automata I wonder if machine learning has ever been applied to space-time diagrams of cellular automata. What comprises a training set seems clear: a number of space-time diagrams of one or several (elementary) cellular automata. For a supervised learning task, the corresponding local rules may be given as labels, e.g. in Wolfram's notation. Another label could be the complexity class of the rule (according to some classification, e.g. Wolfram's). But I am more interested in unsupervised learning tasks.\n\nI'm just starting to think about this topic and am not clear, yet, what the purpose of such a learning task should be. It may be (unsupervised) classification, feature extraction, object recognition (objects = gliders), or hypothesis generation (\"what's the underlying rule?\").\nWhere can I start or continue my investigation? Has there already work been done into this direction? Is it immediately clear by which ML technique the problem should be approached? Convolutional neural networks?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "As you say in your question, there are many directions \"machine learning with cellular automata\" can take.\nClassifying cellular automata space-time diagrams with ML\nI know of these two works that use neural networks to classify cellular automata into one of the 4 Wolfram classes:\n\nhttps://community.wolfram.com/groups/-/m/t/1417114\nhttps://direct.mit.edu/isal/proceedings/isal2019/280/99182 [1]\n\nIn general, predicting the Wolfram class is tricky because it is not a well-defined notion.\nThis is part of the larger problem of classifying cellular automata behavior from their space-time diagram (or rule, etc.), for which there are also many non-ML approaches. For example, [2] uses compression to estimate the complexity of the CA, while [3] uses the asymptotic properties of the transient sizes.\nIn related work [4], Gilpin used a convolutional neural network representation of CA to learn the rules. He estimates the complexity of a rule from \"how hard it is to learn that rule.\"\nCellular automata and neural networks\n@Rexcirus has pointed you to the very interesting \"Growing neural cellular automata\" paper. The same authors have recently been working on a continuous cellular automaton called Lenia, extending it to create Particle Lenia.\nThe whole idea behind these examples is to use a convolutional neural network to implement a CA-like system. This has many advantages, including being able to use all the NN properties and differentiability to \"learn\" things with the CA.\nThere is a fundamental difference between the usual discrete CA and the neural network-based extensions because you move to continuous space. However, there are interesting connections to be made between the two models.\nCellular automata as ML systems\nAnother approach is using the CA as the basis of a ML system, harvesting its computations to make predictions. This is done with something called reservoir computing. This whole subfield is called reservoir computing with cellular automata (ReCA), and you might be interested in it. Here are a few papers to get you started (including one of mine) [5,6,7,8].\n\nSilverman, E. Convolutional Neural Networks for Cellular Automata Classification. Artificial Life Conference Proceedings 31, 280\u2013281 (2019).\nZenil, H. Compression-Based Investigation of the Dynamical Properties of Cellular Automata and Other Systems. Complex Systems 19, (2010).\nHudcov\u00e1, B. & Mikolov, T. Classification of Complex Systems Based on Transients. in 367\u2013375 (MIT Press, 2020). doi:10.1162/isal_a_00260.\nGilpin, W. Cellular automata as convolutional neural networks. arXiv:1809.02942 [cond-mat, physics:nlin, physics:physics] (2018).\nYilmaz, O. Reservoir Computing using Cellular Automata. arXiv:1410.0162 [cs] (2014).\nNichele, S. & Molund, A. Deep Reservoir Computing Using Cellular Automata. arXiv:1703.02806 [cs] (2017).\nCisneros, H., Mikolov, T. & Sivic, J. Benchmarking Learning Efficiency in Deep Reservoir Computing. in Proceedings of The 1st Conference on Lifelong Learning Agents 532\u2013547 (PMLR, 2022).\nGlover, T. E., Lind, P., Yazidi, A., Osipov, E. & Nichele, S. The Dynamical Landscape of Reservoir Computing with Elementary Cellular Automata. in ALIFE 2021: The 2021 Conference on Artificial Life (MIT Press, 2021).\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are examples of machine learning techniques inspired by neuroscience? What are examples of machine learning techniques (i.e. models, algorithms, etc.) inspired (to different extents) by neuroscience?\nParticularly, I'm interested in recent developments, say less than 10 years old, that have their basis in neuroscience to some degree. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There is a category of neural networks that more closely attempt to mimic biological neural networks by incorporating also time (i.e. not all neurons fire at the same time). They are called spiking neural networks (SNNs) and their name comes from the fact that they use spiking neurons (i.e. neurons that fire discrete signals and affect other neurons at possibly different times). \nSNNs are mainly used in neuroscience, and aren't commonly used in machine learning because they currently have some apparent limitations (e.g. non-differentiability, so gradient descent and back-propagation can't be applied, but GD and BP aren't really biologically realistic anyway, although some people already tried to apply GD to SNNs) and their performance isn't still as good as the performance of traditional deep learning models, which make them not so appealing to the deep learning community (which is currently mainly driven by performance and utility). Nevertheless, the performance gap between traditional neural networks and spiking neural networks is decreasing. See Deep Learning in Spiking Neural Networks (2019) by Amirhossein Tavanaei et al. for more details. \nThere are already commercial implementations of a hardware-accelerated SNNs (e.g. BrainChip provides this service). These hardware-accelerators are often called neuromorphic chips (or processors) and all computing based on SNNs or processors that attempt to implement biological neural networks is known as neuromorphic computing.\nThere's also the related area called reservoir computing, which studies neural networks (such as liquid-state machines or echo state machines) that make use of reservoirs (which are fixed during learning) to attempt e.g. to improve training efficiency. See An overview of reservoir computing: Theory, applications and implementations (2007) by Benjamin Schrauwen et al. for an overview.\nNumenta (and, in particular, Jeff Hawkins, the founder of Numenta and author of an interesting book called On Intelligence) has also been studying neuroscience for a long time in order to develop models and theories of human intelligence. They call their new theory The Thousand Brains Theory of Intelligence, which is inspired by biological grid cells. This is also related and similar to capsule networks (often associated with Hinton).\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to detect vanishing gradients? Can vanishing gradients be detected by the change in distribution (or lack thereof) of my convolution's kernel weights throughout the training epochs? And if so how?\nFor example, if only 25% of my kernel's weights ever change throughout the epochs, does that imply an issue with vanishing gradients?\nHere are my histograms and distributions, is it possible to tell whether my model suffers from vanishing gradients from these images? (some middle hidden layers omitted for brevity)\n\n\n\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Vanishing Gradients can be detected from the kernel weights distribution. All you have to look for is whether the weights are dying down to 0.\nIf only 25% of your kernel weights are changing that does not imply a vanishing gradient, it might be a factor, but there can be a variety of reasons, such as poor data, loss function used to the optimizer, etc. Kernel's weight not changing only points out that the model is not learning well.\nFrom the histograms, only the conv_2d_2 layer shows any form of vanishing gradients since the numbers are pretty small. But even that seems to be picking after 600 epochs. Usually, a good indicator is to have the mean of the weights in a layer to be closer to 0 and the standard deviation to be closer to 1. So, if this is maintained to a good extent during training, you're good to go.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Deep Q-Learning: why don't we use mini-batches during experience reply? In examples and tutorial about DQN, I've often noticed that during the experience replay (training) phase people tend to use stochastic gradient descent / online learning. (e.g. link1, link2) \n# Sample minibatch from the memory\nminibatch = random.sample(self.memory, batch_size)\n# Extract informations from each memory\nfor state, action, reward, next_state, done in minibatch:\n # if done, make our target reward\n target = reward\n if not done:\n # predict the future discounted reward\n target = reward + self.gamma * \\\n np.amax(self.model.predict(next_state)[0])\n # make the agent to approximately map\n # the current state to future discounted reward\n # We'll call that target_f\n target_f = self.model.predict(state)\n target_f[0][action] = target\n\nWhy can't they use mini batches instead?\nI'm new to RL, but in deep learning people tends to use mini-batches as they would result in a more stable gradient. Doesn't the same principle apply to RL problems? Is the randomness/noise introduced actually beneficial to the learning process? Am I missing something, or are these sources all wrong?\n\nNote:\nNot all the sources rely on stochastic gradient descent: e.g. keras-rl seems to rely on minibatches (https://github.com/keras-rl/keras-rl/blob/master/rl/agents/dqn.py)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "DQN \"library\" implementations that I have seen do use mini-batches to train, and I would generally recommend this, as it usually strikes a reasonable balance between number of weight updates and accuracy of the gradients.\nIn your first link, and the code excerpt, the sample list is literally called minibatch. However, the developer then goes on to make a series of individual SGD steps per item within that sample. \n\nWhy can't they use mini batches instead? \n\nThey can, and it works just fine. In my DQN explorations I tend to use a single mini-batch per timestep, and the Adam optimiser to accelerate learning. I also use a mini-batch to calculate TD target values.\n\nI'm new to RL, but in deep learning people tends to use mini-batches as they would result in a more stable gradient. Doesn't the same principle apply to RL problems? \n\nIt does, but I don't know if this is the most sample efficient that it could be. I prefer to use mini-batches and more complex optimisers because this runs faster (for a given number of replay training samples per time step), and I can run more time steps of the environment in less time.\nIt is possible for instance that a replay sample size of 32 per time step, with 4 mini-batch updates of 8 each would be the most sample efficient approach for a specific problem (because it makes more updates from the given samples), but it might not be the most CPU efficient.\n\nIs the randomness/noise introduced actually beneficial to the learning process? \n\nI don't think so, but there are plenty of other tuning issues to consider in RL.\n\nAm I missing something, or are these sources all wrong?\n\nThey are not necessarily wrong, but may be CPU inefficient. \nMore likely in my opinion, your sources are explaining algorithms in principle, and did not want to add too many layers of optimisation, or too many components that may need tuning to work. There is a lot going on in a typical DQN agent, and having many performance optimisations can hide the details that the person is trying to teach.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does being on-policy prevent us from using the replay buffer with the policy gradients? \nOne of the approaches to improving the stability of the Policy\nGradient family of methods is to use multiple environments in\nparallel. The reason behind this is the fundamental problem we\ndiscussed in Chapter 6, Deep Q-Network, when we talked about the\ncorrelation between samples, which breaks the independent and\nidentically distributed (i.i.d) assumption, which is critical for\nStochastic Gradient Descent (SDG) optimization. The negative\nconsequence of such correlation is very high variance in gradients,\nwhich means that our training batch contains very similar examples,\nall of them pushing our network in the same direction. However, this\nmay be totally the wrong direction in the global sense, as all those\nexamples could be from one single lucky or unlucky episode. With our\nDeep Q-Network (DQN), we solved the issue by storing a large amount of\nprevious states in the replay buffer and sampling our training batch\nfrom this buffer. If the buffer is large enough, the random sample\nfrom it is much better representation of the states distribution at\nlarge. Unfortunately, this solution won't work for PG methods, at most\nof them are on-policy, which means that we have to train on samples\ngenerated by our current policy, so, remembering old transitions is\nnot possible anymore.\n\nThe above excerpt is from Maxim Lapan in the book Deep Reinforcement Learning Hands-on page 284.\nHow does being on-policy prevent us from using the replay buffer with the policy gradients? Can you explain to me mathematically why we can't use replay buffer with A3C for instance?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Let's say your old policy is $\\pi_b$ and your current one is $\\pi_a$. If you collected trajectory by using policy $\\pi_b$ you would get return $G$ whose expected value is\n\\begin{align}\nE_{\\pi_b}[G_t|S_t = s] &= E_{\\pi_b}[R_{t+1} + G_{t+1}]\\\\\n&= \\sum_a \\pi_b(a|s) \\sum_{s', r} p(s', r|s, a) [r + E_{\\pi_b}[G_{t+1}|S_{t+1} = s']]\\\\\n\\end{align}\nYou can see if you write out this recursively that this expectation depends on $\\pi_b(a|s), \\pi_b(a'|s'), \\ldots$\nIf you collect trajectory with policy $\\pi_a$ you would get expected return that depends on $\\pi_a(a|s), \\pi_a(a'|s'), \\ldots$ Since these are two different policies then $\\pi_b(a|s) \\neq \\pi_a(a|s)$ for some $(s, a)$. That would mean that returns have different expected values and are sampled through different distributions. You cannot then use some return $G$ sampled by following policy $\\pi_b$ to update policy $\\pi_a$ because it's not sampled according to the proper distribution, if we did, we would be updating policy $\\pi_a$ with biased gradient update that does not reflect how policy $\\pi_a$ performed.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "In OCR, how should I deal with the warped text on the sides of oval objects? Consider an image that contains one can (or bottle, or any similar oval object), which has texts all over it. In the image below, I have many bottles, but you can assume that each image only contains one such object.\n\nAs we can see, in each can, the text can flow from left to right, and any OCR system may miss the text on the left and right sides of the can, as they are not aligned with the camera angle.\nSo, is there any solution/s for this, like preprocessing in a certain way, so that we can read the text or make this round object into a straight one? (If there is any Python program that can solve this problem, could you please share it with me?)\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are many papers on this but the following is a good start:\n\nHow to unwrap wine labels programmatically. The author includes source code in Python.\n\n\nYou mentioned you do not want to do a panoramic view but that has more than one meaning. If I assume you mean you do not want to rotate the can while taking multiple photos, or you don't want to take multiple photos from different angles, you could try a pericentric lens. This would require some image processing to do the unwrapping. More resolution is needed as the wrapping is much more severe. The advantage though is that you will have a single image of the full cylindrical surface and won't miss any features or text.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What jobs cannot be automatized by AI in the future? AI is progressing drastically, and imagine they tell you you're fired because a robot will take your place. What are some jobs that can never be automated?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The Oxford study from 2013 in The future of employment paper assess this and estimated the probability of computerisation for 702 detailed occupations using a Gaussian process classifier (using job data from the UK partially merged with data from US), and based on these estimates they identified three areas of computerisation bottleneck areas and nine skills that people are still needed for each profession, this includes:\n\nPerception and Manipulation.\n\nFinger dexterity.\n\nThe ability to make precisely coordinated movements of\n the fingers of one or both hands to grasp, manipulate, or\n assemble very small objects.\n\nManual dexterity.\n\nThe ability to quickly move your hand, your hand together\n with your arm, or your two hands to grasp, manipulate, or\n assemble objects.\n\nThe need for a cramped work space.\n\nHow often does this job require working in cramped work\n spaces that requires getting into awkward positions?\n\n\nCreative Intelligence.\n\nOriginality.\n\nThe ability to come up with unusual or clever ideas about\n a given topic or situation, or to develop creative ways to\n solve a problem.\n\nFine arts.\n\nKnowledge of theory and techniques required to compose,\n produce, and perform works of music, dance, visual arts,\n drama, and sculpture.\n\n\nSocial Intelligence.\n\nSocial perceptiveness.\n\nBeing aware of others\u2019 reactions and understanding why\n they react as they do.\n\nNegotiation.\n\nBringing others together and trying to reconcile\n differences.\n\nPersuasion.\n\nPersuading others to change their minds or behavior.\n\nAssisting and caring for others.\n\nProviding personal assistance, medical attention, emotional\n support, or other personal care to others such as\n coworkers, customers, or patients.\n\n\n\nSource: The future of employment: how susceptible are jobs to computerisation: Table 1.\nWhat this study is basically saying, around 50% of all jobs will be replaced by robots in the next 20 years.\nBased on the above study, the BBC assembled a handy guide that calculates which jobs are likely to be automated within the next two decades:\n\nWill a robot take your job?\n\nSee also: replacedbyrobot.info website.\n\nWith this tool, you can check the prediction of over 700 jobs.\n\nRelated:\n\nWhen robots can do all manual labor and service jobs, what will the majority human population do?\nTED: The jobs we'll lose to machines \u2014 and the ones we won't (by Anthony Goldbloom)\nLabore Ad Infinitum: AI & Automation vs Timeless Tasks\nWhich suggests: Military/Peacekeeper, Athletes, Therapist, Musical Performer, Actors and Dancer, Visual Artists, Religious/Spiritual Leaders, The World\u2019s Oldest Profession, Virtual Goods, Politicians, Judges, Parenting.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the differences between an agent that thinks rationally and an agent that acts rationally? Stuart Russell and Peter Norvig pointed out 4 four possible goals to pursue in artificial intelligence: systems that think/act humanly/rationally.\nWhat are the differences between an agent that thinks rationally and an agent that acts rationally?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Maybe a good example to think about would be something like the Sphyx story. The wasp in the story appears to behave like a rational being: it seems to have a plan of action, it seems to be able to do advanced operations like counting, and it seems to execute the plan well. However, if you disrupt the wasp's plan, it becomes apparent that it is not thinking rationally. Instead, it has evolved a very complex behaviour that appears to include rational components, but is still just an instinct.\nIn the context of AI, consider a GOFAI system for planning like GraphPlan as opposed to a machine learning system for generating plans. While the former is a general-purpose algorithm for reasoning about planning problems, the latter is an input/output mapping that may mimic reasoning, or may be more \"instinctual\". Some AI'ers would say that the latter system is not really engaged in rational thought, while the former is. Both systems exhibit rational action, however.\nInstinctive systems often work very well, and I'd say that the increasing effectiveness of machine learning approaches since that edition of R&N was published (almost 10 years ago now?) makes this a fuzzier distinction in practice than the book might suggest.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Relevance of Weisfeiler\u2013Lehman Graph Isomorphism Test limitation for Graph Neural Networks Graph Neural Networks power is limited by the power of Weisfeiler\u2013Lehman Graph Isomorphism algorithm.\nQuoting wikipedia:\n\nIt has been demonstrated that GNNs cannot be more expressive than the\nWeisfeiler\u2013Lehman Graph Isomorphism Test. In practice, this\nmeans that there exist different graph structures (e.g., molecules\nwith the same atoms but different bonds) that cannot be distinguished\nby GNNs.\n\nWhat are the practical implications of this limitation? Is it an academic example providing no obstacle in real-life applications of GNNs (e.g. to drug discovery) or are there any instances in which it plays a big role? If the latter, please provide an example of such a limitation.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Firstly, as already stated in the Wikipedia quote: Observing that a type of GNN is as expressive as the Weisfeiler\u2013Lehman (WL) Test, means in practice that two graphs $\\mathcal{G}_1$ and $\\mathcal{G}_2$ cannot be differentiated by the GNN, if the 1-WL Test cannot differentiate them. Therefore, if $\\mathcal{G}_1$ and $\\mathcal{G}_2$ are labelled differently, your model cannot ever learn to classify both correctly.\nIn real life applications, this often doesn't matter too much and Zopf et al. provide a nice analysis of that and there you can see that most datasets contain 100% distinguishable graphs. But the 1-WL-Test struggles with the Molecular data of the MUTAG dataset (s. Table II). However, it seems that most of the time 1-WL expressivity will be enough.\nThere is another distinction to be made here: In real-world applications, we want encodings of graphs that reflect their similarity, meaning two similar graphs $\\mathcal{G}_1$ and $\\mathcal{G}_2$ should be encoded as similar vectors in the embedding space. If $\\mathcal{G}_1$ and $\\mathcal{G}_2$ are very slightly different, the vectors should still be close by. This then provides a tool that generalizes to unseen graphs. The WL-Test cannot do this kind of encoding but the GNN can.\nHere it makes sense to think about expressivity of GNNs as the ability to do this smooth encoding. And one aspect of that is this upper bound of expressivity as stated by the quote you provide.\nI hope that was understandable, feel free to follow up on that.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What could happen if we wrongly assume that the POMDP is an MDP? Consider the Breakout environment.\nWe know that the underlying world behaves like an MDP, because, for the evolution of the system, it just needs to know what the current state (i.e. position, speed, and speed direction of the ball, positions of the bricks, and the paddle, etc) is. But, considering only single frames as the state space, we have a POMDP, because we lack in formations about the dynamics [1], [2].\nWhat could happen if we wrongly assume that the POMDP is an MDP and do reinforcement learning with this assumption over the MDP?\nObviously, the question is more general, not limited to Breakout and Atari games.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nWhat could happen if we wrongly assume that the POMDP is an MDP and do reinforcement learning with this assumption over the MDP?\n\nIt depends on a few things. The theoretical basis of reinforcement learning needs the state descriptions to have the Markov property for guarantees of convergence to optimal or approximately optimal solutions. The Markov property is a requirement that the state defines 100% of the controllable variation of reward and next state (given the action) - the rest must be purely stochastic.\nAn MDP can be \"nearly Markov\", and a lot of real-world physical systems are like that. For instance, pole-balancing and acrobot tasks can be implemented as physical systems using motors, wheels, joints etc. In those real systems, there are limits to accuracy of measurement of the state, and many hidden variables, such as variable temperature (affecting length of components), friction effects, air turbulence. Those hidden variables taken strictly by formal definition would make the system a POMDP. However, their influence compared to the key state variables is low, and in some cases effectively random from the perspective of the agent. In practice RL works well in the real physical systems, despite state data being technically incomplete.\nIn Atari games using multiple frame images as states, there are varying degrees of to which those states are already non-Markovian. In general a computer game's state may include many features that are not displayed on the screen. Enemies may have health totals or other hidden state, there can be timers controlling appearance of hazards, and in a large number of games the screen only shows a relatively small window into the total play area. However, the Deep Mind DQN network did well on a variety of scrolling combat and platform games.\nOne game where DQN did notably badly - no better than a default random player - was Montezuma's Revenge. Not only does that platform puzzler game have a large map to traverse, but it includes components where state on one screen affects results on another.\nIt is hard to make a general statement about where an MDP with missing useful state information would benefit from being treated as a POMDP more formally. Your question is essentially the same thing expressed in reverse.\nThe true answer for any non-trivial environment would be to try an experiment. It is also possible to make some educated guesses. The basis for those guesses might be the question \"If the agent could know hidden feature x from the state, how different would expected reward and policy be?\"\nFor the breakout example using each single frame as a state representation, I would expect the following to hold:\n\nValue estimates become much harder since seeing the ball next to a brick - compared to seeing a ball progressively get closer to a brick over 4 frames - gives much less confidence that it is about to hit that brick and score some points.\n\nIt should still be possible for the agent to optimise play, as one working strategy is to position the \"bat\" under the ball at all times. This will mean less precise control over angle of bounces, so I would expect it to perform worse than the four-frame version. However, it should still be significantly better than a default random action agent. A key driver for this observation is that seeing the ball close to the bottom of the screen, and not close to the bat, would still be a good predictor of a low expected future reward (even averaged over chances of ball going up vs going down), hence the controller should act to prevent such states occurring.\n\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is reinforcement learning only about determining the value function? I started reading some reinforcement learning literature, and it seems to me that all approaches to solving reinforcement learning problems are about finding the value function (state-value function or action-state value function).\nAre there any algorithms or methods that do not try to calculate the value function but try to solve a reinforcement learning problem differently?\nMy question arose because I was not convinced that there is no better approach than finding the value functions. I am aware that given the value function we can define an optimal policy, but are there not other ways to find such an optimal policy?\nAlso, is the reason why I don't encounter any non value-based methods that these are just less successful?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are many algorithms that are not based on finding a value function. The most common ones are policy gradients. These methods attempt to map states to actions through a neural network. They learn the optimal policy directly, not through a value function.\n\nThe important part of the image is when Model-Free RL splits into Policy Optimization (which includes policy gradients) and Q-Learning. Later you can see the two sections coming back together in algorithms that are a mix of both techniques. Even the bottom three methods in policy optimization involve some form of learning a value function. The best and most advanced algorithms use value function learning and policy optimization. The value function is only for training. Then when the agent is tested, it only uses the policy.\nThe most likely reason you have only heard of value function methods is because policy gradients are more complicated. There are many algorithms more advanced than ones that only use value functions and policy gradients can learn to operate in continuous actions spaces (an action can be between -1 and 1, like when moving a robot arm) while value functions can only operate with discrete action spaces (move 1 right or 1 left).\nSummary: Yes, there are other methods that learn the optimal policy without a value function. The best algorithms use both types of reinforcement learning.\nThe SpinningUp website has a lot of information about reinforcement learning algorithms and implementations. You can learn more about direct policy optimization there. That is also where I got the image from.\nThis answer is specific to the most common types of Model-Free RL. There are other algorithms related to the RL problem that do not learn value functions, like inverse reinforcement learning and imitation reinforcement learning.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What are the most instructive movies about artificial intelligence? The field of AI has expanded profoundly in recent years, as has public awareness and interest. This includes the arts, where fiction about AI has been popular since at least Isaac Asimov. Films on various subjects can be good teaching aids, especially for younger students, but it can be difficult for a non-expert to know which films have useful observations and insights, suitable for the classroom.\nWhat are insightful films about AI?\nListed films must be suitable for academic analysis, providing insight into theory, methods, applications, or social ramifications.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Here are my suggestions\n\nHer, the AI part (movie spoiler):\n\n The AI can define a user's profile just by hearing his short story, and \"act\" based on the user's profile. The AI makes the user comfort with it (her). It shows a very advance user profiling.\n\nEx Machina the AI part (movie spoiler):\n\n This movie will show you how an AI learn to trick someone. The AI can express her feelings, and make you trust their feeling.\n\nEagle Eye, the AI part (movie spoiler):\n\n A movie about a general story \"AI that want to kill\". This movie can show you how The AI can compile a lot of information for its purpose. \n\nBig Hero 6, the AI part (movie spoiler):\n\n Baymax is a very good example of a very complex expert system, he has a \"knowledge chip\" and a very smart way to diagnose people\n\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do neural nets and machine learning tend to work well with MCTS, but not with regular Minimax game-playing AI? I've often heard MCTS grouped together with neural nets and machine learning. From what I gather, MCTS uses a refined intuition (from maching learning) to evaluate positions. This allows it to better guess which moves are worth playing out more.\nBut I've almost never heard of using machine learning for Minimax+alpha-beta engines. Couldn't machine learning be used for the Engine to better guess which move is best, and then look at that move's subtree first? A major optimization of the minimax algorithm is move-ordering, and this seems like a good way to accomplish that.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "It just does.\nTake a look at this post explaining how MCTS works.\n\nIn both Alpha Go Lee and Alpha Zero the tree traversal follows the nodes that maximize the following UCT variant:\n\\begin{equation}\nUCT(v_i,v) = \\frac{Q(v_i)}{N(v_i)} + cP(v_i, v)\\sqrt{\\frac{N(v)}{1+N(v_i)}}\n\\end{equation}\nwhere P(vi,v)\n is prior probability of the move (transition from v to vi ), its value comes from the output of deep neural network called Policy Network . Policy Network is a function that consumes game state and produce probability distribution over possible moves.\n\nAs you can see the Policy Network(it is actually just one neural network for both the value and the policy) is used to guide the search tree. Not all possible moves are explored. Also during the learning phase the policy network uses the \"visit count\" of the MCTS Nodes to learn. Moves that were explored more are the better ones. The state-of-the-art chess engine Stockfish evaluates about 1000 times more positions per second than Alpha Zero. It relies on exploring \"most of\" the possible positions. Calculating the score using heuristics is much faster than using Alpha Zero's 19 layer residual network. If Google were to use minimax then they wouldn't be able to look very far ahead. Alpha Zero explores about 70K moves per second which would be only a couple ply deep. MCTS allows it to explore only the more promising moves and simulate those positions.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does backpropagation update weights one layer at a time? I am new to Deep Learning.\nSuppose that we have a neural network with one input layer, one output layer, and one hidden layer. Let's refer to the weights from input to hidden as $W$ and the weights from hidden to output as $V$. Suppose that we have initialized $W$ and $V$, and ran them through the neural network via the forward algorithm/pass. Suppose that we have updated $V$ via backpropagation.\nWhen estimating the ideal weights for $W$, do we keep the weights $V$ constant when updating $W$ via gradient descent given we already calculated $V$, or do we allow $V$ to update along with $W$?\nSo, in the code, which I am trying to do from scratch, do we include $V$ in the for loop that will be used for gradient descent to find $W$? In other words, do we simply use the same $V$ for every iteration of gradient descent?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The answer is implied in the term \"backpropagation\". All gradients are calculated at the same time. That is, the error from your loss function is propagated backwards from the output and through your whole network. This propagation results in an error associated with each weight in the network, which determines how you change each weight in order to minimize your loss function.\n\nor do we allow $V$ to update along with $W$?\n\nYes. This saves time, since many of the results of intermediate computations used to update $V$ can be reused in the update of $W$. \nSee http://neuralnetworksanddeeplearning.com for a detailed description of the backpropagation algorithm.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the calcium equivalent role in neural networks I understand that neural networks model biological neurons. Each node in the network represents a neuron cell and the connections between nodes represent the connections between cells. As in nature, a neuron fires an electrical signal to connected neurons based on some kind of threshold or function that mimics such. \nRecent discoveries on how the brain works reveal the importance of calcium within the cells. See http://link.springer.com/article/10.1007/BF01794675 for more information. To summarize, calcium affects the regulation, stimulation and transmission of electrical activity as well as the destruction of neurones.\nFrom my study of neural networks, there does not seem to be a calcium equivalent. Having one would imply that the functions, connections and weights in an artificial network are configured during the training and execution process and can change over time. I understand that back-propagation is used to train the weights, but have not seen anything that trains the function nor the connections (although a zero weight could imply no connection).\nDoes anyone know of such a network (or training algorithm)? If so, do these networks perform better than a network that is pre-configured?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Neural networks don't model biological neurons. \nThey are at best inspired by biological neurons, in that they get excited by certain inputs and fire once the excitation crosses a threshold. And this second point even holds only approximately because the backpropagation algorithm needs smoothed out steps to learn by gradient descent. And backpropagation is not even inspired by biology, that would rather be hebbian learning. \nGenerally in machine learning people do what works. The connection to biology is tenuous at best. You will usually not find one to one correspondence of low level details between machine learning setups and biological neurons. For that you'll have to turn to brain simulations.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How can I detect datetime patterns in text? I want to explore and experiment the ways in which I could use a neural network to identify patterns in text. \nexamples:\n\nPrices of XYZ stock went down at 11:00 am today\nRetrieve a list of items exchanged on 03/04/2018\nShow error logs between 3 - 5 am yesterday.\nReserve a flight for 3rd October.\nDo I have any meetings this Friday?\nRemind to me wake up early tue, 4th sept\n\nThis is for a project so I am not using regular expressions. Papers, projects, ideas are all welcome but I want to approach feature extraction/pattern detection to have a model trained which can Identify patterns that it has already seen.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Approaches\nThere are two main approaches to detecting any human readable representation of a discrete quantity within text.\n\nDetect well known and stable patterns in the input stream and by adjacency determine the output stream.\nWindowing through the text in the input stream and directly detect the quantities.\n\nThere are other approaches and there are hybrids of these two or one of these and the other approaches, but these two are the theoretically most straightforward and likely to produce both reliability and accuracy.\nRe-entrant Learning\nWhether the training involves re-entrant learning techniques, such as reinforcement, is a tangential issue that this answer will not address, but know that whether all training is solely a deployment component or whether adaptation and/or convergence occurs in real time is an architectural decision to be made.\nPractical Concerns\nPractically, the outputs of each recognition are as follows.\n\nStarting index\nEnding index\nInteger year or null\nInteger day of year or null\nInteger hour in military time or null\nMinute or null\nSecond or null\nTime zone or null\nProbability the recognition unit was correctly identified\nProbability the recognition produced accurate results\n\nAlso practically, the input must either be from within one particular locale's norms in terms of\n\nCalendar,\nTime,\nWritten language,\nCharacter encoding, and\nCollation,\n\n... or ...\n\nThe learning must occur using training sets that include the locales that will be encountered during system use\n\n... or ...\n\nMuch of the locale specific syntax must be normalized to a general date and time language such as this:\n\u091c\u0928\u0935\u0930\u0940 --> D_01\nEnero --> D_01\nJan\u00faar --> D_01\n\nso that Filipino and Icelandic names for the first month of the year enter the artificial network as the same binary pattern.\n**Date and Time Specifically*\nIn the case of 1. above, which is semi-heuristic in nature, and assuming that the locale is entirely en-US.utf-8, the CASE INSENSITIVE patterns for a PCRE library or equivalent to use as a search orientation heuristic include the following.\n(^|[^0-9a-z])(19|20|21)[0-9][0-9])([^0-9a-z]|$)\n(^|[^0-9a-z])(Mon|Monday|Tue|Tues|Tuesday|Wed|Wednesday|Thu|Thur|Thurs|Thursday|Fri|Friday|Sat|Saturday|Sun)([^0-9a-z]|$)\n(^|[^0-9a-z])(Jan|January|Feb|February|Mar|March|Apr|April|May|Jun|June|Jul|July|Aug|August|Sep|Sept|September|Oct|October|Nov|November|Dec|December)([^0-9a-z]|$)\n(^|[^0-9a-z])(Today|Yesterday|Tomorrow)([^0-9a-z]|$)\n(^|[^0-9])[AP]M|[AP][.]M[.]|Noon|Midnight)([^0-9a-z]|$)\n(^|[^a-z])(0?[1-9])(:[0-5][0-9]){1,2}([^a-z]|$)\n\nThere should be others for time, hyphenated or slash delimited dates, or time zone.\nThe positions and normalized encoding of these date and time artifacts are then substituted into the artificial network inputs instead of the original text in the stream, reducing redundancy and improving both the speed of training and the resulting accuracy and reliability of recognition.\nIn the case of 2. above, the entire burden of recognition is left to the artificial network. The advantage is less reliance on date and time conventions. The disadvantage is a much larger burden placed on training data variety and training epochs, meaning a much higher burden on computing resources and the pacience of the stake holder for the project.\nWindowing\nAn overlapping windowing strategy is necessary. Unlike FFT spectral analysis in real time, the windowing must be rectangular, because the size of the window is the width of the input layer of the artificial network. Experimenting with the normalization of input such that the encoding of text and data and time components entering the input layer could greatly vary the results in terms of training speed, recognition accuracy, reliability, and adaptability to varying statistical distributions of date and time instances and relationships.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Concrete example of latent variables and observables plugged into the Bayes' rule In the context of the variational auto-encoder, can someone give me a concrete example of the application of the Bayes' rule\n$$p_{\\theta}(z|x)=\\frac{p_{\\theta}(x|z)p(z)}{p(x)}$$\nfor a given latent variable and observable?\nI understand with VAE's we're essentially getting an approximation to $p_{\\theta}(z|x)$ that models the distribution that we think approximates the latent variables, but I need a concrete example to really understand it.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Let's assume the probability distributions are Gaussian (or normal) distributions. In other words, in the Bayes' rule\n\\begin{align}\np(z|x)=\\frac{p(x|z)p(z)}{p(x)}\n\\tag{1}\\label{1}\n\\end{align}\nThe posterior $p(z|x)$, the likelihood $p(x|z)$, the prior $p(z)$ and the evidence (or marginal) $p(x)$ are Gaussian distributions. You can assume this because Gaussian distributions are closed under conditioning and marginalization.\nFor simplicity, let's further assume that they are univariate Gaussian distributions. Given that the Gaussian distribution is a continuous probability distribution, it has an associated probability density function (rather than a probability mass function, which is associated with discrete probability distributions, such as the Bernoulli distribution). The probability density function of the Gaussian distribution is\n\\begin{align}\nf(x \\mid \\mu, \\sigma^2) = \\frac{1}{\\sqrt{2\\pi\\sigma^2} } e^{ -\\frac{(x-\\mu)^2}{2\\sigma^2} } \\tag{2}\\label{2}\n\\end{align}\nwhere $\\mu$ and $\\sigma^2$ are respectively the mean and variance of the Gaussian distribution and $x$ is a variable (similarly to a variable $x$ in any mathematical function $f(x)$). So, given a concrete value for $x$, for example, $x=1$, then $f(x=1, \\mu, \\sigma^2)$ is a so-called density value (rather than a probability, which a probability mass function returns, given an input). For example, let's assume that the mean $\\mu=0$ and the variance $\\sigma^2 = 1$, then, for $x=1$, the density will be\n$$\nf(1 \\mid 0, 1) = \\frac{1}{\\sqrt{2\\pi} } e^{ -\\frac{1}{2} }\n$$\nSo, to obtain the concrete density value, I've just replaced the concrete values of $x$, $\\mu$ and $\\sigma^2$ in equation \\ref{2}. \nTo calculate the posterior $p(z|x)$ in equation \\ref{1}, you just need to replace the likelihood $p(x|z)$, the prior $p(z)$ and the evidence $p(x)$ with the Gaussian probability density shown in equation \\ref{2}, so you will have\n\\begin{align}\np(z|x)=\\frac{f_{X\\mid Z}(x \\mid \\mu_{X\\mid Z}, \\sigma^2_{X\\mid Z}, z) f_{Z}(z \\mid \\mu_{Z}, \\sigma^2_{Z})}{f_{X}(x \\mid \\mu_{X}, \\sigma^2_{X})}\n\\tag{3}\\label{3}\n\\end{align}\nI've explicitly added a subscript to the means and variances of each probability density, given that, for example, the mean of the probability density $f_{X\\mid Z}$ might be different than the mean of the probability density $f_{Z}$ or $f_{X}$, etc. So, to get the actual density value (a real number) that represents $p(z|x)$, you just need to replace $f_{X\\mid Z}$, $f_{Z}$ and $f_{X}$ with the definition of the Gaussian density function in \\ref{2} with their actual mean and variance values. I'll let you do this, given that this is really just a matter of picking up a concrete value for the means and variances and doing some algebra.\nIf you assume the posterior, the likelihood, the prior or the evidence to have a different distribution, you will do the same thing, but using the probability density or mass function of your chosen distribution.\nIn the context of the variational auto-encoder, you will be learning the mean and variance of the distribution, so the mean and variance will not be fixed, but they will be the parameters that you want to find. However, this does not change the way you apply the Bayes' rule.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to compute the action probabilities with Thompson sampling in deep Q-learning? In some implementations of off-policy Q-learning, we need to know the action probabilities given by the behavior policy $\\mu(a)$ (e.g., if we want to use importance sampling).\nIn my case, I am using Deep Q-Learning and selecting actions using Thompson Sampling. I implemented this following the approach in \"What My Deep Model Doesn't Know...\": I added dropout to my Q-network and select actions by performing a single stochastic forward pass through the Q-network (i.e., with dropout enabled) and choosing the action with the highest Q-value.\nSo, how can I calculate $\\mu(a)$ when using Thompson Sampling based on dropout?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nSo, how can I calculate $\\mu(a)$ when using Thompson Sampling based on dropout?\n\nThe only way I could see this being calculated is if you iterate over all possible dropout combinations, or as an approximation sample say 100 or 1000 actions with different dropout, to get a rough distribution.\nI don't think this is feasible for practical reasons (the agent will learn so much more slowly due to these calculations, you may as well abandon Thompson Sampling and use epsilon-greedy), and you will have to avoid using importance sampling if you also want to use action-selection techniques where there is no easy way to calculate a distribution.\nMany forms of Q-learning do not use importance sampling. These typically just reset eligibility traces if the selected action is different from maximising action.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How to verify classification model trained on classification dataset on a detection dataset for classification purpose? I am working on a problem that involves two tasks - detection and classification. There is no single dataset for both tasks. I am training two models, separate on detection dataset and another on classification dataset. I use the images from the detection dataset as input and get classification predictions on top of detected bounding boxes.\nDataset description :\n\nClassification - Image of the single object (E.g. Car) in the center with a classification label.\nDetection - Image with multiple objects (E.g. 4 Cars) with bounding box annotations.\n\nTask - Detect objects(e.g. cars) from detection datasets and classify them into various categories.\nHow do I verify whether the classification model trained on the classification dataset is working on images from detection dataset? (In terms of classification accuracy)\nI cannot manually label the images from the detection dataset for individual class labels. (Need expert domain knowledge)\nHow do I verify my classification model?\nIs there any technique to do this ? Like domain transfer or any weakly-supervised method ?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The Problem\nWe can see from the question that existing information on detection and\nclassification in the small automotive vehicle domain has been\nlocated (in the form of two independent sets of vectors usable for\nmachine training), and there is no already existing mapping or\nother correspondence between the elements of one set and the\nelements of the other. They were obtained independently, remain\nindependent, and are linked only by the conventions of the domain\n(today's aesthetically acceptable and thermodynamically workable\nforms of small vehicles).\nThe goal stated in the question is to create a computer vision system\nthat both detects cars and classifies them leveraging the\ninformation contained in the two distinct sets.\nIn the vision systems of mammals, there are also two distinct equivalences\nof sets; one arising from a genetic algorithm, the DNA that is\nexpressed during the formation of the neural net geometry and\nbio-electro-chemistry of the visual system in early development;\nand the cognitive and coordinative pathways in the cerebrum and\ncerebellum.\nIf a robot, wheelchair, or other vehicle is to avoid traffic, we must\nproduce a system that in some way matches or exceeds the\ncollision avoidance performance of mammals.\nIn crime prevention, toll collection, sales lot inventory,\ncounty traffic analysis, and other like applications,\nperformance will again be expected to match or exceed the\nperformance of biological systems.\nIf a person can record the make, model, year, color, and\nlicense plate strings, so should the machine we employ in\nthese capacities.\nConsequently, this question is pertinent beyond academic curiosity, as\nit is applicable in current research and development of products.\nThat this question author notices the lack of a unified data\nset that can be used to train it to detect and characterize\nin a single network objects of interest is apropos and\nkey to the challenge of finding a solution.\nApproach\nThe simplest approach would be to compose the system of two functions.\n\n$\\quad\\mathcal{D}: \\mathbb{I}^4 \\to {(\\mathbb{I}^2, \\mathbb{I}^2)}_1, \\; {(\\mathbb{I}^2, \\mathbb{I}^2)}_2, \\; ... $\n$\\quad\\mathcal{C}: {(\\mathbb{I}^2, \\mathbb{I}^2)}_i \\to {(\\mathbb{I})}_i$\n\nThe four dimensions of input for $\\mathcal{D}$, the detector, are horizontal position, vertical position,\nrgb index, and brightness to decribe the pixelized image; and the output are bounding boxes as two \"corner\" coordinates corresponding to each identified vehicle, the second coordinate being either relative to the first or to a specific corner of the entire frame.\nThe categorizer, $\\mathcal{C}$, receives as input bounding boxes and produces as output the index\nor code that maps to the categories corresponding to the labels of the training set available for\ncategorization.\nThe system can then be described as follows.\n$\\quad\\quad\\mathcal{S}: \\mathcal{C} \\circ \\mathcal{D}$\nIf the system is not color, subtract one from the above dimensionality of the input. If the system processes video, add one to the dimensionality of the input and consider using LSTM or GRU cell types.\nThe above substitution represented by \"$\\circ$\" appears to be what is meant by, \"I use the images from the detection dataset as input\nand get classification predictions on top of detected bounding boxes.\"\nThe interrogative, \"How do I verify whether the classification model trained on the\nclassification dataset is working on images from detection dataset?\n(In terms of classification accuracy),\"\nappears to refer to the fact that labels do not exist for the second set that correspond to\ninput elements of the first set, so an accuracy metric cannot be directly obtained.\nSince there is no obvious automatic way of generating labels for the vehicles in the pre-detected images\ncontaining potentially multiple vehicles,\nthere is no way to check actual results against expected results.\nComposing multiple vehicle images from the categorization set to use as test input to\nthe entire system $\\mathcal{S}$ will only be useful in evaluating an aspect\nof the performance of $\\mathcal{D}$, not $\\mathcal{C}$.\nSolution\nThe only way to evaluate the accuracy and reliability of $\\mathcal{C}$ is with portions\nof the set used to train it that were excluded from the training and trust\nthat the vehicles depicted in those images were sufficiently representative\nof the concept \"car\" to provide consistency of accuracy and reliability across\nthe range of those detected by $\\mathcal{D}$ in the application of $\\mathcal{S}$.\nThis means that the leveraging of the information, even if optimized to the degree\npossible by any arbitrary algorithm or parallelism in the set of all possible\nalgorithms or parallelisms, is limited by the categorization training set.\nThe number of set elements and the comprehensiveness and distribution of categories\nwithin that set must be sufficient to achieve an approximate equality between\nthese two accuracy metrics.\n\nCategorizing a test sample from the labeled set for $\\mathcal{C}$ excluded from the training\nCategorizing the vehicles isolated by $\\mathcal{D}$ from its training input\n\nWith Additional Resources\nOf course this discussion is in a particular environment, that of the system\ndefined as the two artificial networks, one involving convolution based\nrecognition and the other involving feature extraction, and the two training\nsets.\nWhat is needed is a wider environment where known vehicles are in view so that\nperformance data of $\\mathcal{S}$ is evaluated and a tap on the transfer\nof information between $\\mathcal{D}$ and $\\mathcal{C}$ can be used\nto differentiate between mistakes made on either side of the tap point.\nUnsupervised Approach\nAnother course of action could be to not use the training set for categorization\non the training of $\\mathcal{C}$ at all, but rather use feature extraction and\nauto-correlation in an \"unsupervised\" approach, and then evaluate the results of\non the basis of the final convergence metrics at the point when stability in\ncategorization is detected. In this case, the images in the bounding boxes\noutput by $\\mathcal{D}$ would be used as training data.\nThe auto-trained network realizing $\\mathcal{C}$ can then be further evaluated\nusing the entire categorization training set.\nFurther Research\nHybrids of these two approaches are possible. Also, the independent training only in the rarest of cases leads to optimal performance. Understanding feedback as originally treated with rigor by MacColl in chapter 8 of his Fundamental Theory of Servomechanisms, later applied to the problem of linearity and stability of analog circuitry, and then to training, first in the case of GANs, may lead to effective methods to bi-train the two networks.\nThat evolved biological networks are trained in situ is an indicator that the most optimal performance can be gained by finding training architectures and information flow strategies that create optimality in both components simultaneously. No biological niche has ever been filled by a neural component that is first optimized and then inserted or copied in some way to a larger brain system. That is no proof that such component-ware can be optimal, but there is also no proof that the DNA driven systems that have emerged are not nearly optimized for the majority of terrestrial conditions.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does an unsupervised learning model learn? How does an unsupervised learning model learn, if it does not involve any target values?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Supervised learning is typically an attempt to learn a mathematical function, $f(\\bf X)=\\bf y$. For this, you need both the input vector $\\bf X$ and the output vector $\\bf y$. The model outputs have whatever dimensionality that the target values have.\nUnsupervised learning models instead learn a structure from the data. A clustering model, for example, is learning both how many clusters exist in the data (a number that's not the same type as the inputs) and where those clusters are located (which is also a different type from the inputs). The output of running this model on a new datapoint $x$ is not the same type as $x$, but instead a classification label.\nSimilarly, time series models learn parameters that symbolize how vectors in the input relate to each other, rather than raw inputs themselves.\nAs for how they learn, the structures are mathematical objects whose fitness is determined by the input data. The simplest possible unstructured unsupervised learning problem is probably \"what's the mean of the data?\", and it should be clear how that's 'learned' through processing the input. More sophisticated models are just adding more pieces to that calculation.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it possible to combine two neural networks trained on different tasks into one that knows both tasks? I'm relatively new to artificial intelligence and neural networks.\nLet's say I have two different fully trained neural networks. The first one is trained for mathematical addition and the second one on mathematical multiplication. Now, I want to combine these two neural networks into one that knows about both operations.\nIs this possible? Is there a representative name for this kind of technique?\nI had read something about bilinear CNN models that sounds similar to what I'm looking for, right?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Combining two different fully trained neural networks is not only feasible, it is commonly done. Let's look at the example given as two concepts involving integers, $C_a$ and $C_m$.\n$$ C_a: \\mathcal{Y} = f_a (\\mathcal{X}) = x_0 + x_1 $$\n$$ C_m: \\mathcal{Y} = f_m (\\mathcal{X}) = x_0 \\, x_1 $$\nNow let's define a palette of operations, including these two binary operations, that can be used to construct, a concept $C_e$, an expression comprised of an arbitrary hierarchy of addition, multiplication, constants, and substitution.\n$$ C_e: \\mathcal{Y} = f_e (\\mathcal{X}) \\; \\text{, where} $$\n$$ f_e \\in \\{f_a, f_b\\} \\; \\land \\; i \\in \\{0, 1\\} \\; \\land \\; ( \\, x_i \\in \\mathbb{I} \\; \\lor \\; x_i \\in \\mathcal{Y} \\, ) \\; \\text{.} $$\nNow, one artificial network can be trained to approximate $f_a$ within a concept class $\\mathbb{C}$ of which $C_a$ and $C_m$ are members, using labeled examples of correct integer additions and another artificial network can be trained to approximate $f_b$ within that same concept class, using labeled examples of correct integer multiplications.\nAn expression involving both can be trained to approximate arbitrary product of sums or sum of products under specific conditions. It's unclear though if this is what you are looking for.\nNormally, one wouldn't train a network to perform operations that are already known. Training is normally used to model operations that are not known.\n(Bilinear Convolutional Neural Networks (B-CNNs), introduced in Bilinear CNNs for Fine-grained Visual Recognition, 2017, Tsung-Yu Lin, Aruni RoyChowdhury, Subhransu Maji, is an approach to using two CNNs in conjunction to provide two fine and course visual recognition in the same way the human visual system can have a dual awareness of detail and panorama. B-CNNs probably don't apply to the scenario given in the question.)\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "When is a knowledge base consistent? I am studying a knowledge base (KB) from the book \"Artificial Intelligence: A Modern Approach\" (by Stuart Russell and Peter Norvig) and from this series of slides.\nA formula is satisfiable if there is some assignment to the variables that makes the formula evaluate to true. For example, if we have the boolean formula $A \\land B$, then the assignments $A=\\text{true}$ and $B=\\text{true}$ make it satisfiable. Right?\nBut what does it mean for a KB to be consistent? The definition (given at slide 14 of this series of slides) is:\n\na KB is consistent with formula $f$ if $M(KB \\cup \\{ f \\})$ is non-empty (there is a world in which KB is true and $f$ is also true).\n\nCan anyone explain this part to me with an example?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I will first recapitulate the key concepts which you need to know in order to understand the answer to your question (which will be very simple, because I will just try to clarify what is given as a \"definition\").\nIn logic, a formula is e.g. $f$, $\\lnot f$, $f \\land g$, where $f$ can be e.g. the proposition (or variable) \"today it will rain\". So, in a (propositional) formula, you have propositions, i.e. sentences like \"today it will rain\", and logical connectives, i.e. symbols like $\\land$ (i.e. logical AND), which logically connect these sentences. The propositions like \"today it will rain\" can often be denoted by a single (capital) letter like $P$. $f \\land g$ is the combination of two formulae (where formulae is the plural of formula). So, for example, suppose that $f$ is composed of the propositions \"today it will rain\" (denoted by $P$) or \"my friend will visit me\" (denoted by $Q$) and $f$ is defined as \"I will play with my friend\" (denoted by $S$). Then the formula $f \\land g = (P \\lor Q) \\land S$. In general, you can combine formulae in any logically appropriate way.\nIn this context, a model is an assignment to each variable in a formula. For example, suppose $f = P \\lor Q$, then $w = \\{ P=0, Q = 1\\}$ is a model for $f$, that is, each variable (e.g. $P$) is assigned either \"true\" ($1$) or \"false\" ($0$) but not both. (Note that the word model may be used to refer to different concepts depending on the context; again, in this context, you can simply think of a model as an assignment of values to the variables in a formula.)\nSuppose now we define $I(f, w)$ to be a function that receives the formula $f$ and the model $w$ as input, and $I$ returns either \"true\" ($1$) or \"false\" ($0$). In other words, $I$ is a function that automatically tells us if $f$ is evaluated to true or false given the assignment $w$.\nYou can now define $M(f)$ to be a set of assignments (or models) to the formula $f$ such that $f$ is true. So, $M$ is a set and not just an assignment (or model). This set can be empty, it can contain one assignment or it can contain any number of assignments: it depends on the formula $f$: in some cases, $M$ is empty and, in other cases, it may contain say $n$ valid assignments to $f$, where by \"valid\" I mean that these assignments make $f$ evaluate to \"true\". For example, suppose we have formula $f = A \\land \\lnot A$. Then you can try to assign any value to $A$, but $f$ will never evaluate to true. In that case, $M(f)$ is an empty set, because there is no assignment to the variables (or propositions) of $f$ which make $f$ evaluate to true.\nA knowledge base is a set of formulae $\\text{KB} = \\{ f_1, f_2, \\dots, f_n \\}$. So, for example, $f_2 = $ \"today it will rain\" and $f_3 = $ \"I will go to school AND I will have lunch\".\nWe can now define $M(\\text{KB})$ to be the set of assignments to the formulae in the knowledge base $\\text{KB}$ such that all formulae are true. If you think of the formulae in $KB$ as \"facts\", $M(\\text{KB})$ is an assignment to these formulae in $KB$ such that these facts hold or are true.\nIn this context, we then say that a particular knowledge base (i.e., a set of formulae as defined above), denoted by $\\text{KB}$, is consistent with formula $f$ if $M(\\text{KB} \\cup \\{ f \\})$ is a non-empty set, where $\\cup$ means the union operation between sets: note that (as we defined it above) $\\text{KB}$ is a set, and $\\{ f \\}$ means that we are making a set out of the formula $f$, so we are indeed performing an union operation on sets.\nSo, what does it mean for a knowledge base to be consistent? First of all, the consistency of a knowledge base $\\text{KB}$ is defined with respect to another formula $f$. Recall that a knowledge base is a set of formulae, so we are defining the consistency of a set of formulae with respect to another formula.\nWhen is then a knowledge base $\\text{KB}$ consistent with a formula $f$? When $M(\\text{KB} \\cup \\{ f \\})$ is a non-empty set. Recall that $M$ is an assignment to the variables in its input such that its inputs evaluate to true. So, $\\text{KB}$ is consistent with $f$ when there is a set of assignments of values to the formulae in $\\text{KB}$ and an assignment of values to the variables in $f$ such that both $\\text{KB}$ and $f$ are true. In other words, $\\text{KB}$ is consistent with $f$ when both all formulae in $\\text{KB}$ and $f$ can be true at the same time.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why does having a fixed policy change a Markov Decision Process to a Markov Reward Process? If a policy is fixed, it is said that a Markov Decision Process (MDP) becomes a Markov Reward Process (MRP).\nWhy is this so? Aren't the transitions and rewards still parameterized by the action and current state? In other words, aren't the transition and reward matrices still cubes?\nFrom my current train of thought, the only thing that is different is that the policy is not changing (the agent is not learning the policy). Everything else is the same.\nHow is it that it switches to an MRP, which is not affected by actions?\nI am reading \"Deep Reinforcement Learning Hands-On\" by Maxim Lapan, which states this. I have also found this statement in online articles, but I cannot seem to wrap my head around it.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nIf a policy is fixed, it is said that an MDP becomes an MRP.\n\nI would change the phrasing slightly here, to:\nIf a policy is fixed, an MDP can be accurately modeled as an MRP.\n\nWhy is this so? Aren't the transitions and rewards still parameterized by the action and current state? In other words, aren't the transition and reward matrices still cubes?\n\nThe transition and reward matrices remain the same in the MDP, but it is possible to flatten them into an equivalent MRP, because in terms of observations of next state and reward, the action that is taken is just part of the transition rules - if the policy is fixed, then so are all the probabilities for next state and reward.\nMore concretely, if you have an MDP with $|\\mathcal{A}|$ transition matrices $P_{ss'}^a$ and a fixed policy $\\pi(a|s)$, then you can create a combined transition matrix with a sum:\n$$P_{ss'} = \\sum_{a \\in \\mathcal{A}} \\pi(a|s) P_{ss'}^a$$ \nand you can similarly reduce the reward function. Once you have done so you have data that describe an MRP.\n\nHow is it that it switches to an MRP which is not affected by actions?\n\nIf the MDP represents a real system where actions are still being taken by an agent, then of course those are still present within the system, and still affect it. The difference is that if you know the agent's policy, then the action choice is predictable, and the MRP representation covers the full definition of probabilities of observed state transitions and rewards.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Use cross-validation to train after model selection I have been recently reading about model selection algorithms (for example to decide which value of the regularisation parameter or what size of a neural network to use, broadly hyper-parameters). This is done by dividing the examples into three sets (training 60%, cross-validation 20%, test 20%) and training is done on the data with the first set for all parameters, and then choose the best parameter based on the result in the cross-validation and finally estimate the performance using the test set.\nI understand the need for a different data-set compared to training and test for select the model, however, once the model is selected, why not using the cross-validation examples to improve the hypothesis before estimating the performance?\nThe only reason I could see is that this could cause the hypothesis to worsen and we wouldn't be able to detect it, but, is it really possible that by adding much more examples (60% -> 80%) the hypothesis gets worse?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "You are quite correct. If you have properly followed the Cross Validation procedure and selected the best model indeed, then you can use the CV set as the training set for the final model. And no it will not cause your hypothesis to worsen (for that set maybe, but not for new examples) if you have selected the model correctly. In-fact you may use the entire 100% of the data-set.\nJustin Johnson a TA at Stanford University answered a similar type of question on training CNN's using 100% of the data-set. He said that if you had enough computational resources and want to squeeze that extra 1% or 2% accuracy from your model you can use the entire data-set after model selection.\nNOTE: As @NeilSlater pointed out, if you need the model for reporting purposes you should only use 80% of the data-set, otherwise you'll lose your only source for unbiased model verification. But if you are looking to deploy the model on field you can use 100% of the data-set.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Does MMD-VAE solve the problem of blurred images of vanilla VAEs? I understand that with vanilla VAEs, there are a few reasons justifying the production of blurred out images. The InfoVAE paper describes the case when the decoder is flexible enough to ignore the latent attributes and generate an averaged out image that best reduces the reconstruction loss. Thus the blurred image.\nHow much of the problem of blurring is really mitigated by the MMD formulation in practical experiments? If someone has experience working with MMD-VAEs, I'd like to know their opinion on what the reconstruction quality of MMD-VAEs is really like.\nAlso, does the replacement of the MSE reconstruction loss metric by other perceptual similarity metrics improve generated image quality?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "[Answering my own question after 5 months of studying VAE models]\nThe point of the MMD-VAE or InfoVAE is not exactly to emphasise on the visual quality of generated samples. It is to preserve greater amount of information through the encoding process. The MMD formulation stems from introducing a mutual coefficient factor into the Evidence Lower BOund (ELBO) loss of VAEs. Refer to the paper appendices for full derivation. This formulation improves information content in latent space and provides for more accurate approximation of the true posterior - these results have also been empirically proven in the paper.\nHowever, the InfoVAE uses pixel-wise or element-wise reconstruction loss. An element-wise reconstruction loss is likely to lead to some extent of blurriness inrespective of the prior loss term. On Github, several developers have implemented the InfoVAE model and shown their results. Here is a link to one such implementation whose results I could personally verify.\nFrom my own experimentations, I can say that even though InfoVAE may give better reconstructions for some data, there is still considerable blurriness.\nPerceptual similarity metrics may be learned or computed as a static function of the input image. With a learned perceptual loss, VAEs can produce much sharper images. PixelVAE and VAEGAN are well-known models with such implementations. For a static function of the image itself, reconstruction quality will depend on the nature of that function and such a model may not be very useful for all kinds of datasets. Using measures like SSIM, FSIM, we may still end up getting blurred images.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which machine learning approach should I use to estimate how many products a research group should have to improve its category? Currently, in my country, there is a system in which certain groups of researchers upload information on products of scientific interest, such as research articles, books, patents, software, among others. Depending on the number of products, the system assigns a classification to each group, which can be A1, A, B and C, where A1 is the highest classification and C is the minimum. According to the classification of the groups, they can compete to receive monetary incentives to make their research.\nAt the moment, I am working on an application that takes the data of the system that I mentioned previously. I am able to say what classification the group currently has because we develop a scraper that counts the products and there is another service that is in charge of implementing all the mathematical model that the system has to calculate the category of the group.\nBut what I want to achieve is that my application would be able to give an estimate of how many products a research group should have to improve its category. I want to know if I can do that using neural networks.\nFor example, if there is a category C group, I want the application to tell the user how many articles and books it would make its category go up to B.\nFrom what I have seen in some web resources, I could insert a training set into the neural network and have it learn to classify the groups, but I think it is unnecessary, because I can do that mathematically.\nBut I do not understand if it is possible for a neural network to process the current category that the group has and be able to give suggestions of how many products it needs to improve its category.\nI think it must be a neural network with several outputs, so that in each one it throws the total for each one of the products, although it is not necessary to list all the products that the measurement model contemplates. But it is necessary for the network to learn which products are handled by a certain group, for example if a group does not write books, avoid suggestions that contemplate the production of books for the improvement of the category that the group has.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I believe you want a neural network that can predict future values of multiple variables given multiple inputs. This belongs to the general time series forecasting problem.\nOne of the best neural network architectures that can handle this problem is the LSTM, which is a type of Recurrent Neural Network. Their architecture allows them to develop a memory of what they have seen in the past and use it for future predictions. In other words, they can cross-correlate in a linear/nonlinear fashion several past steps of multiple variables to future values of multiple other variables, like a black box.\nA useful tutorial for your purposes is this.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is case-based reasoning a machine learning technique? A few years ago when I was in university, I had implemented (for my final year project) an Itinerary Planning System, which incorporates an AI technique called \"case-based reasoning\".\nIs case-based reasoning a machine learning technique or an AI technique (that is not machine learning)?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The book Machine Learning (1997) by Tom Mitchell covers case-based reasoning (CBR), a form of instance-based learning (nearest neighbor is the typical example of IBL) in chapter 8 (p. 230).\nT. Mitchell writes\n\nInstance-based methods such as $k$-NEAREST NEIGHBOR and locally weighted regression share three key properties. First, they are lazy learning methods in that they defer the decision of how to generalize beyond the training data until a new query instance is observed. Second, they classify new query instances by analyzing similar instances while ignoring instances that are very different from the query. Third, they represent instances as real-valued points in an $n$-dimensional Euclidean space. Case-based reasoning (CBR) is a learning paradigm based on the first two of these principles, but not the third. In CBR, instances are typically represented using more rich symbolic descriptions, and the methods used to retrieve similar instances are correspondingly more elaborate. CBR has been applied to problems such as conceptual design of mechanical devices based on a stored library of previous designs (Sycara et al. 1992), reasoning about new legal cases based on previous rulings (Ashley 1990), and solving planning and scheduling problems by reusing and combining portions of previous solutions to\nsimilar problems (Veloso 1992).\n\nHe then goes on and gives the example of a CBR system: the CADET system. He also formulates CBR as a learning problem and uses the term \"learn\" to refer to a search process that CADET goes through, which is similar to what k-NN does.\nHe then writes\n\nTo summarize, case-based reasoning is an instance-based learning method in which instances (cases) may be rich relational descriptions and in which the retrieval and combination of cases to solve the current query may rely on knowledge-based reasoning and search-intensive problem-solving methods.\n\nTo conclude, yes, CBR can be considered a machine learning technique (if you also consider k-NN a learning algorithm, which people often do), even though it may rely on knowledge-based reasoning and search-intensive problem-solving methods.\nYou may also be interested in the paper Representation in case-based reasoning (2005) by Ralph Bergmann et al. Moreover, the famous AIMA book (3rd edition) mentions case-based reasoning in chapter 19 (p. 799), which is dedicated to knowledge and learning.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are there any microchips specifically designed to run ANNs? I'm interested in hardware implementation of ANNs (artificial neural networks). Are there any popular existing technology implementations in form of microchips which are purpose designed to run artificial neural networks? For example, a chip which is optimised for an application like image recognition or something similar?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "In May 2016 Google announced a custom ASIC which was is specifically built for machine learningwiki and tailored for TensorFlow. It is using tensor processing unit (TPU) which is a programmable microprocessor designed to accelerate artificial neural networks.\nNeuroCores, 12x14 sq-mm chips which can be interconnected in a binary tree, see: Neurogrid, a supercomputer which can provide an option for brain simulations.\nTrueNorth, a neuromorphic CMOS chip produced by IBM, which has 4096 cores in the current chip, each can simulate 256 programmable silicon \"neurons\", giving a total of over a million neurons.\nFurther readings: Neuromorphic engineering, Vision processing unit, AI accelerators\n\nAs a side note, you can always use an FPGA based piece of hardware which you can implement selected genetic algorithm (GA) directly in hardware. For example the CoDi model was implemented in the FPGA based CAM-Brain Machine (CBM)2001.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are on-line backpropagation iterations perpendicular to the constraint? Raul Rojas' Neural Networks A Systematic Introduction, section 8.1.2 relates off-line backpropagation and on-line backpropagation with Gauss-Jacobi and Gauss-Seidel methods for finding the intersection of two lines.\nWhat I can't understand is how the iterations of on-line backpropagation are perpendicular to the (current) constraint. More specifically, how is $\\frac12(x_1w_1 + x_2w_2 - y)^2$'s gradient, $(x_1,x_2)$, normal to the constraint $x_1w_1 + x_2w_2 = y$?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Answer by Theo Bandit at maths stackexchange\n\nIf you choose two points $(w_1, w_2), (v_1, v_2)$ along this line, then\n $$(x_1, x_2) \\cdot ((w_1, w_2) - (v_1, v_2)) = x_1 w_1 + x_2 w_2 - (x_1 v_1 + x_2 v_2) = y - y = 0.$$\n That is, the direction $(x_1, x_2)$ is perpendicular to any vector lying along the line, i.e. $(x_1, x_2)$ is normal to the line.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the gradient of the objective function in the Soft Actor-Critic paper? In the paper Soft Actor-Critic: Off-Policy Maximum Entropy Deep Reinforcement Learning with a Stochastic Actor, they define the loss function for the policy network as\n$$\nJ_\\pi(\\phi)=\\mathbb E_{s_t\\sim \\mathcal D}\\left[D_{KL}\\left(\\pi_\\phi(\\cdot|s_t)\\Big\\Vert {\\exp(Q_\\theta(s_t,\\cdot)\\over Z_\\theta(s_t)}\\right)\\right]\n$$\nApplying the reparameterization trick, let $a_t=f_\\phi(\\epsilon_t;s_t)$, then the objective could be rewritten as\n$$\nJ_\\pi(\\phi)=\\mathbb E_{s_t\\sim \\mathcal D, \\epsilon \\sim\\mathcal N}[\\log \\pi_\\phi(f_\\phi(\\epsilon_;s_t)|s_t)-Q_\\theta(s_t,f_\\phi(\\epsilon_t;s_t))]\n$$\nThey compute the gradient of the above objective as follows\n$$\n\\nabla_\\phi J_\\pi(\\phi)=\\nabla_\\phi\\log\\pi_\\phi(a_t|s_t)+(\\nabla_{a_t}\\log\\pi_\\phi(a_t|s_t)-\\nabla_{a_t}Q(s_t,a_t))\\nabla_\\phi f_\\phi(\\epsilon_t;s_t)\n$$\nThe thing confuses me is the first term in the gradient, where does it come from? To my best knowledge, the second large term is already the gradient we need, why do they add the first term?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I'll give it a go here and try to answer your question, I'm not sure if this is entirely correct, so if someone thinks that it isn't please correct me.\nI'll disregard expectation here to make things simpler. First, note that policy $\\pi$ depends on parameter vector $\\phi$ and function $f_\\phi(\\epsilon_t;s_t)$, and value function $Q$ depends on parameter vector $\\theta$ and same function $f_\\phi(\\epsilon_t;s_t)$. Also, one important thing that authors mention in the paper and you didn't mention is that this solution is approximate gradient not the true gradient.\nOur goal is to calculate gradient of objective function $J_\\pi$ with respect to $\\phi$, so disregarding the expectation we have: \n$\\nabla_\\phi J_\\pi (\\phi) = \\nabla_\\phi \\log\\pi(\\phi,f_\\phi (\\epsilon_t;s_t)) - \\nabla_\\phi Q(s_t,\\theta,f_\\phi (\\epsilon_t;s_t))$ \nLet's see the gradient of first term on right hand side. To get the full gradient we need to calculate derivative w.r.t to both variables, $\\phi$ and $f_\\phi (\\epsilon_t;s_t)$, so we have: \n$\\nabla_\\phi \\log\\pi(\\phi,f_\\phi (\\epsilon_t;s_t)) = \\frac {\\partial \\log\\pi(\\phi,f_\\phi (\\epsilon_t;s_t))}{\\partial \\phi} + \\frac{\\partial \\log\\pi(\\phi,f_\\phi (\\epsilon_t;s_t))}{\\partial f_\\phi(\\epsilon_t;s_t)} \\frac{\\partial f_\\phi(\\epsilon_t;s_t)}{\\partial \\phi}$\nThis is where approximation comes, they replace $f_\\phi (\\epsilon_t;s_t)$ with $a_t$ in some places and we have: \n$\\nabla_\\phi \\log\\pi(\\phi,f_\\phi (\\epsilon_t;s_t)) \\approx \\frac {\\partial \\log\\pi(\\phi,a_t)}{\\partial \\phi} + \\frac{\\partial \\log\\pi(\\phi,a_t)}{\\partial a_t} \\frac{\\partial f_\\phi(\\epsilon_t;s_t)}{\\partial \\phi}$\n$\\nabla_\\phi \\log\\pi(\\phi,f_\\phi (\\epsilon_t;s_t)) \\approx \\nabla_\\phi \\log\\pi(\\phi,a_t) + \\nabla_{a_t} \\log\\pi(\\phi,a_t) \\nabla_\\phi f_\\phi (\\epsilon_t;s_t)$ \nFor the second term in first expression on right hand side we have: \n$\\nabla_\\phi Q(s_t,\\theta,f_\\phi (\\epsilon_t;s_t)) = \\frac {\\partial Q(s_t,\\theta,f_\\phi (\\epsilon_t;s_t))}{\\partial \\phi} + \\frac{\\partial Q(s_t,\\theta,f_\\phi (\\epsilon_t;s_t))}{\\partial f_\\phi(\\epsilon_t;s_t)} \\frac{\\partial f_\\phi(\\epsilon_t;s_t)}{\\partial \\phi}$\n$\\nabla_\\phi Q(s_t,\\theta,f_\\phi (\\epsilon_t;s_t)) \\approx \\frac {\\partial Q(s_t,\\theta,a_t)}{\\partial \\phi} + \\frac{\\partial Q(s_t,\\theta,a_t)}{\\partial a_t} \\frac{\\partial f_\\phi(\\epsilon_t;s_t)}{\\partial \\phi}$ \nFist term on right hand side is 0 because $Q$ does not depend on $\\phi$ so we have: \n$\\nabla_\\phi Q(s_t,\\theta,f_\\phi (\\epsilon_t;s_t)) \\approx \\nabla_{a_t}Q(s_t, \\theta,a_t)\\nabla_\\phi f_\\phi(\\epsilon_t;s_t)$ \nNow you add up things and you get the final result.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why is Batch Gradient Descent performing worse than Stochastic and Mini-Batch Gradient Descent? I have implemented a neural network from scratch (only using numpy) and I am having problems understanding why the results are so different between Stochastic/Mini-Batch Gradient Descent and Batch Gradient Descent:\n\nThe training data is a collection of point coordinates (x,y).\nThe labels are 0s or 1s (below or above the parabola).\n\nAs a test, I am doing a classification task.\nMy objective is to make the NN learn which points are above the parabola(yellow) and which points are below the parabola(purple).\nHere is the link to the notebook: https://github.com/Pign4/ScratchML/blob/master/Neural%20Network.ipynb\n\nWhy is the Batch Gradient Descent performing so poorly with respect\nto the other two methods?\nIs it a bug? But how can it be since the code is almost identical to the\nMini-Batch Gradient Descent?\nI am using the same (randomly chosen with try and error) hyperparameters for all three\nneural networks. Does Batch Gradient Descent need a more accurate\ntechnique to find the correct hyperparameters? If yes, why so?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Assuming the problem at hand is a classification (Above or Below parabola), this is probably because of the nature of Batch gradient descent. Since the gradient is being calculated on the whole batch, it tends to work well on only convex loss functions. \nThe reason for why batch gradient descent is not working too great probably is because of the high number of minimas in the error manifold, ending up learning nothing relevant. You can change the loss function and observe the change in results, they might not be great (Batch GD usually isn't) but you'll be able to see differences.\nYou can check this out for more on the differences between the three. Hope this helped!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How does the \"Lorem Ipsum\" generator work? I've seen many Lorem Ipsum generators on the web, but not only, there is also \"bacon ispum\", \"space ispum\", etc. So, how do these generators generate the text? Are they powered by an AI?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Lorem ipsum generators don't typically use anything considered as AI. Usually they just store large pieces of text and select sections from it randomly - they are very simple. The main goal is to produce \"nonsense\" text that fills space but does not distract from issues of layout and design. The variations of it are usually just for fun, and like the original, are mostly simple generators which select strings of text from a core data source randomly and without using any AI techniques.\nIt is possible to build more sophisticated random text generators that work using data structures from Natural Language Processing (NLP). \nOne popular and easy-to-code data structure is N-grams, which store the frequencies/probabilities of the Nth word given words 1 to N-1. E.g. a bigram structure can tell you all the possible words to come after \"fish\" e.g. \"fish\" => [\"food\" => 0.2, \"swims\" => 0.3, \"and\" => 0.4, \"scale\" => 0.1] To use that structure to generate text, use a random number generator to select a word based on looking up the Nth word's frequency, then shift the list of words being considered and repeat. \nA more recent text generating NLP model is recurrent neural networks (RNNs), which have a variety of designs. Popular right now are LSTM networks, and these are capable of some quite sophisticated generation, provided they are trained with enough data for long enough. The blog The Unreasonable Effectiveness of Recurrent Neural Networks by Andrej Karpathy has quite a few really interesting examples of using RNNs for text generation. In practice this works similarly to n-grams: Use the RNN to suggest probabilities for next word given words so far, choose one randomly, then feed back the generated word into the RNN and repeat.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What type of neural network would be most feasible for playing a realtime game? For implementing a neural network algorithm that can play air hockey, I had two ideas for input, and I'm trying to figure out which design would be most viable.\nThe output must be two analog values that dictate the best position on half of the table for the robot to be at a specific point in time, evaluated 60 times per second.\nHaving consulted with a professor who has experience with implementing parallel algorithms, it was recommended to me to use a convolutional neural network with a single hidden layer, and directly process the image data as the input layer, after processing it to visualize a direct view of the table and somehow emphasize the puck and mallets with pre-processing. I have already started work on this and have successfully implemented object detection for the puck and mallets using OpenCV to get the center coordinates for all 3 entities.\nHowever, having been able to successfully and accurately pre-process these data at 60 times per second, my thought was to feed those (after normalizing the values using the error function) directly on the input layer and possibly implement a deep learning algorithm that employs more than one hidden layer. The problem is that I don't have any experience implementing neural networks, so I'm not even sure what type of layer would be best for this, or how I should seed the weights.\nAnother reason I want to consider my idea is that given the relatively few inputs and outputs, probably won't need a GPU to execute forward-propagation 60 times per second, whereas with the convolutional network my professor recommended, I know I'll need to implement using CUDA somehow.\nWhich of the two input methods would be most recommended for this, and if I were to try and implement my idea, what types of layers should I consider? Also any recommendations for existing frameworks to use for either approach would be highly appreciated.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I recommend you read up on reinforcement learning. Seeing how AirHockey is similar to the old Atari game Pong, here is a write-up (with code) about how to implement a simple neural network, that plays the game; Deep Reinforcement Learning: Pong from Pixels.\nAs far as the choice of layers go, again, you should read up on deep reinforcement learning, perhaps study some existing models that work, for a similar task and take their architecture as your starting point. The above link is a nice introduction into such thinking.\nAs a continuation, I would recomend you employ one of the well known, and developed, libraries, such as TensorFlow or pyTorch. They will allow you to run your models on GPU, like you desire.\nFor a toolkit, that specializes to reinforcement learning, see openAI gym.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Are Bayesian networks important to learn in 2018? I study AI by myself with the book \"Artificial Intelligence: A Modern Approach\". I've just finished the chapters about the Bayesian network and probabilities, and I found them very interesting. Now, I want to implement different algorithms and test them in different cases and environments. \nIs it worth it to spend time on these techniques? \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "*AI, A Modern Approach,\" was given that title to break from previously narrow approaches to duplicating desirable qualities of human thinking.\nAlthough Bayesian networks require somewhat resource intensive computational elements, the importance of Bayesian inference and probability are still of paramount importance in that some of the highest scientific thinking require mastery of them. Furthermore, developing in silicon dies (or possibly graphene nanites) the machinery to perform elementary probability computations in massively parallel architectures may arise over the next few decades. The use of video DSP circuits to implement ANNs is a notable segue into this kind of development.\nI would not dismiss the techniques you just read about. If your intention is to capitalize on the recent crazes, you may enter the river of wannabees chasing every current trend, implement many systems that other people will rewrite later, and have a meaningless yet profitable career. I would recommend following your inquisitiveness instead.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Should we also shuffle the test dataset when training with SGD? When training machine learning models (e.g. neural networks) with stochastic gradient descent, it is common practice to (uniformly) shuffle the training data into batches/sets of different samples from different classes. Should we also shuffle the test dataset?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Short answer\nShuffling affects learning (i.e. the updates of the parameters of the model), but, during testing or validation, you are not learning. So, it should not make any difference whether you shuffle or not the test or validation data (unless you are computing some metric that depends on the order of the samples), given that you will not be computing any gradient, but just the loss or some metric/measure like the accuracy, which is not sensitive to the order or the samples you use to compute it. However, the specific samples that you use affects the computation of the loss and these quality metrics. So, how you split your original data into training, validation and test datasets affects the computation of the loss and metrics during validation and testing.\nLong answer\nLet me describe how gradient descent (GD) and stochastic gradient descent (SGD) are used to train machine learning models and, in particular, neural networks.\nGradient descent (GD)\nWhen training ML models with GD, you have a loss (aka cost) function $L(\\theta; D)$ (e.g. the cross-entropy or mean squared error) that you are trying to minimize, where $\\theta \\in \\mathbb{R}^m$ is a vector of parameters of your model and $D$ is your labeled training dataset.\nTo minimize this function using GD, you compute the gradient of your loss function $L(\\theta; D)$ with respect to the parameters of your model $\\theta$ given the training samples. Let's denote this gradient by $\\nabla_\\theta L(\\theta; D) \\in \\mathbb{R}^m$. Then we perform a step of gradient descent\n$$\n\\theta \\leftarrow \\theta - \\alpha \\nabla_\\theta L(\\theta; D) \\label{1}\\tag{1}\n$$\nStochastic gradient descent (SGD)\nYou can also minimize $L$ using stochastic gradient descent, i.e. you compute an approximate (or stochastic) version of $ \\nabla_\\theta L(\\theta; D)$, which we can denote as $\\tilde{\\nabla}_\\theta L(\\theta; B) \\approx \\nabla_\\theta L(\\theta; D)$, which is typically computed with a subset of $B$ of your training dataset $D$, i.e. $B \\subset D$ and $|B| < |D|$. The step of SGD is exactly the same as the step of GD, but we use $\\tilde{\\nabla}_\\theta L(\\theta; B)$\n$$\n\\theta \\leftarrow \\theta - \\alpha \\tilde{\\nabla}_\\theta L(\\theta; B) \\label{2}\\tag{2}\n$$\nIf we split $D$ into $k$ subsets (or batches) $B_i$, for $i=1, \\dots, k$ (and these subsets usually have the same size, i.e. $|B_i| = |B_j|, \\forall i$, apart from one of them, which may contain fewer samples), then the SGD step needs to be performed $k$ times, in order to go through all training samples.\nSampling, shuffling, and convergence\nGiven that $\\tilde{\\nabla}_\\theta L(\\theta; B_i) \\approx \\nabla_\\theta L(\\theta; D), \\forall i$, it should be clear that the way you split the samples into batches can affect learning (i.e. the updates of the parameters).\nFor instance, you could consider your dataset $D$ as an ordered sequence/list, and just split it into $k$ sub-sequences. Without shuffling this ordered sequence before splitting, you will always get the same batches, which means that, if there's some information associated with the specific ordering of this sequence, then it may bias the learning process. That's one of the reasons why you may want to shuffle the data.\nSo, you could uniformly choose samples from $D$ to create your batches $B_i$ (and this is a way of shuffling, in the sense that you will be uniformly building these batches at random), but you can also sample differently and you could also re-use the same samples in different batches (i.e. sampling with replacement). Of course, all these approaches can affect how learning proceeds.\nTypically, when analyzing the convergence properties of SGD, you require that your samples are i.i.d. and that the learning rate $\\alpha$ satisfies some conditions (the Robbins\u2013Monro conditions). If that's not the case, then SGD may not converge to the correct answer. That's why sampling or shuffling can play an important role in SGD.\nTesting and validation\nDuring testing or validation, you are just computing the loss or some metric (like the accuracy) and not a stochastic gradient (i.e. you are not updating the parameters, by definition: you just do it during training). The way you compute the loss or accuracy should not be sensitive to the order of the samples, so shuffling should not affect the computation of the loss or accuracy. For instance, if you use the mean squared error, then you will need to compute\n\\begin{align}\nL(\\theta; D_\\text{test}) \n&= \\operatorname {MSE} \\\\\n&= {\\frac {1}{n}}\\sum _{i=1}^{n}(f_\\theta(x_i)-{\\hat {y_{i}}})^{2}\\\\\n&= {\\frac {1}{n}}\\sum _{i=1}^{n}(y_{i}-{\\hat {y_{i}}})^{2}\n\\end{align}\nwhere\n\n$f_\\theta$ is your ML model\n$x_i$ is the $i$th input\n$y_{i}$ is the true label for input $x_i$\n$\\hat {y_{i}}$ is the output of the model\n$n$ is the number of samples you use to compute the MSE\n\nThis is an average, so it doesn't really matter whether you shuffle or not. Of course, it matters which samples you use though!\nFurther reading\nHere you can find some informal answers to the question \"Why do we shuffle the training data while training a neural network?\". There are other papers that partially answer this and/or other related questions more formally, such as this or this.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "How would you encode your input vector/matrix from a sequence of moves in game like tasks to train an AI? e.g. Chess AI? I've seen data sets for classification / regressions tasks in domains such as credit default detection, object identification in an image, stock price prediction etc. All of these data sets could simply be represented as an input matrix of size (n_samples, n_features) and fed into your machine learning algorithm to ultimately yield a trained model offering some predictive capability. Intuitively and mathematically this makes sense to me.\nHowever, I'm really struggling with how to think about the structure of an input matrix for game-like tasks (Chess, Go, Seth Blings Mario Kart AI) specifically (using the Chess example):\n\nHow would you encode the state of the board to something that a model could train on? Is it reasonable to think about the board state as a 8x8 matrix (or 1x64) vector with each point being encoded by a numerical value dependent on the type of piece and color?\n\nAssuming a suitable representation of the board state, how would the model be capable of making a recommendation given that each piece type moves differently? Would it not have to evaluate the different move possibilities for each piece and propose which move it \"thinks\" would have the best long term outcome for the game?\n\nA follow up on 2 - given the interplay between a moves made now and moves made n moves into the future how would the model be able to recognize and make trade-offs between moves which may offer a better position now vs those that offer a position n moves in the future - would one have to extend the board state input to a vector of length 1x64n where n is the total number of moves for expected for an individual player or is this a function of a different algorithm which should be able to capture historical information which training?\n\n\nI am unsure if I'm overthinking this and am missing something really obvious but I would appreciate any guidance in terms of how to approach thinking about this.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The core of the question seems to really be: \"how to approach thinking about this\", where \"this\" is the input of an AI player.\nModern attempts at game playing AI players try to replace a human player \"as is\". No advantage whatsoever. This implies that we want to feed the same \"raw input\" to the software player and to the human player. For a video game, the raw input is usually the screen we see, but it could also include sound, vibration feedback from a game controller, force feedback from driving gears, etc. Basically any sensor input available. For a physical board game like Go, the raw input could be a video feed, as done for AlphaGo. Doing so, we fall back to the video game approach. So the input to the AI player is often a tensor, where each element is the intensity of a screen pixel, or some other sensor signal (note there is nothing here about the shape of the tensor, please see below).\nThe way of thinking here is actually pretty simple, and neat: We want an AI player to replace a human player. So we list up what the human player can sense, and model each input as a tensor (this includes vectors and matrices).\nThere is perhaps a subtlety here. We face choices not so obvious to make, and there are usually trials and errors (many errors). For example, the Deep-Q Network from DeepMind to play Atari games takes as input differences between two consecutive video frames. Some other approach could solve the same problem with actual sequences of inputs (e.g. 10 consecutive frames). The two approaches are valid---they just have different tradeoffs we must evaluate to find the best configuration.\nAnother subtelty is the \"shape\" of the input. Should a single (W, H) input frame be a (W*H) vector, or a (W, H) matrix, or something else? The ramifications can go far. If the frame is an RGB frame with transparency, the input could well be a tensor of shape (W, H, 4), a \"cubic volume\" with 4 \"slices\" of shape (W, H)---one for each RGB channel, and a fourth one for transparency. Imagine now if you also have sound, and can add a fifth \"slice\"---and more if you have stereo or Dolby system channels.\nLast point: There is no reference to the architecture of the AI player beyond the input here. Although most exemples refer to recent architectures based on neural networks, this \"thinking\" also applies whatever can leverage the input. For example, the Big Blue system from IBM, who won Chess against Gary Kasparov, is an AI player using exclusively (if my memory's good) clever tree search. Yet its input is a tensor representing the Chess board.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why should we study causation in artificial intelligence? Judea Pearl won the 2011 Turing Award\n\nFor fundamental contributions to artificial intelligence through the development of a calculus for probabilistic and causal reasoning.\n\nHe is credited with the invention of Bayesian networks and a framework for causal inference.\nWhy should we study causation and causal inference in artificial intelligence? How would causation integrate into other topics like machine learning? There are facts or relations that cannot be retrieved from data (e.g. cause-effect relations), which is the driving force of ML. Are there other reasons for studying causation?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "There are two intermixed elements in your question:\n\nWhy have people already studied causality in AI?\nWhy would people like to continue studying causality in AI?\n\ntl;dr: AI systems can't function in the real world without some way of understanding uncertainty. The best ways we have to understand uncertainty don't work well unless we also understand causal structure. Getting most of the way towards this understanding was a huge accomplishment for AI research, but there's still a big problem waiting to be solved here.\nFor part 1, let's think about where research into causality comes from. Pearl originally set out to solve a major problem plaguing AI researchers in the 1980s: reasoning under uncertainty. This area is so central to AI systems that it has its own, large, conference: UAI. The need for reasoning under uncertainty arose because the real world is filled with uncertainty. Consider even a simple problem, like have a robot navigate an empty room. Even if the robot knows its initial position exactly, it is not likely to know its true position for long. The robots' wheels might have a certain specification, but wheels stick and slip (friction), and they do so unpredictably (e.g. maybe one part of the floor didn't get polished as much as the others). The robot might have sensors, but sensors are imperfect. Does a light sensor value of 0.25 mean a wall is near, or just that the sun is coming through the window at an unfortunate angle? Or maybe just that the shade of paint is slightly different there? Does our acoustic sensor reading of 1.35 mean that we're 1.35 meters from the wall, or did the signal get reflected, and return to us by a different path?\nOne of Pearl's major contributions was showing how we can use the rules of probability to reason about these events correctly. Although others had done the basics of this long ago, Pearl proposed the idea of Bayesian Networks. Thrun and many others used these techniques to solve problems like the robot navigation task discussed above.\nA problem with Bayesian Networks is that, if built incorrectly, they lose much of their efficiency benefits. The correct construction is usually the one that best captures known causal relations between factors. Further, algorithms for inference in a Bayesian Network can not easily answer questions about counterfactuals. They cannot tell our robot what would happen in a world where certain actions were taken. They can only say whether certain behaviors are likely co-occur.\nThese outstanding issues led Pearl to work on causality and causal networks. It is important for our systems to be able to answer counterfactual questions, because often the answers to those questions determine how the system aught to act. Pearl's do-calculus (nicely summarized here, and in Pearl's The Book of Why) has solved this problem, and shown how causes can often be inferred from observation alone. It's super exciting!\nHopefully you're now convinced that Causality was worth studying within AI. You might now wonder why it's still worth studying.\nThe main open problem right now is that to do causal reasoning, we need to already have a network that describes causal relations. These networks are hard to construct by hand, so we'd like to be able to learn the structures of these networks. Unfortunately, this looks like a very hard problem, both to solve exactly (it's #P-hard if I recall correctly), and to approximate. There are no known general algorithms, at least as of 2018. Getting this would be a major breakthrough in AI research, and more generally, in statistics, philosophy of science, and epistemology. Even getting something that mostly worked, most of the time, would be huge. Peter Van Beek has been doing some work on this recently, which could be a good starting place if you want to read more.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Expected SARSA vs SARSA in \"RL: An Introduction\" Sutton and Barto state in the 2018-version of \"Reinforcement Learning: An Introduction\" in the context of Expected SARSA (p. 133) the following sentences:\n\nExpected SARSA is more complex computationally than Sarsa but, in return, it eliminates the variance due to the random selection of $A_{t+1}$. Given the same amount of experience we might expect it to perform slightly better than Sarsa, and indeed it generally does.\n\nI have three questions concerning this statement:\n\nWhy is the action selection random with Sarsa? Isn't it on-policy and therefore $\\epsilon$-greedy?\nBecause Expected-Sarsa is off-policy the experience it learns from can be from any policy that at least explores everything in the limit e.g. random action-selection with equal probabilities for every action. How can Exected-Sarsa learning from such policy be generally better than normal Sarsa learning from an $\\epsilon$-greedy policy, especially with the same amount of experience?\nProbably more general: How can on-policy and off-policy algorithms be compared in such way (e.g. through variance) even though their concepts and assumptions are so different?\n\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "\nWhy is the action selection random with Sarsa? \n\nA policy could be stochastic. In the case of SARSA, it is stochastic because of the use of $\\epsilon$-greedy.\n\nIsn't it on-policy and therefore \u03f5-greedy?\n\nI don't quite understand the question. SARSA is on-policy evaluation with $\\epsilon$-greedy policy. Q-learning is off-policy evaluation with $\\epsilon$-greedy policy. $\\epsilon$-greedy is just a way to turn an action-value function into a policy.\n\nBecause Expected-Sarsa is off-policy the experience it learns from can be from any policy ... How can Exected-Sarsa learning from such policy be generally better than normal Sarsa learning from an \u03f5-greedy policy, especially with the same amount of experience?\n\nIt is unfair to compare different natures of experiences because off-policy experience contains less useful information. Thus, both SARSA and Expected SARSA should use their own on-policy experience for comparison. \nWhile Expected SARSA update step guarantees to reduce the expected TD error, SARSA could only achieve that in expectation (taking many updates with sufficiently small learning rate). Through this perspective, there is little doubt that Expected SARSA should be better.\n\nProbably more general: How can on-policy and off-policy algorithms be compared in such way (e.g. through variance) even though their concepts and assumptions are so different?\n\nSame as the previous answer, it is unfair to compare them without the same quality of experiences.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Proof of Maximization Bias in Q-learning? In the textbook \"Reinforcement Learning: An Introduction\" by Richard Sutton and Andrew Barto, the concept of Maximization Bias is introduced in section 6.7, and how Q-learning \"over-estimates\" action-values is discussed using an example. However, a formal proof of the same is not presented in the textbook, and I couldn't get it anywhere on the internet as well. \nAfter reading the paper on Double Q-learning by Hado van Hasselt (link), I could understand to some extent why Q-learning \"over-estimates\" action values. Here is my (vague, informal) construction of a mathematical proof:\nWe know that Temporal Methods (just like Monte Carlo methods), use sample returns instead of real expected returns as estimates, to find the optimal policy. These sample returns converge to the true expected returns over infinite trials, provided all the state-action pairs are visited. Thus the following notation is used, \n$$\\mathbb{E}[Q()] \\rightarrow q_\\pi()$$\nwhere $Q()$ is calculated from the sample return $G_t$ observed at every time-step. Over infinite trials, this sample return when averaged converges to it's expected value which is the true $Q$-value under the policy $\\pi$. Thus $Q()$ is really an estimate of the true $Q$-value $q_\\pi$.\nIn section 3 on page 4 of the paper, Hasselt describes how the quantity $\\max_a Q(s_{t+1}, a)$ approximates $\\mathbb{E}[\\max_a Q(s_{t+1}, a)]$ which in turn approximates the quantity $\\max_a(\\mathbb{E}[Q(s_{t+1},a)])$ in Q-learning. Now, we know that the $\\max[]$ function is a convex function (proof). From Jensen's inequality, we have\n$$\\phi(\\mathbb{E}[X]) \\leq \\mathbb{E}[\\phi(X)]$$ where $X$ is a random variable, and the function $\\phi()$ is a convex function. Thus,\n$$\\max_a(\\mathbb{E}[Q(s_{t+1},a)]) \\leq \\mathbb{E}[\\max_a(Q(s_{t+1}, a)]$$\n$$\\therefore \\max_a Q(s_{t+1}, a) \\approx \\max_a(\\mathbb{E}[Q(s_{t+1},a)]) \\leq \\mathbb{E}[\\max_a(Q(s_{t+1}, a)]$$\nThe quantity on the LHS of the above equation appears (along with $R_{t+1}$) as an estimate of the next action-value in the Q-learning update equation:\n$$Q(S_t,A_t) \\leftarrow (1-\\alpha)Q(S_t, A_t) + \\alpha[R_{t+1} + \\gamma\\max_aQ(S_{t+1}, a)] $$\nLastly, we note that the bias of an estimate $T$ is given by:\n$$b(T) = \\mathbb{E}[T] - T$$\nThus the bias of the estimate $\\max_a Q(s_{t+1},a)$ will always be positive:\n$$b(\\max_a Q(s_{t+1},a)) = \\mathbb{E}[\\max_a Q(s_{t+1},a)] - \\max_a Q(s_{t+1},a) \\geq 0$$\nIn statistics literature, any estimate whose bias is positive is said to be an \"over-estimate\". Thus the action values are over-estimated by the Q-learning algorithm due to the $\\max[]$ operator, thus resulting in a $maximization$-$bias$.\nAre the arguments made above valid? I am a student, with no rigorous knowledge of random processes. Thus, please forgive me if any of the steps above are totally unrelated, and doesn't make sense in a more mathematically rigorous fashion. Please let me know, if there is a much better proof than this failed attempt. \nThank you so much for your precious time. Any help/suggestions/corrections are greatly appreciated!\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Your bias formula is a bit incorrect. You should subtract a true value, not an estimator.\n\n$\\mathrm{b}(\\hat{\\theta}) \\stackrel{\\text { def }}{=} \\mathbb{E}[\\hat{\\theta}]-\\theta$\n\n$\\mathrm{b}\\left(\\max _{a} Q\\right)=\\mathbb{E}\\left[\\max _{a} Q\\right]-\\max _{a} q=\\mathbb{E}\\left[\\max _{a} Q\\right]-\\max _{a} \\mathbb{E}[Q]$\n\n$\\mathbb{E}\\left[\\max _{a} Q\\right] \\geq \\max _{a} \\mathbb{E}[Q] \\Rightarrow \\mathrm{b}\\left(\\max _{a} Q\\right) \\geq 0$\n\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What should the initial UCT value be with MCTS, when leaf's simulation count is zero? Infinity? I am implenting a Monte Carlo Tree Search algorithm, where the selection process is done through Upper Confidence Bound formula:\ndef uct(state):\n log_n = math.log(state.parent.sim_count) \n explore_term = self.exploration_weight * math.sqrt(log_n / state.sim_count)\n exploit_term = (state.win_count / state.sim_count)\n\n return exploit_term + explore_term\n\nI have trouble however choosing the initial value for UCT, when the sim_count of the node is 0. I tried with +inf (which would be appropriate as approaching lim -> 0 from the positive side would give infinity), but that just means the algorithm will be always choosing an unexplored child.\nWhat would you suggest as a initial value for the uct?\nThank you in advance!\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Assigning a value of $\\infty$ to unvisited nodes is indeed the \"default\" or most basic choice, and it indeed ensures that the search never visits a node for a second time if it also still has siblings that have not had any visits. But many other kinds of values have been tried in the literature too.\nGelly and Wang, in \"Exploration exploitation in Go: UCT for Monte-Carlo Go\" referred to the parameter as \"First-play Urgency\" (FPU), and indeed really treated it as a hyperparameter; they simply tried various different values and some were found to work better than others.\nOther more specific values that you may want to consider (but in most cases we can't really say much about which one will be better than which other ones, without empirical evaluations) are:\n\nThe value of a loss; treating nodes that have not had any visits as losing nodes is probably the most \"pessimistic\" initialisation you could pick. It's not very clearly described in the papers, but there is some evidence out there that this was used by AlphaGo Zero and AlphaZero. Those are not simply vanilla UCTs though, those programs had very strong trained Deep Neural Networks to make additional recommendations for actions. If you don't have such strong neural networks to introduce additional biases in your selection, I would not recommend treating unvisited nodes as losing nodes.\nThe value of a draw; treating unvisited nodes as draws means that you may prioritise re-visiting nodes that look like winning nodes, but you won't prioritise re-visiting nodes that look like losing nodes.\nThe value of a win; this probably produces similar behaviour in practice as a value of $\\infty$\nThe average value backpropagated into the parent (correcting for differences in player-colour-to-move); you may prioritise re-visiting nodes that perform better than average in this subtree, but won't prioritise re-visiting nodes that perform worse than average in this subtree\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why isn't my decision tree classifier able to solve the XOR problem properly? I was trying to solve an XOR problem, and the dataset seems like the one in the image.\n\nI plotted the tree and got this result:\n\nAs I understand, the tree should have depth 2 and four leaves. The first comparison is annoying, because it is close to the right x border (0.887). I've tried other parameterizations, but the same result persists.\nI used the code below:\nfrom sklearn.tree import DecisionTreeClassifier \n\nclf = DecisionTreeClassifier(criterion='gini')\nclf = clf.fit(X, y)\n\nfn=['V1','V2']\n\nfig, axes = plt.subplots(nrows = 1,ncols = 1,figsize = (3,3), dpi=300)\n\ntree.plot_tree(clf, feature_names = fn, class_names=['1', '2'], filled = True);\n\nI would be grateful if anyone can help me to clarify this issue. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I can reproduce this problem for an even more easily separable dataset:\n\nThe ideal tree for it should be as follows:\n\nHowever, when I run DecisionTreeClassifier with the maximal depth = 2 in scikit-learn many times, it splits the dataset randomly and never gets it right.\nThis is an example of 4 different runs:\n\nThe problem is that scikit-learn has only two measures of the quality of a split: gini, and entropy. Both of them estimate mutual information between the target and only one predictor.\nHowever, in XOR problem, mutual information of each predictor with the target is zero. You can read more about it here: link from which you can see that this problem exists not only for XOR but for any task where interaction between features is important.\nIn order to solve it, the tree should be built based neither on the Gini impurity, nor on the information gain but on measures that estimate how the target depends on multiple features, e.g. multivariate mutual information, distance correlation, etc which might solve simple problems like XOR but might fail in the case of real tasks. It is easy to find simple cases when they fail (just try them for a regression for simple non-linear functions of a few variables). There is no such a measure that would estimate the dependence of a target on multiple interacting predictors very well and would work for all problems.\nEDIT to answer Asher's comment: I did several runs for max_depth=3. It is better than for max_depth=2 but still misses the correct classification from time to time. Taking max_depth=4 almost always gets XOR correctly with the occasional misses. Below are pictures of some runs for max_depth=3 and max_depth=4.\n\n\nHowever, the trees for max_depth=3 and max_depth=4 become ugly. They are ugly not only because they are bigger than the ideal tree shown above but they totally obscure the XOR function. For example, can you decipher an XOR from this tree?\n\nIt is probably possible with some pruning technique but still, an extra work.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "What is the typical AI approach for solving blackjack? I'm currently developing a blackjack program. Now, I want to create an AI that essentially uses the mathematics of blackjack to make decisions. \nSo, what is the typical AI approach for solving blackjack?\nIt doesn't have to be language-specific, but if it will help with an answer, the language I plan to use to do this would be Python. \n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Blackjack is usually modelled using Monte Carlo (MC) Methods. There is a lot of literature on MC methods which is interesting on its own right but here is a paper describing how MC is applied to Blackjack. There is also a good description on page 110 of the Introduction to Reinforcement Learning.\nGood luck!\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why do we discount the state distribution? In Reinforcement Learning, it is common to use a discount factor $\\gamma$ to give less importance to future rewards when calculating the returns.\nI have also seen mention of discounted state distributions. It is mentioned on page 199 of the Sutton and Barto textbook that if there is discounting then (for the state distribution) it should be treated as a form of termination, and it is implied that this can be achieved by adding a factor of $\\gamma$ to the state transition dynamics of the MDP, so that now we have\n$$\\mu(s) = \\frac{\\eta(s)}{\\sum_{s'} \\eta(s')}\\;;$$\nwhere $\\eta(s) = h(s) + \\sum_{\\bar{s}} \\eta(\\bar{s})\\sum_a \\pi(a|\\bar{s}) \\gamma p(s|\\bar{s}, a)$ and $h(s)$ is the probability of the episode beginning in state $s$.\nIn my opinion, the book kind of skips over this and it is not immediately clear to me why we need to discount our state distribution if we have discounting in the episode.\nMy intuition would suggest that it is because we usually take an expectation of the returns over the state distribution (and action/transition dynamics), but, if we are discounting the (future) rewards, then we should also discount the future states to give them less importance. In Sergey Levine's lectures he provides a brief aside that I think agrees with my intuition but in a rather unsatisfactory way -- he introduces the idea of a 'death state' that we transition into at each step with probability $1-\\gamma$ but he does not really provide a rigorous enough justification for thinking of it this way (unless it is just a useful mental model and not supposed to be rigorous).\nI am wondering whether someone can provide a more detailed explanation as to why we discount the state distribution.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Not an exhaustive answer, but perhaps this blog post by Alessio Russo may be helpful. In particular, he states how\n\nThere is an equivalence between using a discount factor and reaching a terminal state in a Markov Decision Process. [...] Therefore, we simply need to introduce, artificially, the possibility of terminating the trajectory with a certain probability 1-\u03b3.\n\nThe topic is not 100% clear to me yet either, but I feel like it makes much more sense now why this \"death state\" is used as a model to replace the discounted state distribution.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Which Reinforcement Learning algorithms are efficient for episodic problems? I have some episodic datasets extracted from a turn-based RTS game in which the current actions leading to the next state doesn\u2019t determine the final solution/outcome of the episode.\nThe learning is expected to terminate at a final state/termination condition (when it wins or loses) for each episode and then move on to the next number of episodes in the dataset.\nI have being looking into Q learning, Monte Carlo and SARSA but I am confused about which one is most applicable.\nIf any of the above algorithms are implemented, can a reward of zero be given in preliminary states before the termination state, at which it will be rewarded with a positive/negative (win/loss) value?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "When applying techniques like SARSA(which are on-policy), one needs to have control over a simulator. If one is able to access only the episodic dataset, then the only choice is to opt for Q-learning or Off-policy Monte-Carlo(or off-policy methods in general).\n\nCan a reward of zero\n be given in preliminary states before termination state of each\n episodes at which it will be rewarded with a positive/negative\n (win/loss) value?\n\nWith regards to the above question, the answer is yes. The task would be a sparse reward task with a reward occurring only at the last transition. The issue that one faces in a sparse reward task is that of slow convergence(or even lack of convergence).\nSome guidelines for tackling sparse reward tasks are as follows :\n\nMonte-Carlo, and n-step Q-learning are preferred over Q-learning/SARSA.\nConsider the 10-step chain MDP, where the only reward is +1 when the transition from s10 to END occurs.\n\nLet us consider the first episode in training to be start->s1->s2->s3->....->s10->end. The Q-learning update would result in no sane updates to states s1, s2, s3, s9 because the Q-value of the next state is random-value. The only state with a sane update is s10\nHowever, if we use n-step Q-learning or a Monte-Carlo based update. The Q-values of all the states are updated in a logical manner since the reward from the end of the episode propagates to all states in the episode. \nn-step Q-learning would be ideal since by adjusting the value of n, one can trade-off the benefits of Monte-Carlo methods(described above) and Q-learning(low variance). \nThe use of pseudo/auxiliary rewards. \nThis is not something necessarily recommended since the addition of new reward-structures can cause unintended behaviour. On the flip-side, it could lead to faster convergence. \nA simple example is as follows: Consider a game of chess, where the only reward is at the end of the game. Since the game of chess has very long episodes, one can introduce the following reward-structure instead :\n\n+100 for winning the game\n+1 for capturing any piece on the board\n\nHence, the pseudo reward may provide some direction for learning. Note the different scales in the two rewards(100:1). This is necessary because the primary goal of the task should not shift to capturing pieces, but to win the match.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is it practical to train AlphaZero or MuZero (for indie games) on a personal computer? Is it practical/affordable to train an AlphaZero/MuZero engine using a residential gaming PC, or would it take thousands of years of training for the AI to learn enough to challenge humans?\nI'm having trouble wrapping my head around how much computing power '4 hours of Google DeepMind training' equates to my residential computer running 24/7 trying to build a trained AI.\nBasically, are AlphaZero or MuZero practical for indie board games that want a state of the art AI, or is it too expensive to train?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "The vast majority of neural networks are now trained on graphics processing units (GPUs) or specialised accelerator hardware such as tensor processing units (TPUs).\nIn Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm, Silver et al. say that the training process involved 5,000 first-generation TPUs generating self-play games and 64 second-generation TPUs for training. This is certainly far beyond what any practical gaming computer is likely to achieve, as you'll likely only have one GPU, and that might not even rival a single TPU. Training on the CPU will be substantially slower again than either a GPU or TPU. Training would be orders of magnitude slower; you might find these benchmarks by Wang et al. of interest.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Is deep learning merely experimental? I am an undergraduate student majoring in Computer Science. I am currently about to graduate, so I need to decide on my future path. During my junior and senior years, I took many courses related to deep learning and artificial intelligence. However, I don\u2019t feel like I truly understand deep learning. Unlike other computer science-related courses, deep learning feels to me more like memorizing model architectures rather than achieving a clear understanding.\nEven when I read various research papers, the pattern always seems the same: there is an \"intuitive\" prediction, and then it is simply \"verified\" through experiments. Of course, I understand that in the progress of science, it\u2019s possible for good results to come first and for the underlying reasons to be revealed later. I\u2019m not saying that the field of deep learning is flawed.\nHowever, unlike other disciplines\u2014such as mathematics, especially analysis\u2014when I study deep learning, I rarely feel like I\u2019m truly thinking. That\u2019s why I\u2019m now questioning whether this path is right for me.\nI wonder if this concern is unique to me. I would be truly grateful for any advice from seniors who are currently doing research in deep learning.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I'd also say that a lot of research in deep learning is applied research, i.e. people apply some model to some real-world or toy problem with the hope that their (slightly modified) setup can be useful for this new scenario, sometimes, without supporting the claims or results with a rigorous mathematical analysis. Example: DeepMind recently used their models to help to create a film.\nHowever, not all research is like that. For example, variational auto-encoders can be described quite rigorously. Many RL algorithms can also be shown to converge to optimal solutions, etc. So, not everything is ugly in deep learning.\nIf you're interested in the mathematical analysis of learning, then you could look into learning theory, but even regular ML textbooks cover things like back-propogation, which is basic calculus. So, the most widely used and useful algorithms didn't just fall out of the sky. Even if people don't initially support their claims with mathematical arguments, some other researchers may do it later, if it turns out to be useful.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Why object detection algorithms are poor in optical character recognition? OCR is still a very hard problem. We don't have universal powerful solutions. We use the CTC loss function\nAn Intuitive Explanation of Connectionist Temporal Classification | Towards Data Science\nSequence Modeling\nWith CTC | Distill\nwhich is very popular, but it's still not enough.\nThe simple solution would be to use object detection algorithms for recognizing every single character and combine them to form words and sentences.\nWe already have really powerful object detection algorithms like Faster-RCNN, YOLO, SSD. They can detect even very complicated objects that are not fully visible.\nBut I read that these object detection algorithms are very poor if you use them for recognizing characters. It's very strange since these are very simple objects, just a few lines and circles. And mainly grayscale images. I know that we use object detection algorithms to detect the regions of text on big images. And then we recognize this text. Why can't we just use object detection algorithms (small versions of popular neural networks) for recognizing single characters?\nWhy we use CTC or other approaches (besides the fact that it would require much more labeling)?\nWhy not object detection?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "Good question! Using Yolo to recognise characters would be a good experiment to try. It may be because of the density of characters on a page -- systems like Yolo are very good at detecting a small number e.g. 2,3 or 10, objects, but don't work so well when the number of objects is the hundreds as you might have with OCR. A better approach might be to try face detection methods that work well with large crowds.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Do AlphaZero/MuZero learn faster in terms of number of games played than humans? I don't know much about AI and am just curious.\nFrom what I read, AlphaZero/MuZero outperform any human chess player after a few hours of training. I have no idea how many chess games a very talented human chess player on average has played before he/she reaches the grandmaster level, but I would imagine it is a number that can roughly be estimated. Of course, playing entire games is not the only training for human chess players.\nNonetheless, how does this compare to AI? How many games do AI engines play before reaching the grandmaster level? Do (gifted) humans or AI learn chess faster?\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "According to Table S3 of the AlphaZero paper (p. 15)\n\nAlphaZero was trained for 9 hours and, during these 9 hours, it played 44 million games of chess.\nAccording to this Wikipedia article, the longest human lifespan is that of Jeanne Calment, who lived to age 122 years and 164 days.\nLet's assume that humans cannot live more than 123 years (which is a reasonable assumption, although this record could eventually be broken). Let's also assume that a chess game lasts at least 10 minutes, which means that you can play at most 6 games in 1 hour, which means that you can play at most $6*24 = 144$ games in one day (assuming that you never sleep, which is, of course, impractical, but I'm just trying to show you an upper bound). Let's say that a year has 365 days. So, here is roughly the maximum number of games that a human could play\n$$\n6*24*365*123 = 6464880 \\tag{1}\\label{1},\n$$\nwhich is smaller than 44 million games by a factor of more than 6, i.e. any human could at most play 1/6 of the games that AlphaZero played, and \\ref{1} is a very loose upper bound that doesn't take into account that humans need to sleep, eat, and do many other things.\nSo, humans learn to play chess a lot slower than AlphaZero. This is not surprising at all, given that computers can perform calculations a lot faster than us (that's why they are called computers), and this has been the case for many years. We (humans) just made computers make the right calculations for them to approximately play chess better than us. That's it.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Meaning of Actor Output in Actor Critic Reinforcement Learning In actor critic, The equations for calculating the loss in actor critic are an \nactor loss (parameterized by $\\theta$) \n$$log[\\pi_\\theta(s_t,a_t)]Q_w(s_t,a_t)$$ \nand a critic loss (parameterized by $w$) \n$$r(s_t,a_t) + \\gamma Q_w(s_{t+1}, a_{t+1}) - Q_w(s_{t}, a_t).$$\nThis is bootstrapping in experience replay:\n$$\nL_i(\\theta_i) = \\mathbb{E}_{(s, a, r, s') \\sim U(D)} \\left[ \\left(r + \\gamma \\max_{a'} Q(s', a'; \\theta_i^-) - Q(s, a; \\theta_i)\\right)^2 \\right]\n$$\nIt is clear that bootstrapping is comparable to the critic loss, except that the $max$ operation is lacking from the critic.\nAs i see it, (correct me if I'm wrong):\n$Q(s_t,a_t) = V(s_{t+1}) + r_t$ where $a_t$ is the actual action that had been taken.\nThe critic, as I understand, estimates $V(s)$\nMy question:\nWhat exactly is the critic calculating?\nWhat In actor critic outputs $Q(s_{t+1},a_{t+1})$?\nIt seems to me like the critic calculates the average next state $s_{t+1}$ value, over all possible actions, with their corresponding probabilities, yielding\n$Q(s_t, a_t) = r_t + \\sum_{a_{t+1} \\in A}P(a_{t+1}|s_t)V(s_{t+1})$\nWhich would mean that in order to get $Q(s_{t+1}, a_{t+1})$ for the above formula, I would need to calculate\n$Q(s_{t+1}, a_{t+1}) = r_{t+1} + \\sum_{a_{t+2} \\in A}P(a_{t+2}|s_{t+1})V(s_{t+2})$\nWhere $V(s_{t+2})$ is the critic output on $s_{t+2}$, a state we get to by taking action $a_{t+1}$ from state $s_{t+1}$ but I am not sure that is indeed the meaning of the critic output and still it is unclear to me how to get $Q(s_{t+1}, a_{t+1})$ from actor critic.\nIf indeed that is what's being calculated, then why is it mathematically true that an improvement is being made? Or why does it make sense (even if not mathematically always true)?\n\nPractical use:\nI want to use actor critic with experience replay in an environment with a large action space (could be continuous). Therefore, I cannot use the $max$ term. I need to understand the correct equation for the critic loss, and why it works.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "When using the loss function for the critic described in your question, the Actor-Critic is an on-policy approach (as are most Actor-Critic methods). Your intuition as to what it is learning seems to be quite close, but the notation/terminology is not quite on point.\nFirst it's important to realize that the $Q(s, a)$ critic is an estimator, we're training it to estimate state-action values. You could say that we are training it such that it can hopefully provide accurate estimates of:\n$$Q_w^{\\pi} (s_t, a_t) \\approx \\mathbb{E}_{\\pi} \\left[ r_t + \\gamma V^{\\pi}(s_{t+1}) \\right].$$\nYou'll notice I've added quite a number of symbols there in comparison to your $Q(s_t, a_t) = r_t + V(s_{t+1})$:\n\nI have added the $\\pi$ superscript to $Q$ and $V$; this denotes the behaviour policy, which is the policy that we're using to generate experience. In on-policy methods, this is equal to the target policy (the policy for which we're learning to predict values). Adding this superscript makes explicit the fact that we're learning expected returns for states and state-action pairs that are only accurate under the assumption that we continue following the $\\pi$ policy from state $s_{t+1}$ onwards.\nI added the discount factor $\\gamma$, which is probably just a tiny detail you forgot.\nI added $\\mathbb{E}_{\\pi}$ to indicate that we're trying to estimate an expectation under $\\pi$ (and the environment's dynamics).\n\nSo, the critic is trained to estimate $Q^{\\pi}(s, a)$, which can intuitively be interpreted as the long-term discounted rewards that we expect to collect when executing $a$ in $s$, and selecting actions according to the distribution $\\pi$ subsequently. It definitely still is trying to estimate $Q(s, a)$ values for state-action pairs, not just $V(s)$ values for states alone.\n\n\nWhat In actor critic outputs $Q(s_{t+1},a_{t+1})$?\n\nIn practice, when using the loss function described in your question, $a_{t+1}$ really simply is a single action selected in an actual trajectory of experience by the policy $\\pi$. The trained network simply takes $s_{t+1}$ as input, and the output corresponding to a single action $a_{t+1}$ as selected by the policy is used as the value for $Q(s_{t+1},a_{t+1})$ in the update rule. \nThe update rule does not involve any sum over all actions, multiplied with their probabilities. The \"trick\" is that we do not just run the update rule a single time, but we expect to generate lots (sometimes millions) of trajectories as experience, and we repeatedly run the update rule. In different trajectories, we'll experience the different actions $a_t$ as samples with approximately the correct frequencies, and in expectation we'll have proper update targets (except for potential bias resulting from function approximation).\n\n\nI want to use actor critic with experience replay in an environment with a large action space\n\nThe Actor-Critic method in your question is, as I mentioned above, on-policy. This means that the experience used in update rules has to be generated according to exactly the same policy for which you are also learning value estimates. This is incompatible with the idea of experience replay, because old trajectories stored in a replay buffer were generated by older versions of your policy.\nThere are off-policy Actor-Critic methods which can correct for the mismatch in distributions and use experience replay, but these are going to be quite a bit more complicated. Examples are ACER and IMPALA.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Constructing a dataset that scores well only for a specific set of hyper parameter values When designing a machine-learning system, there are various parameters that have to be determined. I am interested in the following general question: is it possible to construct a dataset on which the system will have good performance with some specific set of parameters, but not with other paramteres?\nTo be more concrete, let's focus on neural networks. Suppose we have a simple neural network: a multilayer perceptron with a single hidden layer. The size of the input is fixed, the activation function is fixed (e.g. tanh), and the output is binary. The only parameter that has to be determined is the size of the hidden layer. \nMy question is: given a number $n$, is it possible to construct a dataset $D_n$ such that:\n\nThe MLP with $n$ hidden nodes has good performance on $D_n$ (e.g. in 10-fold cross validation);\nThe MLP with $n-1$ hidden nodes has bad performance on $D_n$\n\n?\nNote: I asked in CS theory but got no reply.\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I'm not familiar with any existing, robust methods to generate such a dataset. Here are some thoughts though.\nYou propose using an MLP with a single hidden layer. That means we have two weight matrices, and two activation functions (one for hidden layer, one for output layer). Some notation:\n\n$d$: dimensionality of input vectors\n$n$: dimensionality of hidden layer\nYou mentioned binary output, so I'll assume that dimensionality is $2$\n$W_n^{(1)} \\in \\mathbb{R}^{d \\times n}$: the first weight matrix in the scenario where we're using $n$ hidden nodes\n$W_n^{(2)} \\in \\mathbb{R}^{n \\times 2}$: the second weight matrix in the scenario where we're using $n$ hidden nodes\n$g$: first activation function\n$h$: second activation function\n\nThen, given an input vector $x \\in \\mathbb{R}^d$, our neural network will generate output $f_n(x) = h(W_n^{(2)} (g(W_n^{(1)}x)))$.\nNow, in general we of course expect Neural Networks to only find a local optimum, but if you want a robust solution you'll want it to be able to handle the worst case, and the worst case for your \"adversarial\" task is when the Neural Network manages to find the global optimum. So, we'll assume it can find the global optimum.\nEssentially, what you're looking for is a dataset $D_n$ containing a number of input vectors $x$, such that:\n\n$f_n(x) = h(W_n^{(2)} (g(W_n^{(1)}x)))$ provides good / optimal results (after training to the global optimum)\n$f_{n - 1}(x) = h(W_{n - 1}^{(2)} (g(W_{n - 1}^{(1)}x)))$ provides poor results (even after training to the global optimum of this setup).\n\nIn other words, you want to find a collection of vectors $x$ such that it becomes impossible to find a collection of weights in the $n - 1$ case where $f_{n-1}(x)$ is a good approximation of $f_n(x)$. You want to make it impossible that $f_{n - 1}(x) \\approx f_n(x)$.\n\nNow this has turned into a clear mathematical problem. I'm not familiar with any established methods in mathematics to solve a problem like this, maybe there are though. My best guess at this point in time would be a procedure like the following:\n\nGenerate random \"ground truth\" versions of the weight matrices $W^{(1)*}_{n}$ and $W^{(2)*}_{n}$ (just completely random matrices).\nGenerate completely random input vectors $x$. Compute the corresponding ground truth labels as $f^*_n(x) = h(W_n^{(2)*} (g(W_n^{(1)*}x)))$.\nHope that the neural network with $n$ hidden nodes can recover the ground truth weight matrices that were previously generated randomly.\nHope that the neural network with $n - 1$ hidden nodes cannot find an accurate approximation.\n\nIn theory, the MLP with $n$ hidden nodes should be able to learn the exact ground truth function. In theory, under certain conditions, the MLP with $n$ hidden nodes should not be able to learn the exact ground truth function. I suspect those \"certain conditions\" would be that the rows/columns of the weight matrices should be linearly independent, which is likely with randomly generated matrices, but I'm not 100% sure on this. Even if it can't learn the exact ground truth, it may still be capable of learning an approximation... there may be ways to find upper bounds on how close such an approximation could get, but I'm not sure.\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Modern reinforcement learning for video game NPCs Recently, I have been reading about the 1996 artificial life game 'Creatures'. The game features NPCs called 'Norns' that use reinforcement learning to learn continuously through interactions with the player and their environment. From what I have read, there haven't been any later attempts to make a game with similar AI. Have there been any more recent examples/experiments/papers on using modern reinforcement learning techniques to create NPCs that learn based on interactions with the player and game, within the main gameplay loop? What should I read if I want to create a similar system?\nRelevant reading:\nhttps://www.alanzucconi.com/2020/07/27/the-ai-of-creatures/\nhttps://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.81.1278&rep=rep1&type=pdf\n", + "images": null, + "role": "user", + "thinking": null, + "tool_calls": null + }, + { + "context": "I love this question because I grew up with Creatures. I'm not sure if you've played Creatures but from my memory the creatures were relatively simplistic AI. I would not have asked a Norm to play pong much less anything requiring higher level strategy. For anything more complex than reacting to the environment and not algorithm based (see The Sims for algorithmic AI in the pre-2010s) the methods/compute just weren't there.\nThere are some big names (Sony notably) working towards RL in modern video games so we are getting to the age of it but we still aren't there in a few ways.\nBut hey, I'm not here to crush dreams so let's make it realistic:\n\nEnsure there is no simpler method for how you want the NPCs to react to the player. It's fun to jump into DeepRL but, for example, if the desired interaction is \"Oh the player goes B every 3rd round, the AI should learn to go B in those cases\" it's much easier to maintain a table of probabilities and choose a predefined strategy based on it.\nMake the inputs/outputs as simple as possible. The landmark DQN paper down sampled the Atari(!) screen. We've gotten to where Youtubers train Mario kart AI on down sampled N64 screens but the point is we still struggle with really rich inputs. Keeping the input space as small as possible is your friend for training time and to keep the AI from overfitting.\nLearn to transfer train. Players probably wont be happy with NPCs who do little to nothing for the first 12 hours of gameplay. Establish a reasonable model at engineering time and allow a subset of the model to adjust at playtime from interaction with the player. The reality is training even a few layers of a NN won't happen in real time but maybe between rounds or as a background task.\n\n", + "images": null, + "role": "assistant", + "thinking": null, + "tool_calls": null + } + ], + [ + { + "context": "Do good approximations produce good gradients? Let\u2019s say I have a neural net doing classification and I\u2019m doing stochastic gradient descent to train it. If I know that my current approximation is a decent approximation, can I conclude that my gradient is a decent approximation of the gradient of the true classifier everywhere?\nSpecifically, suppose that I have a true loss function, $f$, and an estimation of it, $f_k$. Is it the case that there exists a $c$ (dependent on $f_k$) such that for all $x$ and $\\epsilon > 0$ if $|f(x)-f_k(x)|<\\epsilon$ then $|\\nabla f(x) - \\nabla f_k(x)|