why Keras 2D regression network has constant output -
i working on kind of 2d regression deep network keras, network has constant output every datasets, test handmade dataset in code feed network constant 2d values , output linear valu of x (2*x/100) out put constant.
import resource import glob import gc rsrc = resource.rlimit_data soft, hard = resource.getrlimit(rsrc) print ('soft limit starts :', soft) resource.setrlimit(rsrc, (4 * 1024 * 1024 * 1024, hard)) # limit 4 giga bytes soft, hard = resource.getrlimit(rsrc) print ('soft limit changed :', soft) keras.models import sequential import keras.optimizers keras.layers import dense, dropout, activation, flatten, batchnormalization keras.layers import convolution2d, maxpooling2d,averagepooling2d import numpy np import random keras.utils import plot_model sample_size = 1 batch_size = 50 input_shape = (int(720 / 4), int(1280 / 4), sample_size * 5) # model model = sequential() model.add(batchnormalization(input_shape=input_shape)) model.add(convolution2d(128, (3, 3), activation='relu', dim_ordering="tf", padding="same",kernel_initializer='random_uniform')) model.add(convolution2d(128, (3, 3), activation='sigmoid', dim_ordering="tf", padding="same",kernel_initializer='random_uniform')) model.add(averagepooling2d(pool_size=(4, 4), dim_ordering="tf")) model.add(convolution2d(256, (3, 3), activation='sigmoid', dim_ordering="tf", padding="same",kernel_initializer='random_uniform')) model.add(convolution2d(256, (3, 3), activation='sigmoid', dim_ordering="tf", padding="same",kernel_initializer='random_uniform')) model.add(averagepooling2d(pool_size=(4, 4), dim_ordering="tf")) model.add(convolution2d(512, (3, 3), activation='sigmoid', dim_ordering="tf", padding="same",kernel_initializer='random_uniform')) model.add(convolution2d(512, (3, 3), activation='sigmoid', dim_ordering="tf", padding="same",kernel_initializer='random_uniform')) model.add(averagepooling2d(pool_size=(4, 4), dim_ordering="tf")) model.add(flatten()) model.add(dense(4096, activation='relu',kernel_initializer='random_uniform')) #model.add(dropout(0.5)) model.add(dense(512, activation='sigmoid',kernel_initializer='random_uniform')) model.add(dense(1, activation='sigmoid',kernel_initializer='random_uniform')) model.compile(loss='mean_absolute_error', optimizer='adam', metrics=['mae','mse']) model.summary() plot_model(model,to_file='model.png') def generate_tr(batch_size, is_training=false): x=np.linspace(0, 10, num=5000).reshape(-1, 1) counter = 0 print 'start' while 1: samples=np.zeros((batch_size, 720/4, 1280/4, 5)) labels=[] t in range (batch_size): = int(random.randint(0, 4999)) b in range(sample_size): samples[t, :,:,b*5:b*5+5] = np.random.rand(720/4,1280/4,5)/10+x[i] labels.append((2*x[i])/100) counter += 1 print counter #, labels yield ((samples), np.asarray(labels)) tt = model.fit_generator(generate_tr(batch_size, true), steps_per_epoch=100, epochs=10, use_multiprocessing=false, verbose=2) score = model.predict_generator(generate_tr(batch_size, true), steps=30)
the output average of of values (here .10)
do know why?
wiki
Comments
Post a Comment