示例#1
0
 def curveFromBin(binValues, pb, delta=1):
     '''
     binValues: 经排序的数值列表
     '''
     N = len(binValues)
     binCumulateCount = np.array(range(1, N + 1))
     li = Interpolate(binCumulateCount, binValues, delta)
     cnt = pb * N / 100
     bin = li.evalArray(cnt, sorted=True)
     return CumulativeCurve(bin, cnt)
示例#2
0
def main1():
    random.seed(0)
    np.random.seed(0)
    ll = Localization(grid_len=10)
    # ll.init_data()
    inter = Interpolate(ll.sensors, ll.means, ll.stds)  #''' args... '''
    sensors_inter, means_inter, stds_inter = inter.idw_inter(factor=4)
    ll_inter = Localization(grid_len=40)
    ll_inter.init_data_direct(ll.covariance, sensors_inter, means_inter,
                              stds_inter)
示例#3
0
 def __init__(self, module_2):
     super(Module1, self).__init__()
     self.layer1 = nn.Sequential(
         nn.MaxPool2d(kernel_size=2, stride=2),  # 2x
         Inception(128, 32, [(3, 32, 32), (5, 32, 32), (7, 32, 32)]),
         Inception(128, 32, [(3, 32, 32), (5, 32, 32), (7, 32, 32)]),
         module_2,
         Inception(128, 32, [(3, 64, 32), (5, 64, 32), (7, 64, 32)]),
         Inception(128, 16, [(3, 32, 16), (7, 32, 16), (11, 32, 16)]),
         Interpolate(scale_factor=2, mode='nearest'))
     self.layer2 = nn.Sequential(
         Inception(128, 16, [(3, 64, 16), (7, 64, 16), (11, 64, 16)]))
示例#4
0
    def merge(curves, pb):
        """
        curves: 元素为(bins,counts)元组的列表
        """
        binList = []
        for c in curves:
            binList.append(c[0])
        bs = np.unique(np.ravel(np.array(binList)))

        bsLen = len(bs)
        binCounts = np.zeros(bsLen)

        for cbin, cCount in curves:
            li = Interpolate(cbin, cCount, 0)
            cs = li.evalArray(bs, sorted=True)
            binCounts = binCounts + cs

        newTotal = binCounts[-1]
        li = Interpolate(binCounts * 100 / newTotal, bs, 0)
        newbin = li.evalArray(pb, sorted=True)
        return CumulativeCurve(newbin, pb * newTotal / 100)
 def __init__(self):
     super(Module4, self).__init__()
     self.layer1 = nn.Sequential(
         Inception(256, 64, [(3, 32, 64), (5, 32, 64), (7, 32, 64)]),
         Inception(256, 64, [(3, 32, 64), (5, 32, 64), (7, 32, 64)]))
     self.layer2 = nn.Sequential(
         nn.AvgPool2d(kernel_size=2, stride=2),
         Inception(256, 64, [(3, 32, 64), (5, 32, 64), (7, 32, 64)]),
         Inception(256, 64, [(3, 32, 64), (5, 32, 64), (7, 32, 64)]),
         Inception(256, 64, [(3, 32, 64), (5, 32, 64), (7, 32, 64)]),
         Interpolate(scale_factor=2,
                     mode='nearest')  # Up to 8x, 256 channel
     )
