mlp.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:Dragonfly 作者: duaneloh 项目源码 文件源码
def predict(self, event=None):
        try:
            first = int(self.predict_first.text())
            last = int(self.predict_last.text())
            num_proc = int(self.num_proc.text())
        except ValueError:
            sys.stderr.write('Integers only\n')
            return

        if last < 0:
            last = self.parent.num_frames
        if self.get_and_convert(first).shape[0] != self.parent.converted.shape[1]:
            sys.stderr.write('Wrong length for converted image (expected %d, got %d). You may need to update converter.\n' %
                (self.parent.converted.shape[1], self.get_and_convert(first).shape[0]))
            return

        predictions = multiprocessing.Array(ctypes.c_char, self.parent.num_frames)
        jobs = []
        for i in range(num_proc):
            p = multiprocessing.Process(target=self.predict_worker, args=(i, num_proc, np.arange(first, last, dtype='i4'), predictions))
            jobs.append(p)
            p.start()
        for j in jobs:
            j.join()
        sys.stderr.write('\r%d/%d\n' % (last, last))

        self.predictions = np.frombuffer(predictions.get_obj(), dtype='S1')
        self.gen_predict_summary()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号