I tried to run the ipynb file on my Mac and got this error
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/anaconda/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py in apply_op(self, op_type_name, name, **keywords)
489 as_ref=input_arg.is_ref,
--> 490 preferred_dtype=default_dtype)
491 except ValueError:
~/anaconda/lib/python3.5/site-packages/tensorflow/python/framework/ops.py in convert_to_tensor(value, dtype, name, as_ref, preferred_dtype)
656 if ret is None:
--> 657 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
658
~/anaconda/lib/python3.5/site-packages/tensorflow/python/framework/ops.py in _TensorTensorConversionFunction(t, dtype, name, as_ref)
570 "Tensor conversion requested dtype %s for Tensor with dtype %s: %r"
--> 571 % (dtype.name, t.dtype.name, str(t)))
572 return t
ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float32: 'Tensor("nce_loss/Reshape_1:0", shape=(?, 1, ?), dtype=float32)'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-3-9796681a13df> in <module>()
19 # tf.nn.nce_loss(weights, biases, inputs, labels, num_sampled, num_classes ...)
20 # It automatically draws negative samples when we evaluate the loss.
---> 21 loss = tf.reduce_mean(tf.nn.nce_loss(nce_weights, nce_biases, train_labels, embed, num_sampled, voc_size))
22 # Use the adam optimizer
23 train_op = tf.train.AdamOptimizer(1e-1).minimize(loss)
~/anaconda/lib/python3.5/site-packages/tensorflow/python/ops/nn.py in nce_loss(weights, biases, inputs, labels, num_sampled, num_classes, num_true, sampled_values, remove_accidental_hits, partition_strategy, name)
1189 remove_accidental_hits=remove_accidental_hits,
1190 partition_strategy=partition_strategy,
-> 1191 name=name)
1192 sampled_losses = sigmoid_cross_entropy_with_logits(
1193 logits, labels, name="sampled_losses")
~/anaconda/lib/python3.5/site-packages/tensorflow/python/ops/nn.py in _compute_sampled_logits(weights, biases, inputs, labels, num_sampled, num_classes, num_true, sampled_values, subtract_log_q, remove_accidental_hits, partition_strategy, name)
1049 row_wise_dots = math_ops.mul(
1050 array_ops.expand_dims(inputs, 1),
-> 1051 array_ops.reshape(true_w, new_true_w_shape))
1052 # We want the row-wise dot plus biases which yields a
1053 # [batch_size, num_true] tensor of true_logits.
~/anaconda/lib/python3.5/site-packages/tensorflow/python/ops/gen_math_ops.py in mul(x, y, name)
1517 A `Tensor`. Has the same type as `x`.
1518 """
-> 1519 result = _op_def_lib.apply_op("Mul", x=x, y=y, name=name)
1520 return result
1521
~/anaconda/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py in apply_op(self, op_type_name, name, **keywords)
510 "%s type %s of argument '%s'." %
511 (prefix, dtypes.as_dtype(attrs[input_arg.type_attr]).name,
--> 512 inferred_from[input_arg.type_attr]))
513
514 types = [values.dtype]
TypeError: Input 'y' of 'Mul' Op has type float32 that does not match type int32 of argument 'x'.
when trying to execute the second last line of the second last block
loss = tf.reduce_mean(tf.nn.nce_loss(nce_weights, nce_biases, train_labels, embed, num_sampled, voc_size))
I double checked the document, but still cannot fix the issue. Is there any idea what is going wrong?
Python: 3.5
tensorflow: 0.11.0
OS: Sierra 10.12.2
Many thanks