<issue_start>username_0: This might sound silly to someone who has plenty of experience with neural networks but it bothers me...

Random 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.

**Why are the initial weights of neural networks randomly initialized rather than being all set to, for example, 0.5?**<issue_comment>username_1: The initial weights in a neural network are initialized randomly because the gradient based methods commonly used to train neural networks do not work well when all of the weights are initialized to the same value. While not all of the methods to train neural networks are gradient based, most of them are, and it has been shown in several cases that initializing the neural network to the same value makes the network take much longer to converge on an optimum solution. Also, if you want to retrain your neural network because it got stuck in a local minima, it will get stuck in the same local minima. For the above reasons, we do not set the initial weights to a constant value.

References:
[Why doesn't backpropagation work when you initialize the weights the same value?](https://stats.stackexchange.com/q/45087/82135)
Upvotes: 3 <issue_comment>username_2: You shouldn't assign all to 0.5 because you'd have the "break symmetry" issue.

>
> <http://www.deeplearningbook.org/contents/optimization.html>
>
>
> Perhaps the only property known with complete certainty is that the initial
> parameters need to “**break symmetry**” between different units. If two hidden
> units with the same activation function are connected to the same inputs, then
> these units must have **different initial parameters**. If they have the same initial
> parameters, then a deterministic learning algorithm applied to a deterministic cost
> and model will constantly update both of these units in the same way. Even if the
> model or training algorithm is capable of using stochasticity to compute different
> updates for different units (for example, if one trains with dropout), it is usually
> best to initialize each unit to compute a different function from all of the other
> units. This may help to make sure that no input patterns are lost in the null
> space of forward propagation and no gradient patterns are lost in the null space
> of back-propagation.
>
>
>
Upvotes: 5 [selected_answer]<issue_comment>username_3: That is a very deep question. There was series of papers recently proving the convergence of gradient descent for overparameterized deep networks (for example, [Gradient Descent Finds Global Minima of Deep Neural Networks](https://arxiv.org/abs/1811.03804), [A Convergence Theory for Deep Learning via Over-Parameterization](https://arxiv.org/abs/1811.03962) or [Stochastic Gradient Descent Optimizes Over-parameterized Deep ReLU Networks](https://arxiv.org/abs/1811.08888)). All of the proofs assume that the initial weights are assigned randomly according to a Gaussian distribution. The main reasons this initial distribution is important for the proofs are:

1. Random weights make the ReLU operators in each layer statistically compressive mapping (up to a linear transformation).
2. Random weights preserve separation of input for any input distribution - that is if input samples are distinguishable network propagation will not make them indistinguishable.

Those properties are very difficult to reproduce with deterministically generated initial weight matrices, and even if they are reproducible with deterministic matrices NULL-space (from which we can generate adversarial examples) would likely make the method less useful in practice. More importantly, preservation of those properties during gradient descent would likely make method impractical. But overall it's very difficult but not impossible, and may warrant some research in that direction. In analogous situation, there were some results for [Restricted Isometry Property for deterministic matrices](https://arxiv.org/abs/1202.1234) in a [compressed sensing](https://en.wikipedia.org/wiki/Compressed_sensing).
Upvotes: 2 <issue_comment>username_4: It is okay to initialize the weights to zero for a simple logistic regression, but for a neural network to initialize the weights to parameters to all zero and then apply gradient descent, it won't work.

Assume here that you have in a 2-layered network with just 2 input features and in the hidden layer you have 2 nodes, and the weights are initialized as [u, v] for both the nodes.

So, while optimizing the weights, using gradient descent you would compute:

![](https://latex.codecogs.com/svg.image?w_%7B1%7D&space;=&space;u&space;-&space;%5Calpha&space;%5Cfrac%7B%5Cpartial&space;J%7D%7B%5Cpartial&space;w_%7B1%7D%7D)

![](https://latex.codecogs.com/svg.image?w_%7B2%7D&space;=&space;v&space;-&space;%5Calpha&space;%5Cfrac%7B%5Cpartial&space;J%7D%7B%5Cpartial&space;w_%7B2%7D%7D)

where α is the learning rate and J is the cost function that you want to minimize by optimizing the weights.

By kind of a proof by induction, you should be able to see that after every single iteration of training, your two hidden units are still computing exactly the same function because both hidden units start off computing the same function, have the same influence on the output unit. So even after multiple iterations, the two hidden units are still symmetric. Hence, there's really no point to having more than one hidden unit because they are all computing the same thing.

In summary, no matter how long you run gradient descent, both the two units compute exactly the same function which is not helpful, because you want the different hidden units to compute different functions. The solution to this is to initialize your parameters randomly.

For larger neural networks, say of three features and maybe a very large number of hidden units, a similar argument still works.

Note: It's okay to initialize the bias term to just zeros. Because so long as weights are initialized randomly, you start off with the different hidden units computing different things.
Upvotes: 2 <issue_comment>username_5: Another theory relevant I think to this question is the “lottery ticket hypothesis”:

* <NAME> and <NAME>, The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks, 2019, <https://arxiv.org/abs/1803.03635>

Basically, when you have a neural network with a very high number of neurons with randomly initialized weights in the hidden layers, you have a high chance of a subset of the network being close to a good solution to the problem. Then, by applying gradient descent, you can align the output of the whole network to that of the sub-network and fine tune it.

It would be nice if someone could prove this. If there is a proof I would be interested to see it.
Upvotes: 1


<issue_start>username_0: I have been looking at the Fibonacci series, the golden ratio, and its uses in nature, like how flowers and animals grow based on the series.

I was wondering whether we could use the Fibonacci series and the golden ratio in any way in AI, especially in evolutionary algorithms. Any ideas or insights?

Is this research material? If so where can we start?<issue_comment>username_1: [Face detection evaluation: A new approach based on the golden ratio Φ](https://www.researchgate.net/publication/236132090_Face_detection_evaluation_A_new_approach_based_on_the_golden_ratio_PH)

Abstract:

>
> Face detection is a fundamental research area in computer vision field. Most of the face-related applications such as face recognition and face tracking assume that the face region is perfectly detected. To adopt a certain face detection algorithm in these applications, evaluation of its performance is needed. Unfortunately, it is difficult to evaluate the performance of face detection algorithms due to the lack of universal criteria in the literature. In this paper, we propose a new evaluation measure for face detection algorithms by exploiting a biological property called Golden Ratio of the perfect human face. The new evaluation measure is more realistic and accurate compared to the existing one. Using the proposed measure, five haar-cascade classifiers provided by Intel©OpenCV have been quantitatively evaluated on three common databases to show their robustness and weakness as these classifiers have never been compared among each other on same databases under a specific evaluation measure. A thoughtful comparison between the best haar-classifier and two other face detection algorithms is presented. Moreover, we introduce a new challenging dataset, where the subjects wear the headscarf. The new dataset is used as a testbed for evaluating the current state of face detection algorithms under the headscarf occlusion
>
>
>
Upvotes: 0 <issue_comment>username_2: The use of the Golden Ratio is an interesting suggestion which has intrigued many lovers of the mathematical beauty represented in nature and in AI. The problem lies in the foundations of the AI applications. For example, in designing algorithms for recognizing naturally occurring phenomena, such as face recognition or human body movements (See <https://www.intechopen.com/books/machine-learning-and-biometrics/a-human-body-mathematical-model-biometric-using-golden-ratio-a-new-algorithm>) it is suitable. However, for non natural occurrences, the ratio is limited since the data is usually random or chaotic. However, in order to create a master algorithm for the future which encompasses all the best of the current AI algorithms, the use of mathematical concepts such as the golden ration and fractals will be vital. Watch this space...
Upvotes: 1 <issue_comment>username_3: I mean you can predict these sequences quite easily(with varying levels of accuracy) just by using LSTMs in the time series forecasting context. Obviously, as the number of digits you give it increases, it will increase the prediction accuracy of the next in the sequence(with some caveats), as we can think of neural networks more generally as connectionist function approximators(nonlinear in almost all cases).

As far as direct applications in AI, I suppose not beyond mathematical modeling and economic/financial modeling as these sorts of sequences emerge from a vast majority of pure and applied mathematical concepts. This research is quite relevant and ongoing([1](https://agupubs.onlinelibrary.wiley.com/doi/pdf/10.1029/95WR01955),[2](https://content.iospress.com/articles/algorithmic-finance/af176),[3](https://dl.acm.org/citation.cfm?id=1143891)).
Upvotes: 0 <issue_comment>username_4: It should be a short amount of time before we start seeing exponential complexity growth as the target of AI algorithms, likely involving the golden ratio.

<https://en.wikipedia.org/wiki/Golden_ratio#Relationship_to_Fibonacci_sequence>

We are already using the golden ratio to perform quantum computations :

<https://www.quora.com/How-are-quantum-physics-and-the-golden-ratio-connected>

So, once we scale parallelization to GPU-like networks of quantum processors, we can then be sure we have entered the territory where AI and the Golden Ratio are inherently more intrinsic.

As far as accelerating the learning models/algorithms with them, we can only hope something so fantastic would be found in the future of AI as well; who knows, maybe they will come out of course through necessity much like the biological computers we all execute and replicate our code from, and it's environment :

<https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6047800/>

Not to say it will be the only property present, as the article concludes the golden ratio is "most likely" only related by "chance". I'm sure the same random chance by which it relates to black hole entropy, and, everything else it relates to :P.
Upvotes: 0


<issue_start>username_0: 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!<issue_comment>username_1: 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).

For 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.

For Text classification, there are connections between characters (that form words) so you can use CNN for [text classification in character level](https://papers.nips.cc/paper/5782-character-level-convolutional-networks-for-text-classification.pdf).

For 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](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/CNN_ASLPTrans2-14.pdf).

If 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](https://www.tensorflow.org/api_docs/python/tf/nn/conv1d) and [conv2d](https://www.tensorflow.org/api_docs/python/tf/nn/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.

But 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.
Upvotes: 4 [selected_answer]<issue_comment>username_2: The convolutional models are a method of choice when your problem is translation invariant (or covariant). In image classification, the image should be classified into class 'cow' if a cow is present in any part of the image. In text classification, different orders of phrases and sentences result in related meaning. In speech recognition, the same syllable is used at different places to build different words.

In your problem, you should check whether some subsequences of your 1791 columns give rise to the same meaning although they are located at different places within the sample. If the answer is positive, then convolutional layers are likely going to improve the performance.
Upvotes: 3 <issue_comment>username_3: DeepInsight method has been used for converting tabular data into corresponding images which are then processed by CNN. Here is the link <https://alok-ai-lab.github.io/DeepInsight/>
Upvotes: 1


<issue_start>username_0: I have implemented a CNN for image classification. I have not used fully connected layers, but only a softmax. Still, I am getting results.

Must I use fully-connected layers in a CNN?<issue_comment>username_1: In theory, you do not need fully-connected (FC) layers. FC layers are used to introduce scope for updating weights during back-propagation, due to its ability to introduce more connectivity possibilities, as every neuron of the FC is connected every neuron of the further layers.
Upvotes: 1 <issue_comment>username_2: The reasons people use the FC after convolutional layer is that CNN preserves spatial information. You said you use softmax, so you probably make some classification task. If you don't use FC layer, then you probably evaluate first class by first position of the first kernel, not by whole image with all kernels, second class by second position of the kernel and so on.

The dense net combine the info from all the kernels in all positions.

That said, you technically can convert FC to Conv net, as [described here](http://cs231n.github.io/convolutional-networks/#convert), so then you can said you "skipped" FC layer.
Upvotes: 1 <issue_comment>username_3: >
> Are fully connected layers necessary in a CNN?
>
>
>

No. In fact, you can simulate a fully connected layer with convolutions. A convolutional neural network (CNN) that does not have fully connected layers is called a **fully convolutional network (FCN)**. See [this answer](https://ai.stackexchange.com/a/21824/2444) for more info.

An example of an FCN is the [u-net](https://arxiv.org/abs/1505.04597), which does *not* use any fully connected layers, but only convolution, downsampling (i.e. pooling), upsampling (deconvolution), and copy and crop operations. Nevertheless, u-net is used to classify pixels (more precisely, semantic segmentation).

Moreover, you can use CNNs only for the purpose of feature extraction, and then feed these extracted features in another classifier (e.g. an SVM). In fact, transfer learning is based on the idea that CNNs extract *reusable* features.
Upvotes: 2


<issue_start>username_0: I'm trying to use a Monte Carlo Tree Search for a non-deterministic game. Apparently, one of the standard approaches is to model non-determinism using *chance nodes*. The problem for this game is that it has a very high min-entropy for the random events (imagine the shuffle of a deck of cards), and consequently a very large branching factor ($\approx 2^{32}$) if I were to model this as a chance node.

Despite this issue, there are a few things that likely make the search more tractable:

1. Chance nodes only occur a few times per game, not after every move.
2. The chance events do not depend on player actions.
3. Even if two random outcomes are distinct, they might be "similar to each other", and that would lead to game outcomes that are also similar.

So far all approaches that I've found to MCTS for non-deterministic games use UCT-like policies (e.g. chapter 4 of [A Monte-Carlo AIXI Approximation](https://arxiv.org/pdf/0909.0801.pdf)) to select chance nodes, which weight unexplored nodes maximally. In my case, I think this will lead to fully random playouts since any chance node won't ever be repeated in the selection phase.

What is the best way to approach this problem? Has research been done on this? Naively, I was thinking of a policy that favors repeating chance nodes more over always exploring new ones.<issue_comment>username_1: If you have that sort of a priori knowledge about your environment it, as you said, will simplify the problem substantially. From what I gather you have done a good amount of background research and simply want to apply UTC MCTS(or similar) to the environment. You mention that "chance nodes won't ever be repeated in the selection phase".

If I understand what you are asking correctly, you can simply use what you know to alter the way you search nodes of the tree. I.e you can essentially act greedily wrt the initial chance nodes and then slowly decay that search strategy as the training progresses(to avoid convergence to local maxima).

I encourage you to dig a bit deeper into the methods around exploration vs. exploitation as there may be an elegant solution to this problem in particular.
Upvotes: 0 <issue_comment>username_2: You can try using an "Open-Loop" MCTS approach, instead of the standard "closed-loop" one, and eliminate chance nodes altogether. See, for example, [Open Loop Search for General Video Game Playing](http://www.diego-perez.net/papers/OpenLoopGVG.pdf).

In a "standard" (closed-loop) implementation, you would store a game state in every normal (non-chance) node. Whenever there is a chance event, you would stochastically traverse to one of its children, and then have a normal node with a "deterministic" game state again.

In an open-loop approach, you do not store game states in any node (except possibly the root nodes), because nodes no longer deterministically correspond to specific game states. **Every node in an open-loop MCTS approach only corresponds to the sequence of actions that leads to it from the root node**. This completely eliminates the need for chance nodes, and results in a significantly smaller tree because you only need a single path in your tree for every possible unique sequence of actions. A single sequence of actions may, depending on stochastic events, lead to a distribution over possible game states.

In every separate MCTS iteration, you would re-generate game states again by applying moves "along the edges" as you traverse through the tree. You also "roll the dice" again for any stochastic events. If your MCTS iteration traverses a certain path of the tree often enough, it will still be able to observe all the possible stochastic events through sampling.

Note that, **given an infinite amount of time, the closed-loop approach with explicit chance nodes will likely perform much better**. But when you have a small amount of time (as is the case in the real-time video game setting considered in the paper I linked above), an open-loop approach without explicit chance nodes may perform better.

---

Alternatively, if you prefer the closed-loop approach with explicit chance nodes, you could try some mix of:

* Allowing MCTS to prioritise promising parts of the search tree over parts that have not been visited at all (i.e. do not automatically prioritise nodes with $0$ visits). For example, instead of giving unvisited node a value estimate of $\infty$ (this is how you could interpret the automatic selection of them), you could give them a value estimate equal to the value estimate of the parent node, and just apply the UCB1 equation directly.
* Use AMAF value estimates / RAVE / [GRAVE](https://www.lamsade.dauphine.fr/~cazenave/papers/grave.pdf) in your selection phase. This allows you to very quickly learn some crude value estimates for moves that you have never selected in the Selection phase yet, by generalising from observations of playing them in the Play-out phase. I have noticed that the "standard" implementation of RAVE / GRAVE, without an explicit UCB-like exploration term, does not mix well with my previous suggestion of using a non-infinite value estimate for unvisited children. It may be good to consider a UCB-like variant with an explicit exploration term instead.
Upvotes: 3 <issue_comment>username_3: I would have a look at progressive widening, which was created to address the problem of applying MCTS to continuous stochastic environments. That is, where the probability of encountering the same state twice in simulating a chance node is $0$.

The original paper for DPW (Double Progressive Widening) can be found here <https://hal.science/hal-00542673v2/file/c0mcts.pdf>. DPW addresses the case where both action and state spaces are continuous, but you can ablate it if you only have or the other.

The main idea is that you expand the chance node a few times and then revisit those expansions. When you've saturated existing outcomes according to some hyperparameter, you then randomly sample the chance node.

It has a few limitations, for example the rate at which you sample new nodes is fixed and has to be determined experimentally. In some environments, the optimal rate is dependent on the state itself which leads to more complex techniques. For your problem though, it sounds like it may be a good fit.
Upvotes: 0


<issue_start>username_0: Say I have x,y data connected by a function with some additional parameters (a,b,c):

$$ y = f(x ; a, b, c) $$

Now given a set of data points (x and y) I want to determine a,b,c. If I know the model for $f$, this is a simple curve fitting problem. What if I don't have $f$ but I do have lots of examples of y with corresponding a,b,c values? (Or alternatively $f$ is expensive to compute, and I want a better way of guessing the right parameters without a brute force curve fit.) Would simple machine-learning techniques (e.g. from sklearn) work on this problem, or would this require something more like deep learning?

Here's an example generating the kind of data I'm talking about:

```
import numpy as np
import matplotlib.pyplot as plt

Nr = 2000
Nx = 100
x = np.linspace(0,1,Nx)

f1 = lambda x, a, b, c : a*np.exp( -(x-b)**2/c**2) # An example function
f2 = lambda x, a, b, c : a*np.sin( x*b + c)        # Another example function
prange1 = np.array([[0,1],[0,1],[0,.5]])
prange2 = np.array([[0,1],[0,Nx/2.0],[0,np.pi*2]])
#f, prange = f1, prange1
f, prange = f2, prange2

data = np.zeros((Nr,Nx))
parms = np.zeros((Nr,3))
for i in range(Nr) :
    a,b,c = np.random.rand(3)*(prange[:,1]-prange[:,0])+prange[:,0]
    parms[i] = a,b,c
    data[i] = f(x,a,b,c) + (np.random.rand(Nx)-.5)*.2*a

plt.figure(1)
plt.clf()
for i in range(3) :
    plt.title('First few rows in dataset')
    plt.plot(x,data[i],'.')
    plt.plot(x,f(x,*parms[i]))

```

[![enter image description here](https://i.stack.imgur.com/msnzH.png)](https://i.stack.imgur.com/msnzH.png)

Given `data`, could you train a model on half the data set, and then determine the a,b,c values from the other half?

I've been going through some sklearn tutorials, but I'm not sure any of the models I've seen apply well to this type of a problem. For the guassian example I could do it by extracting features related to the parameters (e.g. first and 2nd moments, %5 and .%95 percentiles, etc.), and feed those into an ML model that would give good results, but I want something that would work more generally without assuming anything about $f$ or its parameters.<issue_comment>username_1: If you read nothing else, **maximum likelihood estimate => chance that the data predicted is the data observed.** If you have a range of points (2, 3, 4, 5, 71) your MLE is going to favour ~4.5 because of means and standard deviations. MLE speeds up finding good input parameters, usually for a different classifier.

To answer your question:

1) [Columbia University have a great example of using MLE classifiers](https://towardsdatascience.com/bayes-classifier-with-maximum-likelihood-estimation-4b754b641488), where everything is broken down into bitesize (or bytesize) chunks. Read this. Seriously.

2) In short, **MLE is best used for simple, univariable distributions.** It doesn't scale well to big problems but is waaay faster than a Bayesian network for simple tasks like predicting your height based on the heights of your immediate relatives. If you want to get technical, the conditional probability network of the Bayesian model reveals insights faster than the chain multiplication of the more primitive MLE.

Hope it helps!
Upvotes: 0 <issue_comment>username_2: Yes, it's called hypothesis testing but normally you need a little bit more than pure MLE.
Upvotes: -1


<issue_start>username_0: Loss is MSE; orange is validation loss, blue training loss. The task is NN regression (18 inputs, 2 outputs), one layer 300 hidden units.
[![](https://i.stack.imgur.com/Rs1sq.png)](https://i.stack.imgur.com/Rs1sq.png)

Tuning the lr, mom, l2 regularization parameters this is the best validation loss I can obtain. Can be considered overfitting? Is 1 a bad vl loss value for a regression task?<issue_comment>username_1: Depends on what does 1 represent in your task.
If you are trying to predict household prices and 1 represents \$1, I think the average validation loss is good. If 1 represents \$10000 in this case, probably something is not right. But remember that there are 2 parts contributing to the overall loss. The mse loss and the l2 penalty loss. (Also remember that most optimizers already implement l2 penalty as weight decay. So you do not need to add it separately)

Some suggestions.

1. Check if your data has any outliers/ anomalies. Based on your task you should know as to what you can do with these data points. Also see if your dataset has high variance.
2. If you are worried about over-fitting, think about your data again. Less data + more parameters often leads to over-fitting. If your dataset is too small, you need to think again.
3. Try to adjust the number of hidden units and observe the results.
4. Try using cross validation.
5. Alternatively, try using different optimizers and see what happens (Try Adam).
Upvotes: 2 <issue_comment>username_2: The validation loss settles exactly at an error of one. Probably means there's something off with either the kind of data validation set has or with something in the training. An exact validation loss of one almost definitely means there's something off.

I'd recommend before doing anything thoroughly go through your data or see if there's anything to debug in the model itself. Considering training error reduces there's probably something different about either the formatting of the validation data or the validation data itself.

A mild description of the type of data and exact problem in hand could further help.
Upvotes: 2 <issue_comment>username_3: The telltale **signature** of overfitting is when your validation loss starts increasing, while your training loss continues decreasing, i.e.:

[![adapted from Wikipedia](https://i.stack.imgur.com/KLM4h.png)](https://i.stack.imgur.com/KLM4h.png)

(Image adapted from Wikipedia entry on [overfitting](https://en.wikipedia.org/wiki/Overfitting))

It is clear that this does not happen in your diagram, hence your model does not overfit.

A difference between a training and a validation score by itself does **not** signify overfitting. This is just the **generalization gap**, i.e. the *expected* gap in the performance between the training and validation sets; quoting from a recent [blog post by Google AI](https://ai.googleblog.com/2019/07/predicting-generalization-gap-in-deep.html):

>
> An important concept for understanding generalization is the *generalization gap*, i.e., the difference between a model’s performance on training data and its performance on unseen data drawn from the same distribution.
>
>
>

An MSE of 1.0 (or any other specific value, for that matter) by itself cannot be considered "good" or "bad"; everything depends on the context, i.e. of the particular problem and the actual magnitude of your dependent variable: if you are trying to predict something that is in the order of some thousands (or even hundreds), an MSE of 1.0 does not sound bad; it's not the same if your dependent variable takes values, say, in [0, 1] or similar.
Upvotes: 1


<issue_start>username_0: I'm doing machine learning projects. I took a look at many datasets I worked with, mostly there are already famous datasets that everyone uses.

Let's say I decided to make my own dataset. Is there a possibility that my data are so random so that no relationship exists between my inputs and outputs? This is interesting because if this is possible, then no machine learning model will achieve to find an inputs outputs relationship in the data and will fail to solve the regression or classification problem.

Moreover, is it mathematically possible that some values have absolutely no relationship between them? In other words, there is no function (linear or nonlinear) that can map those inputs to the outputs.

Now, I thought about this problem and concluded that, if there is a possibility for this, then it will likely happen in regression because maybe the target outputs are in the same range and the same features values can correspond to the same output values and that will confuse the machine learning model.

Have you ever encountered this or a similar issue?<issue_comment>username_1: Not sure if I can answer the question as a whole, but a pure random input/output pair doesn't quite have "no relationship" at all. At the very least, for any fixed training set input/output pair, you can do an if...then mapping to construct a 1-to-1 function, such that you can classify the training set with 100% accuracy (assuming no duplicates of input).

In any case, I assume you mean uniform random, because if you have something like gaussian random, you can still learn some latent structure from how the random numbers are generated.

But even if you assume uniform random, and your algorithm is only guessing, your algorithm is technically still operating optimally per the data generating distribution, which basically means its as optimal as it gets.

The only such case that I can imagine which would satisfy your question, would be if you had a separate training/validation set, where the only element of the training input/output is [1,1], but the validation set only has elements of [1,-1], or something along those lines.

From reading your comments, I suspect that your intention with the question was: "Can there be a relationship of data such that no method can learn it?". To the extent that the data-generating distribution exists, then by the [universal approximation theorem of neural networks](https://en.wikipedia.org/wiki/Universal_approximation_theorem), then it is reasonable that you can at least partially learn it.

However it is important to note that the universal approximation theorem doesn't mean that such a data generating distribution can be *learned* by a neural net, it only means that you can get "non-zero as close as you want" to the data generating distribution. More explicitly: there is a setting of weights that gives you results as good as you want, but gradient descent doesn't necessarily learn it.
Upvotes: 0 <issue_comment>username_2: Of course, it's possible to define a problem where there is no relationship between input $x$ and output $y$. In general, if the mutual information between $x$ and $y$ is zero (i.e. $x$ and $y$ are statistically independent) then the best prediction you can do is independent of $x$. The task of machine learning is to learn a distribution $q(y|x)$ that is as close as possible to the real data generating distribution $p(y|x)$.

For example, looking at the common cross-entropy loss, we have
$$
\begin{align}
H(p,q) = -\mathbb{E}\_{y,x \sim p}\left[\log q(y|x)\right] & = \mathbb{E}\_{x\sim p}\left[\text{H}(p(y|x)) + \text{D}\_{\text{KL}}(p(y|x)\|q(y|x))\right] \\
& = \text{H}(p(y)) + \mathbb{E}\_{x \sim p}\left[\text{D}\_{\text{KL}}(p(y)\|q(y|x))\right],
\end{align}
$$
where we have used the fact that $p(y|x)=p(y)$ since $y$ and $x$ are independent. From this, we can see that the optimal predicted distribution $q(y|x)$ is equal to $p(y)$, and actually independent of $x$. Also, the best loss you can get is equal to the entropy of $y$.
Upvotes: 3 [selected_answer]


<issue_start>username_0: What does the term **"easy negatives"** exactly mean in the context of machine learning for a classification problem or any problem in general?

From a quick google search, I think it means just negative examples in the training set.

Can someone please elaborate a bit more on why the term "easy" is brought into the picture?

Below, there is a screenshot taken from [the paper](https://openaccess.thecvf.com/content_ICCV_2017/papers/Lin_Focal_Loss_for_ICCV_2017_paper.pdf) where I found this term, which is underlined.

[![enter image description here](https://i.stack.imgur.com/oLl7m.jpg)](https://i.stack.imgur.com/oLl7m.jpg)<issue_comment>username_1: OK, I think I understood what this means.

Hard and easy negatives are the ones that have relatively large and small values for the loss function, respectively.
Upvotes: 1 <issue_comment>username_2: It refers to samples that are very easy for the model to classify. If you are interested in the positive class, having many easy negatives could produce misleading results as your model could really struggle to classify not-so-easy samples.

---

In a very hypothetical situation, imagine you are trying to classify brain scan images based on whether they show signs of a tumor or not. For the negative class, say you have a bunch of normal brain scans that have no tumor, but also a bunch of plain images, all black with nothing on them (you wouldn't have that, but let's imagine). For the positive class you got normal brain images with tumors.
If you train a model, it might just learn that plain black pictures have no tumors, which is in fact true. Since half of your negative data have this kind of picture, the model could be virtually performing with a kinda-good accuracy but it would not be learning the actual problem.
Upvotes: 0


<issue_start>username_0: I have been trying to solve the OpenAI lunar lander game with a DQN taken from this paper

<https://arxiv.org/pdf/2006.04938v2.pdf>

The issue is that it takes 12 hours to train 50 episodes so something must be wrong.

```
import os
import random
import gym
import numpy as np
from collections import deque
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.optimizers import Adam
from tensorflow.keras import Model

ENV_NAME = "LunarLander-v2"

DISCOUNT_FACTOR = 0.9
LEARNING_RATE = 0.001

MEMORY_SIZE = 2000
TRAIN_START = 1000
BATCH_SIZE = 24

EXPLORATION_MAX = 1.0
EXPLORATION_MIN = 0.01
EXPLORATION_DECAY = 0.99

class MyModel(Model):
    def __init__(self, input_size, output_size):
        super(MyModel, self).__init__()
        self.d1 = Dense(128, input_shape=(input_size,), activation="relu")
        self.d2 = Dense(128, activation="relu")
        self.d3 = Dense(output_size, activation="linear")

    def call(self, x):
        x = self.d1(x)
        x = self.d2(x)
        return self.d3(x)

class DQNSolver():

    def __init__(self, observation_space, action_space):
        self.exploration_rate = EXPLORATION_MAX

        self.action_space = action_space
        self.memory = deque(maxlen=MEMORY_SIZE)

        self.model = MyModel(observation_space,action_space)
        self.model.compile(loss="mse", optimizer=Adam(lr=LEARNING_RATE))

    def remember(self, state, action, reward, next_state, done):
        self.memory.append((state, action, reward, next_state, done))

    def act(self, state):
        if np.random.rand() < self.exploration_rate:
            return random.randrange(self.action_space)
        q_values = self.model.predict(state)
        return np.argmax(q_values[0])

    def experience_replay(self):
        if len(self.memory) < BATCH_SIZE:
            return
        batch = random.sample(self.memory, BATCH_SIZE)
        state_batch, q_values_batch = [], []
        for state, action, reward, state_next, terminal in batch:
            # q-value prediction for a given state
            q_values_cs = self.model.predict(state)
            # target q-value
            max_q_value_ns = np.amax(self.model.predict(state_next)[0])
            # correction on the Q value for the action used
            if terminal:
                q_values_cs[0][action] = reward
            else:
                q_values_cs[0][action] = reward + DISCOUNT_FACTOR * max_q_value_ns
            state_batch.append(state[0])
            q_values_batch.append(q_values_cs[0])
        # train the Q network
        self.model.fit(np.array(state_batch),
                        np.array(q_values_batch),
                        batch_size = BATCH_SIZE,
                        epochs = 1, verbose = 0)
        self.exploration_rate *= EXPLORATION_DECAY
        self.exploration_rate = max(EXPLORATION_MIN, self.exploration_rate)

def lunar_lander():
    env = gym.make(ENV_NAME)
    observation_space = env.observation_space.shape[0]
    action_space = env.action_space.n
    dqn_solver = DQNSolver(observation_space, action_space)
    episode = 0
    print("Running")
    while True:
        episode += 1
        state = env.reset()
        state = np.reshape(state, [1, observation_space])
        scores = []
        score = 0
        while True:
            action = dqn_solver.act(state)
            state_next, reward, terminal, _ = env.step(action)
            state_next = np.reshape(state_next, [1, observation_space])
            dqn_solver.remember(state, action, reward, state_next, terminal)
            dqn_solver.experience_replay()
            state = state_next
            score += reward
            if terminal:
                print("Episode: " + str(episode) + ", exploration: " + str(dqn_solver.exploration_rate) + ", score: " + str(score))
                scores.append(score)
                break
        if np.mean(scores[-min(100, len(scores)):]) >= 195:
            print("Problem is solved in {} episodes.".format(episode))
            break
    env.close
if __name__ == "__main__":
    lunar_lander()

```

Here are the logs

```
root@b11438e3d3e8:~# /usr/bin/python3 /root/test.py
2021-01-03 13:42:38.055593: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2021-01-03 13:42:39.338231: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1
2021-01-03 13:42:39.368192: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-01-03 13:42:39.368693: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1080 computeCapability: 6.1
coreClock: 1.8095GHz coreCount: 20 deviceMemorySize: 7.92GiB deviceMemoryBandwidth: 298.32GiB/s
2021-01-03 13:42:39.368729: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2021-01-03 13:42:39.370269: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
2021-01-03 13:42:39.371430: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
2021-01-03 13:42:39.371704: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
2021-01-03 13:42:39.373318: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
2021-01-03 13:42:39.374243: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10
2021-01-03 13:42:39.377939: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7
2021-01-03 13:42:39.378118: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-01-03 13:42:39.378702: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-01-03 13:42:39.379127: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] Adding visible gpu devices: 0
2021-01-03 13:42:39.386525: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 3411185000 Hz
2021-01-03 13:42:39.386867: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4fb44c0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2021-01-03 13:42:39.386891: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2021-01-03 13:42:39.498097: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-01-03 13:42:39.498786: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4fdf030 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2021-01-03 13:42:39.498814: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): GeForce GTX 1080, Compute Capability 6.1
2021-01-03 13:42:39.498987: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-01-03 13:42:39.499416: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1080 computeCapability: 6.1
coreClock: 1.8095GHz coreCount: 20 deviceMemorySize: 7.92GiB deviceMemoryBandwidth: 298.32GiB/s
2021-01-03 13:42:39.499448: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2021-01-03 13:42:39.499483: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
2021-01-03 13:42:39.499504: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
2021-01-03 13:42:39.499523: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
2021-01-03 13:42:39.499543: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
2021-01-03 13:42:39.499562: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10
2021-01-03 13:42:39.499581: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7
2021-01-03 13:42:39.499643: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-01-03 13:42:39.500113: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-01-03 13:42:39.500730: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] Adding visible gpu devices: 0
2021-01-03 13:42:39.500772: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2021-01-03 13:42:39.915228: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-01-03 13:42:39.915298: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]      0
2021-01-03 13:42:39.915322: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 0:   N
2021-01-03 13:42:39.915568: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-01-03 13:42:39.916104: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2021-01-03 13:42:39.916555: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1402] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6668 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1)
Running
2021-01-03 13:42:40.267699: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10

```

This is the GPU stats

```
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.66       Driver Version: 450.66       CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    Off  | 00000000:01:00.0  On |                  N/A |
|  0%   53C    P2    46W / 198W |   7718MiB /  8111MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

```

As you can see, TensorFlow does not compute on the GPU but reserves the memory so I'm assuming it's because the inputs of the neural networks are too small and it uses the CPU instead.

To make sure the GPU was installed properly, I ran a sample from their documentation and it uses the GPU.

Is it an issue with the algorithm or the code? Is there a way to utilize the GPU in this case?

Thanks!<issue_comment>username_1: When it comes to GPU usage,

```
nvidia-smi

```

shows the usage at the time it was executed. You should try running

```
watch -n0.01 nvidia-smi

```

to see the usage of GPU every 0.01 second.
It should output some small usage for current model, like 5%. You could try to increase you model, to e.g.

```
self.d1 = Dense(1024, input_shape=(input_size,), activation="relu")
self.d2 = Dense(1024, activation="relu")
self.d3 = Dense(output_size, activation="linear")

```

to see if the usage of GPU increased.
Upvotes: 1 <issue_comment>username_2: Is it training at all? Or is agent performance not improving over time? Q learning can be pretty unstable. I would recommend logging the sum of rewards received by the agent at the end of each episode and the model loss to help in the debugging process. The sum of rewards will show you if the agent is improving over time and the model loss will give you a rough idea about how stable the convergence is. I would recommend using tensorboard to log these metrics (<https://www.tensorflow.org/tensorboard/get_started#using_tensorboard_with_other_methods>). You will be able to monitor these metrics throughout the training process. You could also just print these metrics at the end of every epoch and monitor them in your console. You really just need someway to see what's going on during training.

In the paper you linked, it also mentioned double q learning, which in your code does not seem to be implemented. Vanilla q learning can have a reputation of being overoptimistic in the values that it assigns to states. This results in compounding approximation errors, which tend to destabilize learning. Using double q learning may help speed up convergence. If you need help with double q learning check out this paper: <https://arxiv.org/pdf/1509.06461.pdf>, and this github page: <https://github.com/jihoonerd/Deep-Reinforcement-Learning-with-Double-Q-learning/blob/master/ddqn/agent/ddqn_agent.py>

If you use double q learning, you may have to write your own custom training loop. This can be achieved by using the gradient tape object. Make sure to wrap this new function in a tf.function decorator. This will tell the TensorFlow back-end to compile that bit of code, making it run faster (<https://www.tensorflow.org/guide/function>). There are also some handy speed up tips in this post (<https://www.tensorflow.org/tutorials/reinforcement_learning/actor_critic>). They even wrap the environment step functions in tf.functions.The article uses actor-critic, which is a combination of policy gradient and q learning techniques, but you can swap out their neural network update code with the q learning functionality that you need.

If you need help with double q learning check out this paper: <https://arxiv.org/pdf/1509.06461.pdf>, and this github page: <https://github.com/jihoonerd/Deep-Reinforcement-Learning-with-Double-Q-learning/blob/master/ddqn/agent/ddqn_agent.py>
Upvotes: 2


<issue_start>username_0: I understand that seq2seq models are perfectly suitable when the input and/or the output have variable lengths. However, if we know exactly the input/output sequence lengths of the neural network. Is this the best approach?<issue_comment>username_1: If you would classify a transformer as Seq2Seq, then it is arguably the best. This is only arguably due to accuracy.

Shallow neural networks or even decision trees and forests may be better in production due to lower training time, lower inference time and smaller size in memory.

Overall, it requires a bit of a compromise, and you need to do what suits your use case. For example you wouldn't run GPT-3 on a raspberry pi pico (for example). So it depends on what you mean by "best".
Upvotes: 0 <issue_comment>username_2: I often see this type of question about finding the “best” model. Perhaps the best approach would be to use a sample or even better a toy dataset similar for the kind of problem you are solving and use an AutoML tool such as PyCaret or Darts to evaluate several/many different models to narrow the choices then experiment further. It would at least be a more scientific approach IMO
Upvotes: -1


<issue_start>username_0: I have heard the following argument being made regarding Neural Networks:

* A Neural Network is a composition of several Activation Functions
* Sigmoid Activation Functions are Non-Convex Functions
* The composition of Non-Convex Functions can produce a Non-Convex Function
* Thus, Loss Functions for Neural Networks that contain several Sigmoid Activation Functions can be Non-Convex

Using the R programming language, I plotted the second derivative of the Sigmoid Function and we can see that it fails the Convexity Test (i.e. the second derivative can take both positive and negative values):

```
e = 2.718

eq = function(x){ (-e^-x)* (1+e^-x)^-2  + (e^-x)*(-2*(1+e^-x)^-3 *(-e^-x))}

plot(eq(-100:100), type='l', main = "Plot of Second Derivative of the Sigmoid Function")

```

[![enter image description here](https://i.stack.imgur.com/LGeum.png)](https://i.stack.imgur.com/LGeum.png)

**My Question:** (If the above argument is in fact true) Can the same argument be extended to lack of Convexity of Loss Functions of Neural Networks containing several "RELU Activation Functions" ?

* On it's own, the ReLU function is said to be Convex.
* Mathematically, we can show that compositions of Convex Functions can only produce a Convex Function.

However, Neural Networks that contain compositions of (only) ReLU Activation functions make it **unclear to me how a Loss Functions that contains (only) "RELU Activation Functions" would a Non-Convex.**

[![enter image description here](https://i.stack.imgur.com/0U2jb.png)](https://i.stack.imgur.com/0U2jb.png)

Can someone please comment on this? **If compositions of Convex Functions can only produce Convex Functions - does this mean that the Loss Function of a Neural Network containing only containing ReLU Activation Functions can never be Non-Convex?**

Thanks!

* **References:**

<https://ml-cheatsheet.readthedocs.io/en/latest/activation_functions.html>

**Note:** Using some informal logic, I do not think that the Loss Functions of Neural Networks containing RELU Activation Functions are generally Convex. This is because RELU (style) Activation Functions are generally some of the most common types of activation functions being used - yet the same difficulties concerning mon-convex optimization still remain. Thus, I would like to think that Neural Networks with RELU Activation Functions are still generally non-convex.<issue_comment>username_1: You're missing a couple of quite important concepts:

* [Universal approximation theorem](https://en.wikipedia.org/wiki/Universal_approximation_theorem): with enough parameters a neural network can approximate any function.
* Basically every loss function is non convex. (There is this little problem in machine learning call local minima about which we like to complain a lot :) )

But no need to trust me, just run a simple experiment and try yourself to approximate a non convex function, like **$sin(x)$** with relu:

```
from sklearn.neural_network import MLPRegressor
import numpy as np
import matplotlib.pyplot as plt

f = lambda x: [[x_] for x_ in x]
noise_level = 0.1
X_train_ = np.arange(0, 10, 0.2)
real_sin = np.sin(X_train_)
y_train = real_sin + np.random.normal(0, noise_level, len(X_train_))
nodes = 1000
layers = 10
regr = MLPRegressor(hidden_layer_sizes=tuple([nodes] * 4), activation="relu").fit(f(X_train_), y_train)
predicted_sin = regr.predict(f(X_train_))

plt.plot(X_train_, real_sin, label="sin target")
plt.plot(X_train_, predicted_sin, label="sin predicted")
plt.legend()
plt.show()

```

You'll see it's not a task too hard to learn:

[![enter image description here](https://i.stack.imgur.com/5iVv7.png)](https://i.stack.imgur.com/5iVv7.png)

PS: of course this is just of a toy example, and if you decrease layers and amount of hidden units the results will become crap, but it still proves that activation surely affects, but not constrain the non linearity of the final function learned by a neural network.
Upvotes: 2 <issue_comment>username_2: I think you are asking about Fully Input Convex Neural Networks as proposed in [1].
ReLU is in fact a convex function, and the sum of convex functions can only produce convex functions. However, unlike you said, composition of convex functions can produce non-convex functions, unless they are non-decreasing.
With FICNNs you can only learn convex functions. For that all weights W must be non-negative for the activation function g

From [1] the interesting part is:

>
> The function f is convex in y provided that
> all $W\_i(z)\_{1:k}$ are non-negative, and all functions $g\_i$ are convex and non-decreasing.
> The proof is simple and follows from the fact that non-negative sums of convex functions are also convex and that
> the composition of a convex and convex non-decreasing
> function is also convex (see e.g. Boyd & Vandenberghe
> (2004, 3.2.4)).
>
>
>

[1] Amos, Brandon, <NAME>, and <NAME>. "Input convex neural networks." International Conference on Machine Learning. PMLR, 2017.
Upvotes: 1


<issue_start>username_0: [![enter image description here](https://i.stack.imgur.com/uAwNX.png)](https://i.stack.imgur.com/uAwNX.png)

What does this difference in train and test accuracy mean?<issue_comment>username_1: For the Logistic Regression Classifier and SVC, the `train_accuracy` and `test_accuracy` are very similar; thus, there is no evidence for over or under fitting. However, the KNN, shows a `train_accuracy` that is lower than your `test_accuracy`, which *suggests* overfitting. Alternatively, depending on your sample size, it is entirely possible that this variation is within the expected range of error.

In machine learning, the model is trained on one dataset (i.e., the **training data**), but performing model evaluation (i.e., estimate "real world" performance by calculating `accuracy` or some other metric) on the same dataset that you trained on would be biased. Instead, the evaluation is performed on an independent identically distributed dataset (i.e. the **test data**) to get an unbiased estimate of model performance. However, it is still important to compare accuracy (or whatever performance metric you choose) between training and testing to assess for over- or underfitting.

**Overfitting** means that your model "fit" the training data very well and achieves high accuracy on that data. However, the model performs poorly (or less well) on the test data. This is because the model not only "fits" the signal in the training data but also the noise. The problem is that noise is random and it will surely be different in the test set. Therefore, the model doesn't generalize well to other datasets.

**Underfitting** means that the model performs poorly on both datasets. This is typically because the model does not have the "expressivity" or "capacity" to learn the signals within the data or that the data is random and has no "signal" to speak of (and, therefore, nothing from which to learn).
Upvotes: 0 <issue_comment>username_2: Actually, in the strict sense, you cannot decide overfitting here, because overfitting is tested using losses, not metrics like accuracy.
Upvotes: -1


<issue_start>username_0: All the prompt engineering techniques I've seen seem to focus on telling the model what to do e.g. Few-Shot Prompting.

Is there any value in giving the model examples of what not to do? Can you link me to any papers/techniques on the topic?

Example

I am building a bot to improve students' foreign language writing skills.

Bad output: Corrected spelling of 'heisse' to 'heiße' because 'heiße' is the correct spelling in German.

Better output: Corrected spelling of 'heisse' to 'heiße' because 'ss' can be combined to form 'ß' in German.
I could solve this specific problem using few-shot prompting. But really, I want to tell the model "don't give answers like 'this is how it is done in German', instead explain what is being done and the reasons for it".

I may have answered my own question there... just put it what I said above in the system prompt?<issue_comment>username_1: ### If you want determinism make sure you program it in

A machine learning model will be deterministic to the same extent as any other computer program.
It is entirely based the stability of the inputs you put into it.

If you initialse a network to random weights you have potentially introduced some non-determinism. You can get it back by using a known seed and a known random number generator (library behavior can be system dependendent.

Likewise if you put the same input data in you should get the same results.

I suspect this is not the question were asking or the answer you were looking for so...

### Consider the fitness landscape for the problem

A learning system is trying to find a good solution to a problem.
For example you are trying to minimise the error between the output of your model and actual results.

The complete space of possible solutions gives you a fitness or energy landscape.
Your learning is trying to navigate this to find solutions and avoid local minima.

So if you now add noise to this system. Use a different subset of the possible input data, different initial weights or a different learning algorithm the fitness landscape is still broadly the same so you should get a similar answer.

If you change things too much of course this is no longer the case.

Maybe a interesting set of input data adds a new peak or trough to the landscape.

Maybe a tweak to your learning algorithm enables it to escape a particular kind of local minimum or get trapped in another.

This is probably more the answer you were looking for.

It terms of a theorhetical model they probably exist but require a lot of maths and good citations which others may be able to provide.
Upvotes: 2 <issue_comment>username_2: There's [this paper](https://arxiv.org/pdf/2109.08203.pdf) on the efficacy of random initialization on model performance:

>
> The conclusions are that even if the variance is not very
> large, it is surprisingly easy to find an outlier that performs much better or much worse than the average.
>
>
>

Part of what you said also reminds me of the [lottery ticket hypothesis](https://arxiv.org/pdf/1803.03635.pdf), motivated by the idea that you can prune a large portion of a NN's parameters while keeping the same accuracy, but resulting sparse architecture is difficult to train from scratch. The idea is that certain subnetworks in a NN may happen to be initialized s.t. they are particularly effective for some task.
Upvotes: 1


<issue_start>username_0: **Thank you for your confidence in our abilities!** But have you read the [Android Enthusiasts FAQ](https://android.stackexchange.com/faq)?

This site is primarily a source to help people **use** their Android devices, whether it's an issue with hardware, software, a particular app, or even rooting. However, we get some other questions that don't fit here.

Yes, someone here might be able to help you, but you'll find that other forums and sites more focused on your topic can give you a much better answer than a bunch of Android geeks. It's likely that your question will be downvoted, closed, and in some cases marked "offensive." It's not that we hate you, it's just that we are trying to maintain the site's focus for maximum usability.

What forums can people go to to ask the questions that are off topic here? (Please list only **one** forum per answer so votes can bring the best forums to the top.)

Some potential topics might be:

* shopping recommendations
* phone hardware comparisons
* moderation support
* news blogs
* and so on

**Questions about programming issues with Android belong on [Stack Overflow](http://www.stackoverflow.com/questions/tagged/android).**<issue_comment>username_1: [Android and Me](http://androidandme.com/)
------------------------------------------

News blog.
Upvotes: 2 <issue_comment>username_1: [Android Arena](http://www.androidarena.com/)
---------------------------------------------

News blog.
Upvotes: 1 <issue_comment>username_1: [Android Central](http://www.androidcentral.com/)
-------------------------------------------------

News blog and discussion forums. Here you can:

* check for [Android Accessories](http://forums.androidcentral.com/android-accessories/) (hint: Shopping recommendations seem to be on-topic here)
* participate in [Carrier Discussion](http://forums.androidcentral.com/carrier-discussion/)
* discuss [Android Developers](http://forums.androidcentral.com/android-developers/) issues
Upvotes: 3 <issue_comment>username_1: [Android Community](http://androidcommunity.com/)
-------------------------------------------------

News blog, reviews, discussion forums, videos.
Upvotes: 2 <issue_comment>username_1: [AndroidSPIN](http://androidspin.com/)
--------------------------------------

News, discussion, app finder, phones and accessories store. Discussion forums cover the following areas (among others):

* [Carriers](http://forum.androidspin.com/forumdisplay.php/1406-Carriers)
* [Android Customization and Development](http://forum.androidspin.com/forumdisplay.php/1404-Android-Customization-and-Development)
* [Android Software](http://forum.androidspin.com/forumdisplay.php/1401-Android-Software)
* several device-specific areas, including device-specific development
* [AndroidSPIN Marketplace](http://forum.androidspin.com/forumdisplay.php/1405-AndroidSPIN-Marketplace) to obtain/sell devices
Upvotes: 2 <issue_comment>username_1: [Android Tapp](http://www.androidtapp.com/)
-------------------------------------------

App reviews, dev interviews, news.
Upvotes: 1 <issue_comment>username_1: [Droid Gamers](http://droidgamers.com/)
---------------------------------------

Android game reviews and news. Discussion forums.
Upvotes: 2 <issue_comment>username_1: [Droid Life](http://www.droid-life.com/about/)
----------------------------------------------

Focused on the Droid family, but offers general Android news and information as well. Also reviews of apps and accessories.
Upvotes: 2 <issue_comment>username_2: [Our Chatroom](http://chat.stackexchange.com/)
----------------------------------------------

Anything Android related, really.
Upvotes: 5 <issue_comment>username_1: [Phandroid](http://phandroid.com/)
----------------------------------

News blog and podcast. See news for individual carriers, manufacturers, phones, or apps. Also [discussion forums](http://androidforums.com/):

* find [Android accessories](http://androidforums.com/android-accessories/) (shopping recommendations seem to be on-topic here)
* discussions on [Android Development](http://androidforums.com/android-development/)
* [Android Carriers](http://androidforums.com/android-carriers/) (mentioned in our FAQ as *Android-independent phone questions, such as "Does Carrier X have prepaid plans?"*)
Upvotes: 2 <issue_comment>username_2: [XDA-developers](http://forum.xda-developers.com)
-------------------------------------------------

Large development community with plenty of space for users and devs alike to talk about anything Android. Sub-forums for specific devices. **Beware the trolls!**

* [App Development Forums](http://forum.xda-developers.com/forumdisplay.php?f=2188) (Development tools, marketing, monetization) This e.g. explicitly includes *Issues with the Android Market from the point of view of a developer or publisher* and *Marketing your Android app*, which are off-topic at Android Enthusiasts
* [Android Development and Hacking](http://forum.xda-developers.com/forumdisplay.php?f=564)
* Several device-specific development areas
Upvotes: 6 <issue_comment>username_3: [Android Developers Forums](http://developer.android.com/resources/community-groups.html)
-----------------------------------------------------------------------------------------

List of different groups or forums for discussing development questions.
Upvotes: 3 <issue_comment>username_3: [Anddev.org](http://www.anddev.org/)
------------------------------------

Help with Android development and plenty of tutorials
Upvotes: 3 <issue_comment>username_4: [Reddit's Android Community](http://www.reddit.com/r/android+androidappreviews+androidapps+androiddev+nexusone+androidisawesome+androidquestions+htcevo+Galaxy_S+droid+htcdesire+androidthemes+htchero+redwall)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Links and discussions for all things Android.
Upvotes: 4 <issue_comment>username_2: [Stack Overflow](https://stackoverflow.com/)
============================================

For programming questions, including ones that just happen to be Android-related.
Upvotes: 5 <issue_comment>username_2: [Super User](https://superuser.com/)
====================================

For questions about non-Android technology use. For example, "What's required for a computer to be able to receive video over DLNA from my Android phone?" is really a question about computers, not Android, and should be on SuperUser. If you have a DLNA card and appropriate PC software and can't get your phone to broadcast, however, Android Enthusiasts is a great place to ask a question about that.
Upvotes: 4 <issue_comment>username_5: [Google](http://www.google.com)
-------------------------------

Sometimes a little Google-fu is all you need to solve your problem.
Upvotes: 4 <issue_comment>username_1: [IT Security](https://security.stackexchange.com/questions/tagged/android)
--------------------------------------------------------------------------

One of our very own Stack Exchange sites. It has quite a few questions tagged "[android](https://security.stackexchange.com/questions/tagged/android)".
Upvotes: 3 <issue_comment>username_1: [User Experience](https://ux.stackexchange.com/questions/tagged/android)
------------------------------------------------------------------------

A Stack Exchange site for issues regarding user experience and interface design. It has quite a few questions tagged "[android](https://ux.stackexchange.com/questions/tagged/android)".
Upvotes: 2 <issue_comment>username_1: [Software Engineering](https://softwareengineering.stackexchange.com/questions/tagged/android)
----------------------------------------------------------------------------------------------

>
> Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. If you have a question about...
>
>
> * software development methods and practices
> * requirements, architecture, and design
> * quality assurance and testing
> * configuration management, build, release, and deployment
>
>
> ...then you're *probably* in the right place to ask your question.
>
>
>
Upvotes: 3 <issue_comment>username_6: [AndroidPIT](http://www.androidpit.com/)
----------------------------------------

News Blog, Forums (including device-specific and developer areas), App-Reviews, it even has its own [App Center](http://www.androidpit.de/de/android-market) where reviews are linked to the apps, and more.

* Development: [EN](http://www.androidpit.com/en/android/forum/category/1004000/Android-Developer-Forum) | [DE](http://www.androidpit.de/de/android/forum/category/4000/Android-Developer-Forum)
* Hardware search/shopping recommendations: [EN](http://www.androidpit.com/en/android/forum/category/1005020/) | [DE](http://www.androidpit.de/de/android/forum/category/2002927/)
* phone tariffs/data plans of different providers: [DE](http://www.androidpit.de/de/android/forum/category/2003257/Tarife-Forum)
Upvotes: 1 <issue_comment>username_7: [Android tag on Quora](https://www.quora.com/Android-OS)
--------------------------------------------------------

You can ask anything Android related here. Unlike SE sites, subjective questions are welcomed here. Though you'll most likely get opinions, not solutions there.
Upvotes: 1 <issue_comment>username_1: [PhoneRocket](http://phonerocket.com/)
--------------------------------------

Not a discussion forum per se, the site offers comparisons of different smartphones.

>
> The site scores smartphones based on aggregated reviews, benchmarks, and specs. PhoneRocket also offers some common phone comparisons (Galaxy S4 vs. iPhone 5 and Galaxy S4 vs. HTC One, for example), and the ability to pit any two phones against each other.
>
>
>
Upvotes: 1 <issue_comment>username_8: [Android Police](http://www.androidpolice.com/)
-----------------------------------------------

Android news, app reviews, firmware updates, sharing tips, tricks, tutorials, videos and podcasts, device reviews, info about custom ROMs and hacks.
Upvotes: 2 <issue_comment>username_8: [GSM Arena](http://www.gsmarena.com/)
-------------------------------------

Android news, Android tech blog, device reviews, device tech specs and pictures, device estimated prices, device comparison, device rankings, device search based on user requested features, rumored devices.
Upvotes: 2 <issue_comment>username_6: [Software Recommendations](https://softwarerecs.meta.stackexchange.com/q/336/185)
---------------------------------------------------------------------------------

This is one of our newer sister-sites, dedicated to software recommendations (aka "Is there an app for X?"). Please read the linked article before posting there to not have your question closed straight away, as it needs to meet certain criteria to be accepted.
Upvotes: 4 <issue_comment>username_9: [Unix & Linux](https://unix.stackexchange.com/)
-----------------------------------------------

Another Stack Exchange site specific to Linux and Unix. They do say that [most question about Android are off-topic](https://unix.meta.stackexchange.com/questions/103/are-android-questions-on-topic) (because they belong either at StackOverflow, or Here) but if the questions actually relate to the "\*nix" part of Android, they are on-topic. I have also seen quite a [few "compiling android" questions](https://unix.stackexchange.com/search?q=compile+android) there as well. So *Custom ROM Development* may be able to be asked there.
Upvotes: 2 <issue_comment>username_10: [Android Authority](http://www.androidauthority.com/)
-----------------------------------------------------

You can ask question on the [Q&A page](http://www.androidauthority.com/qa/ask)

**Other Features**:

Forum, Security, Development, Reviews, News, Interviews, Debates, Opinions etc
Upvotes: 1 <issue_comment>username_2: [Hardware Recommendations](https://hardwarerecs.stackexchange.com/)
===================================================================

Similar to Software Recommendations, but for hardware. Please note that they expect questions to be [specific and clear](https://hardwarerecs.meta.stackexchange.com/q/205/944) — you should read their [FAQ](https://hardwarerecs.stackexchange.com/help/asking) and [other guidance](https://hardwarerecs.meta.stackexchange.com/) before posting.
Upvotes: 3


<issue_start>username_0: A publicly downloadable version of the [Bluestacks Android app player](http://bluestacks.com/download.html) has recently been released for Windows. Should we accept questions related to using Bluestacks here?

On the one hand, it's not a full Android environment (no home screen, settings menu, that kind of stuff). On the other hand, it appears to be running an emulator instance under-the-hood, so you can, for example, interact with Bluestacks using `adb` and so forth.<issue_comment>username_1: Emulator questions are on-topic, as are questions about android-x86, so I don't see why this wouldn't be.

It may be too early to tell.
Upvotes: 4 [selected_answer]<issue_comment>username_2: I think the conclusions we came to about the official emulator apply here: [Questions that are on the fence between development and power use](https://android.meta.stackexchange.com/questions/199/questions-that-are-on-the-fence-between-development-and-power-use)

In short, I think we should support end-user questions about it. I think this would extend to installation troubles as well, just like we do with drivers, rather than pushing them to Super User. As Al notes, we can wait and see exactly where we feel the line should be.

Dev uses of this player should be off-topic, of course.
Upvotes: 2


<issue_start>username_0: How do I go about rooting my Samsung Spica?<issue_comment>username_1: The main reference resource site for modders and "cookers" of **Samsung Spica aka i5700** is at Samdroid forum board, [here](http://forum.samdroid.net/#samsung-spica-i5700-android-phone).

It contains all information you need to upgrade your firmware version, [root your phone](http://forum.samdroid.net/f28/spica-v-lk2-02-root-recovery-apps2sd-busybox-wifi-tether-etc-04-15-2010-en-624/), etc.
Upvotes: 3 [selected_answer]<issue_comment>username_2: This rooting tutorial is much easier to follow than Samdroid's (it still uses Samdroid's method, but the tutorial is much less terse and have pictures): <http://www.addictivetips.com/mobile/root-samsung-galaxy-spica-i5700-with-leshaks-kernel/>
Upvotes: 1


<issue_start>username_0: How do you do Google talk voice and video calling from android.

The google talk application only appears to allow text based chatting. But Google talk on the desktop supports both voice calling and video chat.<issue_comment>username_1: There is no official Google talk voice/video chat for Android phones. You can use Google Talk in Android 2.3.4+ to make video chats now. Additionally, any calls made via Google Voice are done via cell tower (using your minutes), not data.
Upvotes: 4 [selected_answer]<issue_comment>username_2: Sorry to bump an old question, but you can now make both audio and video calls from android with google talk if you have 2.3.4 (gingerbread) or higher.
[1](http://www.gsmarena.com/google_talk_update_brings_video_chat_to_your_android_device-news-2577.php)
Upvotes: 2


<issue_start>username_0: How can I see the title ~~alt~~ text for website images on an HTC Desire?

I'm currently using the Dolphin HD browser but I can't see a way of getting the alt text.<issue_comment>username_1: Good question. I don't see an obvious way to do that to solve your problem on all websites. However, there just so happens to be a few xkcd viewer apps. I use [this one](https://play.google.com/store/apps/details?id=net.bytten.xkcdviewer&hl=en) which has a menu > hover text option.

**EDIT:**
This seems like a reasonable thing to try for link hover text, but it does not work for me on the default HTC Incredible browser:

>
> 1. Tap any white empty space near to the link you want to hover over.
> 2. Now move your trackball up/down until it selects the link. Don’t click it.
> 3. There! The tooltip now appears. Simple solution. :)
>
>
>

I saw this suggested [here](http://nitendra.com/blog/2010/05/mouseover-hover-tootltipin-android-browser/).
Upvotes: 5 [selected_answer]<issue_comment>username_2: Download XKCD viewer app in the android market. You can then tap on the comic to bring up the hover text.
Upvotes: 0 <issue_comment>username_3: The right answer is to just go to <http://m.xkcd.com>. There is a link on there to show or hide the alt text.
Upvotes: 5 <issue_comment>username_4: Be an activist and upvote the [defect here](http://code.google.com/p/android/issues/detail?id=5836)! Though that's a longer term answer. :)
Upvotes: 4 <issue_comment>username_5: I created a bookmarklet for this:

```
javascript:(function(){var D=document,i,f,j,e;for(i=0;f=D.images[i];++i)if(f.title!=""){var x=D.createElement("div"),s=x.style;s.color="Black ";s.background="yellow ";x.innerHTML=f.title;f.parentNode.insertBefore(x,f.nextSibling);}})();

```

This displays any TITLE texts as text with yellow background.
Upvotes: 2


<issue_start>username_0: Some friends told me that their Android phones have very little (<100MB) available memory for regular apps, because the OS and some un-killable services take most of the RAM. For example, one phone with 512MB only shows 90MB available memory, so only 2-3 apps can run at the same time.

I'm wondering if creating a swap partition/file will help, but I saw mixed opinions all over the web and I'm not sure what to do. Here are my questions:

(1) Will there be many not-oftenly-used memory pages to swap out, especially in OS and those un-killable services?

(2) How will swapping out small memory pages hurt flash memory life span? Does the flash (or SD card?) do wear-leveling automatically?

(3) Will swapping really help performance when running multiple apps? I assume if the answer to (1) is yes, it will.

(4) Will writing to flash be too slow and thus hurt responsiveness when swapping happens?

(5) Is it true that Android keeps the swapping mechanism from the Linux kernel, so as long as there is a swapping partition/file, it will do swapping without extra configuration?

Thanks for reading.<issue_comment>username_1: I don't think there will be much benefit with swapping for Android, as the Android Application Life Cycle is a much more advanced form of swapping.

>
> (1) Will there be many
>  not-oftenly-used memory pages to swap
>  out, especially in OS and those
>  un-killable services?
>
>
>

You can't swap the OS kernel even in Desktop Linux and Android already kills services when it needs more RAM. If your device vendor persists that you have to have useless services running all the time, then root your device.

>
> (2) How will swapping out small memory
>  pages hurt flash memory life span?
>  Does the flash (or SD card?) do
>  wear-leveling automatically?
>
>
>

Even if the SD-card does wear-leveling, swapping will hurt quite a lot.

>
> (3) Will swapping really help
>  performance when running multiple
>  apps? I assume if the answer to (1) is
>  yes, it will.
>
>
>

Not in the context of Android. Unlike traditional OS that will keep trying to chug in processes as you requested it, Android will Force Kill older, unused processes and reclaims their memory; this killing is fast as applications will already save their state when you task switch.

>
> (4) Will writing to flash be too slow
>  and thus hurt responsiveness when
>  swapping happens?
>
>
>

Probably, probably not. Will need benchmarks for that.

>
> (5) Is it true that Android keeps the
>  swapping mechanism from the Linux
>  kernel, so as long as there is a
>  swapping partition/file, it will do
>  swapping without extra configuration?
>
>
>

I don't know whether Android keeps the swapping mechanism, but even if it does (or if you compile your own kernel), you will still need some configurations. It's usually just having an `fstab` file that points to the swap file and doing `swapon -a`.

In fact I have reasons why swapping may actually hurt performance: it prevents Application Life Cycle, Android's memory management scheme, to work correctly.
Upvotes: 4 [selected_answer]<issue_comment>username_2: There is definitely a benefit to swapping, despite what everyone else on the Internet will tell you. Try it and see for yourself. Empirically, on a G1 or other phone with low memory, swap makes the phone run better and faster.

Yes, Android has Life Cycle "task management" built in, but it's not very good. It [routinely kills processes](http://android-developers.blogspot.com/2010/04/multitasking-android-way.html) when it runs out of memory, and the apps are expected to save their state using "[Bundles](http://blog.rlove.org/2010/04/why-ipad-and-iphone-dont-support.html)" so that when you restart them, they restart in the same state they were last in.

>
> Once Android determines that it needs to remove a process, it does this brutally, simply force-killing it. The kernel can then immediately reclaim all resources needed by the process, without relying on that application being well written and responsive to a polite request to exit. Allowing the kernel to immediately reclaim application resources makes it a lot easier to avoid serious out of memory situations.
>
>
>

This would be great if it actually worked, and would be better than indiscriminate swap. But the apps don't really save their state; they just save the minimal amount of information *to get back to* that state. (And some apps don't even bother to do this.) Getting back to that state takes time. Since swap actually saves the entire state of the app, which just has to be reloaded, it makes switching between apps much faster.

If you switch to another app from the browser, for instance, the browser almost always gets killed, and then it has to reload the entire page *from the Internet* when you switch back to it. This takes wayyyy longer than reloading the state from swap, wastes your money if you're on a data plan, and causes state problems when the web page is dynamic.

Many apps take much longer to start up than they should, or don't actually return to the same state when they're restarted, so swapping them out works better.

I'm guessing the people who are happy with the stock system use their phones differently.

[Should I use a swap partition with Cyanogenmod?](http://www.forceclose.com/questions/367/should-i-use-a-swap-partition-with-cyanogenmod)
Upvotes: 3 <issue_comment>username_3: I have a Spice mi-435(only sold in India) which has a RAM of only 340M. Hell ya, the swap files help a lot. My phone runs ICS on such low RAM and definitely entered many out of memory states and there the swap file helps a lot. All the application states are transfered to swap when not in active use. This gives my phone room for more applications and RAM hungry apps to run smoothly with much much much less lag than before. Though there comes a problem when i open the app i have been using before. It takes time to load its state as the SD is much more slower than the high speed RAM on board. But, the swap option is better for so less RAM. I would recommend to swap partition for RAM less than 512M but not for more than 512M.

Hope it is helpful.
Upvotes: 2 <issue_comment>username_4: Swap file helps even on systems with higher RAM. My quad core 1gb ram 7 inch tablet gets a major multi-tasking boost from chucking in a 2gb swap, on the uhs-1 micro sd card. And of course, the price of memory goes down rapidly, and even at constant write, nand flash is supposed to last years.

Im basically of the opinion, because the performance difference is so radical, that probably anyone with less than a really large amount of RAM should be doing this. In fact it should probably come as a standard option in android (along with bigger app caches, and a proper sized internet cache).

I mean you have a 64-128gb micro sd (uhs-1), or even the uhs-2 that came out this year, plus a 16-64gb internal nand, often "fast" nand, which is a kind of primitive ssd or even SSD, as are used on windows slates - your not exactly filling all that high speed space up with much. The speed only really comes into play with video, or loading apps into memory - which is exactly the use here.

Of course ideally, manufacturers would focus more on RAM, than resolution or extra cores, because clearly the system speed benefits a lot from higher ram - and they should probably also up the speed of the internal storage too (like switching to full ssd type systems, or at minimum "fast" nand. But in the mean time, while high resolutions tend to cause a sort of RAM deficit in all devices, a swap file, and caching to a reasonably snappy external sd makes a lot of sense.

Indeed it would be nice to see some browsers keep fuller caching too, most browsers are either slow, or low feature, rarely fast and full featured - and thats partly because the space for the app cache on the internal drive is tiny. They are designed to operate within a low memory and storage environment, and that whole story is changing. Even if the ram isn't up to chop as much as it should be, the storage certainly is, and it can be pretty darn fast on UHS-1 standards (or the uhs-2 released this year), even if its not "fast" or ssd.

And the cost of external memory, is peanuts really, even for higher capacity uhs-1. At least a 64gb uhs-1 is perfectly affordable (50 bucks where I am, but it would be less USD), much cheaper than the device, and 32 gb and under is basically a couple of tenners.

Plenty of lessons to be learned from the desktop really, especially now the specs are getting higher - the slowest performance link is loading from storage to ram. The more you can do to mitigate that, the better.
Upvotes: 1


<issue_start>username_0: If I set up a VPN connection for Android, what gets routed over the VPN? Just web browsing? All internet connections from all apps?

In Cyanogenmod, in the Add OpenVPN config, "Advanced" settings, there is an option for "Redirect gateway - Force all traffic to berouted thru the VPN tunnel", which is off by default.

With this off, which apps/communications get routed through it?

The other VPN types do not have this option. Do they work this way or not?

After setting up a VPN, how can I verify that it's working?<issue_comment>username_1: Typically, yes.

You're creating a private network -- you want to route stuff through the network. It's private.

If only the browser applications were routing through the private network -- some other app could be sniffing activity, and sending it through the other connection. Goodbye, private!

See Also:

* <http://www.howstuffworks.com/vpn.htm>
* <http://en.wikipedia.org/wiki/Virtual_private_network>
Upvotes: 2 <issue_comment>username_2: The setting that you're talking about is in effect the `--redirect-gateway` option of OpenVPN and is documented on the [OpenVPN man page](http://openvpn.net/index.php/open-source/documentation/manuals/69-openvpn-21.html)

>
> `--redirect-gateway`
>
>
> Automatically execute routing commands to cause all outgoing IP traffic to be redirected over the VPN.
>
>
>
>
> ---
>
>
> This option performs three steps:
>
>
> 1. Create a static route for the --remote address which forwards to the pre-existing default gateway. This is done so that (3) will not create a routing loop.
> 2. Delete the default gateway route.
> 3. Set the new default gateway to be the VPN endpoint address (derived either from --route-gateway or the second parameter to --ifconfig when --dev tun is specified).
>
>
> When the tunnel is torn down, all of the above steps are reversed so that the original default route is restored.
>
>
>

The routing of all network connections occurs at the system level. Only apps that have the ability to modify the routing table of the device to use a different gateway than the default can bypass the VPN. Theoretically any app with SuperUser access could do this.
Upvotes: 3 <issue_comment>username_3: >
> If I set up a VPN, does *everything* go over it?
>
>
>

No, e.g. if one tethers one's Internet connection on the Android phone that is connected to the VPN server, [by default](https://android.stackexchange.com/q/194255/12202) the connections going through tethering won't go through the VPN.
Upvotes: 1


<issue_start>username_0: I'm interested in launching my application to the Android market, however I'm not sure if there is a market for my idea. Is there anyway to see what people are searching for on the android market, and to see how popular various searches are? I'd like to be able to put in a query and see how many searches there are for that query. Google do this for the normal web searches, [Google Insights for Search](http://www.google.com/insights/search/). Is there anything like that for the android market?

Example: I'd like to know which is a more popular search on the android market: "Motorbike" or "Motorcycle". You can do this for Google search engine using Google Insights<issue_comment>username_1: I don't know about feeds from the google market, but [Cyrket](http://www.cyrket.com/m/android/) aggregates this sort of data.
Upvotes: 1 <issue_comment>username_2: [AppBrain](http://www.appbrain.com) will show you who is searching for what. They even show broken down by country, age group and many other areas. You can see what is "Hot Today" or even this week or year. If you load the app on your phone it can make recommendations on what you may like based on what you currently have installed.
Upvotes: 2


<issue_start>username_0: When I play certain MP3 files (such as lessons from [JapanesePod101.com](http://www.japanesepod101.com)) on my iPod Touch, lyrics or transcripts that are embedded in the MP3 files are displayed in the media player.

I find this to be an extremely useful feature, and I believe I'm not alone. Despite that, neither the stock Android media player nor any other media player I've downloaded from the Market seems to support this. I just have not been able to find any way to get feature on my Nexus One.

This feature is important enough to me that I'm considering learning Android development just so I can write a simple media player that displays embedded lyrics or notes. However, the fact that nobody else seems to have done this makes me wonder - is it even possible? **Is there something in the Android architecture or APIs that make it difficult or impossible to read and display lyrics information from MP3 files?**<issue_comment>username_1: Meridian Media player has [support for lyrics](http://sites.google.com/site/eternalsandbox/update-to-professional-version) - i believe, embedded as well as .lrc files, but you might need the payware PRO version for that functionality to be enabled.

UPDATE: You're right! Turns out I had .lrc files in my music folder which is why i was seeing lyrics.
Upvotes: 1 <issue_comment>username_2: I haven't actually researched this answer, so take it with a grain of salt. Basing it off of other development work I have done with MP3s in the past.

I do not think there would be any reason that Android would limit an application from reading the embedded lyrics (or, rather lyrics from the [ID3 tag](http://www.id3.org/)). Because the tag supports this, really all you would need is a Java library that you can bring into your Android app that will read the lyrics.

With that said, the lyrics tag tends to be a little more in the "advanced support" for many applications. Everybody reads the title and artist tags. Most people will even display the album art (which is also part of the ID3). I haven't researched any recent libraries, but if you are curious about the ID3 tag in general, read this [ID3 Easy article](http://www.id3.org/ID3v2Easy).

So, the short answer is: no, nothing is stopping anybody from supporting it other than library support. Either a library doesn't exist, or nobody cares to utilize that feature within an Android media player.

Hope that helps!
Upvotes: 3 [selected_answer]<issue_comment>username_3: >
> Is there something in the Android architecture that prevents people
>  from creating MP3 players that read embedded lyrics?
>
>
>

Apparently the answer is "Yes."

There's an [open issue](http://code.google.com/p/android/issues/detail?id=32547) in Android's issue tracker on this very problem. Only users with Commit permission may comment, but you can star and follow the issue and perhaps help it get more attention.
Upvotes: 0


<issue_start>username_0: can I somehow take a screen shot of a google maps in a `easy way` and then send it via MMS?

---

HTC Desire on 2.1 (not rooted)<issue_comment>username_1: Only if you're rooted. See this answer: [How to take a screenshot with an Android device?](https://android.stackexchange.com/questions/1759/taking-a-screenshot-of-an-android-phone/1773#1773)
Upvotes: 3 <issue_comment>username_2: Try **[Map It!](https://www.appbrain.com/app/map-it-ad-supported/com.androgone.mapit.admob)**

It won't let you send anything from the Maps App, but the Map It! app uses Google Maps and lets you draw routes and put push pins into the map, then take a screenshot of it and send it via email or MMS.

It's useful if you want to send a picture of a particular place on a map or some kind of mock up to a map, but it's no good if you're trying to send the route that you already mapped out in the separate Maps app. To do this, I believe, you'd have to draw the route by hand on the map in Map It.

Also, you should note that it puts an ad at the top of the screen (in the same way other apps do this), and when you take your screenshot, it will show that ad too. There is an [Ad Free version](https://www.appbrain.com/app/map-it-ad-free/com.androgone.mapit) that I haven't tried.
Upvotes: 2


<issue_start>username_0: Every time I plug in my phone, I get a notification for USB connected. Is there any way to disable the notification, without disabling USB debugging?

* Phone: LG Optimus S
* Carrier: Sprint
* Android: 2.2, Rooted<issue_comment>username_1: This is part of a Core system in android. It can not be disabled unless you have a ROM that allows you to disable it. I believe 6.x versions of CyanogenMod have/had the option to disable it.

I am not sure if your phone is supported, and I am not sure if that option is still there (since my device doesn't have "official" support currently)
Upvotes: 2 <issue_comment>username_2: If the sound is what you don't like, on some phones the sound can be turned off by disabling USB Debugging. `Settings` -> `Applications` -> `Development` -> `USB debugging`. However, on some other phones, this will not change the sound that gets played when you plug it in.

To actually remove the notification, as previously mentioned, you'll need a custom ROM to do that for you.

[Update]
Another option to disable the sound is to go into your Sounds settings and set the default notification ringtone to silent and then go to each and every one of your applications that you want to have ringtones in and individually set them up there. I don't recommend this option (sure would be a pain if you forgot to set a ringtone to work email and missed an important one saying "We need you here ASAP or you're fired!"), but it is an option nonetheless.
Upvotes: 4 [selected_answer]<issue_comment>username_3: One option **without rooting** is to use a simple app like this one: [Mute](https://play.google.com/store/apps/details?id=muter.muter).

The only thing this app does is toggles between a muted / not muted state when opened.

Note that this mutes *all* sounds, not just the *`USB connected in debug mode`* notification. So for disabling that annoying sound (for example, when debugging at night), this is perfect. Just don't forget to turn it off after the debugging session.
Upvotes: 1