In [1]:
import numpy as np
import tensorflow as tf
In [4]:
a = np.array([1,2,3])
In [4]:
a
Out[4]:
In [5]:
a.shape
Out[5]:
In [7]:
b = np.array([[1,2,3],[4,5,6]])
In [8]:
b
Out[8]:
In [9]:
b.shape
Out[9]:
In [10]:
a = np.zeros((2,2))
In [11]:
a
Out[11]:
In [12]:
b = np.ones((1,2))
In [13]:
b
Out[13]:
In [14]:
b.shape
Out[14]:
In [15]:
b = np.array([1,1])
In [16]:
b
Out[16]:
In [17]:
b.shape
Out[17]:
In [18]:
b = np.array([[1,1]])
In [19]:
b
Out[19]:
In [20]:
b.shape
Out[20]:
In [21]:
a = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])
In [22]:
a
Out[22]:
In [23]:
b = a[:2, 1:3] #righe 0 e 1, colonne 1 e 2
In [24]:
b
Out[24]:
In [25]:
a = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])
In [26]:
row_r1 = a[1, :] #indexing reduces the rank
In [27]:
row_r1
Out[27]:
In [28]:
row_r2 = a[1:2, :] #slicing keep the same rank
In [29]:
row_r2
Out[29]:
In [34]:
col_r1 = a[:, 1] #second col
In [35]:
col_r1
Out[35]:
In [36]:
col_r1.shape
Out[36]:
In [38]:
col_r2 = a[:, 1:2]
In [39]:
col_r2
Out[39]:
In [40]:
col_r2.shape
Out[40]:
In [41]:
a = np.array([[1,2], [3, 4], [5, 6]])
In [42]:
a
Out[42]:
In [43]:
a.shape
Out[43]:
In [47]:
print a[[0, 1, 2], [0, 1, 0]] #il primo set da' l'indice delle righe, il secondo delle colonne
In [50]:
x = np.array([[1,2],[3,4]], dtype=np.float64)
In [52]:
x.ndim
Out[52]:
In [53]:
a = np.array([0, 1, 2])
In [62]:
a
Out[62]:
In [63]:
a.shape
Out[63]:
In [64]:
a1 = np.tile(a, 2)
In [65]:
a1.shape
Out[65]:
In [66]:
a2 = np.tile(a, (2, 2))
In [67]:
a2
Out[67]:
In [68]:
a2.shape
Out[68]:
In [70]:
a.ndim
Out[70]:
In [71]:
a3 = np.tile(a, (2, 1, 2))
In [72]:
a3
Out[72]:
In [73]:
a3.ndim
Out[73]:
In [74]:
a3.shape
Out[74]:
In [78]:
b = np.array([[1, 2], [3, 4]])
b
Out[78]:
In [76]:
b.shape
Out[76]:
In [79]:
b1 = np.tile(b, 2)
In [84]:
b1.shape
Out[84]:
In [81]:
b2 = np.tile(b, (2, 1))
In [82]:
b2
Out[82]:
In [83]:
b2.shape
Out[83]:
In [85]:
x = np.array([[[1],[2],[3]], [[4],[5],[6]]])
In [86]:
x
Out[86]:
In [87]:
x.shape
Out[87]:
In [5]:
x1 = np.array([[[1,2,3], [4,5,6]], [[1,2,3], [4,5,6]]])
In [6]:
x1
Out[6]:
In [7]:
x1.shape
Out[7]:
In [96]:
x1.ndim
Out[96]:
In [9]:
x1.shape[2]
Out[9]:
In [98]:
x1 = np.array([1, 2, 3, 4, 5])
x2 = np.array([5, 4, 3])
In [99]:
x1
Out[99]:
In [100]:
x2
Out[100]:
In [101]:
x1_new = x1[:, np.newaxis]
In [102]:
x1_new
Out[102]:
In [104]:
x3 = x1_new + x2
In [106]:
x3
Out[106]:
In [4]:
tf1 = tf.zeros([2, 3])
In [6]:
tf1.shape
Out[6]:
In [7]:
tf2 = tf.ones([2, 3,4])
In [8]:
tf2.shape
Out[8]:
In [9]:
tf2
Out[9]:
In [12]:
tf3 = tf.placeholder(tf.float32, shape=[None,3], name="train_inputs")
In [13]:
tf3
Out[13]:
In [ ]: