Day 211
Python – how to run a Python script inside live shell
- executable - run program in Python shell - Stack Overflow
>>> exec(open("C:\\test.py").read())
for Python 3, and \>>> execfile('C:\\test.py')
for Python 2. Works with relative path.
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
)
- tf.expand_dims | TensorFlow Core r1.14 | TensorFlow
- Adds one dimension
# '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]
Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus