Category : keras

This is my model- class CNNHyperModel(HyperModel): def __init__(self, input_shape, num_classes): self.input_shape = input_shape self.num_classes = num_classes def build(self, hp): model = keras.Sequential() model.add( Conv1D( filters=hp.Int( "neurons_1", min_value=20, max_value=400, step=20, default=200,), kernel_size=hp.Int("kernal_sizes_1", min_value=1, max_value=10, step=1, default=3,), strides=hp.Int("stride_sizes_1", min_value=1, max_value=10, step=1, default=3,), activation="relu", input_shape=(25,1), padding="same", ) ) model.add( Dropout( rate=hp.Float( "dropout_1", min_value=0.0, max_value=0.5, default=0.25, step=0.05, ) ) ..

Read more

import random import json import pickle import numpy as np import nltk from nltk.stem import WordNetLemmatizer from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Activation, Dropout from tensorflow.keras.optimizers import SGD lemmatizer = WordNetLemmatizer intents = json.loads(open(‘intents.json’).read()) words = [] classes = [] documents = [] ignore_letters = [‘!’,’?’,’.’,’,’] for intent in intents[‘intents’]: for pattern in ..

Read more

My error is ValueError: x and y must have same first dimension, but have shapes (5,) and (1,) Im not sure what I’m doing wrongly. acc = history.history[‘accuracy’] val_acc = history.history[‘val_accuracy’] loss = history.history[‘loss’] val_loss = history.history[‘val_loss’] epochs_range = range(5) plt.figure(figsize = (8, 8)) plt.subplot(2, 1, 1) plt.plot(epochs_range, acc, label = ‘Training Accuracy’) plt.plot(epochs_range, val_acc, ..

Read more

I’ve created an emotion detection Model with resnet50 and I’m using the Adam optimizer. However, I get the following error TypeError: set_model() missing 1 required positional argument: ‘model’ And here’s my code to create a model: # Build model on the top of base model model = Sequential() model.add(base_model) model.add(Dropout(0.5)) model.add(Flatten()) model.add(BatchNormalization()) # fully connected ..

Read more

I’m trying to run the code in the link below. https://github.com/myeungun/SAR-water-segmentation To run the code, I need 5 prerequisites. CUDA 10.0 Python 3.7.7 Tensorflow 1.14.0 PyTorch 0.4.1 Keras 2.3. I tried to install those packages after creating a new environment in anaconda. However, installing these packages one by one keeps causing inconsistencies. Is there any ..

Read more

I am doing Hyper parameter tuning using Keras tuners. I have made a custom objective function- from keras import backend as K def recall_m(y_true, y_pred): true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1))) possible_positives = K.sum(K.round(K.clip(y_true, 0, 1))) recall = true_positives / (possible_positives + K.epsilon()) return recall def precision_m(y_true, y_pred): true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, ..

Read more

I have the following pre-trained keras model: input_1 (InputLayer) [(None, 12, 4)] __________________________________________________________________________________________________ input_2 (InputLayer) [(None, 12, 4)] __________________________________________________________________________________________________ conv1d (Conv1D) (None, 20, 2) input_1[0][0] __________________________________________________________________________________________________ conv1d_3 (Conv1D) (None, 20, 2) input_2[0][0] __________________________________________________________________________________________________ lstm_1 (LSTM) (None, 12, 2) conv1d_3[0][0] __________________________________________________________________________________________________ time_distributed (TimeDistribut (None, 12, 16) lstm_1[0][0] __________________________________________________________________________________________________ time_distributed_1 (TimeDistrib (None, 12, 1) time_distributed[0][0] ================================================================================================== I ..

Read more