2016-03-29 4 views
1

-Code

I "m versuchen, CNN mit UCF101 Einzelrahmendaten zu trainieren. Soweit ich das Problem verstehe, ist entweder mit dem Gewicht Initialisierung oder der Verlust entweder mit der tf.nn.softmax and tf.nn.softmax_cross_entropy_with_logits oder den Kosten und Optimierer Funktion.Tensorflow-Verlust nicht abnehmend und Fehlerquote bei 0,00%?

auch ist es eine Möglichkeit, verwenden xavier Initialisierung ??

import tensorflow as tf 
import numpy as np 
import scipy as sci 
import cv2 
import input_data_conv 
import skimage.transform 
from skimage import color 


# Parameters 
learning_rate = 0.001 
training_iters = 200000 
batch_size = 64 
display_step = 20 
n_classes=101 # number of classes 

#Input data and classes 
global train_data,train_class,test_data,test_classs,train_i,test_i 
test_i, train_i = 0,0 
train_data=input_data_conv.train_single_frames 
train_class=input_data_conv.train_single_classes 
test_data=input_data_conv.test_single_frames 
test_classs=input_data_conv.test_single_classes 


# Network Parameters 
n_input = [227, 227, 3 ]# MNIST data input (img shape: 227*227*3) 
dropout = 0.5 # Dropout, probability to keep units 

# tf Graph input 
x = tf.placeholder(tf.float32, [None, 227,227,3]) 
y = tf.placeholder(tf.float32, [None, n_classes]) 
keep_prob = tf.placeholder(tf.float32) # dropout (keep probability) 

def resize_im(im, nh, nw): 
    im=np.copy(im) 
    h, w, _ = im.shape 
    im = skimage.transform.resize(im, (nh, nw), preserve_range=True) 
    return im 
def create_class_vec(val,nuoclasses): 
    x=np.zeros(nuoclasses) 
    x[val]=1 
    return x 

def init_weights(shape): 
    return tf.Variable(tf.random_normal(shape, stddev=0.01)) 

def conv2d(name, l_input, w, b,s): 
    return tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(l_input, w, strides=[1, s, s, 1], padding='SAME'),b), name=name) 
def conv2dpad(name, l_input, w, b,s): 
    return tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(l_input, w, strides=[1, s, s, 1], padding='VALID'),b), name=name) 

def max_pool(name, l_input, k,s): 
    return tf.nn.max_pool(l_input, ksize=[1, k, k, 1], strides=[1, s, s, 1], padding='SAME', name=name) 

def norm(name, l_input, lsize): 
    return tf.nn.lrn(l_input, lsize, bias=1.0, alpha=0.0001/9.0, beta=0.75, name=name) 

def vgg_single_frame(_X, _weights, _biases, _dropout): 
    # Reshape input picture 
    _X = tf.reshape(_X, shape=[-1, 227, 227, 3]) 

    conv1 = conv2d('conv1', _X, _weights['wc1'], _biases['bc1'],s=2) 
    pool1 = max_pool('pool1', conv1, k=3,s=2) 
    norm1 = norm('norm1', pool1, lsize=5) 

    conv2 = conv2d('conv2', norm1, _weights['wc2'], _biases['bc2'],s=2) 
    pool2 = max_pool('pool2', conv2, k=3,s=2) 
    norm2 = norm('norm2', pool2, lsize=5) 


    conv3 = conv2d('conv3', norm2, _weights['wc3'], _biases['bc3'],s=1) 
    conv4 = conv2d('conv4', conv3, _weights['wc4'], _biases['bc4'],s=1) 
    conv5 = conv2d('conv4', conv4, _weights['wc5'], _biases['bc5'],s=1) 
    pool5 = max_pool('pool5', conv5, k=3,s=2) 

    # Fully connected layer 
    dense1 = tf.reshape(pool5, [-1, _weights['wd1'].get_shape().as_list()[0]]) # Reshape conv3 output to fit dense layer input 
    dense1 = tf.nn.relu(tf.matmul(dense1, _weights['wd1']) + _biases['bd1'], name='fc6') # Relu activation 
    dense1 = tf.nn.dropout(dense1, _dropout) 
    dense2 = tf.nn.relu(tf.matmul(dense1, _weights['wd2']) + _biases['bd2'], name='fc7') # Relu activation 
    dense2 = tf.nn.dropout(dense2, _dropout) 

    # Output, class prediction 
    out = tf.nn.softmax(tf.matmul(dense2, _weights['out']) + _biases['out']) 
    return out 

