Posts

Showing posts with the label keras

ValueError: Error when checking input: expected gru_5_input to have shape (None, None, 10) but got array with shape (1, 4, 1)

Image
Clash Royale CLAN TAG #URR8PPP ValueError: Error when checking input: expected gru_5_input to have shape (None, None, 10) but got array with shape (1, 4, 1) I am trying to make hourly predictions using a recurrent neural network using TensorFlow and Keras in Python.I have assigned my inputs of the neural network to be (None, None, 5) shown in my . However, I am getting the errorː ValueError: Error when checking input: expected gru_3_input to have shape (None, None, 10) but got array with shape (1, 4, 1) My MVCE code isː ValueError: Error when checking input: expected gru_3_input to have shape (None, None, 10) but got array with shape (1, 4, 1) %matplotlib inline #!pip uninstall keras #!pip install keras==2.1.2 import tensorflow as tf import pandas as pd from pandas import DataFrame import math import numpy from sklearn.preprocessing import MinMaxScaler from keras.models import Sequential import datetime from keras.layers import Input, Dense, GRU, Embedding from keras.optimizers import...

Keras ValueError when loading weights

Image
Clash Royale CLAN TAG #URR8PPP Keras ValueError when loading weights This is the error message I got Traceback (most recent call last): File "/home/xxx/Documents/program/test.py", line 27, in <module> model.load_weights('models/model.h5') File "/home/xxx/Documents/program/venv/lib/python3.6/site-packages/tensorflow/python/keras/engine/network.py", line 1391, in load_weights saving.load_weights_from_hdf5_group(f, self.layers) File "/home/xxx/Documents/program/venv/lib/python3.6/site-packages/tensorflow/python/keras/engine/saving.py", line 732, in load_weights_from_hdf5_group ' layers.') ValueError: You are trying to load a weight file containing 2 layers into a model with 0 layers. From this minimal example that produces the error from tensorflow import keras from data import get_data X_train, y_train, X_val, y_val = get_data() # get some train and val data model = keras.Sequential() model.add(keras.layers.Dense(64, activa...

input shape of dataset in cnn

Image
Clash Royale CLAN TAG #URR8PPP input shape of dataset in cnn My dataset is a simple table of 20 columns and 100,000 rows.It is not a image data as commonly used in CNN. What input shape should I provide in this case? Right now I did- input_shape = (21,109713,1) model.add(Conv2D(32, kernel_size=(5, 5), strides=(1, 1), activation='relu', input_shape=input_shape)) which gives the error- ValueError: rng_mrg cpu-implementation does not support more than (2**31 -1) samples Try giving the shape as (109713,21,1) – Hari Krishnan 3 mins ago By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these p...

keras try save and load model error

Image
Clash Royale CLAN TAG #URR8PPP keras try save and load model error i am trying to fine tuning and save model in Keras and load model but error Value Error: You are trying to load a weight file containing 16 layers into a model with 0 layers. i tried another model for number i made it save and load mode work without error when i try adopt vgg16 and used it give that error i want load model but cant load because this error any help ? Value Error: You are trying to load a weight file containing 16 layers into a model with 0 layers. import keras from keras.models import Sequential,load_model,model_from_json from keras import backend as K from keras.layers import Activation,Conv2D,MaxPooling2D,Dropout from keras.layers.core import Dense,Flatten from keras.optimizers import Adam from keras.metrics import categorical_crossentropy from keras.layers.normalization import BatchNormalization from keras.layers.convolutional import * from keras.preprocessing.image import ImageDataGenerator import m...

Finetuning ResNet50 with keras - val_loss keeps increasing

Image
Clash Royale CLAN TAG #URR8PPP Finetuning ResNet50 with keras - val_loss keeps increasing I am trying to customize resnet50 using keras with a tensorflow backend. However, upon tranining my val_loss keeps increasing. Trying different learning rates and batch sizes does not resolve the problem. Using different preprocessing methods such as rescaling or using the preprocess_input function for resnet50 inside the ImageDataGenerator did not not solve the problem either. This is the code I am using Importing and preprocessing data: from keras.preprocessing.image import ImageDataGenerator from keras.applications.resnet50 import preprocess_input, decode_predictions IMAGE_SIZE = 224 BATCH_SIZE = 32 num_classes = 27 main_path = "C:/Users/aaron/Desktop/DATEN/data" gesamt_path = os.path.join(main_path, "ML_DATA") labels = listdir(gesamt_path) data_generator = ImageDataGenerator(#rescale=1./255, validation_split=0.20, ...

What is the default stride length in Keras' Conv1D?

Image
Clash Royale CLAN TAG #URR8PPP What is the default stride length in Keras' Conv1D? Currently, I am tuning my model by testing the Kernel size. I have the following code : code x = embedding_layer(input_4) x = Conv1D(FILTERS, KERNEL, activation='relu')(x) x = Dropout(DROPOUT)(x) x = Conv1D(FILTERS, KERNEL, activation='relu')(x) x = Dropout(DROPOUT)(x) x = Conv1D(FILTERS, KERNEL, activation='relu')(x) x = Dropout(DROPOUT)(x) x = Conv1D(FILTERS, KERNEL, activation='relu')(x) x = Dropout(DROPOUT)(x) x = Conv1D(FILTERS, KERNEL, activation='relu')(x) x = Dropout(DROPOUT)(x) x = MaxPooling1D(3)(x) x = Conv1D(FILTERS, KERNEL, activation='relu')(x) x = Dropout(DROPOUT)(x) x = Conv1D(FILTERS, KERNEL, activation='relu')(x) x = Dropout(DROPOUT)(x) x = Conv1D(FILTERS, KERNEL, activation='relu')(x) x = Dropout(DROPOUT)(x) x = Conv1D(FILTERS, KERNEL, ...