<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[LSC PSD - Medium]]></title>
        <description><![CDATA[The member of LSC Corp. - Medium]]></description>
        <link>https://medium.com/lsc-psd?source=rss----a901ed844f0c---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>LSC PSD - Medium</title>
            <link>https://medium.com/lsc-psd?source=rss----a901ed844f0c---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 18:27:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/lsc-psd" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[[Object Detection][CoreML][TuriCreate][jupyter notebook][XamariniOS]自作の学習データで物体認識AIを学習させてスマホに移植]]></title>
            <link>https://medium.com/lsc-psd/object-detection-coreml-turicreate-jupyter-notebook-xamarinios-%E8%87%AA%E4%BD%9C%E3%81%AE%E5%AD%A6%E7%BF%92%E3%83%87%E3%83%BC%E3%82%BF%E3%81%A7%E7%89%A9%E4%BD%93%E8%AA%8D%E8%AD%98ai%E3%82%92%E5%AD%A6%E7%BF%92%E3%81%95%E3%81%9B%E3%81%A6%E3%82%B9%E3%83%9E%E3%83%9B%E3%81%AB%E7%A7%BB%E6%A4%8D-8620f8d35af2?source=rss----a901ed844f0c---4</link>
            <guid isPermaLink="false">https://medium.com/p/8620f8d35af2</guid>
            <category><![CDATA[turi-create]]></category>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[xamarin]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coreml]]></category>
            <dc:creator><![CDATA[Yutaka_kun]]></dc:creator>
            <pubDate>Fri, 22 Oct 2021 08:31:46 GMT</pubDate>
            <atom:updated>2021-10-22T08:33:28.192Z</atom:updated>
            <content:encoded><![CDATA[<p>タブレット・携帯端末で動く物体認識AIを作りたかったので、色々調べながら泥臭くやりました。途中「神の声」もかりながらやりましたが一応それっぽいものができたと思います。</p><h4>サンプルAIを動かす</h4><p>まずはそもそもスマホでAIなるものが動くかわからなかったので、サンプルモデルを探して動かしてみました。<br>appleのサイトからサンプルコードをクローンして、「<a href="https://github.com/xamarin/ios-samples/tree/master/ios12/BreakfastFinder">BreakfastFinder</a>」をビルドしてみると意外と簡単に動かせました。</p><p>AIの起動や処理のコードもそうですが</p><p>・<strong>カメラの初期化</strong><br>・<strong>撮影画像をリアルタイムで処理をかけて画面に出力する</strong></p><p>部分など結構そっちの方が勉強になりました。<br>ちなみに一行一行デバックで追って解読していったので、、ここだけで3日くらい潰れてます。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*XWyRohlGpjTYAaCxg8U5Og.png" /><figcaption>＊私の指はバナナだそうです</figcaption></figure><h4>サンプルデータでサンプルAIをトレーニングしてみる</h4><p>AIがスマホで動くことが分かったので、今度はサンプルAIがサンプルデータで学習できるか調べてみます。</p><p><a href="https://apple.github.io/turicreate/docs/userguide/object_detection/data-preparation.html">appleのサイト</a>の説明にしたがってサンプルデータ（車と自転車）をダウンロードします。これは下記の通りにやればダウンロードできました。</p><pre>$ mkdir -p ~/Downloads/ig02<br>$ cd ~/Downloads/ig02<br>$ curl https://lear.inrialpes.fr/people/marszalek/data/ig02/ig02-v1.0-bikes.zip &gt; bikes.zip<br>$ curl https://lear.inrialpes.fr/people/marszalek/data/ig02/ig02-v1.0-cars.zip &gt; cars.zip<br>$ unzip bikes.zip<br>$ mv readme.txt readme-bikes.txt<br>$ unzip cars.zip<br>$ rm bikes.zip cars.zip</pre><p>Turi Createをインストールしておきます</p><pre>pip install turicreate</pre><p>Turi Createでサンプルデータの準備をします。基本的な流れはサイトの手順に従えばいけるとは思いますが、サイトのままではエラーが起きたので私の環境でうまく行ったコードを貼り付けておきます。<br>ちなみにjupyter notebookで実行するとやりやすいと思います。</p><pre>import turicreate as tc<br>import os</pre><pre>ig02_path = &#39;Downloads/ig02&#39;</pre><pre>raw_sf = tc.image_analysis.load_images(ig02_path, recursive=True,<br>                                       random_order=True)</pre><pre>info = raw_sf[&#39;path&#39;].apply(lambda path: os.path.basename(path).split(&#39;.&#39;)[:2])</pre><pre>info = info.unpack().rename({&#39;X.0&#39;: &#39;name&#39;, &#39;X.1&#39;: &#39;type&#39;})</pre><pre>raw_sf = raw_sf.add_columns(info)</pre><pre>raw_sf[&#39;label&#39;] = raw_sf[&#39;name&#39;].apply(lambda name: name.split(&#39;_&#39;)[0])</pre><pre>del raw_sf[&#39;path&#39;]</pre><pre>sf_images = raw_sf[raw_sf[&#39;type&#39;] == &#39;image&#39;]<br>sf_masks = raw_sf[raw_sf[&#39;type&#39;] == &#39;mask&#39;]</pre><pre>def mask_to_bbox_coordinates(img):<br>    import numpy as np<br>    mask = img.pixel_data<br>    if mask.max() == 0:<br>        return None<br><br>    x0, x1 = np.where(mask.max(0))[0][[0, -1]]<br>    y0, y1 = np.where(mask.max(1))[0][[0, -1]]</pre><pre>    return {&#39;x&#39;: (x0 + x1) / 2, &#39;width&#39;: (x1 - x0),<br>            &#39;y&#39;: (y0 + y1) / 2, &#39;height&#39;: (y1 - y0)}</pre><pre>sf_masks[&#39;coordinates&#39;] = sf_masks[&#39;image&#39;].apply(mask_to_bbox_coordinates)</pre><pre>sf_masks = sf_masks.dropna(&#39;coordinates&#39;)</pre><pre>sf_masks = sf_masks.pack_columns([&#39;label&#39;, &#39;coordinates&#39;],<br>                                 new_column_name=&#39;bbox&#39;, dtype=dict)</pre><pre>sf_annotations = sf_masks.groupby(&#39;name&#39;,<br>                                 {&#39;annotations&#39;: tc.aggregate.CONCAT(&#39;bbox&#39;)})</pre><pre>sf = sf_images.join(sf_annotations, on=&#39;name&#39;, how=&#39;left&#39;)</pre><pre>sf[&#39;annotations&#39;] = sf[&#39;annotations&#39;].fillna([])</pre><pre>del sf[&#39;type&#39;]</pre><pre>sf.save(&#39;ig02.sframe&#39;)</pre><p>準備ができたので、トレーニングさせてみます。<br>トレーニングはサイトどおりに進めればできるはずです。<br>短いコードなので一応貼り付けておきます。</p><pre>import turicreate as tc</pre><pre>data = tc.SFrame(&#39;ig02.sframe&#39;)</pre><pre>train_data, test_data = data.random_split(0.8)</pre><pre>model = tc.object_detector.create(train_data)</pre><pre>predictions = model.predict(test_data)</pre><pre>metrics = model.evaluate(test_data)<br><br>model.save(&#39;ig02.model&#39;)<br><br>model.export_coreml(&#39;Car_Bike_Detector.mlmodel&#39;)</pre><p>作成されたCar_Bike_Detecter.mlmodelをBreakfastFinderのObjectDetecter.mlmodelと入れ替えてビルドします。<br>カメラで撮影すると車と自転車を認識できるようになりますが、精度は微妙です。もう少しちゃんと学習が必要のようです。この辺は1日もかからず突破しました。</p><h4>自分で画像にラベル付けして学習データを準備する</h4><p>何はともあれデータがあればAIを学習されられることが分かったので、自分で学習データを準備します。</p><p>画像のラベル付けが一番迷いました。アノテーションツールのLabelImageは使ったことがありますが、、アノテーションしたデータをどのような出力形式でエクスポートして.sframeにすればいいのか道筋がなかなか見えませんでした。</p><p>迷走していると「VoTTを使いなさい」という<a href="https://twitter.com/kurikuri54">神のお告げ</a>があったため、使ってみるとまあー使いやすいこと使いやすいこと。<br><a href="https://github.com/Microsoft/VoTT/releases">ここ</a>からVoTTをインストールして、操作説明は<a href="https://qiita.com/clerk67/items/8e7207284037dcf1f9ec">このサイト</a>か<a href="https://sleepless-se.net/2019/06/21/how-to-use-vott/">このサイト</a>を見れば誰でも使えます。</p><p>アノテーション後、”エクスポート設定”でプロバイダーを”コンマ区切り値（CSV）”に設定してCSVを出力します。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RxnS8wDk0stRwp5fW4qZ5A.png" /><figcaption>出力されるCSVはこんな感じ</figcaption></figure><p>先程のappleのサイトの手順に従ってCSVのデータを.sframeにしていきますが、サイトのコードだとうまく動かなかったので下記にコードを載せておきます。</p><pre>import turicreate as tc<br>import os</pre><pre>IMAGES_DIR = &#39;&#39; //画像がある場所<br>csv_path = &#39;&#39; //CSVがある場所</pre><pre>csv_sf = tc.SFrame.read_csv(csv_path)</pre><pre>def row_to_bbox_coordinates(row):<br>    &quot;&quot;&quot;<br>    Takes a row and returns a dictionary representing bounding<br>    box coordinates:  (center_x, center_y, width, height)  e.g. {&#39;x&#39;: 100, &#39;y&#39;: 120, &#39;width&#39;: 80, &#39;height&#39;: 120}<br>    &quot;&quot;&quot;<br>    return {&#39;x&#39;: row[&#39;xmin&#39;] + (row[&#39;xmax&#39;] - row[&#39;xmin&#39;])/2, <br>            &#39;width&#39;: (row[&#39;xmax&#39;] - row[&#39;xmin&#39;]),<br>            &#39;y&#39;: row[&#39;ymin&#39;] + (row[&#39;ymax&#39;] - row[&#39;ymin&#39;])/2, <br>            &#39;height&#39;: (row[&#39;ymax&#39;] - row[&#39;ymin&#39;])}</pre><pre>csv_sf[&#39;coordinates&#39;] = csv_sf.apply(row_to_bbox_coordinates)</pre><pre>del csv_sf[&#39;xmin&#39;], csv_sf[&#39;xmax&#39;], csv_sf[&#39;ymin&#39;], csv_sf[&#39;ymax&#39;]</pre><pre>csv_sf = csv_sf.rename({&#39;image&#39;: &#39;name&#39;})</pre><pre>sf_images = tc.image_analysis.load_images(IMAGES_DIR, recursive=True,random_order=True)</pre><pre>info = sf_images[&#39;path&#39;].apply(lambda path: os.path.basename(path).split(&#39;/&#39;)[:1])</pre><pre>info = info.unpack().rename({&#39;X.0&#39;: &#39;name&#39;})</pre><pre>sf_images = sf_images.add_columns(info)</pre><pre>del sf_images[&#39;path&#39;]</pre><pre>csv_sf = csv_sf.pack_columns([&#39;label&#39;, &#39;coordinates&#39;], new_column_name=&#39;bbox&#39;, dtype=dict)</pre><pre>sf_annotations = csv_sf.groupby(&#39;name&#39;, <br>    {&#39;annotations&#39;: tc.aggregate.CONCAT(&#39;bbox&#39;)})</pre><pre>sf = sf_images.join(sf_annotations, on=&#39;name&#39;, how=&#39;left&#39;)</pre><pre>sf[&#39;annotations&#39;] = sf[&#39;annotations&#39;].fillna([])</pre><pre>sf.save(&#39;mydata.sframe&#39;)</pre><h4>mydata.sframeを使ってモデルをトレーニングしてみる</h4><p>ここはサイトのコードをそのまま使えばいけますが、短いので貼り付けておきます。</p><pre>import turicreate as tc</pre><pre>data = tc.SFrame(&#39;mydata.sframe&#39;)</pre><pre>train_data, test_data = data.random_split(0.8)</pre><pre>model = tc.object_detector.create(train_data)</pre><pre>predictions = model.predict(test_data)</pre><pre>metrics = model.evaluate(test_data)</pre><pre>model.save(&#39;mymodel.model&#39;)</pre><pre>model.export_coreml(&#39;MyObjectDetector.mlmodel&#39;)</pre><p>先程と同じ要領で、作成されたMyObjectDetecter.mlmodelをBreakfastFinderのObjectDetecter.mlmodelと入れ替えてビルドします。</p><p>これで自作したAIモデルをタブレット・携帯端末で動かせるはずです。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8620f8d35af2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lsc-psd/object-detection-coreml-turicreate-jupyter-notebook-xamarinios-%E8%87%AA%E4%BD%9C%E3%81%AE%E5%AD%A6%E7%BF%92%E3%83%87%E3%83%BC%E3%82%BF%E3%81%A7%E7%89%A9%E4%BD%93%E8%AA%8D%E8%AD%98ai%E3%82%92%E5%AD%A6%E7%BF%92%E3%81%95%E3%81%9B%E3%81%A6%E3%82%B9%E3%83%9E%E3%83%9B%E3%81%AB%E7%A7%BB%E6%A4%8D-8620f8d35af2">[Object Detection][CoreML][TuriCreate][jupyter notebook][XamariniOS]自作の学習データで物体認識AIを学習させてスマホに移植</a> was originally published in <a href="https://medium.com/lsc-psd">LSC PSD</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[持参薬鑑別でお困りの医師・薬剤師の皆様、お待たせしました。「Medkan」です。]]></title>
            <link>https://medium.com/lsc-psd/%E6%8C%81%E5%8F%82%E8%96%AC%E9%91%91%E5%88%A5%E3%81%A7%E3%81%8A%E5%9B%B0%E3%82%8A%E3%81%AE%E5%8C%BB%E5%B8%AB-%E8%96%AC%E5%89%A4%E5%B8%AB%E3%81%AE%E7%9A%86%E6%A7%98-%E3%81%8A%E5%BE%85%E3%81%9F%E3%81%9B%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F-medkan-%E3%81%A7%E3%81%99-975a58568336?source=rss----a901ed844f0c---4</link>
            <guid isPermaLink="false">https://medium.com/p/975a58568336</guid>
            <category><![CDATA[鑑別]]></category>
            <category><![CDATA[文字認識]]></category>
            <category><![CDATA[錠剤]]></category>
            <category><![CDATA[ocr]]></category>
            <category><![CDATA[カプセル]]></category>
            <dc:creator><![CDATA[Yutaka_kun]]></dc:creator>
            <pubDate>Mon, 23 Aug 2021 08:18:17 GMT</pubDate>
            <atom:updated>2021-08-23T08:06:54.005Z</atom:updated>
            <content:encoded><![CDATA[<p>薬剤鑑別アプリケーション「Medkan」のご紹介です。<br>薬の写真を撮影するだけで一度に複数の薬剤を鑑別することができます。<br>今までのように認識記号を一つ一つ入力する作業は不要です！<br>写真一枚でスピーディーに鑑別作業が完結できます。<br>現在はiOSのみ対応ですが、今後Androidにも対応していく予定です。</p><h4>2021.9.1から2021.9.3まで医療と介護の総合展（オンライン）に出展しております。ご興味がある方はぜひお立ち寄りください。</h4><p><a href="https://www.medical-jpn.jp/online/ja-jp.html">医療と介護の総合展</a></p><p><a href="https://www.lscc.co.jp/">弊社ホームページ</a></p><p>＊現在このアプリはAppStoreではインストールできないようになっています。ご試用になりたい方はお手数ですが一度弊社までお問い合わせください。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*Y1KSpeEpIwlCP9ZXDIOCuA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5zIHvIIOyTwtNGOodX8uUg.png" /><figcaption>Medkanイメージ画像</figcaption></figure><h4>錠剤・カプセル等を撮影</h4><p>錠剤に印字されている文字や刻印が目視できるようにカメラのピントを合わせます。<br>画面右下のスライドでズームの調整や明るさの調整ができます。<br>ピントが合ったタイミングで画面左下の「認識ボタン」をタップすると、錠剤がオレンジの枠で囲まれます。<br>画面右下の「検索ボタン」をタップすると写真から錠剤の画像がトリミングされ、それぞれ検索サーバーに送信されます。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vbCv8nLnMsu74oR6gjlq_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mOa5qoBN-0Pi369-W2RVUw.png" /><figcaption>認識前：認識後</figcaption></figure><h4>認識補助機能</h4><p>＊オレンジ枠内をタップすると枠の削除ができます<br>＊「全クリア」をタップすると全ての枠の削除ができます<br>＊画面をタップしたままドラッグすると手動で枠の作成ができます</p><h3>検索結果画面</h3><p>それぞれの画像から抽出された文字列が返却されます。<br>返ってきた文字列がさらに薬剤データベースに送信され、文字列と一致する薬剤データーが返却されます。薬剤データは画面右側にリストで表示されます。「PDF」ボタンをタップすると薬剤の添付文書が展開されます。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezdeFjpFKOvTlEOuTc5DFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*muNEshIjOL5KjSPW2TZouQ.png" /><figcaption>結果表示画面：PDF表示画面</figcaption></figure><h3>あいまい検索機能</h3><p>下の図のように画像の向きなどによって完全に文字が抽出できず、対応する薬剤データが得られない場合があります。<br>その場合は”あいまい検索機能”により文字列の「類似度」の高い順に薬剤データが返却されます。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xYVoCSZvA2dyMQCYmoiY_A.png" /></figure><h3>薬剤データのソート機能</h3><p>画像から抽出された文字列によっては大量のデータが返ってくる場合があります（”100”とか”250”などの文字列）。</p><p>実は文字列の検索は2つのルートが存在します。</p><p>・抽出した文字列を「認識コード」として検索するルート<br>・抽出した文字列を「商品名」として検索するルート</p><p>「コード」ボタン「商品名」ボタンで返ってきた総取得件数をざっくり2つに2分できます。さらにそこから、</p><p>・錠剤の「割線なし」<br>・錠剤の「割線あり」<br>・「カプセル」<br>・「その他」</p><p>の4つスイッチでデータを分けることができます</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P8JwZtDeT0znY5AFcbFxiQ.png" /><figcaption>文字列を 250 で検索した場合</figcaption></figure><h3>文字列抽出補助機能</h3><h4>画像の回転</h4><p>スライダーを調節することで、画像を回転させることができます</p><p>・右にスライド→右回転<br>・左にスライド→左回転</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lO-wuu8IQLEvvFswcStPKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Le929WYX_BHj4ysocRPv6w.png" /><figcaption>回転前：回転後</figcaption></figure><h4>画像の文字の強調・再抽出</h4><p>「電球」ボタンをタップすると画像内の文字を強調することができます<br>「目」のボタンをタップすると、画像内の文字を再抽出ができます</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Le929WYX_BHj4ysocRPv6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7koczXX_erLOW9jCraiXAA.png" /><figcaption>強調前：強調後再検索</figcaption></figure><h4>手動で入力</h4><p>入力欄をタップするとキーボード入力により手動で文字列を修正することも可能です。入力完了後「search」ボタンで再検索ができます。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aLdxtLFDw8eO7b3c3yun7w.png" /></figure><h3>カメラ撮影時の手ブレ</h3><p>カメラは常時最新フレームから５フレーム分の画像を保持しています。タブレットをうまく固定できず、画面がブレてしまった場合は数フレーム前に戻ることで、撮り直しを防ぐことができます。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*AMg8k5VvJigCZgISNobZNA.png" /></figure><p>画面下の「-1」「+1」ボタンを押すことでフレームの移動が可能です。</p><p>・-1→1フレーム戻る<br>・+1→1フレーム進む</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/168/1*tutsKPdKoW7oozGzbPqrXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/156/1*_ZqEh94qsi_u0nmCG1rxKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/168/1*BMeDV7sVkdEo6WvJZI2Khg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/162/1*0O-CNXLRmRvZStv5evHnPA.png" /></figure><h3>カメラロールの写真をアップロードして使用する</h3><p>カメラ画面右上の「花びら」ボタンをタップするとカメラロールに保存されている画像が出てきます。<br>任意の画像をタップすると選択した画像が画面にアップロードすることができます。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mwrOajc_gtISGrTtgCTwLg.png" /></figure><h3>認識記号のみで検索</h3><p>画像からではなく、文字列だけの検索も可能です。<br>画面下部の「手入力モード」をタップして、入力欄に”認識記号”または”商品名”などを入力し「search」ボタンをタップすると、対応する薬剤データが返却されます。PDFの観覧方法やデータのソート機能方法は「カメラモード」と同じです。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4HsOrtVFND_n7hfQ76LJcg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=975a58568336" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lsc-psd/%E6%8C%81%E5%8F%82%E8%96%AC%E9%91%91%E5%88%A5%E3%81%A7%E3%81%8A%E5%9B%B0%E3%82%8A%E3%81%AE%E5%8C%BB%E5%B8%AB-%E8%96%AC%E5%89%A4%E5%B8%AB%E3%81%AE%E7%9A%86%E6%A7%98-%E3%81%8A%E5%BE%85%E3%81%9F%E3%81%9B%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F-medkan-%E3%81%A7%E3%81%99-975a58568336">持参薬鑑別でお困りの医師・薬剤師の皆様、お待たせしました。「Medkan」です。</a> was originally published in <a href="https://medium.com/lsc-psd">LSC PSD</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[xamarin][ListView][Entry]キーボードでEntryの入力欄が隠れる問題が意外と問題]]></title>
            <link>https://medium.com/lsc-psd/xamarin-listview-entry-%E3%82%AD%E3%83%BC%E3%83%9C%E3%83%BC%E3%83%89%E3%81%A7entry%E3%81%AE%E5%85%A5%E5%8A%9B%E6%AC%84%E3%81%8C%E9%9A%A0%E3%82%8C%E3%82%8B%E5%95%8F%E9%A1%8C%E3%81%8C%E6%84%8F%E5%A4%96%E3%81%A8%E5%95%8F%E9%A1%8C-e560fd70b9e?source=rss----a901ed844f0c---4</link>
            <guid isPermaLink="false">https://medium.com/p/e560fd70b9e</guid>
            <category><![CDATA[xamarin]]></category>
            <category><![CDATA[entry]]></category>
            <category><![CDATA[listview]]></category>
            <dc:creator><![CDATA[Yutaka_kun]]></dc:creator>
            <pubDate>Fri, 19 Mar 2021 08:20:47 GMT</pubDate>
            <atom:updated>2021-03-19T08:20:20.357Z</atom:updated>
            <content:encoded><![CDATA[<p>xamarinって簡単にできそうなことが意外とできなかったりしますよね。<br>前々回記事「<a href="https://medium.com/lsc-psd/xamarin-c-listview-%E9%81%B8%E6%8A%9E%E4%B8%AD%E3%81%AEviewcell%E3%81%AE%E8%83%8C%E6%99%AF%E8%89%B2%E3%82%92%E5%A4%89%E3%81%88%E3%82%8B%E3%81%AE%E3%81%8C%E7%89%A9%E5%87%84%E3%81%84%E3%82%81%E3%82%93%E3%81%A9%E3%81%8F%E3%81%95%E3%81%8B%E3%81%A3%E3%81%9F-e1173fe1d371">ListViewの選択中のViewCell背景色変更</a>」しかり、、、</p><p>今回はEntryに入力しようとした時に、入力欄が画面キーボードで隠れてしまう問題を回避してみます。</p><p>＊2021/3/19 更新</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*aQxOLbU6N9VtxwfALtpXyA.jpeg" /></figure><p>私もいろいろサイトを調べてみたんですがどれも難しく、特に<a href="https://qiita.com/amay077/items/6fcdec829a96bc604532">ここのサイト</a>とか素人にはパッと見無理。そしてAndroid/iOS用に個別で作らないといけないのでめんどくさそう。</p><p>Android/iOS両方一括で作れて、なおかつ誰でもかけるように工夫してみました。</p><h3>MainPage.xaml</h3><pre>&lt;Grid&gt;<br>    &lt;ListView x:Name=&quot;Item_List&gt;<br>        &lt;ListView.ItemTemplate&gt;<br>            &lt;DataTemplate&gt;<br>                &lt;ViewCell&gt;<br>                    &lt;Grid&gt;<br>                        &lt;Entry Focused=&quot;Entry_is_focused&quot;/&gt;<br>                    &lt;/Grid&gt;<br>                &lt;/ViewCell&gt;<br>            &lt;/DataTemplate&gt;<br>        &lt;/ListView.ItemTemplate&gt;<br>    &lt;/ListView&gt;<br>&lt;/Grid&gt;</pre><p>上記のようにListViewのViewCellそれぞれにEntryが入っている体で説明します。<br>・ListViewにx:Nameで名前をつけてあげます。<br>・Focused=でEntryにフォーカスした時に”Entry_is_focused”が呼び出されます。</p><h3>MainPage.xaml.cs</h3><pre>public void Entry_is_focused(object sender, EventArgs e)<br>{<br>Item_List.ScrollTo(((Entry)sender).BindingContext,ScrollToPosition.Start, true);<br>}</pre><p>(インデントがおかしいですが、ご容赦を)<br>送られてきたsenderをEntryでキャストして、そのBindingContextをScrollToPosition.StartでListViewの先頭にスクロールしてあげます。<br>そうすればEntryの入力欄はキーボードからだいたい逃げられるはずです。<br> ListViewをスクロールさせるScrollTo()の詳しい使い方は<a href="https://docs.microsoft.com/ja-jp/dotnet/api/xamarin.forms.listview.scrollto?view=xamarin-forms">こちら</a>を参照してください。</p><p>ListViewを使ってないViewの下の方ににあるEntryはどうするんだ！！！<br>と言うツッコミが飛んできそうですが、、、、<br>その場合はやはり最初に紹介した<a href="https://qiita.com/amay077/items/6fcdec829a96bc604532">このサイト</a>のやり方でやるしかない気がします。お役に立てず申し訳ありません。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e560fd70b9e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lsc-psd/xamarin-listview-entry-%E3%82%AD%E3%83%BC%E3%83%9C%E3%83%BC%E3%83%89%E3%81%A7entry%E3%81%AE%E5%85%A5%E5%8A%9B%E6%AC%84%E3%81%8C%E9%9A%A0%E3%82%8C%E3%82%8B%E5%95%8F%E9%A1%8C%E3%81%8C%E6%84%8F%E5%A4%96%E3%81%A8%E5%95%8F%E9%A1%8C-e560fd70b9e">[xamarin][ListView][Entry]キーボードでEntryの入力欄が隠れる問題が意外と問題</a> was originally published in <a href="https://medium.com/lsc-psd">LSC PSD</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[【SkiaSharp】PNG画像をBitmapで読み込みbyte配列変換して処理した後PNGで保存する方法]]></title>
            <link>https://medium.com/lsc-psd/skiasharp-png%E7%94%BB%E5%83%8F%E3%82%92bitmap%E3%81%A7%E8%AA%AD%E3%81%BF%E8%BE%BC%E3%81%BFbyte%E9%85%8D%E5%88%97%E5%A4%89%E6%8F%9B%E3%81%97%E3%81%A6%E5%87%A6%E7%90%86%E3%81%97%E3%81%9F%E5%BE%8Cpng%E3%81%A7%E4%BF%9D%E5%AD%98%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95-1bbd6afed83f?source=rss----a901ed844f0c---4</link>
            <guid isPermaLink="false">https://medium.com/p/1bbd6afed83f</guid>
            <category><![CDATA[bitmap]]></category>
            <category><![CDATA[skiasharp]]></category>
            <category><![CDATA[png]]></category>
            <category><![CDATA[byte]]></category>
            <dc:creator><![CDATA[Yutaka_kun]]></dc:creator>
            <pubDate>Fri, 05 Mar 2021 15:57:02 GMT</pubDate>
            <atom:updated>2021-03-05T15:56:44.873Z</atom:updated>
            <content:encoded><![CDATA[<h3>【SkiaSharp】PNG画像をBitmapImageで読み込みbyte配列で処理した後PNGで保存する方法</h3><p>＊2021.3.6更新</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hg6xZ1kZVj5SSt6fobw5SQ.png" /></figure><p>SkiaSharpで画像処理するサイトがあまりなかったので載せておきます。”何か処理”以降は僕もあまり理解してませんがとりあえずコピペでいけるはずです。</p><pre>var bitmap = SKBitmap.Decode(&quot;path/imagename.png&quot;);<br>var bitmap_byte = bitmap.Bytes;</pre><pre>//バイト配列（bitmap_byte）を処理....<br>//処理したバイト配列をbitmap_byteに上書きしたと仮定</pre><pre>SKBitmap new_bitmap = new SKBitmap(bitmap.Width, bitmap.Height);</pre><pre>IntPtr pixelsAddr = new_bitmap.GetPixels();<br>Marshal.Copy(bitmap_byte, 0, pixelsAddr, b_byte.Length);<br>            <br>var stream = File.OpenWrite(&quot;path/new_imagename.png&quot;);<br>new_bitmap.Encode(stream, SKEncodedImageFormat.Png, 80);<br>stream.Dispose();</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bbd6afed83f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lsc-psd/skiasharp-png%E7%94%BB%E5%83%8F%E3%82%92bitmap%E3%81%A7%E8%AA%AD%E3%81%BF%E8%BE%BC%E3%81%BFbyte%E9%85%8D%E5%88%97%E5%A4%89%E6%8F%9B%E3%81%97%E3%81%A6%E5%87%A6%E7%90%86%E3%81%97%E3%81%9F%E5%BE%8Cpng%E3%81%A7%E4%BF%9D%E5%AD%98%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95-1bbd6afed83f">【SkiaSharp】PNG画像をBitmapで読み込みbyte配列変換して処理した後PNGで保存する方法</a> was originally published in <a href="https://medium.com/lsc-psd">LSC PSD</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[xamarin][C#][ListView]選択中のViewCellの背景色を変えるのが物凄いめんどくさかった]]></title>
            <link>https://medium.com/lsc-psd/xamarin-c-listview-%E9%81%B8%E6%8A%9E%E4%B8%AD%E3%81%AEviewcell%E3%81%AE%E8%83%8C%E6%99%AF%E8%89%B2%E3%82%92%E5%A4%89%E3%81%88%E3%82%8B%E3%81%AE%E3%81%8C%E7%89%A9%E5%87%84%E3%81%84%E3%82%81%E3%82%93%E3%81%A9%E3%81%8F%E3%81%95%E3%81%8B%E3%81%A3%E3%81%9F-e1173fe1d371?source=rss----a901ed844f0c---4</link>
            <guid isPermaLink="false">https://medium.com/p/e1173fe1d371</guid>
            <category><![CDATA[selecteditem]]></category>
            <category><![CDATA[xamarin]]></category>
            <category><![CDATA[listview]]></category>
            <category><![CDATA[change-background-color]]></category>
            <category><![CDATA[viewcell]]></category>
            <dc:creator><![CDATA[Yutaka_kun]]></dc:creator>
            <pubDate>Thu, 04 Feb 2021 10:23:38 GMT</pubDate>
            <atom:updated>2021-03-19T07:08:09.179Z</atom:updated>
            <content:encoded><![CDATA[<p>ViewCellは選択するものだから、選択中のセルの背景色ぐらいxamarinでささっと設定できるでしょ？？って思ってたらほんと痛い目にあいました。<br>一応やり方はネットにのっていて、&lt;ListView.Behavior&gt;を使ったり、IValueConverterを使ったりすればできるらしいですが、初心者の僕には訳わからんかったです。激闘の末、それ以外のやり方でできたのでここにのせておきます。</p><p>いろいろ省略している部分もあるので、そのまんまコピペだとうまく動かないかもしれません。でも順を追って読んでいけばどの様な手順でコードを組んでいけばいいか想像はつくはずです。（上級者からみたら突っ込みどころは満載かも）（突っ込んでいただける人はコメントまで、、）</p><p>＊2021/2/4 更新</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AjRcXrgm8BQbi8Ze_FokXg.jpeg" /></figure><h3>MainPage.xaml</h3><pre>&lt;Grid&gt;<br>    &lt;ListView SelectedItem=&quot;{Binding SelectedItem}&quot;<br>              ItemsSource=&quot;{Binding Items}&quot; <br>              BackgroundColor=&quot;Silver&quot;&gt;<br>        &lt;ListView.ItemTemplate&gt;<br>            &lt;DataTemplate&gt;<br>                &lt;ViewCell&gt;<br>                    &lt;Grid BackgroundColor=&quot;{Binding CellColor}&gt;<br>                        //何か書く<br>                    &lt;/Grid&gt;<br>                &lt;/ViewCell&gt;<br>            &lt;/DataTemplate&gt;<br>        &lt;/ListView.ItemTemplate&gt;<br>    &lt;/ListView&gt;<br>&lt;/Grid&gt;</pre><p>ListViewのSelectedItem,ItemsSourceはそれぞれViewModelのSelectedItemプロパティ,Itemsプロパティとバインドさせます<br>ViewCellの中のGridのBackgroundColorは（後述する）Itemクラスの中のCellColorプロパティと直接バインドさせます</p><h3>ViewModel.cs</h3><pre>public ObservableCollection&lt;Item&gt; Items { get =&gt; Items; }<br>public object SelectedItem { get =&gt; SelectedItem; set =&gt; SelectedItem = value; }</pre><p>ViewModelのItemsプロパティ,SelectedItemプロパティはModelのItemsプロパティ,SelectedItemプロパティとそれぞれバインドさせます（ここはViewとModelをつないでいるだけですね）</p><h3>Model.cs</h3><pre>private ObservableCollection&lt;Item&gt; _items = null;<br>public ObservableCollection&lt;Item&gt; Items<br>{<br>    get { return _detecteditems; }<br>    set { _detecteditems = value;<br>          RaisePropertyChanged(nameof(Items)); }<br>}<br>private object _selecteditem;<br>public object SelectedItem<br>{<br>    get{ return _selecteditem; }<br>    set{<br>        //ここマジ重要(後述)<br>           <strong>if(_selecteditem != null &amp;&amp; _selecteditem is Item item)<br>           {<br>               item.IsSelect = false;<br>           }<br>           _selecteditem = value;<br>           if(_selecteditem != null &amp;&amp; _selecteditem is Item item1)<br>           {<br>               item1.IsSelect = true;<br>           }<br>           RaisePropertyChanged(nameof(SelectedItem));}</strong><br>        //<br>}</pre><pre>//CommandでListmake関数を呼び出す<br>public void Listmake()<br>{<br>    Items = null;<br>    var itemlist = new ObservableCollection&lt;Item&gt;();<br>    Items = itemlist;<br>    var item_0 = new Item();<br>    var item_1 = new Item();<br>    itemlist.Add(item_0);<br>    itemlist.Add(item_1);<br>}</pre><p>xamlのコマンドかなにかでListmake関数を発動させ、Items SourceとバインドしているItemsの中にItemクラスがいくつか入ったitemlistをぶちこみます。</p><h3>Item.cs</h3><pre>private bool _isselect = false;<br>public bool IsSelect<br>{<br>    get { return _isselect; }<br>    set { _isselect = value;<br>          RaisePropertyChanged(nameof(IsSelect));<br>          <strong>Change_BackgroundColor()</strong>; }<br>}<br>private Color _cellcolor = Color.Silver;<br>public Color CellColor<br>{<br>    get { return _cellcolor; }<br>    set { _cellcolor = value;<br>          RaisePropertyChanged(nameof(CellColor)); }<br>}<br>public void Change_BackgroundColor()<br>{<br>    if (IsSelect == true)<br>    {<br>        CellColor = Color.White;<br>    }<br>    else<br>        CellColor = Color.Silver;<br>}</pre><p>ItemクラスはIsSelectプロパティ、CellColorプロパティを持っていて、IsSelectのsetが走った時は Change_BackgroundColor関数が呼び出されるようにしておきます。</p><h3>ここマジ重要</h3><p>の部分の説明</p><pre>if(_selecteditem != null &amp;&amp; _selecteditem is Item item)<br>{<br>    item.IsSelect = false;<br>}<br>_selecteditem = value;<br>if(_selecteditem != null &amp;&amp; _selecteditem is Item item1)<br>{<br>    item1.IsSelect = true;<br>}<br>RaisePropertyChanged(nameof(SelectedItem));}<br>//</pre><p>① SelectedItemに変更があった場合setの中が走る</p><p>② 新しく選択されたItemクラスが_selecteditem = valueで代入される前に、以前選択されていたItemクラスのIsSelectプロパティをfalseに変える</p><p>③ 新しく選択されたItemクラスが_selecteditem = valueで代入される</p><p>④新しく選択されたItemクラスのIsSelectプロパティをtrueに変える</p><h4>ここまでくれば説明は不要ですね、、、</h4><p>IsSelectのプロパティに変更があった場合IsSelectプロパティのsetが走りますから、Change_BackgroundColor関数が呼び出されます。<br>Itemクラスが持ってるIsSelectプロパティのtrue/falseによってCellColorプロパティに変更がかかります。<br>GridのBackgroundColorがCellColorプロパティとバインドしていますので、これでViewCellの背景色が変わると言うわけです。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1173fe1d371" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lsc-psd/xamarin-c-listview-%E9%81%B8%E6%8A%9E%E4%B8%AD%E3%81%AEviewcell%E3%81%AE%E8%83%8C%E6%99%AF%E8%89%B2%E3%82%92%E5%A4%89%E3%81%88%E3%82%8B%E3%81%AE%E3%81%8C%E7%89%A9%E5%87%84%E3%81%84%E3%82%81%E3%82%93%E3%81%A9%E3%81%8F%E3%81%95%E3%81%8B%E3%81%A3%E3%81%9F-e1173fe1d371">[xamarin][C#][ListView]選択中のViewCellの背景色を変えるのが物凄いめんどくさかった</a> was originally published in <a href="https://medium.com/lsc-psd">LSC PSD</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[人間の知能と人工知能(AI)のコストパフォーマンスを比較する]]></title>
            <link>https://medium.com/lsc-psd/%E4%BA%BA%E9%96%93%E3%81%AE%E7%9F%A5%E8%83%BD%E3%81%A8%E4%BA%BA%E5%B7%A5%E7%9F%A5%E8%83%BD-ai-%E3%81%AE%E3%82%B3%E3%82%B9%E3%83%88%E3%83%91%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%B3%E3%82%B9%E3%82%92%E6%AF%94%E8%BC%83%E3%81%99%E3%82%8B-2162f5e08540?source=rss----a901ed844f0c---4</link>
            <guid isPermaLink="false">https://medium.com/p/2162f5e08540</guid>
            <category><![CDATA[人工知能]]></category>
            <category><![CDATA[日本語]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[エネルギー]]></category>
            <category><![CDATA[比較]]></category>
            <dc:creator><![CDATA[Kai]]></dc:creator>
            <pubDate>Thu, 27 Aug 2020 07:20:08 GMT</pubDate>
            <atom:updated>2020-08-28T00:35:29.813Z</atom:updated>
            <content:encoded><![CDATA[<p>人工知能の定義は<a href="https://ainow.ai/artificial-intelligence-3/#AIAI">色々</a>ありますが、最終的な目標は「人間のような知能を作る≒汎用人工知能を作る」という事だと思います。今回は最新AIが人間の知能にどれだけ近づいたかをエネルギー効率の側面から考えてみたいと思います。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*UZFY1QKFhNgESlRqx99FdQ.jpeg" /><figcaption>これを作るのがAIのゴール</figcaption></figure><h3>1. AIの必要エネルギー</h3><p>最近のAIはどんどん大型化しており、その開発には大量のエネルギーを必要としています。例えば<a href="https://arxiv.org/abs/2005.14165">GPT-3</a>(最新の文章生成AI)を例にとると、このモデルを１つを作る際には</p><ul><li><strong>消費電力: 432,000 kWh</strong><br>（<a href="https://medium.com/r?url=https%3A%2F%2Fblog.inten.to%2Fgpt-3-language-models-are-few-shot-learners-a13d1ae8b1f9">50台のDGX-2を36日間ぶっ通しで使用</a>）</li><li><strong>排出二酸化炭素: 144トン</strong>(<a href="https://selectra.jp/energy/guides/ryokin/1kwh">334g/kWh</a>と仮定）</li></ul><p>という莫大なエネルギーを消費しました。</p><p>この仮定は一発でハイパーパラメータやデータの前処理が決まった場合です。実際にGPT-3を作り上げるまでには、試行錯誤の中でこの何倍ものエネルギーを消費しています。</p><p>さて、最新AIはこれだけのエネルギーを消費してまるで人のような文章生成を行うわけですが、このエネルギーは人間に例えるとどれくらいなのでしょうか。</p><h3>2. 人間との比較</h3><h4>1.1 人体の消費エネルギーと比較</h4><p>kWhのままだと想像しずらいので、エネルギーをkcalの単位に直します。調べたところ、1kWh≒860kcalと変換できるそうです。つまり上記の432,000kWhは371,520,000kcalに相当します。私(成人男性)が1日に必要なカロリーは2,500kcalなので、GPT-3は</p><ul><li><strong>ヒトが148,608日(407年)活動出来る</strong></li></ul><p>だけのエネルギーを使って作ったことになります。私はまだ50年も生きていませんが、GPT-3に負けず劣らずの文章生成能力を持っていると思っています。実際はちょっと負けてるんでしょうけども。</p><h4>1.2 脳の消費エネルギーと比較</h4><p>人工知能はあくまで知能なので、脳の消費エネルギーだけに着目して比較してみます。正直脳については現在の脳科学でも分からない事だらけなのですが、2020年時点においては脳の消費カロリーは全体の15~20%ほどと言われています。1日あたり400kcalです。つまり脳だけに着目すると</p><ul><li><strong>大人の脳が2545年活動出来る</strong></li></ul><p>だけのエネルギーということになります。</p><h4>1.3 人間への供給エネルギー全体との比較</h4><p>日本では、1人につき<a href="http://www.rri.kyoto-u.ac.jp/NSRG/kouen/dent-11.pdf">120,000kcal/日</a>ほどエネルギーが供給されているようです。これは140kWhに相当するため、GPT-3を1つ作るのに必要なエネルギーは、</p><ul><li><strong>日本で3085日(約8.5年)暮らす</strong></li></ul><p>だけのエネルギーという考え方もできます。子供が8歳になるまでと同じだけのエネルギーを使って、すごい文章生成が出来る…そう考えると意外と悪くないような気もします。しかしGPT-3は文章生成しか出来ません。8歳児は知らない人の家の冷蔵庫から飲み物を取り出してコップに注ぐことが出来ます。GPT-3には勿論出来ません。8歳児は靴紐も結べますし、横断歩道を見たら白い線だけを踏む遊びを勝手に思いつけます。</p><h4>1.4 お金の面から考える</h4><p>上記のエネルギーを電気代に直すと<strong>1166万円 （</strong>日本の電気代=27円/kWhで計算）です。言い換えると<strong>月額971万円</strong>です。電気代としては高すぎますが、たった1000万円ぽっちでGPT-3が作れると思うと安い気がします。</p><h3>まとめ</h3><p>冒頭の「人間のような知能をつくる」という目標が正しいとすると、今のAIの進化の方向性は確実におかしいです。なぜなら人間の脳は1日400kcalでアレコレ出来るにも関わらず、現在のAIは432,000kWh使ってやっと文章生成が出来るだけ（「だけ」と書きつつ文章生成に関わることなら色々応用できる）の状態だからです。このまま大規模化していけばいくほど、脳からは遠ざかっていくことになります。</p><p>確かにニューロンとパーセプトロンは似ています。しかしそれを組み合わせ、出来上がったものが脳とGPT-3ではあまりに差があります。何か根本的にアプローチが間違っているのだと思います。</p><p>ビジネスでAIを作っている人たちからすると、最終的にビジネスモデルが成り立てば作るまでの途中経過や、モデルの運用が人間に似ていようが似ていまいが知ったこっちゃないと思いますので、まあ仕方ない気もします。</p><p>脳のコスパは現在のAIと比べると異常と言えるほどに優れています。もしくは現在のAIのコスパは相対的に最悪です。現在のAIは大量のエネルギーに任せた力押しに過ぎません。</p><p>ちなみに冒頭のドラえもん、動力は原子力です。つまり大量のエネルギーを使って動いていることが予想されます。藤子･F･不二雄先生はこうなることを想定していたのかもしれません笑</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2162f5e08540" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lsc-psd/%E4%BA%BA%E9%96%93%E3%81%AE%E7%9F%A5%E8%83%BD%E3%81%A8%E4%BA%BA%E5%B7%A5%E7%9F%A5%E8%83%BD-ai-%E3%81%AE%E3%82%B3%E3%82%B9%E3%83%88%E3%83%91%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%B3%E3%82%B9%E3%82%92%E6%AF%94%E8%BC%83%E3%81%99%E3%82%8B-2162f5e08540">人間の知能と人工知能(AI)のコストパフォーマンスを比較する</a> was originally published in <a href="https://medium.com/lsc-psd">LSC PSD</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to convert .py including pytorch to .exe using  pyinstaller. (Windows)]]></title>
            <link>https://medium.com/lsc-psd/how-to-convert-py-including-pytorch-to-exe-using-pyinstaller-windows-1c869a4061e7?source=rss----a901ed844f0c---4</link>
            <guid isPermaLink="false">https://medium.com/p/1c869a4061e7</guid>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[pyinstaller]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[execute]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Kai]]></dc:creator>
            <pubDate>Fri, 21 Aug 2020 07:07:14 GMT</pubDate>
            <atom:updated>2020-08-21T07:07:14.742Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to convert .py including pytorch to .exe using pyinstaller. (Windows)</h3><p>I was able to get out of the maze! How happy I am!</p><h4>Environment</h4><ul><li>Windows 10</li><li>python 3.7.7</li><li>pytorch 1.5.1+cu101</li><li>pyinstaller 3.6</li><li>anaconda</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*pNdmcOgxPZnIXW7T7AfuAQ.jpeg" /><figcaption>.py -&gt; .exe</figcaption></figure><p>You can make .exe file by using pyinstaller, like below.</p><pre>pyinstaller sample.py --onefile</pre><p>But if .py included pytorch, you’ll get an error.</p><pre>[18208] WARNING: file already exists but should not: C:\path\_C.cp37-win_amd64.pyd<br>Traceback (most recent call last):<br>  File &quot;pytorch_exe.py&quot;, line 1, in &lt;module&gt;<br>  File &quot;c:\local\anaconda3\envs\autofocus\lib\site-packages\PyInstaller\loader\pyimod03_importers.py&quot;, line 623, in exec_module<br>    exec(bytecode, module.__dict__)<br>  File &quot;site-packages\torch\__init__.py&quot;, line 136, in &lt;module&gt;<br>ImportError: numpy.core.multiarray failed to import<br>[13044] Failed to execute script sample</pre><p>or this error.</p><pre>OSError: Can&#39;t get source for &lt;function _rejection_sample at 0x00000212A1902400&gt;. TorchScript requires source access in order to carry out compilation, make sure original .py files are available. Original error: could not get source code</pre><p>(note: If you get an error saying Failed to execute script pyi_rth_pkgres, you can solve by changing .spec file as follows and run pyinstaller sample.spec --onefile)</p><pre>a = Analysis([&#39;sample.py&#39;],<br>             pathex=[&#39;path&#39;],<br>             binaries=[],<br>             datas=[],<br>             hiddenimports=[&#39;pkg_resources.py2_warn&#39;], # add this<br>             hookspath=[],<br>             runtime_hooks=[],<br>             excludes=[],<br>             win_no_prefer_redirects=False,<br>             win_private_assemblies=False,<br>             cipher=block_cipher,<br>             noarchive=False)<br>pyz = PYZ(a.pure, a.zipped_data,<br>             cipher=block_cipher)</pre><p>I looked up the solution on the internet. They say “ downgrade pytorch” or “reinstall pytorch with pip”. Neither method solved the error for me, and I don’t want to downgrade the version of pytorch.</p><p>The most common comments written were</p><p><em>“ Hi, I have a similar issue.”</em></p><p>Jesus!</p><h4>THE SOLUTION</h4><ul><li>Change .spec file a little as below</li><li>The --onefile option is probably bad.</li></ul><pre># -*- mode: python ; coding: utf-8 -*-</pre><pre>block_cipher = None<br>excluded_modules = [&#39;torch.distributions&#39;] # add this</pre><pre>a = Analysis([&#39;sample.py&#39;],<br>             pathex=[&#39;path&#39;],<br>             binaries=[],<br>             datas=[],<br>             hiddenimports=[&#39;pkg_resources.py2_warn&#39;], # add this<br>             hookspath=[],<br>             runtime_hooks=[],<br>             excludes=excluded_modules, # add this<br>             win_no_prefer_redirects=False,<br>             win_private_assemblies=False,<br>             cipher=block_cipher,<br>             noarchive=False)<br>pyz = PYZ(a.pure, a.zipped_data,<br>             cipher=block_cipher)</pre><p>Then run again.</p><p>pyinstaller <strong>-F </strong>sample.spec</p><p>Now, your pytorch program should be working without python:)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c869a4061e7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lsc-psd/how-to-convert-py-including-pytorch-to-exe-using-pyinstaller-windows-1c869a4061e7">How to convert .py including pytorch to .exe using  pyinstaller. (Windows)</a> was originally published in <a href="https://medium.com/lsc-psd">LSC PSD</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[【ALC2020採択論文】Don’t Stop Pretraining: Adapt Language Models to Domains and Tasks]]></title>
            <link>https://medium.com/lsc-psd/alc2020%E6%8E%A1%E6%8A%9E%E8%AB%96%E6%96%87-dont-stop-pretraining-adapt-language-models-to-domains-and-tasks-ea618f36ad96?source=rss----a901ed844f0c---4</link>
            <guid isPermaLink="false">https://medium.com/p/ea618f36ad96</guid>
            <category><![CDATA[alc2020]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[日本語]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Kai]]></dc:creator>
            <pubDate>Wed, 19 Aug 2020 09:49:04 GMT</pubDate>
            <atom:updated>2020-08-27T02:48:14.912Z</atom:updated>
            <content:encoded><![CDATA[<p>RoBERTaのような大規模モデルをあるドメインのタスクに適応させるためには、その事前学習済みモデルを、さらに特定のドメインに絞ったデータで追加の事前学習（中間タスク）させることが有用だということを示した論文です。ALC2020においてHonorable Mention Papersを<a href="https://acl2020.org/blog/ACL-2020-best-papers/">受賞</a>しています。</p><p>元論文は<a href="https://www.aclweb.org/anthology/2020.acl-main.740.pdf">こちら</a></p><p>ちなみにGithubも公開済みです。</p><p><a href="https://github.com/allenai/dont-stop-pretraining">allenai/dont-stop-pretraining</a></p><p>以下和訳です。</p><h4>概要</h4><p>本論文では、超大規模データセットで学習された事前学習済みモデルを、対象タスクのドメインに合わせてさらに事前学習させることが有用かどうかを調査しました。4つのドメイン（生物医学論文、コンピュータサイエンス論文、ニュース、Amazonレビュー）と8つの分類タスク(各ドメインで2つずつ）で実験を行った結果、二回目の事前学習（ドメイン適応型事前学習）を行う事によって、その事前学習に用いたリソースの多寡に関わらずモデルの性能が向上することが示されました。</p><p>さらに、ドメイン適応型事前学習を行った後に、対象タスクのラベル付けされていないデータにさらに適応させる（タスク適応型事前学習）ことで精度が向上することを示しました。</p><p>最後に、あるタスクにおいてドメイン適応型事前学習のためのデータがない場合には、単純なデータ選択アルゴリズムによってデータ拡張されたデータベースを用いることが、有効な代替手段となることを示しました。総じて、多段階の適応事前学習はタスクの性能を大きく向上させることが分かりました。</p><h3>1 序論</h3><p>今日頻繁に使用される自然言語における事前学習モデルは、大規模で複数ドメインにまたがったコーパス上で学習されています。例えば<a href="https://arxiv.org/pdf/1907.11692.pdf">RoBERTa</a>は百科事典、ニュース記事、文学作品、ウェブページなどありとあらゆるソースのデータを160GB以上用いて学習されました。その結果、RoBERTaは多くのタスクにおいてSoTAを達成しました。しかしながらRoBERTa上において、あるトピックやジャンルを特徴づけるような用語（「科学」や「推理小説」など）の分布が、あるタスクと関連付けられているかは不明です。最新の大規模な事前学習モデルは普遍的に機能するでしょうか、それとも特定のドメインのために別個事前学習モデルを構築する方が有用なのでしょうか。</p><p>ドメイン固有の、ラベル付けされていないデータ上での事前学習が有用であると示された研究もいくつかありますが、これらの研究では一度に一つのドメインのみを考慮しており、最新の言語モデルより小さく、多様性の低いコーパス上で事前学習された言語モデルを使用していました。さらに、ラベル付けされたタスクデータの量や、対象ドメインと事前学習コーパスの近さなどの要因によって、事前学習の恩恵がどのように変化するかまでは知られていません。（図1参照)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*YOJPOa7Bmk7M_oNBi3bSRA.jpeg" /><figcaption>図1：データ分布の図。あるタスクデータ（濃い灰色)は観測可能なタスク分布から構成されており、通常はより大きい対象領域内（薄い灰色）からランダムサンプリングされたものとなりますが、これが必ず元のLM(neural Language Model)の事前学習領域に含まれている保証はありません。そのため、あるタスク分布と対象となるドメインの分布から得られたデータで事前学習を続けることには意味があるかもしれません。</figcaption></figure><p>そこで私たちはSoTAモデルの1つであるRoBERTaを用いてこの問題に取り掛かりました。4つのドメイン（生物医学系の論文、コンピュータサイエンス系の論文、ニュース、レビュー）と8つの分類タスク(各ドメインで2つずつ）で実験を行いました。この４つのドメインはいずれもRoBERTaの学習データに含まれています。RoBERTaに含まれていないドメインについては、そのドメイン上での継続した事前学習（ドメイン適応型事前学習、またはDAPT(Domain-Adaptive Pre-Training)と呼ぶ）によって、リソースの多寡にかかわらず、ターゲットドメインからのタスクの性能を向上させることは上記によって同時に示されます。</p><p>上記ではジャンルによって各ドメインを決めましたが、教師付き学習で使用されるコーパスのように、あるタスクに対して与えられたコーパスからドメインを誘導することも可能です。これは、直接的にタスクに結びついたコーパスで事前学習を行う事で性能をさらに向上させるかもしれないという疑問を私たちに投げかけます。私たちはドメイン適応型事前学習(DAPT)と、より小さいがより直接タスクに関連したコーパス、すなわちタスク分布から抽出されたラベルなしのタスクデータセットを用いたタスク適応型事前学習(TAPT)で、あるドメインに対する適応具合の比較を行いました。タスク適応型事前学習は有効であることが既に示されています(Howard and Ruder, 2018)が、最新モデルにおいては一般的に使用されていません。私たちはドメイン適応型事前学習の有無にかかわらず、TAPTがRoBERTaの性能を大きく押し上げていることを発見しました。</p><p>最後に、タスクの設計者やアノテーターが手動で作ったタスク分布にラベルの付いていないデータを追加した場合に、タスク適応型事前学習の利点が増大することを示します。この事実に触発され、私たちはタスクに関連するラベルの付いていないテキストを自動で追加する方法を提案し、これが特定の低リソースのケースでどの程度パフォーマンスを向上させるかを示します。全てのタスクにおいて、適応型事前学習技術を用いた私たちの結果は、最先端の技術に匹敵するものとなりました。</p><p>要約すると、この論文の貢献ポイントは以下の3つです。</p><ul><li>4つのドメインと8つのタスクを対象に、低リソース環境から高リソース環境に至るまで、ドメインとタスクに適応した事前学習の効果の徹底した分析</li><li>ドメイン/タスク適応済み自然言語モデルの、ドメイン間及びタスク間での伝達可能性の調査</li><li>人が作ったデータセットでの事前学習の重要性の調査と、シンプルなデータ選択アルゴリズムを用いてこの性能に到達するための戦略。</li></ul><h3>2 背景：事前学習について</h3><p>2018年以降のほとんどの自然言語処理(NLP)の研究は、2段階で学習されています。まずベースとなる自然言語モデル(LM)（多くの場合数百万のパラメータを持つ）が、ラベル付けされていない大規模なコーパス上で学習されます。事前学習済みモデルで学習された単語の分散表現は、その後下流タスクの教師あり学習で再利用され、第一段階のネットワークと分散表現は必要に応じてアップデートされます（ファインチューニング）。</p><p>このような事前学習済みLMの一つがRoBERTaです。元となるBERTと同じ変換器を使用しています。これは、文章の一部をMASKすること（つまりランダムにマスクされたトークンを予測するためのクロスエントロピー損失）で学習されています。RoBERTaのために使われたラベル付けされていない事前学習用コーパスは、色々な媒体を用いた160GB以上のテキストです。RoBERTaは様々なタスクにおいてSoTAを達成し、今日の研究のベースラインとなっています。</p><p>RoBERTaの事前学習用コーパスは複数のソースから得られていますが、これらのソースが英語のバリエーションを一般化する上で十分かどうかはまだ分かっていません。つまり、RoBERTaの領域外にあるものを理解することは非常に重要です。そのために、私たちはこの大規模なLMを<br><strong>(i) あるドメイン固有のテキストによる大規模コーパス<br>(ii) 与えられたタスクに関連づけられているラベルなしデータ</strong><br>という2つのカテゴリーのラベル付けされていないデータを用いてさらに事前学習させることで、より適応が出来るのではないかと考えました。</p><h3>3 ドメイン適応型事前学習</h3><p>私たちのドメイン適応型事前学習（DAPT）へのアプローチは簡単で、ラベル付けされていないドメイン固有のテキストによる大規模コーパスでRoBERTaの事前学習を続けるだけです。私たちが注目している4つのドメインは、生物医学系の論文、コンピュータサイエンス系の論文、REALNEWSのテキスト、それからAmazonのレビューです。これらのドメインが選ばれた理由は、過去の研究でも人気の分野で、下流で行うテキスト分類のためのデータセットがそれぞれ利用可能だったからです。表1に4つのドメイン全てのラベルなしデータセットの詳細と、RoBERTaの学習コーパスを示します。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KMuUFVbqOA7X18BHD5Pa3g.jpeg" /><figcaption>表1. ドメイン固有のラベルなしデータのリスト。5列目と6列目では、DAPTの前(L_ROB)と後(L_DATA)における各ドメインからランダムにサンプリングされた50Kの文章において、RoBERTaのマスクされた単語に対する損失を記述しています（値は小さいほどいいです）。‡は、RoBERTaの事前学習コーパスに似ているソースから推定されたmasked LM lossです。</figcaption></figure><h4>3.1 ドメイン間の類似性の分析</h4><p>DAPTを実行する前に、対象ドメインとRoBERTaの事前学習ドメインの類似性の定量化を試みます。私たちは各ドメインからランダムサンプリングされた文書の中で最も頻繁に使用されるトークンの上位10,000個（ストップワードを除く）を使って考察を行いました。Amazonレビューを除く各ドメインのコーパスでは5万件の文書を、Amazonのレビューは1件あたりが短いので15万件の文書を用いました。また、RoBERTaの事前学習用コーパスは公開されていないため、RoBERTaの事前学習用コーパスと同様のソース(BookCorpus、STORIES、Wikipedia、RealNews)から5万件の文書を抽出し、同様にトークンを抜き出しました。図2はこれらのサンプル間のトークンの重複を示しています。RoBERTaの事前学習領域、ニュース、レビューはそれぞれ類似性があるのに対し、生物医学やコンピュータサイエンスは他分野と比べかなり異質な分野であることが分かります。この簡単な分析結果は、RoBERTaを異なるドメインに適応させることによって期待される利益の程度を表しています。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*GxD1H4PO8u1kJSuffVC3uw.jpeg" /><figcaption>図2 各ドメイン間のトークンの重複率(%)。PTはRoBERTaの事前学習コーパスと類似したソースからのサンプルです。各ドメインの語彙は各ドメインから抽出された文書の中で最も頻繁に使われたトークン（ストップワードを除く）の上位10k個を考慮して作成されています。</figcaption></figure><h4>3.2 実験</h4><p>私たちの学習はRoBERTaの学習で使われた設定に従っています。RoBERTaを各ドメインに対して12.5Kステップ、つまり各ドメインのデータセットをTPUタイプv3–8上でシングルパスで学習させています（詳細は元論文の付録Bを参照）。この第2段階の事前学習の結果、各ドメインごとに1つずつ、計4つのドメイン適応済LMが生成されます。表1にDAPTの前後におけるRoBERTaのマスクされた単語の損失の値が書かれています。DAPT後にはNEWSを除く全てのドメインで、マスクされた単語の損失が減少していることが確認されました。複数ドメインにまたがったマスクされた単語の損失については本論文の付録Eで議論しています。</p><p>各ドメインについて、表２に示すようにそれぞれ2つのテキスト分類タスクによる実験も行いました。私たちのタスクは高リソースと低リソース(5K以下のラベル付き学習例、追加のラベルなしデータはないもの）の両方を設定して表しています。HYPERPARTISANについてはBeltagyら(2020）のデータ分割を使用しています。RCTについては同時予測のために全ての文を1つの長いシーケンスで表現しています。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5BkmuhDLjcAaf1AlJF8PTA.jpeg" /><figcaption>表2 各種ターゲットタスクのデータセットの仕様です。✟は高リソース設定であることを示します。</figcaption></figure><p><strong>ベースライン<br></strong>ベースラインは既存のRoBERTaベースのモデルを用いて、各分類タスクに対して教師あり学習によるファインチューニングを行ったものを用いています。RoBERTaは現在の最先端(各タスクのSoTAは本論文の付録参照)と比べても大きく劣っているわけではない上、異なるドメインに適応するための単一のLMであるため、良いベースラインとして機能します。</p><p><strong>分類タスクの構造<br></strong>標準的な構造(Devlin et al., 2019)を用いています。私たちは予測のために最終層[CLS]トークンの表現をタスク固有の順伝播層に渡しました。</p><p><strong>結果</strong><br>結果を表3のDAPT列の下に示します（検証結果については付録Cを参照）。全ての領域において、DAPTがRoBERTaよりも改善されていることが観察されました。生物医学、コンピュータサイエンス、レビューではRoBARTaより一貫して性能がよくなっており、対象ドメインがRoBERTaのソースドメインから離れているほどDAPTが有用であることを示しています。これはリソースの多寡にかかわらず一貫しています。DAPTはAGNEWSの性能を向上させませんでしたが、HYPERPARTISANで観察された恩恵はRoBERTaのソースドメインとより近い関係にあるタスクにおいてもDAPTが有用である可能性を示唆しています。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*Ppr0IWQyRWuwspP-Aqvi6Q.jpeg" /><figcaption>表3 RoBERTaとDAPTと無関係ドメインのDAPT (¬ DAPT)の比較。この結果はCHEMPROTとCRTはMicro-F1で、それ以外はMacro-F1です。添え字は標準偏差で5つのランダムシードに対する平均を取っています。✟は高リソース設定です。最高の性能を達成したものについては太字としています。無関係なドメインについては3.3を参照してください。</figcaption></figure><h4>3.3 DAPTのドメインの関連性</h4><p>さらに各タスクについて、LMを対象ドメイン以外のドメインに適応させた設定とDAPTを比較しました。これは改善された結果がドメインに関係なく、より多くのデータに触れたことに起因している可能性がある場合を考慮したものです。この設定ではニュースにコンピュータサイエンスLMを、レビューに生物医学LMを、コンピュータサイエンスにニュースLMを、生物医学にレビューLMを使用しています。図2の単語重複統計を参考にこの対応を決めました。</p><p>結果は表3の最後の列(¬DAPT)です。各タスクにおいてDAPTは無関係なドメインへの適応(¬DAPT)より優位に優れており、ドメインに関連したデータを用いた事前学習の重要性が示唆されています。さらに¬DAPTはRoBERTaよりも最終タスクでの性能が低くなりました。つまりほとんどの場合、ドメインの関連性を考慮せずに事前学習を行うと、最終タスクでの性能が低下することが分かりました。しかし2つのタスク(SCIERCとACL-ARC)では、¬DAPTの方がRoBERTaよりわずかにスコアが高かったです。これはBaevskiら(2019）で指摘されているように、いくつかのケースでは任意の追加データによる継続的な事前学習が有用であることを示唆しているのかもしれません。</p><h4>3.4 ドメインの重複</h4><p>私たちのDAPTの分析はタスクデータが特定のドメインにどのように割り当てられるかについて事前の直感に基づいています。例えばHELPFULNESSのDAPTを実行するために、私たちはAmazonのレビューのみに適応し、REALNEWSの記事には適応させていません。しかし図2のグラデーションから分かる通り、ドメイン間の境界は実際には曖昧です。例えば単語の40%はレビューとニュースの間で共有されています。この重複を更に示すものとして、私たちは複数ドメインに重複する文書を定性的に特定しています。表4はレビュータスクとニュースの類似例です（他の例は本論文付録Dを参照）。実際、RoBERTaをニュースに適応させてもレビュータスクのパフォーマンスに有害にはならないことが分かりました（実際にニュースのDAPTはHELPFULNESSで65.5(2.3)、IMDBで95.0(0.1)を達成しました）。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*efpbIBDcvyxaEN320sQiHA.jpeg" /><figcaption>表4 いくつかのドメインが他のドメインと重複している可能性があり、想定していない事前学習を生むかもしれない例です。REALNEWSの記事にもあるようなレビューの表現を背景色で表示しています。</figcaption></figure><p>この分析は包括的なものではありませんが、各ドメインが相互に排他的でないことを示しています。ドメインの領域を工夫することでより効果的なDAPTが得られる可能性もありますが、それは今後の研究に委ねます。一般的にコーパスが集められたプロセスを含むデータの出どころは、事前学習の手順を設計したり、領域外の汎化能力をテストする新しいベンチマークを作成する際には考慮しなければなりません。</p><h3>4 タスク適応型事前学習</h3><p>ある特定のタスクを解くために集められたデータセットは、より広い領域で使えるテキストのサブセットのみをカバーしていることが多いです。例えば、化学物質-タンパク質-疾患間の関係についてまとめられているCHEMPROTデータセットは、PubMedカテゴリの中から、最近発表されたインパクトの大きい記事を手動で選び、その要約に焦点を当てています。私たちはタスクデータがより広い領域の狭義のサブセットであるような場合は、事前学習にタスクデータセットそのものや、より広い領域のデータを用いることが有用である可能性を考えました。</p><p>タスク適応型事前学習（<strong>TAPT</strong>=<em>Task-adaptive pretraining</em>)は、与えられたタスクのためのラベルの付いていないデータセットで事前学習を行う事です。先行研究でもその有効性は示されています（Howard and Ruder, 2018)。DAPTと比較すると、TAPTはまた違ったトレードオフにぶつかります。つまり、データセットをタスクに近づけようとすればするほど、データセットのサイズは小さくなってしまうという問題です（学習データがタスクをよく表現できている場合に限る）。TAPTはDAPTより実行コストは低く、以下の実験で示しますが、TAPTの性能はDAPTとよく似ます。</p><h4>4.1 実験</h4><p>TAPTはDAPTと同様に２段階の事前学習RoBERTaで構成されていますが、扱うデータセットはタスク固有の学習データに基づいたもののみです。DAPTは12.5Kステップで学習させましたが、TAPTは100エポックで実行します。私たちはエポックごとに異なる単語をマスキングする事で、各データセットを人為的に増強させました（マスキング確率は0.15）。DAPTにおける実験と同様に、最終層[CLS]のトークン表現を、分類のためにタスク固有の順伝播層に渡しました。（ハイパーパラメータの詳細については元論文付録の表14を参照）</p><p>結果は表５の通りです。TAPTはRoBERTaのベースラインを一貫して改善させました。RoBERTaの事前学習コーパスに含まれていたニュース領域でも、TAPTによってスコアが向上したため、タスク適応させる優位性が示されています。TAPTとDAPTの違いに注目してみると、DAPTの方がリソースを多く消費するにもかかわらず（§5.3の表9参照）、TAPTはSCIERCなどいくつかのタスクでその性能がDAPTに肉薄しています。RCT, HYPERPARTISAN, AGNEWS, HELPFULNESS, IMDBでは結果がDAPTを上回っており、リソースの少なさに対する費用対効果の良さを強調しています。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*b5DFZbxuV05lGHnUS31b8g.jpeg" /><figcaption>表5 RoBERTaとTAPT, DAPT,２つを併用した場合の結果の比較表</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*rPH3PfjfraXUIT7q0M78fg.jpeg" /><figcaption>表6 TAPTを同じドメインの異なるタスク間で行うとマイナスに働きます</figcaption></figure><p><strong>DAPTとTAPTの併用 <br></strong>両者を併用した場合の効果を検討します。まずRoBERTaから始め、それにDAPTを適用し、次にTAPTを適用します。３段階の事前学習を行う事で、その計算量は全ての設定の中で最も多く要求されます。期待通り、DAPTとTAPTを組み合わせることで全てのタスクで最高のスコアを叩き出しました（表5）。</p><p>よってDAPT→TAPTと行う事でドメインとタスクの両方で最高の性能を出せることが分かりました。TAPT→DAPTの順で行う場合、タスクに関連するコーパスによる影響を受けやすくなってしまうと考えていますが、とにかく、複数の手順を組み合わせる事で下流の性能を向上させられる可能性を示しました。今後の研究ではより洗練されたドメインとタスクの分布を用いた事前学習を研究してもいいかもしれません。</p><p><strong>別タスクへの転移<br></strong>TAPTとDAPTの比較は、同じドメインの他のタスクに転移できるかどうかを調べる事でより完了します。例えば、RCTのラベル付けされていないデータを用いて言語モデルを更に学習させ、CHEMPROTのラベル付けされたデータを用いてモデルを調整してみます。この設定をTransfer-TAPTと呼ぶことにします。４つのドメインの、全てのタスクにおける結果を表６に示します。TAPTは、単一タスクに対する性能を引き出していると同時に、異なるタスクへの転移性を損ねていることが分かります。この結果は、与えられたドメイン内のタスクのデータ分布が異なる可能性があることを示しています。さらにこれは、広い領域への適応だけでは十分でない理由や、DAPT後のTAPTが有効である理由を説明することにもなっています。</p><h3>5 TAPTのためのデータ拡張</h3><p>第４章では教師付きタスクの学習データのみを用いて事前学習を継続して行いました。TAPTが上手くいったので、今度はあるタスク分布に属する管理されていない大量のデータの山から、人の手でデータを整理されたような例を考えます。</p><p>私たちは２つのストーリーを考えました。１つ目は、３つのタスク（RCT, HYPERPARTISAN, IMDB)について、人が集めた利用可能なコーパス（§5.1)に対し、より大きなラベルなしデータを集める方法です。２つ目に、大量のラベルなしデータにおいて、人が整理したデータが存在しない場合に、TAPTのための、タスク分布に基づいたラベルなしデータを収集する方法を考えます。</p><h4>5.1 人によって整備されたTAPT(Curated TAPT)</h4><p>データセットの作成において多くの場合、既知のソースからラベル付けされていない大量のコーパスを収集します。このコーパスのサイズは、データセットを作るのに許された予算に依存しており、しばしばダウンサンプリングされたものとなります。したがって、より大きなラベルなしコーパスでも、タスクの学習データと同様の分布を持つことが期待されます。さらにそれは色々な場面で利用可能です。私たちはTAPTにおけるそのようなコーパスの役割を探ります。</p><p><strong>データ<br></strong>RCTデータセットの学習データを500例(全体(180,000例)のわずか0.3%)にダウンサンプリングし、残りのトレーニングデータをラベルなしとして扱う事で、低リソース設定のRCT500をシミュレーションしてみます。HYPERPARTISANは低リソース設定と高リソース設定の２つがあります。私たちは高リソース設定の5,000例をラベルなしデータとして扱い、低リソースのデータをファインチューニング用に使用します。IMDBはアノテーターがラベル付きデータと同じ分布から抽出した、手動で追加で集めたラベルなしデータを使用しました(Maas et al., 2011)。</p><p><strong>結果<br></strong>Curated TAPT、普通のTAPT、DAPT+TAPTの結果の比較を表７に示しました。Curated TAPTは３つのデータセット全てにおいて§4で得られた先行結果をさらに改善させました。HYPERARTISANでは”DAPT+Curated TAPT”は選定されたTAPTの標準偏差内に全て収まっています。さらにCurated TAPTは完全にラベル付けされたRCTコーパスではラベル付けされたデータの僅か0.3%でDAPT+TAPTの95%の性能を達成しました。これらの結果は、タスク分布から大量のデータを集めることが最終タスクのパフォーマンスに非常に有効であることを示唆しています。タスク設計者は、事前学習によるモデル適応を支援するために、ラベル付けされていないタスクデータを大量に公開することを推奨します。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*M9u8hwpL-J6nR46T8RG8qg.jpeg" /><figcaption>表7 ５つのランダムシードにわたって選定されたTAPTを用いた平均テストセット。</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*IKysl4Wle2wX2yYqrVdoDQ.jpeg" /><figcaption>表8 RAND-TAPT（５０個の候補を持つ）とkNNTAPTセレクションを比較し、５つのランダムシードにわたる平均テストセットmicro-F1(CHEMPROTとRCT）とmacro-F1(ACL-ARC)の表。タスクデータの隣はドメインデータから選択されています。</figcaption></figure><h4>5.2 TAPTのための自動データ選択</h4><p>TAPTのためのラベルなしデータにアクセスできず、DAPTに必要な計算資源がないパターンを考えてみましょう（異なる事前学習段階における計算資源の詳細については表９を参照）。私たちは大規模領域にまたがったコーパスから、タスクの分布に一致するラベル付けされていないテキストを検索するための、単純な教師なし手法を提案します。私たちは、タスクとドメインの両方のテキストを共有空間に埋め込むことで、ドメインからタスクに関連したデータを見つけ出し、タスクデータからのクエリに基づいてドメインから候補を選択するようなアプローチを考えました。この埋め込み方法は数百万の文章をそこそこの時間で埋め込むことができるくらい軽量である必要があります。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*MCiSVdBqJmTxOP4xVNGYSQ.jpeg" /><figcaption>図3 VAMPIREの図解。ラベル付けされていないCHEMPROT文と100万ある生物医学文を、訓練済みVIMPIREを使ってベクトル空間にマッピングします。そして各CHEMPROT文について、生物医学ドメインからk個の最近傍となる文を識別します。</figcaption></figure><p>このような制約の中で、私たちは軽量なbag-of-wordsモデルであるVAMPIRE(Gurururangan et al., 2019; 図3)を採用しました。私たちはタスクとドメインの両方からテキストの埋め込みを得るために、ドメインの大規模な重複排除サンプル（100万）上で、VAMPIREを事前学習させました。次に、各タスク文ごとにk個の候補を、埋め込み空間上でドメインサンプルの中から選択します。候補は(i)k近傍選択(kNN-TAPT), (ii)ランダム選択(RAND-TAPT）のいずれかです。私たちはTAPTと同様に、タスクデータと選択された候補データの両方を用いて、この拡張コーパス上でRoBERTaの事前学習を続けました。</p><p><strong>結果<br></strong> 結果は表８の通りです。全てのケースでkNN-TAPTがTAPTより優れている事が分かります。RAND-TAPTはkNN-TAPTより悪いですが、RCTとACLARCについては標準偏差の範囲内です。kを増加させるとkNN-TAPTの性能は増加し、DAPTに近付きます。タスクデータの最近傍探索の例が元論文付録Fに示されています。今後は、kNN-TAPTのより詳細な研究、より洗練されたデータ選択方法、及び選定された例の多様性とタスクの関連性の間のトレードオフを検討する余地があります。</p><h4>5.3 計算量</h4><p>生物医学分野におけるRCT-500における、全手法の計算量を表9に示します。TAPTは単一のTPUタイプv3–8上でDAPTより60倍高速で、このタスクでのDAPTのストレージ要件はTAPTの580万倍になります。DAPT+TAPTでは３段階の事前学習が必要なため、一見すると非常にコストがかかるように見えますが、一回広い領域に言語モデルを適用させてしまえばその領域内の複数のタスクに使いまわすことが出来、タスクごとにTAPTを１回追加するだけで済みます。今回の実験ではCurated-TAPTが最も高いコスパを発揮しましたが、大規模な領域内データのCuratedにかかるコストも考慮する必要があります。kNN-TAPTのような自動手法はDAPTと比べてはるかに計算量が少なくて済みます。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*vgAWQyJHMDcdFHDY8O-VSQ.jpeg" /><figcaption>表9 RCT-500タスクに適応するために必要な計算量。これまでに説明した様々なDAPT、TAPTと比較しています。</figcaption></figure><h3>6 関連研究</h3><p><strong>ドメイン適応のための転移学習<br></strong>先行研究では、ドメインでの事前学習を行う事の利点が示されています。私たちの研究は、大規模で多様な事前学習コーパスと対象ドメインとの間でのシフトがタスクへのパフォーマンスに与える影響についてのさらなる調査に貢献しました。他の研究（Huangら、2019)では、関心のあるドメインの言語モデル(LM)を一から学習させています。私たちは複数のドメインを探索しており、RoBERTaという強力な言語モデルから事前学習を行ったため、議論の余地なく費用対効果が優れています。</p><p><strong>タスク適応のための転移学習<br></strong>あるのラベル付けされていないデータ上での言語モデルの事前学習は、最終タスクのパフォーマンスに有益であることが先行研究によって示されています（例えば、Howard and Ruder, 2018; Phangら, 2018; Sunら, 2019）。同じタスクの学習データの分布とテストデータの分布の間のドメイン転移においては、DAPTはTAPTとほぼ同一とみなせます(Logeswaranら, 2019; Han and Eisenstein, 2019)。タスク分類器のファインチューニングのために言語モデリングを行ったり、タスク固有のデータに適応しながら入力の単純な構文構造を考慮するパターンもあります。私たちはDAPTとTAPTを比較し、第２段階の事前学習のためのデータセットサイズ、与えられたタスクのデータサンプルへの関連性、他のタスクやデータセットへの転移性に関して、それらの相互作用を比較しました。これらの詳細は元論文付録§Aの表11を参照してください。</p><p><strong>転移学習のためのデータ選択</strong><br>このテーマはNLPにおいて昔から研究され続けています。Daiら(2019）は１つのタスクに対して言語モデルを一から事前学習させるうえで最も適したコーパスを特定することに焦点を当てました。一方私たちは§5.2で様々なタスクに関連する例を選択しています。私たちの研究と並行して、AharoniとGoldberg(2020)は、効率性を考慮してDISTIBERTを用いて、埋め込み空間におけるコサイン類似度に基づくNMT(ニューラル機械翻訳）のためのデータ選択法を提案しています。私たちはVAMPIREを使ってテキスト分類タスクのためのTAPTデータの増強に焦点を当てました。Khandelwalら(2020）は、ドメインごとにデータを追加するだけで、それ以上の学習を必要とせずに事前学習させた言語モデルのドメイン適応を容易にするkNN-LMを導入しました。私たちの研究では人がデータを選定しており、(§5.1)、これは言語モデルの依存性を用いた適切なデータの収集のためのクローリング(Chakrabartiら,1999）に関連しています。</p><p><strong>そもそもドメインとは？</strong><br>ドメイン適応法は非常に人気であるにも関わらず、ほとんどの研究は、ドメインに対して直感的な理解に留まっているような気がします。いくつかの研究はこの問題に取り組んでいます。例えば、AharoniとGoldberg(2020)はドメインを「事前学習された言語モデルにおける文表現の、暗黙的なクラスタリング」と定義しました。私たちの研究ではDAPTとTAPTが互いに補完し合う事を示しており、これは様々なレベルの粒度（例えば特定の商品に対するAmazonレビュー、全てのAmazonレビュー、web上の全てのレビュー、webページ）のタスクによって定義されたドメインのスペクトルを示唆しています。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*WaIxIMDHc0hPzgBFsb5Lvw.jpeg" /><figcaption>表10 本論文で行った２段階事前学習に関するまとめ</figcaption></figure><h3>7 結論</h3><p>私たちは、事前学習された言語モデルを、あるドメインや、そのドメイン内のタスクに適応させるためのいくつかの手法を調べました(表10にまとめました）。私たちの実験の結果、数億個のパラメータを持つモデルでさえ言語全体はおろか、単一のテキスト領域の複雑さを符号化するのに苦戦していることが明らかとなりました。私たちは特定のタスクや小さなコーパスのためにモデルを事前学習させることが非常に有意義であることを示しました。本研究で得られた知見は、大規模な言語モデルの研究と並行して、モデルを特化させるための研究も有益である可能性を示唆しています。私たちの結果はあくまでRoBERTaをベースにしたものですが、他の言語モデルに対しても応用できる汎用的な考え方です。私たちの結果は、TAPTのためのよりいいデータ選択、大規模な事前学習済みモデルのドメイン適応範囲変更、適応後の再利用可能な言語モデルの構築など、多くの将来性を魅せてくれます。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea618f36ad96" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lsc-psd/alc2020%E6%8E%A1%E6%8A%9E%E8%AB%96%E6%96%87-dont-stop-pretraining-adapt-language-models-to-domains-and-tasks-ea618f36ad96">【ALC2020採択論文】Don’t Stop Pretraining: Adapt Language Models to Domains and Tasks</a> was originally published in <a href="https://medium.com/lsc-psd">LSC PSD</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A history of AI incidents that got me thinking about AI and ethics.]]></title>
            <link>https://medium.com/lsc-psd/a-history-of-ai-incidents-that-got-me-thinking-about-ai-and-ethics-6f9438952351?source=rss----a901ed844f0c---4</link>
            <guid isPermaLink="false">https://medium.com/p/6f9438952351</guid>
            <category><![CDATA[facial-recognition]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[ethics]]></category>
            <category><![CDATA[summary]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Kai]]></dc:creator>
            <pubDate>Mon, 03 Aug 2020 09:19:45 GMT</pubDate>
            <atom:updated>2020-08-03T09:19:20.669Z</atom:updated>
            <content:encoded><![CDATA[<p>There are some people who dislike AI. They say “AIs will take human jobs.”, “It will be a surveillance society”, “AIs are not trustworthy”, “AIs will take over the world.”, “I don’t know why, but it’s scary.”, etc. Therefore I’ve summarized the incidents about</p><ul><li>Incidents that makes you think about the free application of AI.</li><li>Incidents of citizens defying the expansion of AI.</li></ul><p>from the third AI boom(2012~) to latest.</p><h3>2013</h3><h4>September</h4><ul><li><strong>There was the publication of “THE FUTURE OF EMPLOYMENT” by Prof. Osborne of Oxford University, which said that 47% of jobs will be gone in 20 years.<br></strong>Note: The reason for this impact is that the work was pre-processed as a series of tasks. In reality, the conclusion is not correct at all, as there are many jobs that cannot be represented by tasks. Since this paper, the issue of employment by AI has become one of the major themes.</li></ul><h3>2014</h3><h4>August</h4><ul><li><a href="https://arxiv.org/abs/1408.6491"><strong>A paper</strong></a><strong> which Google’s ad serving AI may be discriminating against women was published.</strong><br>Note: The number of high-paying jobs posted just by using “female” as the gender was drastically reduced.</li></ul><h3>2015</h3><h4>March</h4><ul><li><strong>Google’s facial recognition software tags African-Americans as gorillas</strong><br>Note: The cause is that the amount of training data was insufficient, and although the training data used images from SNS, there were many images of black people labeled as gorillas.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*qPu-314okmBLrNTyLkWb1A.jpeg" /><figcaption>My friend’s not a gorilla.</figcaption></figure><h3>2016</h3><ul><li><strong>People begin to attacks on Self-Driving Cars (Arizona).</strong><br>Note: Cutting, throwing rocks, yelling, threatening employees in the car, shooting, etc. This activity increases after self-driving cars first killed people in March 2018 (see below). Drivers of Uber and bus are particularly fearful of self-driving car.</li><li><strong>A patient prognostic AI operating at the University of Pittsburgh Hospital was found to be sending patients home with a high risk of complications. </strong><br>Note: This is because there was a large discrepancy between the accuracy in the laboratory and in the field.</li></ul><h4>March</h4><ul><li><strong>Microsoft’s AI bot ‘Tay’ deactivated after one day of public release because saying nothing but racist remarks.</strong><br>Note: Tay had a function to learn from conversations with people, but people taught it all sorts of bad words. This incident illustrates the importance of post-development maintenance; perhaps software with AI will be taken care of after release.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Zxl9jDvzV2cYXaZ9xXAssw.jpeg" /><figcaption>I fucking hate feminists and they should all die and burn in hell.</figcaption></figure><h4>May</h4><ul><li><strong>The driver who drove Tesla’s self-driving car died after crashing into trailer.</strong><br>Note: We haven’t killed a third party yet at this time.</li></ul><h3>2017</h3><ul><li><strong>Deep fakes become popular.</strong><br>Note: Now, many sites prohibit the use of deep fakes. If it uses with malicious intent, it can be applied to pornographic video, or as a visual technology (e.g., making movies) if used with good intentions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yUrLteJw_-hN-LTF4loWFA.jpeg" /></figure><h4>January</h4><ul><li><strong>Goldman Sachs announces that there are already only two stock traders, compared to 600 in 2000.</strong><br>Note: Tasks like trading, which have little relevance to instinctive human behavior, are an area where AI excels. The number of traders has been reduced by 598, but instead there are now 200 engineers increased in running the trading program.</li></ul><h4>June</h4><ul><li><strong>Two trading AIs created by FAIR (Facebook’s AI Research) started to talk in a language which humans couldn’t understand, and FAIR forced the system to shut down.</strong><br>Note: The language was optimized because the purpose of the two AIs was “two-way conversation” and not “conversation in English”. The reason for the forced shut down was that the purpose of creating these AIs was to create an “AI that can talk with humans” and they decided that there was no point in continuing the optimized conversation any further. That same month, the <a href="https://arxiv.org/abs/1706.03762">Transformer</a> was announced.</li></ul><h4>October</h4><ul><li><a href="https://arxiv.org/abs/1710.06169"><strong>A paper</strong></a><strong> which US recidivism predicting AI “COMPAS” is discriminating against blacks was published.</strong><br>Note: COMPAS tended to predict recidivists as good for whites and predict good people as suspected recidivists for blacks. Although race status was not included in the recidivism predictions, it produced the same results as effectively identifying race from other attributes. This was already known since about 2016, but the paper was not published until October 2017.</li></ul><h3>2018</h3><h4>February</h4><ul><li><strong>Facial Recognition AI (made by GAFA) is biased by gender and skin color, says MIT.</strong><br>Note: The lowest error rate in gender determination was for light-skinned males (up to 0.8%) and the highest was for dark-skinned females (up to 34.7%) I think making a mistake of a third is too much. According to the AI, Serena Williams is male. Michelle Obama is a man wearing a wig.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FQxuyfWoVV98%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DQxuyfWoVV98&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FQxuyfWoVV98%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/affda39ce5a9e7432c9801fd920ffc23/href">https://medium.com/media/affda39ce5a9e7432c9801fd920ffc23/href</a></iframe><h4>March</h4><ul><li><strong>Uber’s self-driving car killed a pedestrian.<br></strong>Note: This occurs because the system was not designed for people walking in anything but crosswalks. self-driving technology must be able to handle many unknown situations (i.e. automated driving cannot be solved by narrow AI), so the level of difficulty in achieving this is very high compared to the current state of progress.</li><li><strong>Google announced it had a contract with the Department of Defense.</strong><br>Note: Google was famous for not using its technology for military purposes. Furthermore, in April, it was revealed that the company would be involved in the development of military drones, which led to the retirement of Google employees who opposed the project.</li></ul><h4>April</h4><ul><li><strong>Up to 87 million people’s personal information was leaked from Facebook.</strong><br>Note: This is so-called Cambridge Analytica scandal. The personal information was used in election campaigns, etc.</li></ul><h4>June</h4><ul><li><strong>California Consumer Privacy Act passed.</strong><br>Note: The law was submitted by citizens not by congress. It would be significant that it was passed in California.</li></ul><h4>July</h4><ul><li><strong>Amazon’s facial recognition AI misidentifies 28 US lawmakers as criminals.</strong><br>Note: Only 20% of the members of Congress are people of color, but 40% of the people be misjudged were people of color. I’ll post Amazon’s excuse.<br>“ We did it at 80% confidence level, so we get 28 people out, but when we did it at 99%, we got a zero. In short, your use of AI is bad.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*5tNUf6oRU9tVOjagCvD0iw.png" /><figcaption>sited from ACLU</figcaption></figure><h4>August</h4><ul><li><strong>Artificial voice fraud in the UK.</strong><br>Note: An illegal transfer of 220,000 euros was made by imitating the CEO’s German accent in English.</li></ul><h4>September</h4><ul><li><strong>IBM and New York City Police Department develop race-determining AI.</strong></li></ul><h4>October</h4><ul><li><strong>Amazon stopped using a machine learning system to recruit people because of discrimination against women.</strong><br>Note: They used past applicants’ resumes as a training data, but many of Amazon’s engineering aspirants were men, and there was a strong bias towards men. Or rather, the word “women” had a negative bias.</li></ul><h3>2019</h3><ul><li><strong>Mass protests against facial recognition around the world.</strong><br>Note: The introduction of facial recognition at airports, schools, streets, and in the front door has led to protest against it.</li></ul><h4>February</h4><ul><li><strong>Amazon abandoned its plan to build a second headquaters building in New York City due to opposition from residents.</strong><br>Note: Amazon had planned to introduce facial recognition and contract with ICE(Immigration and Customs Enforcement). There were also concerns about the large influx of Amazon’s high wage earners, such as rising rent prices in the neighborhood.</li></ul><h4>August</h4><ul><li><strong>Smart streetlights were vandalized in Hong Kong with movement for democratization</strong><br>Note: The smart streetlights were equipped with surveillance cameras, and there were concerns that this would lead to a crackdown on demonstrations. Employees of the company that make these streetlights were threatened.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*wsR_GvD8y8EXAJRWNJCzOA.jpeg" /><figcaption>A streetlight with a suspicious crest.</figcaption></figure><h4>September</h4><ul><li><strong>ImageNet (a large dataset used in image recognition) was found to have a large amount of discriminatory labeling.</strong><br>Note: This removed half of the images in the people category. The discriminatory expressions are attributed to poor filtering when the dataset was first created.</li><li><strong>AI </strong><a href="https://en.wikipedia.org/wiki/Hibari_Misora"><strong>Misora Hibari</strong></a><strong> (famous Japanese singer) was announced in Japan</strong><br>Note: This news was talked about as a desecration her. Because she is already gone.</li><li><strong>Employees from Amazon, Twitter, Google, Microsoft, Facebook and other tech companies participate in environmental demonstrations.</strong><br>Note: This is occured by Greta Thunberg’s influence. AI development requires large amounts of energy and in June 2019, <a href="https://arxiv.org/abs/1906.02243">a paper</a> says that it would emit 600,000 pounds of CO2 to create one NLP model was published.</li></ul><h3>2020</h3><p><strong>“Social Credit System” will be fully implemented in China.</strong><br>Note: It scores and ranks all citizens. It affects everything from mortgage interest rates, confiscation of property, travel bans, exclusion from private schools, internet connection speeds, etc. Foreigners and foreign companies in China could also be targeted.</p><h4>May</h4><ul><li><strong>Google withdraw from the Toronto’s smart city plan.</strong><br>Note: The plan was announced in 2017. The #BlockSidewalk movement arose among the local population, and it was criticized by outsiders as an experiment in colonization by surveillance society.</li></ul><h4>June</h4><ul><li><strong>IBM withdraw the facial recognition AI business, Amazon stopped to offer facial recognition AI system over the next year, and Microsoft refused to provide facial recognition AI to police.</strong><br>Note: We already knew that facial recognition AI discriminates, but the George Freud case gave us a trigger.</li><li><strong>False arrest due to facial recognition was found out.</strong><br>Note: A Detroit man was falsely arrested of shoplifting in January 2020 and held for 30 hours. Of course, the man was black. The face recognition technology in “SNAP” is used in this case was developed by NEC and Rank One Computing. This release announced two weeks after the above news.</li></ul><h3>Summary</h3><p>Deep Learning has been in the spotlight for nearly a decade, ever since AlexNet took power in the image recognition competition in 2012. Different from previous AI, the models created by Deep Learning have the AI Black Box Explanation Problem.</p><p>Until about 2015, there was a tendency to focus on the applicability of Deep Learning and neglect the Black Box Explanation Problem. In other words, there was very little awareness of the fairness of AI and the correctness of the benchmarks.</p><p>Ironically, I think that lack of awareness was the catalyst for the widespread introduction of AI, and the Deep Learning model was used in many different places and in many different ways. But the downside of this was soon to come: a number of papers and reports showed that AI actually discriminates strongly.</p><p>The environment around AI has changed from an era of rule-less anything-goes to an era in which it has to operate under well-developed rules (except in some countries). IEEE’s Ethically Aligned Design, Partnership on AI, Ethics The guidelines for trustworthy AI, the Human-Centered AI Social Principles (Cabinet Office), and other common understanding about the development and operation of AI have also been established. The same applies to data handling. In particular, attention must be paid to the operation of the data collected in a way that allows individuals to be identified. In this surveillance society, there is a risk of unintentional misuse and discrimination.</p><p>Also, the incidents described here are only a small part of the story. In fact, many more news stories are being reported every day.</p><p>Just as the Internet has settled from the days of anything-goes to its current form, I think AI follow the same way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f9438952351" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lsc-psd/a-history-of-ai-incidents-that-got-me-thinking-about-ai-and-ethics-6f9438952351">A history of AI incidents that got me thinking about AI and ethics.</a> was originally published in <a href="https://medium.com/lsc-psd">LSC PSD</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object Detection Memo from RCNN to the Latest (2020 July)]]></title>
            <link>https://medium.com/lsc-psd/object-detection-memo-from-rcnn-to-now-2020-july-be015a94bd9f?source=rss----a901ed844f0c---4</link>
            <guid isPermaLink="false">https://medium.com/p/be015a94bd9f</guid>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[cnn]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Neil Wu]]></dc:creator>
            <pubDate>Wed, 22 Jul 2020 04:58:14 GMT</pubDate>
            <atom:updated>2020-07-29T07:42:56.410Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*I4nKx3tEiEn0Y7IaeYovpg.png" /></figure><h3>TL; DR</h3><p>Object detection is a relatively well studied task in Machine Learning field. However, like every other field, latest research is always based on tons of previous research. <br>This article is aimed to organize every representative research in object detection, and note the key features that makes them representative. <br>Feel free to notice me if you think there’re other important research I haven’t mentioned or important features I skipped in specific research by response.</p><h3>Model Zoo</h3><h4>2014</h4><p><a href="#3909">R-CNN <em>(Ross Gishick et al.)</em></a><br><a href="#2abf">SPPNet <em>(Kaiming He et al.)</em></a></p><h4>2015</h4><p><a href="#c1bb">Fast R-CNN <em>(Ross Gishick et al.)</em></a><br><a href="#da82">Faster R-CNN <em>(Ren et al.)</em></a></p><h4>2016</h4><p><a href="#7799">YOLO <em>(Redmon et al.)</em></a><br><a href="#e107">SSD <em>(Liu et al.)</em></a><br><a href="#f2d0">YOLOv2 <em>(Redmon et al.)</em></a></p><h4>2017</h4><p><a href="#a56d">Feature Pyramid Network <em>(Tsung-Yi Lin et al.)</em></a><br><a href="#ac85">RetinaNet (<em>Tsung-Yi Lin et al.</em>)</a></p><h4>2018</h4><p><a href="#e46b">YOLOv3 (Redmon et al.)</a></p><h4>2019</h4><p>Object as Points (<em>Xingyi Zhou et al.</em>) <strong>&lt;Coming soon&gt;</strong><br>CornerNet (<em>Hei Law et al.</em>)<strong>&lt;Coming soon&gt;</strong><br>CenterNet (<em>Kaiwen Duan et al.</em>)<strong>&lt;Coming soon&gt;</strong><br><a href="#45d4">FCOS (<em>Zhi Tian et al.</em>)</a></p><h4>2020</h4><p>DETR<em>(Nicolas Carion et al.) </em><strong>&lt;Coming soon&gt;</strong><br>YOLOv4 <em>(Alexey Bochkovskiy et al.) </em><strong>&lt;Coming soon&gt;</strong><br>EfficientDet <em>(Mingxing Tan et al.)</em><strong>&lt;Coming soon&gt;</strong><br>YOLOv5 <em>(Glenn Jocher)</em> <strong>&lt;Coming soon&gt;</strong></p><h3>R-CNN</h3><p><a href="https://arxiv.org/pdf/1311.2524.pdf">Original paper</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*AkZC9Lmd-PQ-Us8--Hyl3g.png" /><figcaption>(<a href="https://link.springer.com/content/pdf/10.1007/s11263-019-01247-4.pdf">source</a>)</figcaption></figure><p>First extract region proposal proposed by selective search, and then warped each proposed region to fixes sized image and input to CNN. Train SVM classifier and Bounding box regression model by output features of CNN. Since R-CNN input every region into CNN, CNN has to calculate ~2k(# of region proposal) for single images.</p><h4>Selective search</h4><p><a href="http://www.huppelen.nl/publications/selectiveSearchDraft.pdf">Original paper</a><br>Estimating possible region for objects by continuously checking similar region.</p><h3>SPPNet (Spatial Pyramid Pooling Net)</h3><p><a href="https://arxiv.org/pdf/1406.4729.pdf">Original paper</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*CIogQ1JTc6O1FEzuVcGu_w.png" /></figure><p>SPPNet originally aimed to solve the issue that after region proposal by selective search in R-CNN, proposed region will lose its size and aspect ratio due to resizing. Instead of crop and resize images before input to CNN, SPPNet straight input whole image and use Spatial Pyramid Pooling Layer to extract and represent specific region from images. Therefore CNN in SPPNet only need to calculate once for single images.</p><p><strong>The most important takeaway in SPPNet is that feature maps are able to represent the original images</strong>, so that region proposal don’t need to proposed before input to CNN.</p><h3>Fast R-CNN</h3><p><a href="https://arxiv.org/pdf/1504.08083.pdf">Original paper</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*0vczySMHuLpKbpFxrVoVrg.png" /><figcaption>(<a href="https://link.springer.com/content/pdf/10.1007/s11263-019-01247-4.pdf">source</a>)</figcaption></figure><p>Fast R-CNN adopt concept of SPPNet, create Region of Interest (RoI) pooling layer. Instead of crop&amp;warp regions before input to CNN, Fast R-CNN input image at once, and extract region from last layer of CNN. From the last layer of CNN, RoI pooling layer pooling out region projection from original layer and predict classes from extract region.</p><h4>RoI pooling layer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cfMAttJNSyacKsLx.png" /></figure><p>RoI pooling pooling region of interest by projection of original images. Check here for the details: <a href="https://deepsense.ai/region-of-interest-pooling-explained/"><strong>https://deepsense.ai/region-of-interest-pooling-explained/</strong></a></p><h3>Faster R-CNN</h3><p><a href="https://papers.nips.cc/paper/5638-faster-r-cnn-towards-real-time-object-detection-with-region-proposal-networks.pdf">Original paper</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*d5hzbtEsIATKcZRCzVPpgA.png" /><figcaption>(<a href="https://link.springer.com/content/pdf/10.1007/s11263-019-01247-4.pdf">source</a>)</figcaption></figure><p>Instead of using a general region proposal methods like selective search, Faster R-CNN proposed Region Proposal Network(RPN) as its region proposal. RPN adopt anchor s of different scales and aspect ratio, and using regressor to modify bounding box.</p><h4>Region Proposal Network</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*NK0xCK54yE63P9w4yFA0Mw.png" /></figure><p>RPN slide a small network over the conv feature map output by the last shared conv layer. For every sliding window, RPN predict k anchor boxes and see whether it’s object or not. RPN starting the era of anchor box based object detection.</p><h3>YOLO</h3><p><a href="https://arxiv.org/abs/1506.02640">Original paper</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*ZQy5RBiOFCLEXRP2TiLKGw.png" /></figure><p>YOLO is first single-shot object detection. Main concept of YOLO is, it split original images into n*n grid, and for every grid, there’s k bounding box in charge for predict at most 1 object. <br>After area projection from feature map to original image, YOLO then added a fully connected layer for both classification and bounding box prediction. By doing so, YOLO can achieve object classification by one model which started one-shot object detection.</p><h3>SSD (Single Shot Detection)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*i88g4LhMyMemdBDxBXs12A.png" /></figure><p>SSD is definitely the milestone in object detection. Unlike other previous models take 1 feature map for prediction, SSD started multiple layer extraction for predictions. By looking at different feature map, it is able to check object in different resolutions.<br>This multiple feature extractions is basically adopted for every later object detection models.</p><h3>YOLOv2</h3><p><a href="https://arxiv.org/pdf/1612.08242.pdf">Original paper</a></p><p>YOLOv2 based on structure of YOLO and made some changes showed below:</p><ul><li>Adopted<strong> Batch normalization</strong>, removed dropout.</li><li><strong>High Resolution Classification</strong> by changing training image size from <em>256*256</em> to <em>448*448.</em></li><li><strong>Anchor boxes </strong>methodology replace original bounding box, using 9 anchor boxes.</li><li><strong>Dimensions Clustering</strong>. Anchor box aspect ratios aren’t chosen by handpick anymore, now it use k-means on data to pre-chosen best ratio.</li><li><strong>Direct Location Prediction</strong>. Restrict Anchor boxes prediction value and add linear activation, prevent unstable iteration in early stage.</li><li><strong>Fine-Grained Features</strong>. Pass early layer features(26*26) to deeper layer(13*13)</li><li><strong>Multi-scale Training</strong>. Resize image in training epoch to increase backbone robustness of different size</li></ul><h3>FPN(Feature Pyramid Network)</h3><p><a href="https://arxiv.org/pdf/1612.03144.pdf">Original paper</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*tfAUv7MbFpmNmgLrNh-eiw.png" /></figure><p>Feature Pyramid is a technique to share semantic informations from deeper feature maps to shallower feature maps. This will makes predictions in shallower feature maps to have semantic stronger features.</p><h3>RetinaNet</h3><p><a href="https://arxiv.org/abs/1708.02002">Original paper</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*CyawHTwKSWq5c66gIT5Cqg.png" /></figure><p>RetinaNet is a combination of <strong>Feature Pyramid Network</strong> and novel loss function: <strong>Focal Loss</strong>. Achieve SoTA of the time.</p><h4>Focal Loss</h4><p>The anchor-box based detection models have a common issues. After labeling the anchor boxes, the sample size of positive boxes(box as object) and negative boxes(box as background) is extremely imbalanced. This is because anchor-box based models use numerous preset box (e.g. ~9k in SSD) to detect fix count object on all images. <strong>The sample imbalances cause negative sample dominates the back propagation</strong>, and decrease the learning rate and performance.</p><p>Focal Loss designed a weight to tuned the imbalances, and makes positive sample affect more in model.</p><h3>YOLOv3</h3><p><a href="https://pjreddie.com/media/files/papers/YOLOv3.pdf">Original paper</a></p><p>YOLOv3 based on YOLOv2 and made some changes showed below:</p><ul><li><strong>Add logistic regression</strong> for object score while bounding box prediction.</li><li>Change softmax classifier to <strong>logistic classifier</strong>, due to assumption that image normally includes multiple objects instead of 1.</li><li>Extract multiple feature map from model , obtain higher resolution information and enable <strong>prediction across scale</strong>.</li><li>No more DarkNet19+ResNet, using brand new<strong> </strong>backbone<strong> DarkNet 53 </strong>instead.</li></ul><h3>Object as Points</h3><p><a href="https://arxiv.org/abs/1904.07850">Original paper</a></p><h3>CornerNet</h3><p><a href="https://arxiv.org/pdf/1808.01244.pdf">Original paper</a></p><h3>CenterNet</h3><p><a href="https://arxiv.org/abs/1904.08189">Original paper</a></p><h3>FCOS</h3><p><a href="https://arxiv.org/abs/1904.01355">Original paper</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vOzIPmFFptE17MY1.png" /></figure><p>FCOS is a anchor-free object detection models, which using Feature Pyramid Network(FPN) to create feature maps, and adding head after every feature maps. The training process also using a novel loss funciton called <strong>Center-ness </strong>besides the classification loss and bounding box loss.</p><h4>Center-ness</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/0*D2u0E7k5obm8iclY.png" /></figure><p>This is the suppression index of low-quality predicted bounding boxes produced by locations far away from the center of an object. Center-ness is a index describe the distance of point to the center of ground truth box, and added as a branch after feature maps.</p><p><a href="https://medium.com/lsc-psd/fcos-one-shot-anchor-free-object-detection-a3102da819bc">FCOS, One Shot Anchor-Free Object Detection</a></p><h3>YOLOv4</h3><p><a href="https://arxiv.org/pdf/2004.10934v1.pdf">Original paper</a></p><h3>EfficientDet</h3><p><a href="https://arxiv.org/abs/1911.09070">Original paper</a></p><h3>YOLOv5</h3><p><a href="https://blog.roboflow.ai/yolov5-improvements-and-evaluation/">Original article</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be015a94bd9f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lsc-psd/object-detection-memo-from-rcnn-to-now-2020-july-be015a94bd9f">Object Detection Memo from RCNN to the Latest (2020 July)</a> was originally published in <a href="https://medium.com/lsc-psd">LSC PSD</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>