In [1]:
require 'piranhas'
require 'torch'
require 'gnuplot'
param = param:param_init_all(nil)
scale = param.scale
fovea = param.fovea
e0_in_deg = param.e0_in_deg
visual_field_radius_in_deg = param.visual_field_radius_in_deg
deg_per_pixel = param.deg_per_pixel
-- Get Peripheral Architecture Parameters:
N_e, N_theta = get_pooling_parameters(scale,e0_in_deg,visual_field_radius_in_deg,deg_per_pixel)
e_max = visual_field_radius_in_deg
visual_field_width = math.floor(0.5 + 2*(visual_field_radius_in_deg/deg_per_pixel))
In [2]:
regions = create_regions_vector_smooth(e0_in_deg,e_max,visual_field_width,deg_per_pixel,N_theta,N_e)
In [3]:
regions:size()
Out[3]:
In [4]:
regions2 = regions:permute(3,4,1,2)
In [5]:
regions2:size()
Out[5]:
In [6]:
M = torch.zeros(((3,3,3)))
In [7]:
M = torch.zeros(3,3)
In [8]:
M
Out[8]:
In [9]:
M = torch.zeros(3,3,3)
In [10]:
M
Out[10]:
In [ ]:
In [11]:
mask = torch.zeros(visual_field_width,visual_field_width)
In [12]:
nt=1
ne=1
mask = regions2(nt,ne,:,:)
In [13]:
nt
Out[13]:
In [14]:
nt=1
ne=1
In [15]:
nt
Out[15]:
In [17]:
mask = regions2[nt][ne][:][:]
In [18]:
mask = regions[{{nt},{ne},{},{}}]
In [19]:
mask
Out[19]:
In [20]:
[r,c] = mask:gt(0)
In [21]:
mask:gt(0)
Out[21]:
In [22]:
mask
Out[22]:
In [23]:
mask_indxs = mask:maskedSelect(mask:gt(0))
In [24]:
mask_indxs
Out[24]:
In [25]:
mask_indxs_r, mask_indx_c = torch.nonzero(mask)
In [26]:
mask_indxs_r
Out[26]:
In [27]:
mask = torch.squeeze(mask)
In [28]:
mask
Out[28]:
In [29]:
mask = regions[{{nt},{ne},{},{}}]
mask = torch.squeeze(mask)
mask_indxs_r, mask_indx_c = torch.nonzero(mask)
In [30]:
mask_indxs_r
Out[30]:
In [31]:
mask_indxs_c
Out[31]:
In [36]:
mask_indxs_r[{{},{1}}]:size(1)
Out[36]:
In [37]:
for nt=1,N_theta do
for ne=1,N_e do
mask = regions[{{nt},{ne},{},{}}]
mask = torch.squeeze(mask)
mask_indxs = torch.nonzero(mask)
r = mask_indxs[{{},{1}}]
c = mask_indxs[{{},{2}}]
centers[{{},{nt},{ne}}] = [torch.mean(r) torch.mean(c)]
areas[{{nt},{ne}}] = r:size(1)
end
end
In [38]:
r
Out[38]:
In [39]:
mask = regions[{{nt},{ne},{},{}}]
mask = torch.squeeze(mask)
mask_indxs = torch.nonzero(mask)
r = mask_indxs[{{},{1}}]
c = mask_indxs[{{},{2}}]
In [40]:
r
Out[40]:
In [46]:
require 'torch'
Out[46]:
Out[46]:
In [42]:
math.mean(r)
In [43]:
require 'math'
Out[43]:
In [50]:
X = torch.mean(r:double())
In [49]:
r:type()
Out[49]:
In [51]:
X
Out[51]:
In [52]:
for nt=1,N_theta do
for ne=1,N_e do
mask = regions[{{nt},{ne},{},{}}]
mask = torch.squeeze(mask)
mask_indxs = torch.nonzero(mask)
r = mask_indxs[{{},{1}}]
c = mask_indxs[{{},{2}}]
centers[{{},{nt},{ne}}] = [torch.mean(r:double()) torch.mean(c:double())]
areas[{{nt},{ne}}] = r:size(1)
end
end
In [53]:
-- Double Check this:
for nt=1,N_theta do
for ne=1,N_e do
mask = regions[{{nt},{ne},{},{}}]
mask = torch.squeeze(mask)
mask_indxs = torch.nonzero(mask)
r = mask_indxs[{{},{1}}]
c = mask_indxs[{{},{2}}]
centers[{{1},{nt},{ne}}] = torch.mean(r:double())
centers[{{2},{nt},{ne}}] = torch.mean(c:double())
areas[{{nt},{ne}}] = r:size(1)
end
end
In [54]:
centers
Out[54]:
In [55]:
centers = torch.zeros(2,N_theta,N_e)
In [56]:
centers:size()
Out[56]:
In [57]:
areas = torch.zeros(N_theta,N_e)
In [58]:
-- Double Check this:
for nt=1,N_theta do
for ne=1,N_e do
mask = regions[{{nt},{ne},{},{}}]
mask = torch.squeeze(mask)
mask_indxs = torch.nonzero(mask)
r = mask_indxs[{{},{1}}]
c = mask_indxs[{{},{2}}]
centers[{{1},{nt},{ne}}] = torch.mean(r:double())
centers[{{2},{nt},{ne}}] = torch.mean(c:double())
areas[{{nt},{ne}}] = r:size(1)
end
end
In [1]:
Filters = { regions = torch.Tensor(N_theta,N_e,visual_field_width,visual_field_width),
centers = torch.Tensor(2,N_theta,N_e),
areas = torch.Tensor(N_theta,N_e)
offsets_r = {}
offsets_c = {}
weights = {}
uniq_pix = {}
for i=1,N_theta do
offsets_r[i] = {}
offsets_c[i] = {}
weights[i] = {}
uniq_px[i] = {}
for j=1,N_e do
offsets_r[i][j] = torch.Tensor()
offsets_c[i][j] = torch.Tensor()
weights[i][j] = torch.Tensor()
uniq_px[i][j] = torch.Tensor()
end
end
}
In [2]:
Filters = { regions = torch.Tensor(N_theta,N_e,visual_field_width,visual_field_width),
centers = torch.Tensor(2,N_theta,N_e),
areas = torch.Tensor(N_theta,N_e),
offsets_r = {},
offsets_c = {},
weights = {},
uniq_pix = {},
for i=1,N_theta do
offsets_r[i] = {}
offsets_c[i] = {}
weights[i] = {}
uniq_px[i] = {}
for j=1,N_e do
offsets_r[i][j] = torch.Tensor()
offsets_c[i][j] = torch.Tensor()
weights[i][j] = torch.Tensor()
uniq_px[i][j] = torch.Tensor()
end
end
}
In [3]:
Filters = { regions = torch.Tensor(N_theta,N_e,visual_field_width,visual_field_width),
centers = torch.Tensor(2,N_theta,N_e),
areas = torch.Tensor(N_theta,N_e),
offsets_r = {},
offsets_c = {},
weights = {},
uniq_pix = {},
}
In [4]:
filters = Filters
In [5]:
filters
Out[5]:
In [6]:
for i=1,N_theta do
filters.offsets_r[i] = {}
filters.offsets_c[i] = {}
filters.weights[i] = {}
filters.uniq_px[i] = {}
for j=1,N_e do
filters.offsets_r[i][j] = torch.Tensor()
filters.offsets_c[i][j] = torch.Tensor()
filters.weights[i][j] = torch.Tensor()
filters.uniq_px[i][j] = torch.Tensor()
end
end
In [7]:
filters = Filters
for i=1,N_theta do
filters.offsets_r[i] = {}
filters.offsets_c[i] = {}
filters.weights[i] = {}
filters.uniq_pix[i] = {}
for j=1,N_e do
filters.offsets_r[i][j] = torch.Tensor()
filters.offsets_c[i][j] = torch.Tensor()
filters.weights[i][j] = torch.Tensor()
filters.uniq_pix[i][j] = torch.Tensor()
end
end
In [8]:
filters
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
Out[8]:
In [ ]: