Categories
Mastering Development

Boolean Labels Training with Keras causes the error “Please provide data which shares the same first dimension”

So, here is what I am trying to do. My model has to receive a number of training samples, each a conjunction of Boolean literals (i.e. a vector of 0 or 1s) assigned with a truth value. Learning from the samples, it must be able to receive some test vector and determine its truth value. […]

Categories
Mastering Development

code does not work when converted into function

I am trying to turn this code into a unique (or alternatively two) function(s). def create_model(neurons): # create model model = Sequential() model.add(Dense(neurons, input_dim=8, kernel_initializer=’uniform’, activation=’linear’, kernel_constraint=maxnorm(4))) model.add(Dropout(0.2)) model.add(Dense(1, kernel_initializer=’uniform’, activation=’sigmoid’)) # Compile model model.compile(loss=’binary_crossentropy’, optimizer=’adam’, metrics=[‘accuracy’]) return model # split into input (X) and output (Y) variables X = dataset[:,0:8] Y = dataset[:,8] # […]

Categories
Mastering Development

Validation accuracy very low but good training accuracy

I am in the process of implementing ResNet50 model on medical images of four classes. I intially had a dataset of 250 images per class and I split them into 2 folders train and val and used val data as test dataset and 80% of train as training dataset and 20% as validation dataset. I […]

Categories
Mastering Development

Getting ValueError while fitting ANN

I am trying to fit ANN on Kaggle’s Titanic dataset but getting ValueError. When I used RandomForest, there was no problem and when I am trying to use Artificial Neural Network, the code is throwing below error. Can you point out why I am getting the below error. I have pasted the code below import […]

Categories
Mastering Development

No completed or running application displayed on Apache Spark

When I launch my ANN script, everything works fine at console level, but nothing changes on the Spark web interface: The application is not displayed in Running Applications or Completed Applications. I created a config file spark-defaults.conf in which I put: spark.master spark://master:7077 spark.eventLog.enabled true spark.eventLog.dir /opt/spark/eventLogging I created a spark-event folder in /tmp to […]

Categories
Linux Mastering Development Ubuntu

CUDNN Probelm when training a model on keras (Using Tensorflow as Backend)

I was working fine with keras (Tensorflow as Backend) and training the model without any problems but when I installed cuda and CUDNN (follwoing in this link) to work with gpu, it gives me the following error: UnknownError Traceback (most recent call last) in 562 #print(gan_model.) 563 # train model –> 564 train(d_model, g_model, gan_model, […]

Categories
Development

ValueError: The model is not configured to compute accuracy. You should pass `metrics=[“accuracy”]` to the `model.compile()` method

I am very new in Deep Learning: I am doing a deep learning course on Udemy. once I execute my code, it says: ValueError: The model is not configured to compute accuracy. You should pass metrics=[“accuracy”] to the model.compile() method. I tried to change ‘accuracy’ into ‘acc’, It gives me no more error, but the […]

Categories
Development

ValueError: Error when checking input: expected input_14 to have 4 dimensions, but got array with shape (2970, 6000, 3)

def compile(model): model.compile(optimizer=’adam’, loss=’binary_crossentropy’, metrics=[‘binary_accuracy’]) def fit(model): model.fit(xTrain, yTrain, batch_size=10, validation_data=(xVal, yVal), epochs=1, class_weight=’auto’, callbacks=[checkpoint, csv_logger]) def VGG(): vgg =vgg16.VGG16() x = vgg.layers[-4].output y = Dense(1,activation = ‘sigmoid’)(x) model = Model(inputs=vgg.input, outputs=y) model.summary() compile(model) return model vgg_model=VGG() fit(vgg_model) How to fix the problem of the shape, I have tried many solutions. where reshape the xtrain […]

Categories
Development

implement a CNN model using Tensorlow 2.0

I am facing a lot of errors in my project as I am new to this field. Please help me out with these issues. **Please see the code below** Thanks in advance Kind Regards, Mazhar Bukhari Assignment No. 2 Due Date: 20/10/2019 In this assignment you have to implement a CNN model using Tensorlow 2.0. […]

Categories
Development

Early stopping during, before or after using GridSearchCV?

I try to find the optimal hyperparameters for the final training of a CNN. So far I have tried to optimize the hyperparameters (number of epochs, learning rate and dropout rate) per GridSearchCV with the following code: def create_model(learn_rate=0.01, dropout=0.0): # create model model = Sequential() model.add(Dense(12, input_dim=8, activation=’relu’)) model.add(Dropout(dropout)) model.add(Dense(1, activation=’sigmoid’)) # Compile model […]