Python – how to run a Python script inside live shell

Or, from the same SO thread, one can do just import filename_without_extension, even if it doesn’t follow the structure with main() etc., in my experience.

Tensorflow

Indexing and slicing multi-dimensional arrays or tensors in pandas, numpy, Tensorflo

This is probably one of the most SEO titles I’ve ever created, but I think it applies to all of them.

Tensorflow add one dimension (expand dims, expand_dims)

# 't' is a tensor of shape [2]
tf.shape(tf.expand_dims(t, 0))  # [1, 2]
tf.shape(tf.expand_dims(t, 1))  # [2, 1]
tf.shape(tf.expand_dims(t, -1))  # [2, 1]