Comments (11)
Thank you very much!!
But,"x_train = np.empty((num_train_samples, 3, 100, 100), dtype='uint8')" should be true,as I run the code as you said,having the following question:
ValueError: could not broadcast input array from shape (120,3,100,100) into shape (120,100,100,3)
Thanks
from rmdl.
Thank you for your question,
The could happen in many possible issue, as we explain NOT all models in rmdl will be good but majority votes helped to get good results, as I see in your results the RNN contains acceptable results, probability for DNN and CNN contains good results so you should look at your feature space of your dataset
Do you apply RMDL for text or image dataset?
from rmdl.
Thank you for your reply.
Yes,I apply RMDL for classification in my own image dataset(size(100x100)).About this question " val_acc: 0.1000",there has no this problem in MNIST and CIFAR datasets,but in my datasets have this question.I restart the code for many times,there will be no these problem.If there are many " val_acc: 0.1000"s in these models, will it have a great influence in VOTEs??
Thanks!
one:
"""
/home/nchen/anaconda3/bin/python /media/nchen/DISK_E/TH/RMDL-master/Examples/YPT.py
Using TensorFlow backend.
sys.version_info(major=3, minor=6, micro=3, releaselevel='final', serial=0)
sys.version_info(major=3, minor=6, micro=3, releaselevel='final', serial=0)
[nltk_data] Downloading package stopwords to /home/nchen/nltk_data...
[nltk_data] Package stopwords is already up-to-date!
DNN 0
(100, 100, 3)
<keras.optimizers.RMSprop object at 0x7f5e6ff8ff60>
Train on 7000 samples, validate on 3000 samples
Epoch 1/100
- 4s - loss: 14.3419 - acc: 0.0986 - val_loss: 14.5063 - val_acc: 0.1000
Epoch 00001: val_acc improved from -inf to 0.10000, saving model to weights\weights_DNN_0.hdf5
Epoch 2/100
- 2s - loss: 14.5063 - acc: 0.1000 - val_loss: 14.5063 - val_acc: 0.1000
Epoch 00002: val_acc did not improve from 0.10000
Epoch 3/100
- 2s - loss: 14.5063 - acc: 0.1000 - val_loss: 14.5063 - val_acc: 0.1000
Epoch 00003: val_acc did not improve from 0.10000
Epoch 4/100
- 2s - loss: 14.5063 - acc: 0.1000 - val_loss: 14.5063 - val_acc: 0.1000
Epoch 00004: val_acc did not improve from 0.10000
Epoch 5/100
"""
two:
"""
/home/nchen/anaconda3/bin/python /media/nchen/DISK_E/TH/RMDL-master/Examples/YPT.py
Using TensorFlow backend.
sys.version_info(major=3, minor=6, micro=3, releaselevel='final', serial=0)
sys.version_info(major=3, minor=6, micro=3, releaselevel='final', serial=0)
[nltk_data] Downloading package stopwords to /home/nchen/nltk_data...
[nltk_data] Package stopwords is already up-to-date!
CNN 0
<keras.optimizers.Adagrad object at 0x7f9c41d60518>
Train on 7000 samples, validate on 3000 samples
Epoch 1/400
- 74s - loss: 14.3458 - acc: 0.0991 - val_loss: 14.5063 - val_acc: 0.1000
Epoch 00001: val_acc improved from -inf to 0.10000, saving model to weights\weights_CNN_0.hdf5
Epoch 2/400
- 68s - loss: 14.5063 - acc: 0.1000 - val_loss: 14.5063 - val_acc: 0.1000
Epoch 00002: val_acc did not improve from 0.10000
Epoch 3/400
...
"""
three:
"""
/home/nchen/anaconda3/bin/python /media/nchen/DISK_E/TH/RMDL-master/Examples/YPT.py
Using TensorFlow backend.
sys.version_info(major=3, minor=6, micro=3, releaselevel='final', serial=0)
sys.version_info(major=3, minor=6, micro=3, releaselevel='final', serial=0)
[nltk_data] Downloading package stopwords to /home/nchen/nltk_data...
[nltk_data] Package stopwords is already up-to-date!
CNN 0
Error in model 0 try to re-generate another model
CNN 0
<keras.optimizers.RMSprop object at 0x7ff9ed1cf240>
Train on 7000 samples, validate on 3000 samples
Epoch 1/400
- 120s - loss: 14.3388 - acc: 0.0993 - val_loss: 14.5063 - val_acc: 0.1000
Epoch 00001: val_acc improved from -inf to 0.10000, saving model to weights\weights_CNN_0.hdf5
Epoch 2/400
- 112s - loss: 14.5063 - acc: 0.1000 - val_loss: 14.5063 - val_acc: 0.1000
Epoch 00002: val_acc did not improve from 0.10000
Epoch 3/400
- 113s - loss: 14.5063 - acc: 0.1000 - val_loss: 14.5063 - val_acc: 0.1000
Epoch 00003: val_acc did not improve from 0.10000
Epoch 4/400
...
"""
from rmdl.
Did you normalize your data before sending it to RMDL/?
from rmdl.
Can you share your code here?
from rmdl.
Thank you very much!
I transfer my images into the format of Cifar-10,and using the loading code of cifar-10.
[####code1:YPT.py
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
RMDL: Random Multimodel Deep Learning for Classification
- Copyright (C) 2018 Kamran Kowsari [email protected]
- Last Update: May 3rd, 2018
- This file is part of RMDL project, University of Virginia.
- Free to use, change, share and distribute source code of RMDL
- Refrenced paper : RMDL: Random Multimodel Deep Learning for Classification
- Refrenced paper : An Improvement of Data Classification using Random Multimodel Deep Learning (RMDL)
- Comments and Error: email: [email protected]
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
import sys
sys.path.append("/media/nchen/DISK_E/TH/RMDL-master")
from keras.datasets import cifar10
from RMDL import RMDL_Image as RMDL
from load_selfdatasets import yuputu
if name == "main":
number_of_classes = 10
shape = (100, 100, 3) #(64, 64, 1)
# (x_train, y_train), (x_test, y_test) = cifar10.load_data()
(x_train, y_train), (x_test, y_test) = yuputu.load_data()
x_train = x_train.astype('float32')
x_test = x_test.astype('float32')
x_train /= 255
x_test /= 255
batch_size = 100 #100
sparse_categorical = 0
n_epochs = [100, 150, 200] ## DNN--RNN-CNN [500, 500, 500]
Random_Deep = [0, 0, 5] ## DNN--RNN-CNN
RMDL.Image_Classification(x_train, y_train, x_test, y_test,(100,100,3),
batch_size=batch_size,random_deep=Random_Deep,
epochs=n_epochs)
######code2:yuputu.py
"""CIFAR10 small images classification dataset.
"""
from future import absolute_import
from future import division
from future import print_function
import sys
sys.path.append("/media/nchen/DISK_E/TH/RMDL-master")
from load_selfdatasets.load_batch_YPT import load_batch
from keras import backend as K
import numpy as np
import os
def load_data():
# dirname = 'cifar-10-batches-py'
# origin = 'https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz'
# path = get_file(dirname, origin=origin, untar=True)
# path = '/media/nchen/DISK_E/TH/RMDL-master/dataset-100-random-bin'
# path = '/media/nchen/DISK_E/TH/RMDL-master/dataset-100-random-green-bin'
path = '/media/nchen/DISK_E/TH/RMDL-master/dataset-100-random-pink-bin'
num_train_samples = 7000
x_train = np.empty((num_train_samples, 3, 100, 100), dtype='uint8')
y_train = np.empty((num_train_samples,), dtype='uint8')
for i in range(1, 6):
fpath = os.path.join(path, 'data_batch_' + str(i))
(x_train[(i - 1) * 1400: i * 1400, :, :, :],
y_train[(i - 1) * 1400: i * 1400]) = load_batch(fpath)
fpath = os.path.join(path, 'test_batch')
x_test, y_test = load_batch(fpath)
y_train = np.reshape(y_train, (len(y_train), 1))
y_test = np.reshape(y_test, (len(y_test), 1))
if K.image_data_format() == 'channels_last':
x_train = x_train.transpose(0, 2, 3, 1)
x_test = x_test.transpose(0, 2, 3, 1)
return (x_train, y_train), (x_test, y_test)
#####code3:load_batch_YPT.py
from future import absolute_import
from future import division
from future import print_function
import sys
sys.path.append("/media/nchen/DISK_E/TH/RMDL-master")
from load_selfdatasets.load_batch_YPT import load_batch
from keras import backend as K
import numpy as np
import os
def load_data():
# dirname = 'cifar-10-batches-py'
# origin = 'https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz'
# path = get_file(dirname, origin=origin, untar=True)
# path = '/media/nchen/DISK_E/TH/RMDL-master/dataset-100-random-bin'
# path = '/media/nchen/DISK_E/TH/RMDL-master/dataset-100-random-green-bin'
path = '/media/nchen/DISK_E/TH/RMDL-master/dataset-100-random-pink-bin'
num_train_samples = 7000
x_train = np.empty((num_train_samples, 3, 100, 100), dtype='uint8')
y_train = np.empty((num_train_samples,), dtype='uint8')
for i in range(1, 6):
fpath = os.path.join(path, 'data_batch_' + str(i))
(x_train[(i - 1) * 1400: i * 1400, :, :, :],
y_train[(i - 1) * 1400: i * 1400]) = load_batch(fpath)
fpath = os.path.join(path, 'test_batch')
x_test, y_test = load_batch(fpath)
y_train = np.reshape(y_train, (len(y_train), 1))
y_test = np.reshape(y_test, (len(y_test), 1))
if K.image_data_format() == 'channels_last':
x_train = x_train.transpose(0, 2, 3, 1)
x_test = x_test.transpose(0, 2, 3, 1)
return (x_train, y_train), (x_test, y_test)
Thanks.
from rmdl.
x_train = np.empty((num_train_samples, 3, 100, 100), dtype='uint8') should be
x_train = np.empty((num_train_samples, 100, 100, 3), dtype='uint8')
from rmdl.
try:
def load_data():
# path = '/media/nchen/DISK_E/TH/RMDL-master/dataset-100-random-bin'
# path = '/media/nchen/DISK_E/TH/RMDL-master/dataset-100-random-green-bin'
path = '/media/nchen/DISK_E/TH/RMDL-master/dataset-100-random-pink-bin'
num_train_samples = 7000
x_train = np.empty((num_train_samples, 3, 100, 100), dtype='uint8')
y_train = np.empty((num_train_samples,), dtype='uint8')
for i in range(1, 6):
fpath = os.path.join(path, 'data_batch_' + str(i))
(x_train[(i - 1) * 1400: i * 1400, :, :, :],
y_train[(i - 1) * 1400: i * 1400]) = load_batch(fpath)
fpath = os.path.join(path, 'test_batch')
x_test, y_test = load_batch(fpath)
y_train = np.reshape(y_train, (len(y_train), 1))
y_test = np.reshape(y_test, (len(y_test), 1))
if K.image_data_format() == 'channels_last':
x_train = x_train.transpose(0, 2, 3, 1)
x_test = x_test.transpose(0, 2, 3, 1)
x_train = np.reshape(x_train.shape[0],100,100,3)
x_test = np.reshape(x_trest.shape[0],,100,100,3)
return (x_train, y_train), (x_test, y_test)
and following code for RMDL:
from keras.datasets import mnist
import numpy as np
from RMDL import RMDL_Image as RMDL
if __name__ == "__main__":
(X_train, y_train), (X_test, y_test) = load_data()
X_train = X_train_D / 255.0
X_test = X_test_D / 255.0
number_of_classes = np.unique(y_train).shape[0]
shape = (100,100, 3)
batch_size = 128
sparse_categorical = 0
n_epochs = [100, 100, 100] ## DNN--RNN-CNN
Random_Deep = [3, 3, 3] ## DNN--RNN-CNN
RMDL.Image_Classification(X_train, y_train, X_test, y_test,shape,
batch_size=batch_size,
sparse_categorical=True,
random_deep=Random_Deep,
random_optimizor=False,
epochs=n_epochs)
from rmdl.
Thanks.
Can I set the shape of input image be [100,1000,3] ? (height:100,width:1000,channel:3)
from rmdl.
ah. i have a question. how to set saving path of model
from rmdl.
ah. i have a question. how to set saving path of model
Thank you for your question, the model is saved next to your file, but if you want to manually set it we did not send a parameter for this version,
Probably we add it in next version,
Best regards,
Kamran
from rmdl.
Related Issues (20)
- How to set the number of "n" in the experiment? HOT 3
- accuracy question
- How to use saved model and weights for prediction? HOT 1
- Text classification task accuracy problem HOT 7
- Functional API HOT 1
- How to we make prediction on new data? HOT 1
- Error in model 0 try to re-generate an other model DNN 0 HOT 2
- Error in model 0 try to re-generate an other model DNN 0 HOT 4
- Upload Trained Model HOT 1
- Unseen data... HOT 1
- random_optimier not use
- Could not find %s Set GloVe Directory in Global.py HOT 1
- Multi label classifier in RMDL. HOT 1
- The dataset is not divided into train data, validation data and test data?
- Using my own image dataset HOT 1
- Error when trying to run for my dataset HOT 2
- How to use a trained model for predictions? HOT 3
- ValueError HOT 18
- Prediction time HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rmdl.