2017-12-08 11 views
1

복잡한 가치 무게 backpropagate 방법 : https://openreview.net/forum?id=H1S8UE-Rb우리는 현재 다음과 같은 용지의 결과를 복제하려고

그렇게하려면, 우리는 복잡한 평가 가중치를 포함하는 신경 네트워크에 역 전파를 실행해야합니다.

우리가 (코드 [0]으로)하려고하면 ([1]에서) 오류가 발생합니다. 복잡한 가치있는 가중치를 포함하는 신경망을 훈련시키는 프로젝트의 소스 코드를 찾을 수 없습니다.

종이의 역 전파 조정을 구현해야하는지 아니면 이미 이것이 일부 신경망 라이브러리의 일부인지 궁금합니다. Tensorflow에서 구현해야하는 경우이를 달성하기위한 적절한 단계는 무엇입니까? [0]

:

def define_neuron(x): 
    """ 
    x is input tensor 
    """ 

    x = tf.cast(x, tf.complex64) 

    mnist_x = mnist_y = 28 
    n = mnist_x * mnist_y 
    c = 10 
    m = 10 # m needs to be calculated 

    with tf.name_scope("linear_combination"): 
     complex_weight = weight_complex_variable([n,m]) 
     complex_bias = bias_complex_variable([m]) 
     h_1 = x @ complex_weight + complex_bias 

    return h_1 

def main(_): 
    mnist = input_data.read_data_sets(
     FLAGS.data_dir, 
     one_hot=True, 
    ) 

    # `None` for the first dimension in this shape means that it is variable. 
    x_shape = [None, 784] 
    x = tf.placeholder(tf.float32, x_shape) 
    y_ = tf.placeholder(tf.float32, [None, 10]) 

    yz = h_1 = define_neuron(x) 

    y = tf.nn.softmax(tf.abs(yz)) 

    with tf.name_scope('loss'): 
     cross_entropy = tf.nn.softmax_cross_entropy_with_logits(
      labels=y_, 
      logits=y, 
     ) 

    cross_entropy = tf.reduce_mean(cross_entropy) 

    with tf.name_scope('adam_optimizer'): 
     optimizer = tf.train.AdamOptimizer(1e-4) 
     optimizer = tf.train.GradientDescentOptimizer(1e-4) 
     train_step = optimizer.minimize(cross_entropy) 

[1] : 나는 또한 tensorflow에서 유사한 네트워크를 구현하기 위해 노력하고 최적화 복잡한 가치 텐서를 사용하여 역 전파 할 수없는 것을보고 한

Extracting /tmp/tensorflow/mnist/input_data/train-images-idx3-ubyte.gz 
Extracting /tmp/tensorflow/mnist/input_data/train-labels-idx1-ubyte.gz 
Extracting /tmp/tensorflow/mnist/input_data/t10k-images-idx3-ubyte.gz 
Extracting /tmp/tensorflow/mnist/input_data/t10k-labels-idx1-ubyte.gz 
Traceback (most recent call last): 
    File "complex.py", line 156, in <module> 
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed) 
    File "/Users/kevin/wdev/learn_tensor/env/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run 
    _sys.exit(main(_sys.argv[:1] + flags_passthrough)) 
    File "complex.py", line 58, in main 
    train_step = optimizer.minimize(cross_entropy) 
    File "/Users/kevin/wdev/learn_tensor/env/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py", line 343, in minimize 
    grad_loss=grad_loss) 
    File "/Users/kevin/wdev/learn_tensor/env/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py", line 419, in compute_gradients 
    [v for g, v in grads_and_vars 
    File "/Users/kevin/wdev/learn_tensor/env/lib/python3.6/site-packages/tensorflow/python/training/optimizer.py", line 547, in _assert_valid_dtypes 
    dtype, t.name, [v for v in valid_dtypes])) 
ValueError: Invalid type tf.complex64 for linear_combination/Variable:0, expected: [tf.float32, tf.float64, tf.float16]. 

답변

1

. 해결 방법은 실수 및 허수 부에 대해 실제 실수를 분리하는 것입니다. 단순히 Re^2 - Im^2 인 네트워크의 "복잡한"출력의 진폭을 얻을 수있는 함수를 작성해야합니다. 이 출력 값은 손실을 계산하는 데 사용됩니다.

+0

현재 다음을 검토 중입니다. https://github.com/ChihebTrabelsi/deep_complex_networks. – Slackware