本文整理汇总了Python中location.Location.setGrids方法的典型用法代码示例。如果您正苦于以下问题:Python Location.setGrids方法的具体用法?Python Location.setGrids怎么用?Python Location.setGrids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类location.Location
的用法示例。
在下文中一共展示了Location.setGrids方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateGrids
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import setGrids [as 别名]
def updateGrids(self, ca1grids, ca1hd, b_odom, N_mazeSize, dictGrids):
loc=Location()
loc.setGrids(ca1grids, dictGrids)
(x_hat_prev, y_hat_prev) = loc.getXY()
## Hard coded again here North negative.....
dxys = [[1,0],[0,1],[-1,0],[0,-1]] #by hd cell
ihd = argmax(ca1hd)
odom_dir = dxys[ihd]
odom = [0,0]
if b_odom:
odom=odom_dir
x_hat_now = x_hat_prev + odom[0]
y_hat_now = y_hat_prev + odom[1]
##SMART UPDATE -- if odom took us outside the maze, then ignore it
#pdb.set_trace()
##if this takes me to somewhere not having a '3'(=N_mazeSize) in the coordinate, then the move was illegal?
if sum( (x_hat_now==N_mazeSize) + (y_hat_now==N_mazeSize))==0:
print "OFFMAZE FIX: OLD:" ,x_hat_now, y_hat_now
x_hat_now = x_hat_prev
y_hat_now = y_hat_prev
print "NEW:",x_hat_now, y_hat_now
x_hat_now = crop(x_hat_now, 0, 2*N_mazeSize)
y_hat_now = crop(y_hat_now, 0, 2*N_mazeSize) #restrict to locations in the maze
loc=Location()
loc.setXY(x_hat_now, y_hat_now)
#self.placeCells=zeros(ca1placeCells.shape)
#self.placeCells[loc.placeId] = 1
self.grids = loc.getGrids().copy()
示例2: __init__
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import setGrids [as 别名]
def __init__(self, ec, dictGrids, dghelper=None, N_place_cells=13):
self.N_place_cells=N_place_cells
self.dghelper = dghelper
#HOOK:, needs to use EC data to define "combis" of features aswell
if dghelper is not None:
#Lets say for now that place whisker combos etc are all encoded normally, and SURF features are encoded using WTA DG. In the end we may make sure that we have blocks referring only to location, blocks refering only to whiskers, blocks refering only to light, etc.
#FIXME: This needs changing when integrated to just get the number of surf features from ec!
if unittesting:
#Slice the SURF features from the numpy array
self.numOfSurfFeatures = len(ec)
self.surfFeatures = ec[-self.numOfSurfFeatures:]
else:
self.numOfSurfFeatures = len(ec.surfs)
self.surfFeatures = ec.surfs
#Choose semantics by choosing X random features N times to make N blocks
#For now be stupid, allow the same combinations to come up and the same indices to be compared with each other for winner take all (will the conflict break it?)
#Make this more intelligent later
#Make random windows associated with the features, i.e. for N windows, choose X random features to encode, make a matrix with the blocks and values
# <---X--->
# +-------------+
# ^ | 0 0 0 0 1 0 |
# | | 1 0 0 0 0 0 |
# N | |
# | | |
# | | |
# +-------------+
self.semanticValues = dghelper.getSemanticValues(self.surfFeatures)
#These are our input activations, once passed through a neural network with competitive learning applied to its ECDGweights to encourage winner takes all, the output should only have 1 active value per block (row), thus is sparse
#What happens if none of the features are active?? Should the one with the highest weight win? Or should there just be no activation in that block making it a even sparser matrix? I suspect the latter!
self.encode()
if not unittesting:
if dghelper is None:
self.encodedValues = np.array([])
#TODO: Need to remove place cells....
#self.N_place_cells = 13
# N_hd = 4
loc=Location() #NEW, pure place cells in DG
loc.setGrids(ec.grids, dictGrids)
self.place=np.zeros(self.N_place_cells)
self.place[loc.placeId] = 1
self.hd_lightAhead = np.zeros(4)
if ec.lightAhead == 1:
self.hd_lightAhead = ec.hd.copy()
self.whisker_combis = np.zeros(3) #extract multi-whisker features.
self.whisker_combis[0] = ec.whiskers[0] * ec.whiskers[1] * ec.whiskers[2] #all on
self.whisker_combis[1] = (1-ec.whiskers[0]) * (1-ec.whiskers[1]) * (1-ec.whiskers[2]) #none on
self.whisker_combis[2] = ec.whiskers[0] * (1-ec.whiskers[1]) * ec.whiskers[2] # both LR walls but no front
示例3: plotResults
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import setGrids [as 别名]
def plotResults(path, hist, dictGrids, b_useNewDG, learningRate, note=""):
str_title = hist.str_title + "\nDG: %s learningRate: %f" % (b_useNewDG, learningRate )
plt.figure()
T=len(hist.ca1s)
xys_bel = np.zeros((T,2))
ihds_bel = np.zeros((T,1))
N_places = (1+2*path.N_mazeSize)**2
for t in range(0,T):
loc=Location()
loc.setGrids(hist.ca1s[t].grids, dictGrids)
xys_bel[t,:] = loc.getXY()
ihds_bel[t] = np.argmax(hist.ca1s[t].hd)
#plt.subplot(4,2, (b_col2)+1)
plt.subplot(4,1, 1)
plt.plot(0.1+xys_bel[:,0], 'b')
plt.hold(True)
plt.plot(path.posLog[:,0], 'k')
plt.ylabel('x location')
plt.title(str_title)
# plt.subplot(4,2, (b_col2)+3)
plt.subplot(4,1, 2)
plt.plot(0.1+xys_bel[:,1], 'b')
plt.hold(True)
plt.plot(path.posLog[:,1], 'k')
plt.ylabel('y location')
#head directions
# plt.subplot(4,2, (b_col2)+5)
plt.subplot(4,1, 3)
plt.plot(path.posLog[:,2], 'k') #ground truth
plt.plot(ihds_bel, 'b') #EC HD cells
plt.ylabel('Heading')
# plt.subplot(4,2, (b_col2)+7)
plt.subplot(4,1, 4)
plt.plot(hist.sub_errs, 'y')
plt.hold(True)
plt.plot(5*hist.sub_fires, 'b')
plt.plot(hist.sub_ints, 'r')
plt.ylim(0,1)
plt.ylabel('Subiculum activation')
plt.xlabel('time')
b_losts = (np.sum(xys_bel!=path.posLog[:,0:2], 1)!=0)
# COMMENTED OUT SAVING AS THE PATH IS BUGGY IN NOTEBOOK
#str = "Results/run_"+hist.str_title+"LR_%d_DG_%s_%s.eps" % (learningRate*1000, b_useNewDG, note)
#plt.savefig(str)
return (b_losts, xys_bel)