weights = { 
    'wc1': tf.Variable(tf.random_normal([7, 7, 3, 96])), # 7x7 conv, 1 input, 96 outputs ,stride 2 
    'wc2': tf.Variable(tf.random_normal([5, 5, 96, 384])), # 5x5 conv, 32 inputs, 64 outputs 
    'wc3': tf.Variable(tf.random_normal([3, 3, 384, 512])),#s 2 ,p a 
    'wc4': tf.Variable(tf.random_normal([3, 3, 512, 512])),#s 2, p 1 
    'wc5': tf.Variable(tf.random_normal([3, 3, 512, 384])),#s 2, p 1 
    'wd1': tf.Variable(tf.random_normal([8*8*384, 4096])), # fully connected, 7*7*64 inputs, 1024 outputs 
    'wd2': tf.Variable(tf.random_normal([4096, 4096])), # fully connected, 7*7*64 inputs, 1024 outputs 
    'out': tf.Variable(tf.random_normal([4096, n_classes])) # 1024 inputs, 10 outputs (class prediction) 
} 

biases = { 
    'bc1': tf.Variable(tf.random_normal([96])), 
    'bc2': tf.Variable(tf.random_normal([384])), 
    'bc3': tf.Variable(tf.random_normal([512])), 
    'bc4': tf.Variable(tf.random_normal([512])), 
    'bc5': tf.Variable(tf.random_normal([384])), 
    'bd1': tf.Variable(tf.random_normal([4096])), 
    'bd2': tf.Variable(tf.random_normal([4096])), 
    'out': tf.Variable(tf.random_normal([n_classes])) 
} 

def train_next_batch(batch_size): 
    temp_data=np.ndarray(shape=(batch_size,227,227,3),dtype=float) 
    temp_class=np.ndarray(shape=(batch_size,n_classes),dtype=float) 
    for idx,x in enumerate(train_data[train_i:train_i+batch_size]): 
     temp_data[idx,:,:,:]=resize_im(cv2.imread(x,1),227,227) 
     temp_class[idx,:]=create_class_vec(train_class[train_i+idx],101) 
    return temp_data,temp_class 


pred = vgg_single_frame(x, weights, biases, keep_prob) 
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(pred, y)) 
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost) 
# Evaluate model 
correct_pred = tf.equal(tf.argmax(pred,1), tf.argmax(y,1)) 
accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32)) 
# 
# cost = -tf.reduce_sum(y*tf.log(pred)) 
# optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost) 
# correct_pred = tf.equal(tf.argmax(pred,1), tf.argmax(y,1)) 
# accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32)) 

# Initializing the variables 
init = tf.initialize_all_variables() 

with tf.Session() as sess: 
    sess.run(init) 
    step = 1 
    # Keep training until reach max iterations 
    while step * batch_size < training_iters: 
     batch_xs, batch_ys = train_next_batch(batch_size) 
     # Fit training using batch data 
     sess.run(optimizer, feed_dict={x: batch_xs, y: batch_ys, keep_prob: dropout}) 
     if step % display_step == 0: 
      # Calculate batch accuracy 
      acc = sess.run(accuracy, feed_dict={x: batch_xs, y: batch_ys, keep_prob: 1.}) 
      # Calculate batch loss 
      loss = sess.run(cost, feed_dict={x: batch_xs, y: batch_ys, keep_prob: 1.}) 
      print "Iter " + str(step*batch_size) + ", Minibatch Loss= " + "{:.6f}".format(loss) + ", Training Accuracy= " + "{:.5f}".format(acc) 
     step += 1 
    print "Optimization Finished!" 
    # Calculate accuracy for 256 mnist test images 
    print "Testing Accuracy:", sess.run(accuracy, feed_dict={x: mnist.test.images[:256], y: mnist.test.labels[:256], keep_prob: 1.}) 

Ausgabe

