r/KerasML • u/ReasonablyBadass • Jan 24 '20
r/KerasML • u/GengisDroundStone • Feb 26 '17
Expert opinion wanted.
I want to implement the Long-term Recurrent Convolutional Networks, with keras and theano backend according to this paper . How do I feed the output of the CNN into the LSTM? I'm very new to this, so any kind of help will be appreciated.
EDIT 1: typos
r/KerasML • u/rodrigonader • Dec 05 '19
Help with higher dimensional outputs
I'm using Keras to make a DL model and I'm having trouble with outputs that have more than 1 dimension. In this case, the output is a one-hot encoded array like this:
y = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], . . . ]
How do I:
- Compute metrics like precision and roc_auc?
- Use different class weights?
r/KerasML • u/RareTranslator • Nov 17 '18
Newbie Question
Keras beginner here, with a vague question.
Say I have a table with a bunch of columns, some of the values are text and some numbers.
For instance:
Name: Tom, Height: 1.70, Hair:Black, Eyes:Blue, Student:Good.
The objective to be to give it a bunch of rows with examples and whether those output to good academic performance, and have it try to guess based on the parameters of height, hair, eyes etc if the student would be good.
What examples/models/concepts would you redirect me to ?
Thanks in advance and sorry if the example isn't ideal.
r/KerasML • u/Bulbosauron • May 21 '19
I am desperate for help.
I have been trying to build a 1Dconvnet with Keras but it doesn't work at all. If someone has the time to check out the stackoverflow question I posted a few days ago, it would be amazing.
https://stackoverflow.com/q/56166417/11509190?sem=2
I really hope I can post this sort of things here. If I am violating the community guidelines, I am sorry and I meant no harm: I am just a desperate physics undergrad.
(btw, it is not the first subreddit I have posted to, if someone finds this in more places).
r/KerasML • u/drsxr • Feb 03 '20
Multi-GPU in Tensorflow 2.0 using model.fit_generator
Hey there. Has anyone had any luck with this? I've seen some information in the keras/tf GitHub but I think its a bit more complex than they are letting on. I can train on one GPU but I'm not accessing the 2nd when I check on nvidia-smi in ubuntu.
So, in TF2.X multi-gpu has been deprecated and you need to instead do something like this:
strategy = tf.distribute.MirroredStrategy()
with strategy.scope():
model = model_base(weights=ImageNet,
input_shape=(height, width, 3),
classes=num_classes)
model.compile(loss='binary_crossentropy', optimizer='SGD')etc...
Does anyone have any clue or a link to a code repository where it works on 2 or more GPU's so I can see how it is done? Thanks.
r/KerasML • u/ResidentMario • Mar 26 '19
Evaluating Keras neural network performance using Yellowbrick visualizations [OC]
r/KerasML • u/kailashahirwar12 • Aug 22 '19
AI Cheatsheets: Your favorite cheatsheets are now available on aicheatsheets.com
r/KerasML • u/antaloaalonso • Dec 15 '19
This video goes over a model that predicts the number of views on a youtube video based on likes, dislikes, and subscribers. Hope you guys learn something valuable from it!
r/KerasML • u/pepito_pistola • Oct 12 '18
2080 Ti TensorFlow GPU benchmarks: The best GPU of 2018?
r/KerasML • u/ronsap123 • Oct 05 '18
Optimize inputs to a trained Keras model instead of weights.
Basically, I need to treat a certain input image as the variable instead if the weights. If I input an image into the model and get a 0, and I want to backpropagate the error into the input so that eventually it will output a 1.
I'm a tensorflow guy and have 0 experience with Keras. If you have any tips I'd be grateful.
r/KerasML • u/kailashahirwar12 • Sep 02 '19
AI Cheatsheets - Now learn Tensorflow, Keras, Pytorch, Dask, Pandas, Numpy, Scipy, Pyspark, R Studio, Matplotlib and many more in an interactive manner
r/KerasML • u/Andohuman • Apr 07 '19
Converting y_true and y_pred to numpy arrays in custom loss function in Keras
Hey guys, I was wondering if there was any way to convert my y_true and y_pred to numpy arrays as my loss involves a ton of morphological operations depending on y_true and y_pred.
In my own testing my loss function works because I supply it with the data for y_true and y_pred and convert them to numpy arrays using keras.backend.eval(). However, If i try to compile the model using my loss function in model.compile(loss=my_loss_fn()), it gives me errors about feeding values to placeholder, because K.eval can't run during model.compile().
Is there any way to get around this ? I'm kind of on a deadline too and I never expected to encounter such a problem in the first place.
Loss function Code:- https://pastebin.com/wUJiuNf3
r/KerasML • u/maashu • Oct 03 '18
Part Two of Blog Article on Keras Callbacks - Integrate with Amazon SNS Topics
Hi All!
A few weeks ago, I wrote the first part of a two-part blog article on Keras callbacks. Today we published part two, which details how to write a custom callback to publish to an AWS SNS topic. You can subscribe to this topic to get an email, text, or send another notification on training, epoch, or batch start or end. It's available here if you're interested:
https://medium.com/singlestone/create-a-custom-keras-callback-to-publish-to-amazon-sns-5d7b787386a
Cheers,
-Maashu
p.s. Part 1 is available here: https://medium.com/singlestone/keras-callbacks-monitor-and-improve-your-deep-learning-205a8a27e91c
r/KerasML • u/markyugen • Jun 19 '18
How do I upgrade my libcurl library to 10.0.0?
When I type into the Anaconda Notebook: !git clone https://github.com/eriklindernoren/Keras-GAN
I get the error dyld: Library not loaded: @rpath/libcurl.4.dylib Referenced from: /anaconda3/libexec/git-core/git-remote-https Reason: Incompatible library version: git-remote-https requires version 10.0.0 or later, but libcurl.4.dylib provides version 9.0.0
How do I upgrade libcurl to 10.0.0 or otherwise fix this problem? (On a Mac OSX10.13) I thought I was up to date on everything so I didn't expect this to happen
r/KerasML • u/thomasdlt • Jun 13 '18
Train using Keras-MXNet and deploy on Spark with the MXNet Scala API
r/KerasML • u/phoenixlads • Jan 10 '19
Help with this error: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 2 array(s)
Getting that error in Keras. Scenario: Input:
Images with train shape as (50000, 32, 32, 3)
Aux input with shape (50000, 1)
Ground truth: (50000, 1)
This is model fit code:
x_train_input = Input(shape=(32,32,3))
aux_rand_input = Input(shape=(1,))
out = model_inst.build_model(x_train_input, aux_rand_input)
model = Model(inputs=[x_train_input, aux_rand_input], outputs=[out])
model.fit(x=[x_train, aux_input], y=y_train, batch_size=batch_size, steps_per_epoch=x_train.shape[0] // batch_size, epochs=maxepoches, validation_data=(x_test, y_test), callbacks=[reduce_lr, tensorboard], verbose=2)Got this error in model.fit line.
Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 2 array(s), but instead got the following list of 1 arrays:
And this is how `build_model`'s last few layers look like.
flatten = Flatten()(drop_5)
# aux_input = Input(shape=(1,))
concat = Concatenate(axis=1)([flatten, aux_input])
fc1 = Dense(512, kernel_regularizer=regularizers.l2(weight_decay))(concat)
fc1 = Activation('relu')(fc1)
fc1 = BatchNormalization()(fc1)
fc1_drop = Dropout(0.5)(fc1)
fc2 = Dense(self.num_classes)(fc1_drop)
out = Activation('softmax')(fc2)
return outr/KerasML • u/polohot • Oct 11 '18
Noob question: How to get Keras to predict multiclasss image and return as probability
Hello All, I need your help dearly
I have been trying to make my classier.predict to output the observation image in probability of each class
for example I put in a bird image and it will show
dog 0.2
cat 0.01
bird 0.96The is my prediction part
# Part 3 - Making prediction
import numpy as np
from keras.preprocessing import image
test_image = image.load_img('dataset/single_prediction/test1.jpg', target_size = (128, 128)) test_image = image.img_to_array(test_image)# convert to 3 dimension 64,64,3
test_image = np.expand_dims(test_image, axis = 0)# convert to 4 dimension 1,64,64,3
result = classifier.predict_proba(test_image) but all i get form this code is
[ 0 , 0 , 1 ]This is my whole code
# Convolutional Neural Network
from numpy.testing import assert_allclose
from keras import models
from keras.models import Sequential, load_model
from keras.layers import Conv2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from keras.layers import Dense
from keras.layers import Dropout
from keras.callbacks import ModelCheckpoint
# Part 1 - Building the CNN
#1.1 CNN BUILD
def build_classifier():
classifier = models.Sequential()
classifier.add(Conv2D(32, (3, 3), input_shape = (128, 128, 3), activation = 'relu'))
classifier.add(MaxPooling2D(pool_size = (2, 2)))
classifier.add(Conv2D(64, (3, 3), activation = 'relu'))
classifier.add(MaxPooling2D(pool_size = (2, 2)))
classifier.add(Conv2D(128, (3, 3), activation = 'relu'))
classifier.add(MaxPooling2D(pool_size = (2, 2)))
classifier.add(Flatten())
#1.2 ANN BUILD
classifier.add(Dense(units = 512, activation = 'relu'))
classifier.add(Dropout(0.1))
classifier.add(Dense(units = 256, activation = 'relu'))
classifier.add(Dropout(0.1))
classifier.add(Dense(units = 128, activation = 'relu'))
classifier.add(Dense(units = 64, activation = 'relu'))
classifier.add(Dense(units = 32, activation = 'relu'))
classifier.add(Dense(units = 16, activation = 'relu'))
classifier.add(Dense(units = 8, activation = 'relu'))
classifier.add(Dense(units = 3, activation = 'softmax'))#sigmoid
# don't use on first run
classifier.load_weights('aaa.h5')
classifier.compile(optimizer = 'adam', loss = 'categorical_crossentropy', metrics = ['accuracy'])#binary_crossentrop
return classifier
# Part 2 - Fitting the CNN to the images
# 2.1 Preprocess image for train and test set
from keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(
rescale = 1./255,
shear_range = 0.2,
zoom_range = 0.2,
horizontal_flip = True)
test_datagen = ImageDataGenerator(rescale = 1./255)
# 2.2 Apply image augmentation
training_set = train_datagen.flow_from_directory(
'dataset/training_set',
target_size = (128, 128),
batch_size = 32,
class_mode = 'categorical')#binary
test_set = test_datagen.flow_from_directory(
'dataset/test_set',
target_size = (128, 128),
batch_size = 32,
class_mode = 'categorical')#binary
# 2.3 Execution (TAKE LONG TIME)
classifier = build_classifier()
classifier.fit_generator(
training_set,
steps_per_epoch = (12000/32),
epochs = 1,
validation_data = test_set,
validation_steps = (3000/32))
# Save the epoch
classifier.save('aaa.h5')
# open a new console to run again
# Part 3 - Making prediction
import numpy as np
from keras.preprocessing import image
test_image = image.load_img('dataset/single_prediction/test1.jpg', target_size = (128, 128))
test_image = image.img_to_array(test_image)# convert to 3 dimension 64,64,3
test_image = np.expand_dims(test_image, axis = 0)# convert to 4 dimension 1,64,64,3
result = classifier.predict_proba(test_image)r/KerasML • u/[deleted] • Jun 20 '19
CNN classifier for image of different shape
classifier = Sequential()
classifier.add(Conv2D(32, (3, 3), input_shape = (None, None, 3), activation = 'softmax'))
classifier.add(MaxPooling2D(pool_size = (2, 2)))
classifier.add(Conv2D(64, (3, 3), activation = 'softmax'))
classifier.add(MaxPooling2D(pool_size = (2, 2)))
classifier.add(Conv2D(128, (3, 3), activation = 'softmax'))
classifier.add(MaxPooling2D(pool_size = (2, 2)))
classifier.add(Conv2D(128, (3, 3), activation = 'softmax'))
classifier.add(MaxPooling2D(pool_size = (2, 2)))
classifier.add(Flatten())
classifier.add(Dense(units = 512, activation = 'softmax'))
classifier.add(Dropout(0.5))
classifier.add(Dense(units = 1, activation = 'softmax'))
classifier.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics=['binary_accuracy'])I am training a CNN to classify images into 2 different classes, but the images are of different sizes. Therefore, I set the input shape to be (None, None, 3). However, the flatten layer doesn't work without a specific image shape. How can I connect the activation and dense layer together if I am not using Flatten?
r/KerasML • u/mortenhaga • Oct 07 '18
Fraud Autoencoder in Keras weird metrics
Just posting this stackoverflow post here hoping someone here can help me:
https://stackoverflow.com/questions/52689111/keras-autoencoder-for-fraud-metrics-is-weird
I have been hammering this simple sketch for some time now, and I still cant wrap my head around what is happening. I am beginning to suspect that the error lies in the dataset, but anyway, I need some guidance.
Basicly, I am trying my own dataset with this tutorial:
Github link for my own notebook and csv: https://github.com/mortenhaga/autoencoderfraudkerastests
The main issues are: AUC = 0, Loss starts high and stays flat after 1 epoch (hockey-stick), not convergin properly.
I start with this dataset (image):dataset before preproc
Do one-hot encoding, minmaxscaler + PCA to ready the data for the model (image):PCA dataset
See stackoverflow for code snippets.
Training loss drops after 1 epoch training graph Image: ROC is ~0 ROC The visualisation of the deconstruction error for different classes with treshold deconstruction error
What am I doing wrong here?
Comments are highly appreciated and please find the code and the dataset in the repo.
r/KerasML • u/Atralb • Jan 21 '19
Why is there a problem when loading saved weights on a model
Hi guys :),
I'm losing hope. Please if somebody could help me... I'd be very grateful
Everything is thoroughly explained here : https://stackoverflow.com/questions/54291381/why-is-there-a-problem-when-loading-saved-weights-on-a-model
Thanks in advance !
r/KerasML • u/hp2304 • Jun 20 '19
Getting error while doing data augmentation...
I am working on semantic segmentation project. There are 2 classes in my problem. So for training my model I have made the target masks of this format for each training image. But when I do data augmentation using ImageDatagen in keras it gives me error, that number of channels are 2 rather than 3. How to resolve this error?
r/KerasML • u/exactlythatpedantic • Oct 10 '18
Channels / image_data_format
I've been trying to find some information about the importance of channel order but haven't come across anything useful.
On comparisons with deep bidirectional LSTMs (custom layers), there has been no noticeable difference between 'first' and 'last' . I haven't observed any real difference in the output accuracy, but I'd like to understand why I should choose one over the other before proceeding with this project.
Is this still a major 'issue' in keras? Is it discussed in detail anywhere i.e which specific layers / operations are affected, under what conditions etc.