2016-08-19 4 views
2

저는 TensorFlow를 처음 사용하고 언어 모델을 훈련해야하지만 다음과 같이 document을 읽는 동안 어려움에 처하게됩니다. 이 라인이 필요한 이유를 이해가 안이 문서의 softmax_w 및 softmax_b는 무엇입니까?

lstm = rnn_cell.BasicLSTMCell(lstm_size) 
# Initial state of the LSTM memory. 
state = tf.zeros([batch_size, lstm.state_size]) 

loss = 0.0 
for current_batch_of_words in words_in_dataset: 
    # The value of state is updated after processing each batch of words. 
    output, state = lstm(current_batch_of_words, state) 

    # The LSTM output can be used to make next word predictions 
    logits = tf.matmul(output, softmax_w) + softmax_b 
    probabilities = tf.nn.softmax(logits) 
    loss += loss_function(probabilities, target_words) 

,

I 출력이 밖으로 계산하고 target_words가 알려져되면 우리가 직접 손실을 해결할 수 있다는 것을 배웠 때문에
logits = tf.matmul(output, softmax_w) + softmax_b 

. 의사 코드가 추가 레이어를 추가하는 것 같습니다. 또한, 언급되지 않은 softmax_w 및 softmax_b는 무엇입니까? 나는 그런 간단한 질문을 제기함으로써 내가 중요한 것을 놓친 것일 수도 있다고 생각했다.

올바른 방향으로 나를 가리 키시면 어떤 제안이라도 대단히 감사하겠습니다. 고마워.

답변

3

코드가 수행하는 것은 softmax를 계산하기 전에 추가 선형 변환을 추가하는 것입니다. softmax_w은 가중치 행렬을 포함하는 tf.Variable이어야합니다. softmax_b은 바이어스 벡터가 포함 된 tf.Variable이어야합니다.

은 자세한 내용은이 튜토리얼의 softmax를 예를 살펴 보자 : https://www.tensorflow.org/versions/r0.10/tutorials/mnist/beginners/index.html#softmax-regressions

+0

네, 두 변수가 적절하게 - 이름과 그 의미를 추측하기 때문에 직관적된다. 그것이 내가 놓친 softmax입니다. 고마워. – lerner