Total memory: 12.00GiB 
Free memory: 10.77GiB 
I tensorflow/core/common_runtime/gpu/gpu_init.cc:126] DMA: 0 
I tensorflow/core/common_runtime/gpu/gpu_init.cc:136] 0: Y 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:717] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX TITAN X, pci bus id: 0000:03:00.0) 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 1.0KiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 2.0KiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 4.0KiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 8.0KiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 16.0KiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 32.0KiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 64.0KiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 128.0KiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 256.0KiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 512.0KiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 1.00MiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 2.00MiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 4.00MiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 8.00MiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 16.00MiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 32.00MiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 64.00MiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 128.00MiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 256.00MiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 512.00MiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 1.00GiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 2.00GiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 4.00GiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 8.00GiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 16.00GiB 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:73] Allocating 10.23GiB bytes. 
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:83] GPU 0 memory begins at 0xb06c80000 extends to 0xd9579bb34 
Iter 1280, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 2560, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 3840, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 5120, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 6400, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 7680, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 8960, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 10240, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 11520, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 12800, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 14080, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 15360, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 16640, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 17920, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 19200, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 20480, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 21760, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 23040, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 24320, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 25600, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 26880, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 28160, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 29440, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 30720, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 32000, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 33280, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 34560, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 35840, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 37120, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 38400, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 39680, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 40960, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 42240, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 43520, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 44800, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 46080, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 47360, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 48640, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 49920, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 51200, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 52480, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 53760, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 55040, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 56320, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 57600, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 58880, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 60160, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 61440, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 62720, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 64000, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 65280, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 66560, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 67840, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 69120, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 70400, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 71680, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 72960, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 74240, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 75520, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 76800, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 78080, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 79360, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 80640, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 81920, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 83200, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 84480, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 85760, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 87040, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 88320, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 89600, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 90880, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 92160, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 93440, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 94720, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 96000, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 97280, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 98560, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 99840, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 101120, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 102400, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 103680, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 104960, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 106240, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 107520, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 108800, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 110080, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 111360, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 112640, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 113920, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 115200, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 116480, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 117760, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 119040, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 120320, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 121600, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 122880, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 124160, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 125440, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 126720, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 128000, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 129280, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 130560, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 131840, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 133120, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 134400, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 135680, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 136960, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 138240, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 139520, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 140800, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 142080, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 143360, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 144640, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 145920, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 147200, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 148480, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 149760, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 151040, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 152320, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 153600, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 154880, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 156160, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 157440, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 158720, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 160000, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 161280, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 162560, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 163840, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 165120, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 166400, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 167680, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 168960, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 170240, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 171520, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 172800, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 174080, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 175360, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 176640, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 177920, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 179200, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 180480, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 181760, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 183040, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 184320, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 185600, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 186880, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 188160, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 189440, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 190720, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 192000, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 193280, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 194560, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 195840, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 197120, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 198400, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Iter 199680, Minibatch Loss= 4.631989, Training Accuracy= 0.00000 
Optimization Finished! 
+0

Woher wissen Sie, dass Sie nicht nur eine schlechte Architektur für Ihr Problem haben? –

+0

Ich implementierte das gleiche Netzwerk auf Caffe und gab eine Genauigkeit von 59% ... daher denke ich, das ist nicht das Problem .. aber vielleicht ein Implementierungsfehler ich gemacht .. lassen Sie mich wissen, wenn Sie irgendwelche Ideen haben –

+1

Eine nützliche Debugging-Technik Vergleichen Sie die Farbverläufe mit dem Originalmodell bei jedem Schritt. Sie können 'optimizer.compute_gradients' verwenden, um die Farbverläufe zu erhalten. –

Antwort

1

Sie können ein anderes Initialisierungsschema verwenden, indem Sie numpy Arrays für die Anfangswerte Ihrer Variablen erstellen.

Ihr Verlust ändert sich überhaupt nicht, daher besteht eine Möglichkeit zum Debuggen darin, zu bestätigen, dass sich die Variablen tatsächlich ändern, während Sie Aktualisierungen vornehmen.

1

Von Tensorflow documentation!

WARNUNG: Dieser Befehl erwartet unskalierte Logits, da er intern einen Softmax für Logits aus Effizienzgründen ausführt. Rufen Sie dieses Op nicht mit der Ausgabe von softmax auf, da dies zu falschen Ergebnissen führt.

Vor diesem Hintergrund sollten Sie

out = tf.nn.softmax(tf.matmul(dense2, _weights['out']) + _biases['out']) 

aus Ihrem Netzwerk Definition herausnehmen und ersetzen mit

out = tf.matmul(dense2, _weights['out']) + _biases['out'] 

Da Sie also nicht die Feinabstimmung nicht Gewichte auf ein ähnliches Problem ausgebildete Portierung das Training würde eher langsam sein. Wenn man bedenkt, könnte dies eines von vielen Problemen beim Training sein. Ich hoffe es hilft.

1

Ich konfrontiert das gleiche Problem. Lassen Sie die Reluktivierung aus der letzten dichten Schicht fallen. hat für mich gearbeitet.

dense2 = tf.nn.relu(tf.matmul(dense1, _weights['wd2']) + _biases['bd2'], name='fc7') # Relu activation 

danach wieder

out = tf.nn.softmax(tf.matmul(dense2, _weights['out']) + _biases['out']) 

Damit ist die erste "relu" scheint mir überflüssig zu sein. Ich habe eine ähnliche Sache gemacht. Nach dem Löschen dieser Zeile wurde das Problem behoben.

+0

Sie haben etwas dagegen, etwas auszuarbeiten? ab jetzt sieht das eher wie ein Kommentar für mich aus. –

+0

Tut mir leid, dass ich nicht weiter ausgearbeitet habe. Im Code sehe ich, dass die "dichte2" -Schicht eine erneute Aktivierung hat –

Verwandte Themen