New answers tagged

0

Your code implements timeseries split from scratch. Implementing from scratch has the potential to introduce subtle bugs. Another option would be to use an established package. Examples include scikit-learn's TimeSeriesSplit and Keras' TimeseriesGenerator.


0

I suggest you to automate the optimal hyperparameters search with a standard hyperparametrization strategy, like bayesian search for instance; Keras offers you this option with Keras tuner as follows (example): from tensorflow import keras from kerastuner.tuners import BayesianOptimization n_input = 6 def build_model(hp): model = Sequential() model....


1

This error is caused by the fact that you are passing a list of arrays with the image data to .fit() instead of a single array with the first dimension being the number of samples. Try using numpy.stack to convert the list of arrays to a single numpy array.


0

One "neural network zoo" is a collection of architecture visualizations from the Asimov Institute. Pre-trained Kera networks can be found in Keras Applications.


1

Usually with NN you would use LSTM layers to deal with time. Time steps can be a little confusing with TF/Keras. However, there is a great tutorial using the Jena data. Maybe this helps: https://blogs.rstudio.com/ai/posts/2017-12-20-time-series-forecasting-with-recurrent-neural-networks/


0

You do not need to reshape the labels. The labels in an LSTM can be one dimension. Only the array holding the x values needs to be reshaped.


1

You are running on GPU but you may find issues if you try and use the Adam optimiser. If you do try SGD instead. You can add %GPU and GPU Time to the Activity Monitor if you want to check you are using GPU when training.


0

Consider renaming your custom adam optimizer to anything other than adam variable (like opt or optimizer) as adam optimizer is already available in keras. reference from tensorflow import keras opt = keras.optimizers.Adam(learning_rate=0.00001) model_new.compile(loss='binary_crossentropy', optimizer=opt)


1

The path you are providing to the flow_from_directory method is one level to deep. The data generator expects a path to a directory which contains one subdirectory for each class in your dataset, see tensorflow documentation. This github gist shows how to apply the ImageDataGenerator to a dataset (coincidentally also using 'cat' and 'dog classes') together ...


0

The main issue here is that your labels - Y values you initialize randomly at the beginning is 432 dimensional, while your final layer is 2 dimensional and you are using binary cross-entropy. Which means you are trying to predict a 432 dimensional vector as a binary classification. But that is not reason you are receiving an error message for. To fix the ...


0

Note: In Keras, every SimpleRNN has only three different weight matrices, and these weights are shared between all input cells; In other words, for all five cells in your network: \begin{align} h_t = tanh( w_{h} h_{t-1} + w_{x} x_{t} + b_h)\ ; t= 1..5 \end{align} For a deeper understanding of recurrent networks in Keras, you may want to read this eloquent ...


0

import spacy nlp = spacy.load('en_core_web_trf') def identify_futuristic(sentence): sentence_doc = nlp(sentence) if any((token.morph.get('Tense') == [] and token.morph.get('VerbForm') == ['Fin'] and token.morph.get('Mood') == []) or (token.morph.get('Tense') == ['Pres'] and token.morph.get('...


0

It does not seem like the Adam optimizer object you created is being used because you write: optimizer='Adam' in the following line. Otherwise it looks fine. Though it is very strange that your loss is not extremely high, which is what you would expect with a log loss and confident wrong predictions. Check that the labels have the right dimensions and ...


2

Even though virtually any supervised classification algorithm can be used when having categorical features by applying some encoding technique, my first thought is using Catboost, an algorithm specially designed just for handling categorical features without a necessary explicit preprocessing/encoding phase. In short this algorithm will use an adaptation of ...


1

There are some ML models which use both categorical and numerical data Decision trees(with bagging), Random forest(with bagging & random subspace) Naive Bayes(numeric by Gaussian distribution or kernel density estimation) KNN based approach Ensemble Techniques linear regression Note: you can always use different encoding techniques to transform ...


1

Update for anyone googling this in 2021: Keras has implemented a MultiHead attention layer. If key, query, and value are the same, this is self-attention.


1

The problem is simple: recall, precision and F1-score work only with binary classification. If you try with a example manually you will see that the definitions that you're using for precision and recall can only work with classes 0 and 1, they go wrong with class 2 (and this is normal). When working with more than 2 classes you must use either micro f1-...


1

As complementary information to BeamsAdept's post, you can also calculate Matthews correlation coefficient, a metric that is robust to class imbalance. It provides a single value (balanced measure), ranging between +1 and -1. In your case, scikit-learn provides an api for calculating MCC: from sklearn.metrics import matthews_corrcoef mcc = matthews_corrcoef(...


2

Accuracy is not a good metric when you have an unbalanced Dataset. Imagine a binary classification with a dataset composed of 90% of '0' and 10% of '1'. If you make a model that always predict '0', (so which is useless, because your goal is to identify ones), it'll have a 90% accuracy. Since you obtain 99% accuracy, I believe you trained your model in a goal ...


1

Here is a brief discussion of the Xavier initialization. The goal of Xavier Initialization is to initialize the weights such that the variance of the activations are the same across every layer. This constant variance helps prevent the gradient from exploding or vanishing. Also check this for a slightly longer discussion on the topic by the same instructor....


0

Very generally speaking I don't see any major problems with your approach. You can make a few modifications though. For starters you might want to scale your data. You can use 0-1 scaling or -1,1, shouldn't matter much. Of course each column needs to be scaled separately. I am assuming there is no relation between your columns, if there is a specific ...


0

I wonder what you mean by "Everything after (and including) the 1st LSTM layer outputs the same value"? It's not technically possible for that to be true and for the loss to be changing. Knowing nothing else about your model, it looks like it's probably over-parameterized relative to your dataset and/or training resources. The layers that sticks ...


1

I think your input dimension to the autoencoder and its output dimensions are different. The input is (1,933,1) while the output is (933,1). These should be same actually.


1

Since you have less data, please provide more data for training as try split like 80% 20%. If training accuracy is 100% then try increasing the dropout percentage. If training accuracy is still less than 100% then try decreasing the dropout percentage and add more convolution layer. Thanks


0

If you found this via Google and use keras.preprocessing.sequence.pad_sequences to pad sequences to train RNNs: Make sure that keras.preprocessing.sequence.pad_sequences() does not have the argument value=None but either value=0.0 or some other number that does not occur in your normal data.


2

Functional API allows you to design more complicated models, including multi-output models. Check the documentation to see how you can connect specific neurons to others of your choice. You should be able to make custom layers from scratch. Once you build distinct output layers, probabilities within each can be set just as usual by using softmax activation.


1

The bit of this code that surprised me matches the tutorial you linked to, but they seem to get very poor performance. Their val_loss at the (best) epoch 105 is 0.3232; whereas in the RNN tutorial they had a best val_loss of 0.0895 (epoch 376). The bit that surprised me was using Conv1D(filters=4, kernel_size=1) as the feed-forward network. I looked a couple ...


Top 50 recent answers are included