TensorBoard doesn’t show all data points

You don’t have to change the source code for this, there is a flag called –samples_per_plugin. Quoting from the help command –samples_per_plugin: An optional comma separated list of plugin_name=num_samples pairs to explicitly specify how many samples to keep per tag for that plugin. For unspecified plugins, TensorBoard randomly downsamples logged summaries to reasonable values to … Read more

How does the Flatten layer work in Keras?

The Flatten() operator unrolls the values beginning at the last dimension (at least for Theano, which is “channels first”, not “channels last” like TF. I can’t run TensorFlow in my environment). This is equivalent to numpy.reshape with ‘C’ ordering: ā€˜C’ means to read / write the elements using C-like index order, with the last axis … Read more

400% higher error with PyTorch compared with identical Keras model (with Adam optimizer)

The problem here is unintentional broadcasting in the PyTorch training loop. The result of a nn.Linear operation always has shape [B,D], where B is the batch size and D is the output dimension. Therefore, in your mean_squared_error function ypred has shape [32,1] and ytrue has shape [32]. By the broadcasting rules used by NumPy and … Read more

Working with multiple graphs in TensorFlow

Your product is a global variable, and you’ve set it to point to “g2/MatMul”. In particular Try print product and you’ll see Tensor(“g2/MatMul:0”, shape=(1, 1), dtype=float32) So the system takes “g2/MatMul:0” since that’s the Tensor’s name, and tries to find it in the graph g1 since that’s the graph you set for the session. Incidentally … Read more

Plot multiple graphs in one plot using Tensorboard

If you are using the SummaryWriter from tensorboardX or pytorch 1.2, you have a method called add_scalars: Call it like this: my_summary_writer.add_scalars(f’loss/check_info’, { ‘score’: score[iteration], ‘score_nf’: score_nf[iteration], }, iteration) And it will show up like this: Be careful that add_scalars will mess with the organisation of your runs: it will add mutliple entries to this … Read more

How to convert tf.int64 to tf.float32?

You can cast generally using: tf.cast(my_tensor, tf.float32) Replace tf.float32 with your desired type. Edit: It seems at the moment at least, that tf.cast won’t cast to an unsigned dtype (e.g. tf.uint8). To work around this, you can cast to the signed equivalent and used tf.bitcast to get all the way. e.g. tf.bitcast(tf.cast(my_tensor, tf.int8), tf.uint8)

Clarification on tf.Tensor.set_shape()

As far as I know (and I wrote that code), there isn’t a bug in Tensor.set_shape(). I think the misunderstanding stems from the confusing name of that method. To elaborate on the FAQ entry you quoted, Tensor.set_shape() is a pure-Python function that improves the shape information for a given tf.Tensor object. By “improves”, I mean … Read more

Change images slider step in TensorBoard

I answered this question over there “TensorBoard doesn’t show all data points”, but this seems to be more popular so I will quote it here. You don’t have to change the source code for this, there is a flag called –samples_per_plugin. Quoting from the help command –samples_per_plugin: An optional comma separated list of plugin_name=num_samples pairs … Read more