In [ ]:
%load_ext autoreload
%autoreload 2
%matplotlib inline
#%config InlineBackend.figure_format = 'svg'
#%config InlineBackend.figure_format = 'pdf'

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import tensorflow as tf

In [ ]:
# font options
font = {
    #'family' : 'normal',
    #'weight' : 'bold',
    'size'   : 18
}

plt.rc('font', **font)
plt.rc('lines', linewidth=2)
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42

In [ ]:
a = np.reshape(np.arange(6), [3, 2])
b = np.reshape(np.arange(6, 12), [3, 2])

In [ ]:
a

In [ ]:
b

In [ ]:
np.concatenate((a, b), axis=1)

In [ ]:
a1 = a[:, np.newaxis]
a1

In [ ]:
b1 = b[:, np.newaxis]
b1

In [ ]:
np.concatenate((a1, b1), axis=2)

New axis as the first index


In [ ]:
a0 = a[np.newaxis, :]
a0

In [ ]:
b0 = b[np.newaxis, :]
b0

In [ ]:
ab0 = np.concatenate((a0, b0), axis=0)
ab0

In [ ]:
T = np.transpose(ab0, (1, 2, 0))
T

In [ ]:
T.reshape(3, -1)

Sum a tensor along one dim


In [ ]:
A = np.arange(24).reshape(4, 3, 2)

In [ ]:
np.sum(A, 1)

In [ ]:


In [ ]:


In [ ]: