博客

  • ros中开发rnnoise语音增强算法的开发示例

    最近看了一个关于rnn语音增强算法的项目,想到机器人听觉可能会需要语音降噪方面的算法,于是一时兴起搞了一下。除噪效果还是很明显的。

    采用的是 GRU/LSTM 模型。项目地址为:rnnoise

    我们可以考虑采用用作者训练的模型来构建数据集,也可以自己根据上面项目工程的地址按照步骤自己训练模型供自己调用,具体的请自己开发。

    但是目前作者提供的只是一个仅支持48K采样率的音频数据。

    不过测了一下16k的,可以用但是效果可能没有48k性能好。

    下面给出封装成ros节点的rnnoise的算法,其实这种方法我并不推荐的,我感觉要把降噪放在最前端的位置,就是麦克风拾音那个位置上,把该项目可以封装成一个共享库,供自己调用。这个要看每个人开发的习惯而言。

    由于只是尝试一下该算法的调用,故给出在ros中的调用示例如下:

    void Callback(const jack_msgs::JackAudio::ConstPtr& msg)
    {
    //    int16_t* outputS16 = (int16_t*)malloc(sizeof(int16_t) * msg->size);
        int data_length = msg->size;
        int16_t* outputS16 = (int16_t*)malloc(sizeof(int16_t) * data_length);
        int k=0;
        printf("%d\n",data_length);
        short in_shorts[data_length];
        short in_shorts1[data_length];
    //    DenoiseState* st = rnnoise_create();
        float flag = 0;
        float processFrame[data_length];
        char outFile[256] = "rnnoise.wav";

        DenoiseState* st = rnnoise_create();
        printf("***********");

        for(int i=0; i<data_length; i++){
            processFrame[i] = (msg->data[i] * 65535);

            }
            flag = rnnoise_process_frame(st, processFrame, processFrame);
            for (size_t i = 0; i < data_length; i++) {
       
        in_shorts[i] = (short)processFrame[i];
        }
        rnnoise_destroy(st);
       
    }   

    int main(int argc, char **argv) {

    ros::init(argc, argv, "rnnoise");
            ros::NodeHandle n;
        printf("aaaaaaaaaaaa");
    //    DenoiseState* st = rnnoise_create();
            ros::Subscriber Sub = n.subscribe("/jackaudio", 1000, Callback);
        std_msgs::String msg;
        signal( SIGINT, sig_handler );
        ros::spin();
        }

    可以看出还是挺简单的,但是实际操作中并不会使用48k采样率的音频输入,因此下面给出冲采样的过程,添加上以后会实现所有采样率都支持的情况,根据需要添加。

    void resampleData(const int16_t *sourceData, int32_t sampleRate, uint32_t srcSize, int16_t *destinationData,
                      int32_t newSampleRate) {
        if (sampleRate == newSampleRate) {
            memcpy(destinationData, sourceData, srcSize * sizeof(int16_t));
            return;
        }
        uint32_t last_pos = srcSize – 1;
        uint32_t dstSize = (uint32_t) (srcSize * ((float) newSampleRate / sampleRate));
        for (uint32_t idx = 0; idx < dstSize; idx++) {
            float index = ((float) idx * sampleRate) / (newSampleRate);
            uint32_t p1 = (uint32_t) index;
            float coef = index – p1;
            uint32_t p2 = (p1 == last_pos) ? last_pos : p1 + 1;
            destinationData[idx] = (int16_t) ((1.0f – coef) * sourceData[p1] + coef * sourceData[p2]);
        }
    }

    可以在除噪算法中添加上面的函数,具体请参考以下:

    resampleData(data_in, in_sampleRate, (uint32_t) in_size, data_out, out_sampleRate);
    resampleData(data_out, out_sampleRate, (uint32_t) out_size, data_in, in_sampleRate);

  • Where We See Shapes, AI Sees Textures

    When you look at a photograph of a cat, chances are that you can recognize the pictured animal whether it’s ginger or striped — or whether the image is black and white, speckled, worn or faded. You can probably also spot the pet when it’s shown curled up behind a pillow or leaping onto a countertop in a blur of motion. You have naturally learned to identify a cat in almost any situation. In contrast, machine vision systems powered by deep neural networks can sometimes even outperform humans at recognizing a cat under fixed conditions, but images that are even a little novel, noisy or grainy can throw off those systems completely.

    A research team in Germany has now discovered an unexpected reason why: While humans pay attention to the shapes of pictured objects, deep learning computer vision algorithms routinely latch on to the objects’ textures instead.

    This finding, presented at the International Conference on Learning Representations in May, highlights the sharp contrast between how humans and machines “think,” and illustrates how misleading our intuitions can be about what makes artificial intelligences tick. It may also hint at why our own vision evolved the way it did.

    Cats With Elephant Skin and Planes Made of Clocks

    Deep learning algorithms work by, say, presenting a neural network with thousands of images that either contain or do not contain cats. The system finds patterns in that data, which it then uses to decide how best to label an image it has never seen before. The network’s architecture is modeled loosely on that of the human visual system, in that its connected layers let it extract increasingly abstract features from the image. But the system makes the associations that lead it to the right answer through a black-box process that humans can only try to interpret after the fact. “We’ve been trying to figure out what leads to the success of these deep learning computer vision algorithms, and what leads to their brittleness,” said Thomas Dietterich, a computer scientist at Oregon State University who was not involved in the new study.

    To do that, some researchers prefer to look at what happens when they trick the network by modifying an image. They have found that very small changes can cause the system to mislabel objects in an image completely — and that large changes can sometimes fail to make the system modify its label at all. Meanwhile, other experts have backtracked through networks to analyze what the individual “neurons” respond to in an image, generating an “activation atlas” of features that the system has learned.

    But a group of scientists in the laboratories of the computational neuroscientist Matthias Bethge and the psychophysicist Felix Wichmann at the University of Tübingen in Germany took a more qualitative approach. Last year, the team reported that when they trained a neural network on images degraded by a particular kind of noise, it got better than humans at classifying new images that had been subjected to the same type of distortion. But those images, when altered in a slightly different way, completely duped the network, even though the new distortion looked practically the same as the old one to humans

          Robert Geirhos, a graduate student in computational neuroscience at the University of Tübingen, sought to understand why the performance of deep learning computer vision algorithms is so vulnerable to noise in images. The question led to the discovery that the systems prioritize texture over shape.
          Courtesy of Robert Geirhos

    To explain that result, the researchers thought about what quality changes the most with even small levels of noise. Texture seemed the obvious choice. “The shape of the object … is more or less intact if you add a lot of noise for a long time,” said Robert Geirhos, a graduate student in Bethge’s and Wichmann’s labs and the lead author of the study. But “the local structure in an image — that gets distorted super fast when you add a bit of noise.” So they came up with a clever way to test how both humans and deep learning systems process images.

    Geirhos, Bethge and their colleagues created images that included two conflicting cues, with a shape taken from one object and a texture from another: the silhouette of a cat colored in with the cracked gray texture of elephant skin, for instance, or a bear made up of aluminum cans, or the outline of an airplane filled with overlapping clock faces. Presented with hundreds of these images, humans labeled them based on their shape — cat, bear, airplane — almost every time, as expected. Four different classification algorithms, however, leaned the other way, spitting out labels that reflected the textures of the objects: elephant, can, clock.

    “This is changing our understanding of how deep feed-forward neural networks — out of the box, or the way they’re usually trained — do visual recognition,” said Nikolaus Kriegeskorte, a computational neuroscientist at Columbia University who did not participate in the study.

    Odd as artificial intelligence’s preference for texture over shape may seem at first, it makes sense. “You can think of texture as shape at a fine scale,” Kriegeskorte said. That fine scale is easier for the system to latch on to: The number of pixels with texture information far exceeds the number of pixels that constitute the boundary of an object, and the network’s very first steps involve detecting local features like lines and edges. “That’s what texture is,” said John Tsotsos, a computational vision scientist at York University in Toronto who was also not involved in the new work. “Groupings of line segments that all line up in the same way, for example.”

    Geirhos and his colleagues have shown that those local features are sufficient to allow a network to perform image classification tasks. In fact, Bethge and another of the study’s authors, the postdoctoral researcher Wieland Brendel, drove this point home in a paper that was also presented at the conference in May. In that work, they built a deep learning system that operated a lot like classification algorithms before the advent of deep learning — like a “bag of features.” It split up an image into tiny patches, just as current models (like those that Geirhos used in his experiment) initially would, but then, rather than integrating that information gradually to extract higher-level features, it made immediate decisions about the content of each small patch (“this patch contains evidence for a bicycle, that patch contains evidence for a bird”). It simply added those decisions together to determine the identity of the object (“more patches contain evidence for a bicycle, so this is an image of a bicycle”), without any regard for the global spatial relationships between the patches. And yet it could recognize objects with surprising accuracy.

    “This challenges the assumption that deep learning is doing something completely different” than what previous models did, Brendel said. “Obviously … there’s been a leap. I’m just suggesting the leap is not as far as some people may have hoped for.”

    According to Amir Rosenfeld, a postdoctoral researcher at York University and the University of Toronto who did not participate in the study, there are still “large differences between what we think networks should be doing and what they actually do,” including how well they reproduce human behavior.

    Brendel expressed a similar view. It’s easy to assume neural networks will solve tasks the way we humans do, he said. “But we tend to forget there are other ways.”

    A Nudge Toward More Human Sight

    Current deep learning methods can integrate local features like texture into more global patterns like shape. “What is a bit surprising in these papers, and very compellingly demonstrated, is that while the architecture allows for that, it doesn’t automatically happen if you just train it [to classify standard images],” Kriegeskorte said.

    Geirhos wanted to see what would happen when the team forced their models to ignore texture. The team took images traditionally used to train classification algorithms and “painted” them in different styles, essentially stripping them of useful texture information. When they retrained each of the deep learning models on the new images, the systems began relying on larger, more global patterns and exhibited a shape bias much more like that of humans.
     

    And when that happened, the algorithms also became better at classifying noisy images, even when they hadn’t been trained to deal with those kinds of distortions. “The shape-based network got more robust for free,” Geirhos said. “This tells us that just having the right kind of bias for specific tasks, in this case a shape bias, helps a lot with generalizing to a novel setting.”

    It also hints that humans might naturally have this kind of bias because shape is a more robust way of defining what we see, even in novel or noisy situations. Humans live in a three-dimensional world, where objects are seen from multiple angles under many different conditions, and where our other senses, such as touch, can contribute to object recognition as needed. So it makes sense for our vision to prioritize shape over texture. (Moreover, some psychologists have shown a link between language, learning and humans’ shape bias: When very young children were trained to pay more attention to shape by learning certain categories of words, they were later able to develop a much larger noun or object vocabulary than children who did not receive the training.)

    The work serves as a reminder that “data exert more biases and influences than we believe,” Wichmann said. This isn’t the first time researchers have encountered the problem: Facial recognition programs, automated hiring algorithms and other neural networks have previously been shown to give too much weight to unexpected features because of deep-rooted biases in the data they were trained on. Removing those unwanted biases from their decision-making process has proved difficult, but Wichmann said the new work shows it is possible, which he finds encouraging.

    Nevertheless, even Geirhos’ models that focused on shape could be defeated by too much noise in an image, or by particular pixel changes — which shows that they are a long way from achieving human-level vision. (In a similar vein, Rosenfeld, Tsotsos and Markus Solbach, a graduate student in Tsotsos’ lab, also recently published research showing that machine learning algorithms cannot perceive similarities between different images as humans can.) Still, with studies like these, “you’re putting your finger on where the important mechanisms of the human brain are not yet captured by these models,” Kriegeskorte said. And “in some cases,” Wichmann said, “perhaps looking at the data set is more important.”

    Sanja Fidler, a computer scientist at the University of Toronto who did not participate in the study, agreed. “It’s up to us to design clever data, clever tasks,” she said. She and her colleagues are studying how giving neural networks secondary tasks can help them perform their main function. Inspired by Geirhos’ findings, they recently trained an image classification algorithm not just to recognize the objects themselves, but also to identify which pixels were part of their outline, or shape. The network automatically got better at its regular object identification task. “Given a single task, you get selective attention and become blind to lots of different things,” Fidler said. “If I give you multiple tasks, you might be aware of more things, and that might not happen. It’s the same for these algorithms.” Solving various tasks allows them “to develop biases toward different information,” which is similar to what happened in Geirhos’ experiments on shape and texture.

    All this research is “an exciting step in deepening our understanding of what’s going on [in deep learning], perhaps helping us overcome the limitations we’re seeing,” Dietterich said. “That’s why I love this string of papers.”

  • 8倍提升表现:谷歌新算法,多人对话分清谁在发

    8倍提升表现:谷歌新算法,多人对话分清谁在发言,错误率降到2%

     

    其实,从多人对话的音频里,分辨出哪段话是哪个人说的,早就不是新鲜问题了。

    不过,可以有新鲜解法啊 (毕竟从前的成绩不够好) 。

    谷歌AI团队说,最近这20年套路都没变过,就分两步:

    一是检测声谱的变化,确定说话人什么时候换了。二是识别对话里的每个说话人。

    他们不想被传统做法困住,开发了新方法:利用语音识别,把语言学线索和声学线索搭配食用,帮助区分。

    团队还发现,要有机结合这两种线索,RNN-Transducer (RNN-T) 是最合适的架构。

    最终结果,谷歌新模型把单词级的错误率 (WDER) ,从15.8%降到了2.2%。且多种错误情况皆有明显改善。

    8倍提升表现:谷歌新算法,多人对话分清谁在发言,错误率降到2%

    推特已有500多人点赞。

    论文还中选了INTERSPEECH 2019

    传统方法缺陷在哪

    谷歌团队总结了四个主要的局限:

    第一,对话先要被拆解成单人片段。不然就没办法准确传达一个说话人的特征。

    但事实上,现有的说话人变换检测方法不完美,会导致拆分出的片段里,还是有多个说话人。

    第二,聚类的时候,必须要知道总共有多少个说话人。这个信息如果不准确,就会严重影响模型的表现。

    第三,系统需要在拆分片段的大小上面,做一个艰难的权衡。

    片段越长,嗓音名片的质量就越好,因为每个说话人的信息多了。但风险在于,短暂的插话 (Short Interjections) 容易被判断错误。

    这在医疗或金融领域的对话上,都可能产生很严重的后果。

     

    8倍提升表现:谷歌新算法,多人对话分清谁在发言,错误率降到2%

     

    比如,医生问患者:“你有没有按时吃药?”

    患者回答“有 (Yes.) ”,和医生问“有么 (Yes?) ”,差别是很大的。

    第四,传统方法没有一个简单的机制,来利用好语言学线索。

    比如,“你用药多长时间了?”通常是医生问的,不是患者问的。

    所以,这些坑要怎么填呢?

    得天独厚的RNN-T

    RNN-T这个架构,原本是在语音识别上大展拳脚。

    而团队发现,它最适合用来把声学语言学的线索整合到一起。注意,语音识别说话人区分,不是暴力结合,是优雅地整合成了一个简单系统。

    RNN-T模型,由三个不同的网络组成:

    8倍提升表现:谷歌新算法,多人对话分清谁在发言,错误率降到2%

    一是转录网络,或者叫编码器,把音频的每一帧映射到一个潜在表征上;二是预测网络,负责根据前面的目标标签 (Target Labels) ,预测下个目标标签。RNN-T能预测的符号 (Symbol) 更丰富,如说话人角色 (Speaker Role) ,如发音 (Pronunciation) 。三是联合网络,把前两个网络的输出结合起来,在输出标签的集合上,生成一个当前时间步的概率分布。

    划重点,架构里有一个反馈循环 (Feedback Loop) 。在这里,先前识别出的单词都会作为输入,反馈回去。

    这样,RNN-T模型就能利用语言学的线索了:比如一个问句结束,很可能是要换人了。

    谷歌说,这个模型可以像训练语音识别系统那样训练:

    训练样本,是一个人说的话加上一个标签 (Tag) ,用来定义说话人的角色。比如:

    “作业什么时候交?”<学生>“明天上课之前交。”<老师>

    训练完成,就可以输入一段语音,得到每个字的分类结果了。

    那么,和基线对比一下,来看成果如何。

    主角是把语音识别 (Speech Recognition) 和说话人区分 (Speech Diarization) 结合成一个系统,基线是把两者分开再适配:

     

    8倍提升表现:谷歌新算法,多人对话分清谁在发言,错误率降到2%

     

    结果,说话人区分的单词级错误率 (Word Diarization Error Rate) ,从基线的15.8%,下降到了新方法的2.2%。

    8倍提升表现:谷歌新算法,多人对话分清谁在发言,错误率降到2%

    除此之外,多种原因造成的错误,RNN-T都能有效避免,包括:

    说话人在很短的时间里发生变化,单词边界 (Word Boundaries) 处的切分,语音重叠造成的数据集说话人标注错误,以及音频质量差的问题。

     

    8倍提升表现:谷歌新算法,多人对话分清谁在发言,错误率降到2%

     

    红色是RNN-T,蓝色是传统方法。每一种错误情况都大幅减少。

    团队还补充说,RNN-T系统在各种不同的对话里,平均错误率比传统方法更稳定:方差更小。

    传送门

    论文在这里:

    https://arxiv.org/abs/1907.05337

    博客在这里:

    https://ai.googleblog.com/2019/08/joint-speech-recognition-and-speaker.html

    — 完 —

    诚挚招聘

    量子位正在招募编辑/记者,工作地点在北京中关村。期待有才气、有热情的同学加入我们!相关细节,请在量子位公众号(QbitAI)对话界面,回复“招聘”两个字。

    量子位 QbitAI · 头条号签约作者

  • 2019 Google I/O大会亮点集锦:实时字幕、隐身模式

    3434

    2019年5月7日至5月9日,为开发者和技术爱好者举办的谷歌I/O大会在美国加州的山景城海岸露天剧场举行。

    谷歌I/O 2019大会为期3天。在谷歌年度I/O大会的两个小时主题会议上,谷歌进行了大量“剧透”,对于粉丝们期待的Pixel及安卓系统更新也有不少新爆料。

    与前几年不同的是,谷歌今年大会的主题是“Keep Making Magic”,还表示要“Building a more helpful Google for everyone”。与之相呼应的是,谷歌今年大会宣布的更新更多地关注了人文情怀:

    为语言障碍者开发的新功能Live Relay,让人们国外旅游更方便的Google Go,关注用户隐私的隐身模式……

    以下就是谷歌在发布会上的爆料内容摘要:

    谷歌Pixel 3a和3a XL

    谷歌推出了更实惠的Pixel 3手机版本。Pixel 3a的零售价为399美元,配备5.6英寸显示屏,1220万像素后置摄像头,运行Android P系统。而Pixel 3a XL的零售价为479美元,屏幕升级至6.0英寸。

    Nest Hub和Nest Hub Max

    谷歌的Google Home Hub被重新命名为“Nest Hub”,价格从149美元降至129美元。Nest Hub Max的显示屏将从7英寸增加到10英寸,并增加一个摄像头。

    它可以被当做一个厨房电视,可以通过手势控制。此外它也是一个不错的电子相框,亦或是一个智能家居控制器。

    AR搜索技术

    用户很快就可以搜索像“大白鲨”这样的词语,并通过AR中的手机摄像头看到它就在你面前。利用Google Search,你将能直接浏览3D对象并与之交互,直接将它们叠加在个人空间,从而获取详细的信息和感受实际的尺寸。

    谷歌同时与NASA,New Balance,三星,塔吉特,Visible Body,沃尔沃和Wayfair等一系列品牌进行了内容制作方面的合作。所以无论你是在学习人体解剖学还是选购运动鞋,都能直接在Search中直接与3D模型交互,并在现实世界中进行可视化。

    Google Lens升级

    新功能将添加到谷歌智能拍照图搜应用Google Lens。它将能够突出显示餐馆菜单上最受欢迎的菜式,或计算收据上的小费和总金额。

    拍摄杂志上的一道美味菜肴也可以获取详细的烹饪过程,不过目前该功能仅限于与谷歌达成合作的部分报刊杂志。

    对于国外旅游,Lens也可以提供帮助。只需将摄像头指向外文字词,它将自动显示对应的母语翻译。Lens目前支持超过100种语言。

    web上的Duplex

    谷歌将在去年的I/O发布Duplex后开放其web版。Duplex是去年谷歌带来的一项全新技术,现场的早期展示中,语音助手能够提取现有的预订信息,一旦进入预订环节,它将开始使用其拥有的信息(如姓名、地址、到达时间)自动完成填写。

    谷歌的“新一代”语音助手

    谷歌将语音识别模型从几百GB缩小到0.5 GB,这样它们就可以装进手机了。它的速度将是现在的10倍,可以在零延迟的情况下完成任务。

    下一代语音助手将在今年晚些时候于新款Pixel手机上推出。

    谷歌助手内置导航应用Waze

    谷歌助手将内置在导航应用Waze中。

    通过说“嘿,谷歌,让我们开车吧”,Google Assistant助手将转变为驾驶模式,这是一个极简主义的仪表盘,专注于你在驾驶时可能需要的东西,比如你的日常地点导航和音乐控制。

    谷歌地图中的隐身模式

    谷歌地图中的新隐身模式将阻止您在谷歌地图上的搜索或路线保存到您的谷歌帐户历史记录。这是谷歌强调自己关注用户数据安全和隐私的又一举措。

    实时字幕和实时转录

    Android很快就能自动为你的手机媒体生成字幕,包括播客。Live Caption的原理是借助移动端人机交互以及设备上的机器学习能力来训练模型(Federater Learning),即便在飞行模式下,这一功能仍可以在本地使用,当然也可应用于YouTube、Instagram、Skye此类应用。

    Live Caption所提供的在线语言转录,以及语音转化为文本的功能,即使在日常生活中也十分实用。Live Caption不仅能够帮助常人在不方便收听音频的特定环境下完成信息的交互,也能够帮助残障人士实现信息无障碍的交流。

    Live Relay功能可帮助聋哑人打电话,可以将对方的语音生成实时文字。

    Euphonia项目

    谷歌正在研究如何调整其现有的人工智能语音算法,以更好地理解有语音障碍的用户。Google AR 的研究人员正在探索个性化通信模式这一概念以及如何使用人工智能帮助那些无法正常发音的人士。通过和这些非营利组织的合作,谷歌的Project Euphonia项目团队成员记录了ALS患者的声音,然后将这些声音来训练人工智能,从而创建能够识别这些语音的算法和频谱图。

    Android Q夜间主题

    Android Q将有一个夜间模式,可以手动触发,也可以通过电池保护模式自动触发。以黑色为主的主题设计可以省电,而且也对眼睛更友好。

    专注模式(Focus mode)

    有了专注模式,你可以列出你不喜欢的应用程序列表——按下开关,它们就会消失,被禁用,直到专注模式关闭。家长也可通过Focus模式来对子女手机上的应用进行查看与管理。

    Pixel手机上的谷歌地图AR模式

    几个月前,谷歌推出了一种新的增强现实(AR)模式,它一直在为谷歌地图工作。这种模式已经测试了很长一段时间,应该很快就会开始在Pixel手机上出现。

    Kotlin成应用程序开发的首选语言

    谷歌宣布Android开发将越来越“Kotlin优先”。该公司还推出了Jetpack Compose,这是一个新的未打包的Kotlin工具包。

    Flutter for web 的首个技术预览版

    开发团队发布了 Flutter for web 的首个技术预览版,宣布 Flutter 正在为包括 Google Home Hub 在内的 Google 智能显示平台提供支持,并通过结合 Chrome OS 为桌面级应用程序提供支持迈出第一步。

    在去年发布 Flutter 1.0 时,谷歌就已尝试将 Flutter 扩展到其他平台,并在内部启动了一个代号为“Hummingbird”的探索性项目 —— 使用 Dart 构建 Web 框架,以评估通过移植 Flutter 引擎支持基于标准 Web 技术的优势。

    谷歌还表示将于本周发布稳定版的 Flutter 1.5,包含重要更新。

    用智能显示器玩游戏

    开发者将能够为谷歌的智能显示器创建游戏。谷歌正在开放一个基于谷歌助手的名为Interactive Canvas的框架,该框架将允许用户在智能显示器上构建全屏应用程序(或Actions),将触摸屏输入、语音和视觉结合在一起。目前,游戏是他们可以使用画布为智能显示器创建的唯一类型的操作,更多的类别很快就会出现。

    Android Q其它更新

    该系统对用户所关心的隐私问题进行了50项改进,如不运行的App无法获取LBS位置,收集用户信息的App也将会通过提示的方式发送给用户。

    另一项重大的改进在于系统的更新,此次谷歌推出的全新实时系统更新模式,无需重启即可完成系统的更新。

    该系统还能利用机器学习技术,实时识别面部表情。例如对渐冻症患者来说,他们一般用目光来控制打字。

    谷歌今年继续推进导航手势的改进,逐步取消导航栏,支持全屏手势,以争取到一些额外的屏幕空间。

    另外一个由设备机器学习驱动的功能是智能回复,将无缝地适用于Android Q中的所有消息应用,为回复提供有用的建议,同时也为操作提供有用的建议。

    谷歌还将为Android Q带来53款非二元(nonbinary)表情符号以模糊性别差异,它们已于本周二登陆Pixel智能机。Android Q的正式版本则定于今年晚些时候到来。

  • 尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、

    北京时间 5 月 8 日凌晨,一年一度的谷歌 I/O 大会在加州山景城如期开幕。今年的大会上,除了常规的安卓 Q 版本更新以外,新手机和「家庭智能设备中心」Nest Hub 显得更加引人注目。而去年惊艳的「能和人打电话的 AI」Duplex 也有了新升级。

    前有微软 Build 大会推出多个重磅产品,谷歌 CEO 桑达尔·皮查伊并不希望被抢去风头。在阵阵掌声中,一个又一个新应用与新产品呈现在了人们的眼前。

    「今天我们发布的新产品和设备,有关你的工作、你的家庭和你的生活。」皮查伊在大会 Keynote 开场白中表示。

    「鲨鱼上舞台」的谷歌搜索

    搜索,是谷歌的核心业务。Pichai 首先介绍了谷歌搜索添加的新特征。

    去年,谷歌发布 Google News 新特征 Full Coverage。如今谷歌把 Full Coverage 功能加入到了搜索中,从而更好地组织与搜索主题相关的资源。以搜索「黑洞」为例,谷歌使用机器学习识别不同类型的文章,全景展示与搜索词条相关的故事。此外,Podcasts 也将融入到谷歌搜索中。

    但谷歌搜索最令人尖叫的新特征是视觉展示。使用计算机视觉与增强现实,谷歌进一步强化了搜索体验:3D。

    例如搜索大白鲨,查看 3D 模式,然后可以直接把它搬到舞台中央!

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    当然,这一功能并非只是噱头,它还有很强的实用性,例如购买鞋子时,可以把 3D 展示拉入现实场景,看鞋子和自己的衣服是否搭配,从而提升购物体验。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    搜索,只是计算机视觉技术应用的场景之一。从今天的大会上,我们可以看到谷歌在 CV 上的研究已经融入谷歌的产品生态中,例如通过 Assistant、Camera 等 APP,用户可以借助 Google Lens 识别菜单中的热门菜品;通过 Google Go,翻译图片中的外语,并进行语音诵读。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    接管一切的智能助手

    介绍完了视觉相关应用,进入语音部分。

    去年的 I/O 大会上,Google Duplex 和人类打电话订餐馆的表演震惊了世人。但当时 Duplex 只能通过手机语音订餐馆,今年谷歌把该功能升级成为 Duplex on web,让人工智能可以帮助你在电脑和手机上自动订餐、订机票、打车了。以打车为例,新版的 Duplex 可以自动填充乘车人信息,使用者只需根据需要作出修改并确认即可。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    此外,谷歌在模型压缩方面的研究也有了回报。Pichai 介绍了谷歌取得的一项新的里程碑,近年来深度学习的发使得谷歌能够把 100GB 的语音识别模型压缩到 0.5GB,从而让 Google Assistant 在移动端变得更快。

    有多快?移动端实时识别语音速度提升 10 倍!谷歌工作人员的演示引起了现场观众的阵阵尖叫。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    今天的语音助手和人的对话已经接近自然,在与 Google Assistant 对话中,用户不在需要每次说「hey,Google」唤醒词,且能跨越手机上的 APP 工作,例如在短信对话框让 Google Assistant 搜索一张图片发给好友。

    此外,Google Assistant 还加入了一些新功能,例如 Personal References 能够为你优化沟通结果;通过说"Hey Google, let's drive.",开启谷歌助手驾驶模式,不过这个功能要在今年夏天才会到来。

    预计在今年下半年新的 Pixel 手机中,你就能看到新一代的 Google Assistant 了。

    模型偏见与数据隐私

    「以隐私与安全为核心,开发我们的技术」,这是 Pichai 介绍过前面如此多强大的 AI 应用之后强调的重点。

    随着深度学习在我们日常生活中的应用越来越普遍,我们不得不重视神经网络的一大问题:模型可解释性。在使用大量数据训练深度学习模型时,一个普遍的担心是它们会学习到人类所拥有的偏见。

    为了保证 AI 模型不会学习到这种偏见,谷歌做了大量研究提升模型透明度。

    首先,Pichai 介绍了谷歌曾发布的一种方法:TCAV。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    以识别斑马的模型为例,使用了 TCAV 方法,能够理解每个概念 (如条纹)对模型预测的重要性。

    TCAV 相关论文:https://arxiv.org/pdf/1711.11279.pdf

    除了提升模型透明度,谷歌建立「AI for Everyone」的另一种方式是保证产品的安全与私密性,让人们清楚、明白数据所带来的选择。

    从 2004 年到 2018 年,谷歌为其所有的产品添加了大量安全保护特征,包括 Google Takeout、Activity Controls,以及如今谷歌账户的自动(数据)删除设置、谷歌地图的匿名模式。

    「我们想要使用更少的数据,为用户做更多的事。」联邦学习为谷歌的这一愿景提供了解决方案。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    2016 年,谷歌提出联邦学习用于解决安卓手机终端用户在本地更新模型的问题,从而保障数据交换时的信息安全、保护终端数据和个人数据隐私,保证合法合规的前提下,在多参与方或多计算结点之间开展高效率的机器学习。

    以谷歌 Gboard 为例,单独的设备上学习无法为用户主动推荐经常用到的词汇,但加上联邦学习,就能在用户多次使用相关词汇之后自动推荐。如今,大量设备的 Gboard 都已经使用到了联邦学习,在输入时为用户推荐单词与表情。

    安卓 Q:加入防沉迷功能

    在搜索之外,安卓(Android)系统是谷歌今天成功的重要原因之一。在 I/O 大会上谷歌透露,今天全球约有 25 亿台正在运行的安卓设备。它已经成为了谷歌以及大多数其他公司部署新应用最优先的平台。如谷歌 AI 语音助理、人工智能图像识别产品等。Android 也是 Wear OS、Android Auto 和 Google 的流媒体电视平台 Android TV 的基础。

    Beta 版的安卓 Q 已经在一些开发者手中出现一段时间了,其中包括广受人们欢迎的系统级暗色模式。在华为和三星推动下,安卓 Q 也加入了对折叠屏手机的完整支持:在打游戏的时候,手机在副屏幕和主屏幕(折叠屏)上可以无缝立即切换显示。谷歌智能推荐功能现在已经可以预测你下一步的动作了。而「设备上学习」功能的存在可以让手机越用越聪明。

    手机好用,但过于沉迷也不是好事,谷歌特意在安卓 Q 中加入了 Focus Mode,可以让用户选择屏蔽邮件、信息的提示。谷歌表示在美国,孩子开始接触手机的年龄已经下降到 8 岁左右了。安卓 Q 也引入了家长模式,可以让父母观察孩子们的手机使用了哪些应用,并控制他们的使用时间。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    安卓 Q 上内置了 Live Caption 功能,可以为任何手机正在播放的视频实时显示字幕,这是此前帮助听障人士的功能 Live Transcribe 的升级版,适用于从 Youtube 视频到相册中视频的任何视频内容。「它不仅可以帮助听障人士无障碍地接触更多信息,也可以在普通人不方便打开声音的时候安静地观看视频。」桑达尔·皮查伊介绍道。

    值得一提的是,Live Caption 功能可以完全在设备端运行,在不联网甚至飞行模式下也可以实时生成字幕。这得益于谷歌在设备上机器学习方面取得的突破,他们将模型进一步缩小,使得数据可以直接在客户端进行处理,无需离开手机上传到云端,可以有效保护用户隐私。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    随着 I/O 大会的召开,安卓 Q 的第三版测试也已开始,首批将在这些品牌的手机上出现,其中包括华为、小米、vivo、oppo 和一加。

    由于 Beta 版是面向开发者的,在安装前请三思而后行,除了所有 Pixel 手机之外,安卓 Q Beta 3 还支持华为 Mate 20 Pro、小米 9、一加 6T 等机型。Google 让 Pixel 所有者只需使用谷歌账号登录,然后选择兼容测试版的相应设备即可加入测试阶段。你可以通过这种方式获得测试版更新,就像通常用于稳定版本的系统一样。

    「平价版」Pixel 手机

    谷歌从未在 I/O 大会上发布新手机,但今年是个例外。今天,谷歌在 I/O 大会上发布了 Pixel 家族的两款新机 Pixel 3A 和 3A XL,并表示,这是为了让全球更多人能够接触到最先进的人工智能技术。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    谷歌首次在 I/O 大会上开了场「手机发布会」,推出了 Pixel 3a 和 3a XL。

    Pixel 手机永远不是硬件配置最好的那一个,不过它总会最先得到谷歌官方带来的新技术应用,如 Duplex、Night Sight 等。这些功能不受手机硬件的限制,更多的是谷歌的开发水平和利用人工智能能力的体现。谷歌特别提醒道:Pixel 3a 将会得到谷歌未来三年内所有新技术升级的保证。

    两款手机都有相同的背面指纹识别、1220 万像素单摄像头(前摄像头 800 万像素)以及 OLED 屏幕,尺寸分别为 5.6 寸和 6 寸,电池容量分别为 3000mAh 和 3700mAh,据说可以至少满足「长达 30 小时的使用时间」。两款手机都有黑白粉色三种颜色可选。

    在最重要的配置上,Pixel 3a 和 Pixel 3a XL 搭载骁龙 670 处理器,运存 4G,存储容量 64G。

    谷歌希望新技术可以为更多人服务,但发现当今的高端手机越来越贵了,因此希望让 AI 技术能够在普通配置的手机上也能呈现。新手机就是这种思想的载体。

    「Pixel 3a 保留了 3.5mm 耳机接口,并使用 AI 算法让单摄像头在各种光线下保持高拍照水准。」谷歌产品负责人 Sabrina Ellis 表示。在谷歌的展示中,低光、景深虚化、超分辨率等其他手机需要双摄像头、甚至三摄四摄实现的功能,在 3a 上都可以通过高效率的算法来完成。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    使用 Pixel 就意味着可以抢先体验谷歌最新发布的各种应用,现在你已经可以用谷歌地图 AR 显示巨大的虚拟路标用来导航了。

    Pixel 3a 和 3a XL 的售价分别为 399 美元和 479 美元(折合人民币 2700/3250 元),讲道理这样的价格已经可以在国内买到很多品牌的骁龙 855 级旗舰机了,可能只有喜欢尝试谷歌新 app 的玩家才会去买吧。

    进军智能家居

    谷歌重组了智能家居的产品线,将所有产品都集中在 Nest 旗下,希望能够让自己的智能家居设备覆盖 5 岁到 95 岁的人群。Nest Hub Max 是谷歌这次在 I/O 大会上推出最具特色的新硬件,它是谷歌的 10 英寸屏幕版本 Home Hub,是一个带有摄像头、大屏幕的智能音箱,它将成为智能家庭的控制中心,也可以作为监控摄像头或者视频通话设备。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    与其他厂商声纹识别区分用户的方式不同,谷歌有一个基于人脸识别的 Face Match 功能:不同的人在 Nest Hub Max 的屏幕上看到的内容都是他们专属的。

    大屏幕也让 Hub Max 可以当做一个「厨房电视」,放音乐或者用视频教你做饭。有摄像头的音箱也可以加手势识别功能,如果你的电话来了想停止音乐,冲它抬一下手就行了。

    助力残障人士

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    在过去的一年里,谷歌曾因与政府合作军事项目而备受指责,让人怀疑谷歌变了,不再是那个坚持「不作恶」的谷歌了。在今年的 I/O 大会上,谷歌似乎竭力挽回其社会形象,致力于打造「人人可用的产品」(Accessible products for Everyone)。

    大会中,谷歌多位负责人强调了其产品的可及性以及对人的帮助,尤其是对残障人士的帮助,其代表产品包括 Live Transcribe、Live Caption、Live Relay、Project Euphonia 等。

    前面已经提到,Live Caption 和 Live Transcribe 都是语音转文字的应用,可以帮助到全球 5 亿的听力障碍者。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    一位听力障碍人士在利用谷歌的 Live Transcribe「听」其他人讲话。

    Live Relay 是一款帮助聋哑人士接电话的应用。电话接通后,语音助手会将聋哑用户想要表达的内容生成语音展现给对方,同时将对方的语音信息转换为文字呈现给聋哑人士,将电话界面转换成了聊天窗口。这款应用也适用于渐冻症等特殊疾病人群。

    尖叫连连!谷歌I/O新惊喜:智能助手0延迟对话、3D鲨鱼「上舞台」

    Project Euphonia 是专为中风、口吃等语音不清晰的人群打造的项目。这些人无法使用普通的语音模型,需要对模型进行个性化训练。研究人员收集了大量来自目标人群的语音数据,使得这类人群也能用上谷歌最新的语音技术,提高其产品的可及性和公平性。

    Bert 太牛,上台吹一波!

    在今天上午的 keynote 中,最后上台的是 Jeff Dean 大神,这在之前的谷歌 I/O 中极为罕见。

    在一片掌声中,Jeff Dean 介绍了谷歌 AI 近来取得的新成果,特别是在自然语言理解方面。Jeff Dean 说,「我们想要计算机有人类一样流畅的语言能力」。因此过去数年,谷歌 AI 在这方面做了大量工作,特别是 2017 年提出 Transformers,取得了极大进步。

    后来,在 Transformers 的基础上,谷歌提出 Bert,在 11 种语言处理任务上都取得了顶尖成果,引发业内巨震。如今,Bert 模型广为人知……

    除了 Bert,Jeff Dean 在演讲中简略提及了 TensorFlow 框架,谷歌 AI 医疗团队的 Lily Peng 介绍了一项她们在医疗领域的最新研究成果:从 CT 图像识别肺癌,相关论文将发表在 Nature Medicine 期刊上。

    小结

    未来你的生活或许会是这样:早晨,在厨房打开 Nest Hub 的食谱学做早餐,打开 Pixel 手机看到明天要去的城市,使用 Duplex 租一辆车,谷歌地图会帮你计划好行车路线——而在整个过程中,你不需要动一个手指。这就是谷歌 I/O 大会为我们展示的 AI 智能时代新体验。

  • I/O 2019:谷歌展示Live Caption实时字幕功能

    在北京时间今天凌晨的 I/O 2019 开发者大会上,谷歌向我们展示了 Android Q 中的诸多新特性,其中就包括强大的 Live Caption 实时字幕功能。你可以给手机上播放的任何音视频内容,启用这项独特的转录功能,而且识别的准确率相当惊人。实时字幕可以覆盖在当前使用的任何 App 之上,无论是 YouTube、Instagram、Pocket Casts,还是 Skype、Google Duo 等视频聊天应用,都可以体验到 Live Caption 的强大魅力。

    livecaption.gif

    你甚至可以在自己录制的音视频内容上启用 LiveCaption 字幕功能(题图 via TheVerge

    谷歌在一篇博客文章中写到:“对于世界各地的 4.66 亿耳聋和听力障碍人士而言,字幕不仅便利、而且易于获取。我们与该社区实现了密切的合作,开发了意向可以改善数字媒体访问的新功能”。

    在今日的主题演讲期间,谷歌 CEO Sundar Pichai 在台上表示:此举是为了确保每个人都可以轻松使用该公司的产品。

    其相信人工智能新工具有助于提升技术的包容性,从而显著改善残障人士的体验。

    据悉,Live Caption 是通过设备本机上的机器学习方案实现的,能够完全支持脱机工作、无需将任何活动数据发送到云端。

    字幕转录功能在一个悬浮的黑框中完成,你可以在屏幕上自由拖动它。更给力的是,即便手动调低了音量(甚至静音),该功能同样有效,因为它可以离线分析音频元数据。

    不过转录字幕无法保存以供日后查看,因为它是在媒体播放时同步进行的。当退出播放时,Live Caption 转录文本框也会立即消失。

    Android Q _ exclusive hands-on with the new features(via

    显然,这是谷歌“可访问性”项目的一个重要补充,能够为用户带来各种情况下的使用便利。Pichai 表示:“你可以想象更加广泛的社区用例,比如在会议或地铁上观看任何视频,但不会打扰到周围的人”。

    感兴趣的朋友,可以在 Android Q beta 3 中抢先体验(首批支持的设备数量有限)。你可以通过其中一颗音量键来触发该功能,当 UI 弹出时,可以显示 Live Caption 的软件图标。

    需要注意的是,在 Android Q 系统中,Live Caption 功能是被默认禁用的。你需要在设置中启用这项辅助功能,才会在调节音量时看到 Live Caption 的图标。

  • Linux下创建和使用RamDisk的技巧

    CentOS5.2后默认的ramdisk的大小只有16M,通过以下的方法可以修改默认大小:

    修改/etc/grub.conf

    default=0
    timeout=5
    splashimage=(hd0,0)/grub/splash.xpm.gz
    hiddenmenu
    title CentOS (2.6.18-92.el5)
            root (hd0,0)
            kernel /vmlinuz-2.6.18-92.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet ramdisk_size=131072
            initrd /initrd-2.6.18-92.el5.img

    以上设置的大小为124M。ramdisk_size=524288 最大512M。

     

    每次重启后自动生效的方法:

    编辑/etc/rc.local

    /sbin/mke2fs -q -m 0 /dev/ram0
    /bin/mount /dev/ram0 /mnt/rd0
    /bin/chown root /mnt/rd0
    /bin/chmod 0750 /mnt/rd0

     

    Ramdisk 的读写速度测试如下:

    写入速度:

    #time dd if=/dev/zero of=test.dbf bs=8k count=100000  conv=fsync
    100000+0 records in
    100000+0 records out
    819200000 bytes (819 MB) copied, 1.35819 seconds, 603 MB/s

    real 0m1.369s
    user 0m0.030s
    sys 0m1.330s

    读取速度:

    # time dd if=/dev/ram0 of=/dev/null bs=8k
    512000+0 records in
    512000+0 records out
    4194304000 bytes (4.2 GB) copied, 3.00381 seconds, 1.4 GB/s

    real 0m3.029s
    user 0m0.010s
    sys 0m2.995s

    另外一个方法是用tmpfs 来实现:

    手工命令行实现:
     mount -t tmpfs tmpfs /tmp_dir/ -o size=5M
    该命令创建5M 的内存空间
     
    如果下次系统启动生效,请在下面的文件中增加:
    vi /etc/fstab
    tmpdisk                /tmp_dir/   tmpfs  rw,size=3G     0 0

  • Linux-tempfs文件系统

    tmpfs是一种虚拟内存的文件系统,通俗点就是在内存中开辟一个空间,来存放要运行的文件,它d读取块,通过mount来挂载的。因为在树莓派中要连物联网,传上我外接传感器的数据,所以使用tmpfs来实现,避免sd卡擦写太多次。(ps:tmpfs读取速度快,但是在重启后数据不会保存。)

    首先,建立文件夹
    sudo mkdir /mnt/tmp
    把文件夹挂入内存中
    sudo mount -t tmpfs -o size=5m tmpfs /mnt/tmp
    运行后可以使用df -h查看是否正确,使用free查看内存使用情况
    如果要在开机后自动将文件夹挂入内存中,修改 /etc/fstab
    (/etc/fstab文件夹是用来存放文件系统静态信息的文件)
    加入 tmpfs /mnt/tmp size=5m 0 0

    tmpfs是一种虚拟内存文件系统,而不是块设备。是基于内存的文件系统,创建时不需要使用mkfs等初始化。
    它最大的特点就是它的存储空间在VM(virtual memory),VM是由linux内核里面的vm子系统管理的。Linux下面VM的大小由RM(Real Memory)和swap组成,RM的大小就是物理内存的大小,而Swap的大小是由自己决定的。
    Swap是通过硬盘虚拟出来的内存空间,因此它的读写速度相对RM(Real Memory)要慢许多,当一个进程申请一定数量的内存时,如内核的vm子系统发现没有足够的RM时,就会把RM里面的一些不常用的数据交换到Swap里面,如果需要重新使用这些数
    据再把它们从Swap交换到RM里面。如果有足够大的物理内存,可以不划分Swap分区。
    VM由RM+Swap两部分组成,因此tmpfs最大的存储空间可达(The size of RM + The size of Swap)。 但是对于tmpfs本身而言,它并不知道自己使用的空间是RM还是Swap,这一切都是由内核的vm子系统管理的。
    tmpfs默认的大小是RM的一半,假如你的物理内存是1024M,那么tmpfs默认的大小就是512M,一般情况下,是配置的小于物理内存大小的。tmpfs配置的大小并不会真正的占用这块内存,如果/dev/shm/下没有任何文件,它占用的内存实际上就是0字节;如果它最大为1G,里头放有100M文件,那剩余的900M仍然可为其它应用程序所使用,但它所占用的100M内存,是不会被系统回收重新划分的。当删除tmpfs中文件,tmpfs 文件系统驱动程序会动态地减小文件系统并释放 VM 资源。
    LINUX中可以把一些程序的临时文件放置在tmpfs中,利用tmpfs比硬盘速度快的特点提升系统性能。

     

  • 各自深度网络特征比较

    Name Acc. test finetuned Acc. test. Train time Forward pass time On disk model size Year Paper
    AlexNet 93.65% 97.98% 35m 3.01 ms 227.5Mb 2012 link
    SqeezeNet v1.1 92.46% 98.87% ~2h 3.91 ms 2.9Mb 2016 link
    GoogLeNet 94.62% 99.58% 50m 11.73 ms 41.3Mb 2014 link
    VGG-16 96.51% 99.40% 5h20m 15.41 ms 537.1Mb 2014 link
    VGG-19 97.42% 99.48% 25h50m 19.23 ms 558.3Mb 2014 link
    Network-In-Network 93.65% 98.49% ~2h 3.17 ms 26.3Mb 2014 link
    ResNet-50 95.84% 99.52% 18h 24.91 ms 94.3Mb 2015 link
    ResNet-101 96.39% 99.48% 1d 20h 40.95 ms 170.5Mb 2015 link
  • 高效编程之cache命中对于程序性能的影响

    下面这个代码用两个双层循环遍历了一个二维数组里所有的元素,以我自己机器的测试 上面那个循环耗时基本为下面的一半,两个循环的时间复杂度相同,为什么会有这么大的差别?

    首先要明白的是不管是几维数组,他们都是用一块地址连续的内存来存储所有的元素,而内存布局的顺序是一整行接着下一个整行排列,第一个循环是一行一行访问,所以从内存上看是顺序的遍历了这块内存,每次读取的位置都在上一次的附近,所以cache命中率高。第二个循环是一列一列访问,可以说访问的元素都不是连续的内存访问(相隔了一行的大小),从而降低了cache的命中率。

    cache的命中率对多层循环的影响是最明显的,因此在设计循环逻辑的时候,如果有某个数据结构需要多次访问,尽量让其全部在最里层中完成访问,提高cache对其的命中率。

    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
         int hang = 1024*8;
         int lie = 1024*8;
         int c = 0;
         int **arr = (int **)malloc(sizeof(int*) * lie);
         for(c = 0; c < lie; c++)
         {
              arr[c] = (int*)malloc(sizeof(int) * hang);
         }
     
         struct timeval time1, time2;
         int i, j;
     
         gettimeofday(&time1, 0);
         for(j = 0; j < lie; j++)
         {
              for(i = 0; i < hang; i++)
              {
                   arr[j][i] ++;
              }
     
         }
         gettimeofday(&time2, 0);
         printf("time %f\n", (double)(time2.tv_sec-time1.tv_sec) + (double)(time2.tv_usec-time1.tv_usec) /1000000);
     
     
         gettimeofday(&time1, 0);
         for(i = 0; i < hang; i++)
         {
              for(j = 0; j < lie; j++)
              {
                   arr[j][i] ++;
              }
     
         }
         gettimeofday(&time2, 0);
         printf("time %f\n", (double)(time2.tv_sec-time1.tv_sec) + (double)(time2.tv_usec-time1.tv_usec) /1000000);
     
     
         return 0;
    }