In the use of a sampled_softmax_loss appear on '' nput 'b' of 'MatMul' Op has type float32 that does not match type int32 of argument 'a'. "Error causes and solutions

When using negative sampling function of the error occurred, error code:

tf.nn.sampled_softmax_loss(softmax_weights, softmax_biases,
                tf.reduce_sum(embeds, 1),
                train_labels,
                num_sampled, vocabulary_size) 
Cause: The parameter assignment error
View sampled_softmax_loss source code was understood that the parameter is defined as
DEF sampled_softmax_loss (weights, 
biases,
Labels,
Inputs,
num_sampled,
num_classes,
num_true =. 1,
sampled_values = None,
remove_accidental_hits = True,
partition_strategy = "MOD",
name = "sampled_softmax_loss",
SEED = None):
thus the code parameter assignment sequence error corresponding labels should train_labels inputs should be corresponding to tf.reduce_sum (embeds, 1)

solution:
use specify assignment: tf.nn.sampled_softmax_loss (weights = softmax_weights,
                 = softmax_biases biases, 
                Inputs = tf.reduce_sum (Embeds,. 1),
                Labels = train_labels,
                num_sampled = num_sampled,
                num_classes = vocabulary_size
)

or change the positions assigned variables:
tf.nn.sampled_softmax_loss (softmax_weights, softmax_biases, 
train_labels, tf.reduce_sum (Embeds, 1), num_sampled, vocabulary_size)

can successfully solve this problem

is also a matter of habit to the usual programming, in the case of many parameters, the best way to specify the use of copy!

  


Guess you like

Origin www.cnblogs.com/deeplearning1/p/11413206.html