keras

Tensorflow keras timeseries prediction with X and y having different shapes

半世苍凉 提交于 2021-02-10 15:43:05
问题 I am trying to do time series prediction with tensorflow and keras with X and y having different dimensions: X.shape = (5000, 12) y.shape = (5000, 3, 12) When I do the following n_input = 7 generator = TimeseriesGenerator(X, y, length=n_input, batch_size=1) for i in range(5): x_, y_ = generator[i] print(x_.shape) print(y_.shape) I get as desired the output (1, 7, 12) (1, 3, 12) (1, 7, 12) (1, 3, 12) ... This is because my data is meteorological, I have 5000 days, for training in the array X I

How to change the backend of Keras to Theano?

半腔热情 提交于 2021-02-10 15:28:09
问题 I installed keras. When I import keras, it says tensorflow not installed. I tried changing the backend in keras.json file to theano. But this doesn't help as it still says no module named tensorflow. Please help me fix this. 回答1: Did you try this? you will find the Keras configuration file at: $HOME/.keras/keras.json The default configuration file looks like this: { "image_data_format": "channels_last", "epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow" } Simply change the field

Binary classification with softmax activation always outputs 1

核能气质少年 提交于 2021-02-10 15:16:58
问题 Sorry for the quality of the question but a beginner here , I was just trying my luck with titanic dataset, but it always predicts that the passenger died. I try to explain code below: import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tensorflow.keras import losses from tensorflow.keras.layers.experimental import preprocessing import os Load dataset dataset

Binary classification with softmax activation always outputs 1

回眸只為那壹抹淺笑 提交于 2021-02-10 15:14:50
问题 Sorry for the quality of the question but a beginner here , I was just trying my luck with titanic dataset, but it always predicts that the passenger died. I try to explain code below: import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tensorflow.keras import losses from tensorflow.keras.layers.experimental import preprocessing import os Load dataset dataset

Does tensorflow allow LSTM deconvolution ( convlstm2d) as it does for 2D convolution?

你说的曾经没有我的故事 提交于 2021-02-10 15:11:55
问题 I am trying to augment a network. For the convolution part, I am using convlstm2d from keras. Is there a process to perform deconvolution ( i.e. lstmdeconv2d ? ) 回答1: There is Conv3D for that, checkout this example used to predict the next frame 回答2: It should be possible to combine any model with the TimeDistributed wrapper. So you can create a deconv-model, and apply it on the output (which is a sequence of vectors) of the LSTM using the TimeDistributed wrapper. An example. First create a

Does tensorflow allow LSTM deconvolution ( convlstm2d) as it does for 2D convolution?

徘徊边缘 提交于 2021-02-10 15:02:13
问题 I am trying to augment a network. For the convolution part, I am using convlstm2d from keras. Is there a process to perform deconvolution ( i.e. lstmdeconv2d ? ) 回答1: There is Conv3D for that, checkout this example used to predict the next frame 回答2: It should be possible to combine any model with the TimeDistributed wrapper. So you can create a deconv-model, and apply it on the output (which is a sequence of vectors) of the LSTM using the TimeDistributed wrapper. An example. First create a

Limiting probability percentage of irrelevant image in CNN

时间秒杀一切 提交于 2021-02-10 14:51:40
问题 I am training a cnn model with five classes using keras library. Using model.predict function i get prediction percentage of the classes. My problem is for a image which doesn't belong to these classes and completely irrelevant, the predict class still predicts the percentages according to the classes. How do I prevent it? How do I identify it as irrelevant? 回答1: I assume you are using a softmax activation on your last layer to generate the probabilities for each class. By definition, the sum

ImportError: cannot import name 'context' from 'tensorflow.python.eager' (unknown location)

拈花ヽ惹草 提交于 2021-02-10 14:51:01
问题 I created virtual environment and installed both tensorflow and tensorflow-gpu. After that I installed keras. And then I checked in my conda terminal by importing keras and I was able to import keras in it. However, using jupyter notebook if I try to import keras then it gives me below error. import keras ImportError Traceback (most recent call last) <ipython-input-5-88d96843a926> in <module> ----> 1 import keras ~\Anaconda3\lib\site-packages\keras\__init__.py in <module> 1 from __future__

Error when checking input: expected embedding_1_input to have shape (4,) but got array with shape (1,)

拟墨画扇 提交于 2021-02-10 14:43:51
问题 I use pretrained embedding vectors for my keras model. Before I did it everything worked and now I get this error: ValueError: Error when checking input: expected embedding_1_input to have shape (4,) but got array with shape (1,) Maybe somebody can help me, what I do wrong here. I am not sure if I did correct model.fit and model.evaluate. Maybe there is a problem? import csv import numpy as np np.random.seed(42) from keras.models import Sequential, Model from keras.layers import * from random

How to implement SegNet with preserving max-indexes in Keras

戏子无情 提交于 2021-02-10 14:42:00
问题 I'm trying to implement SegNet in Keras (tf backend) to do semantic segmentation. The most impressived trick of SgeNet is to pass max-pooling indices to the upsampling layers. However, there are many implementations of SegNet in Keras(e.g.) I find on github just using simple UpSampling (called SegNet-Basic). I notice that it can be achieved in Tensorflow with " tf.nn.max_pool_with_argmax ". So I want to know is there any similar method to get the max-pooling indices and put them back in