deep-learning

expected conv2d_1_input to have shape (28, 28, 1) but got array with shape (1, 28, 28)

谁都会走 提交于 2020-04-11 05:42:28
问题 So i'm using the mnist example on keras and I am trying to predict a digit of my own. I'm really struggling with how I can match the dimension sizes as I cant seem to find a way to resize my image to have the rows and columns after the image no. I've tried resizing with via numpy however I just get error after error... The code from __future__ import print_function import keras from keras.datasets import mnist from keras.models import Sequential from keras.layers import Dense, Dropout,

Is there any way I can download the pre-trained models available in PyTorch to a specific path?

こ雲淡風輕ζ 提交于 2020-04-10 18:07:07
问题 I am referring to the models that can be found here: https://pytorch.org/docs/stable/torchvision/models.html#torchvision-models 回答1: As, @dennlinger mentioned in his answer : torch.utils.model_zoo, is being internally called when you load a pre-trained model. More specifically, the method: torch.utils.model_zoo.load_url() is being called every time a pre-trained model is loaded. The documentation for the same, mentions: The default value of model_dir is $TORCH_HOME/models where $TORCH_HOME

How to disable dropout while prediction in keras?

早过忘川 提交于 2020-04-10 07:07:48
问题 I am using dropout in neural network model in keras. Little bit code is like model.add(Dropout(0.5)) model.add(Dense(classes)) For testing, I am using preds = model_1.predict_proba(image) . But while testing Dropout is also participating to predict the score which should not be happen. I search a lot to disable the dropout but didn't get any hint yet. Do anyone have solution to disable the Dropout while testing in keras?? 回答1: Keras does this by default. In Keras dropout is disabled in test

How to disable dropout while prediction in keras?

家住魔仙堡 提交于 2020-04-10 07:06:50
问题 I am using dropout in neural network model in keras. Little bit code is like model.add(Dropout(0.5)) model.add(Dense(classes)) For testing, I am using preds = model_1.predict_proba(image) . But while testing Dropout is also participating to predict the score which should not be happen. I search a lot to disable the dropout but didn't get any hint yet. Do anyone have solution to disable the Dropout while testing in keras?? 回答1: Keras does this by default. In Keras dropout is disabled in test

How to disable dropout while prediction in keras?

笑着哭i 提交于 2020-04-10 07:06:11
问题 I am using dropout in neural network model in keras. Little bit code is like model.add(Dropout(0.5)) model.add(Dense(classes)) For testing, I am using preds = model_1.predict_proba(image) . But while testing Dropout is also participating to predict the score which should not be happen. I search a lot to disable the dropout but didn't get any hint yet. Do anyone have solution to disable the Dropout while testing in keras?? 回答1: Keras does this by default. In Keras dropout is disabled in test

How to visualize attention weights?

淺唱寂寞╮ 提交于 2020-04-08 06:59:06
问题 Using this implementation I have included attention to my RNN (which classify the input sequences into two classes) as follows. visible = Input(shape=(250,)) embed=Embedding(vocab_size,100)(visible) activations= keras.layers.GRU(250, return_sequences=True)(embed) attention = TimeDistributed(Dense(1, activation='tanh'))(activations) attention = Flatten()(attention) attention = Activation('softmax')(attention) attention = RepeatVector(250)(attention) attention = Permute([2, 1])(attention) sent

Using keras tokenizer for new words not in training set

大兔子大兔子 提交于 2020-04-08 02:03:07
问题 I'm currently using the Keras Tokenizer to create a word index and then matching that word index to the the imported GloVe dictionary to create an embedding matrix. However, the problem I have is that this seems to defeat one of the advantages of using a word vector embedding since when using the trained model for predictions if it runs into a new word that's not in the tokenizer's word index it removes it from the sequence. #fit the tokenizer tokenizer = Tokenizer() tokenizer.fit_on_texts

Using keras tokenizer for new words not in training set

混江龙づ霸主 提交于 2020-04-08 01:59:07
问题 I'm currently using the Keras Tokenizer to create a word index and then matching that word index to the the imported GloVe dictionary to create an embedding matrix. However, the problem I have is that this seems to defeat one of the advantages of using a word vector embedding since when using the trained model for predictions if it runs into a new word that's not in the tokenizer's word index it removes it from the sequence. #fit the tokenizer tokenizer = Tokenizer() tokenizer.fit_on_texts

Get the location of all text present in image using opencv

萝らか妹 提交于 2020-04-07 13:50:30
问题 I have this image that contains text(numbers and alphabets) in it. I want to get the location of all the text and numbers present in this image. Also I want to extract all the text as well. How do I get the cordinates as well as the all the text(numbers and alphabets) in my image. For eg 10B, 44, 16, 38, 22B etc 回答1: Here's a potential approach using morphological operations to filter out non-text contours. The idea is: Obtain binary image. Load image, grayscale, then Otsu's threshold Remove

What is the use of verbose in Keras while validating the model?

筅森魡賤 提交于 2020-04-07 11:01:26
问题 I'm running the LSTM model for the first time. Here is my model: opt = Adam(0.002) inp = Input(...) print(inp) x = Embedding(....)(inp) x = LSTM(...)(x) x = BatchNormalization()(x) pred = Dense(5,activation='softmax')(x) model = Model(inp,pred) model.compile(....) idx = np.random.permutation(X_train.shape[0]) model.fit(X_train[idx], y_train[idx], nb_epoch=1, batch_size=128, verbose=1) What is the use of verbose while training the model? 回答1: Check documentation for model.fit here. By setting