示例#6
0
 def __init__(self, module_3):
   super(Module2, self).__init__()
   self.layer1 = nn.Sequential(
                   nn.MaxPool2d(kernel_size=2, stride=2), # 4x
                   Inception(128, 32, [(3,32,32), (5,32,32), (7,32,32)]),
                   Inception(128, 64, [(3,32,64), (5,32,64), (7,32,64)]),
                   module_3,
                   Inception(256, 64, [(3,32,64), (5,32,64), (7,32,64)]),
                   Inception(256, 32, [(3,32,32), (5,32,32), (7,32,32)]),
                   Interpolate(scale_factor=2, mode='nearest') # up to 2x, output is 128 channel
                 )
   self.layer2 = nn.Sequential(
                   Inception(128, 32, [(3,32,32), (5,32,32), (7,32,32)]),
                   Inception(128, 32, [(3,64,32), (7,64,32), (11,64,32)])
                 )
 def __init__(self, module_4):
     super(Module3, self).__init__()
     self.layer1 = nn.Sequential(
         Inception(256, 64, [(3, 32, 64), (5, 32, 64), (7, 32, 64)]),
         Inception(256, 64, [(3, 64, 64), (7, 64, 64), (11, 64, 64)]))
     self.layer2 = nn.Sequential(
         nn.AvgPool2d(kernel_size=2, stride=2),  # 8x
         Inception(256, 64, [(3, 32, 64), (5, 32, 64), (7, 32, 64)]),
         Inception(256, 64, [(3, 32, 64), (5, 32, 64), (7, 32, 64)]),
         module_4,  # down 16x then up to 8x
         Inception(256, 64, [(3, 32, 64), (5, 32, 64), (7, 32, 64)]),
         Inception(256, 64, [(3, 64, 64), (7, 64, 64), (11, 64, 64)]),
         Interpolate(scale_factor=2,
                     mode='nearest')  # up to 4x. 256 channel
     )
示例#8
0
    def input(self):
        '''
        '''
        fig, ax = plt.subplots(1)

        self.filename = self.filelist[self.date]
        self.data = Interpolate(filename=self.filename, bounds=c.BOUNDS)
        xyz = self.data.xyz

        ax.scatter(x=xyz[:, 0], y=xyz[:, 1], c=xyz[:, 2], cmap='viridis')

        title = self._set_title(fn=self.filename)
        self._format_plt(fig=fig, ax=ax, title=title)

        plt.close('all')

        return fig
示例#9
0
    def curveFromBinCount(binCounts, pb, delta=1):
        '''
        binCounts: 元素为(bin,count)元组的列表,可以是多次累积,bin可以无序
        '''
        from collections import Counter
        c0 = Counter()
        for bin, cnt in binCounts:
            c0[bin] += cnt

        c1 = sorted(c0.items(), key=lambda item: item[0])
        clen = len(c1)

        if c1[0][1] == 0:
            b = np.zeros(clen)
            binCumulateCount = np.zeros(clen)
            b[0] = c1[0][0]
            binCumulateCount[0] = 0
            for i in range(1, clen - 1):
                b[i] = b[i - 1] + 2 * (c1[i][0] - b[i - 1])
                binCumulateCount[i] = binCumulateCount[i - 1] + c1[i][1]
            b[-1] = c1[-1][0]
            binCumulateCount[-1] = binCumulateCount[-2]
        else:
            b = np.zeros(clen + 1)
            binCumulateCount = np.zeros(clen + 1)
            b[0] = c1[0][0] - delta
            binCumulateCount[0] = 0
            for i in range(clen):
                b[i + 1] = c1[i][0]
                binCumulateCount[i + 1] = binCumulateCount[i] + c1[i][1]

        N = binCumulateCount[-1]
        li = Interpolate(binCumulateCount, b, 0)
        cnt = pb * N / 100
        bin = li.evalArray(cnt, sorted=True)
        return CumulativeCurve(bin, cnt)
示例#10
0
 def cumulativeCount(self, b):
     if not self._interpolateFromBin:
         self._interpolateFromBin = Interpolate(self._bin, self._cnt, 0)
     return self._interpolateFromBin.eval(b)
示例#11
0
 def p(self, r):
     if self._interpolateFromPct is None:
         self._interpolateFromPct = Interpolate(self._pb, self._bin, 0)
     return self._interpolateFromPct.innerEval(r)
示例#12
0
 def cumulativePercentage(self, b):
     if not self._interpolateFromBin:
         self._interpolateFromBin = Interpolate(self._bin, self._cnt, 0)
     return self._interpolateFromBin.eval(b) / self._N