反面教師あり学習

*/

(旧)反面教師あり学習

Negative Supervised Learning

TikZの覚書

概要

  • TikZで図を描くときに「こういうの描けるの覚えてるけどどうやるんだっけ?」と思って調べたことのまとめ
  • 座標の計算方法が多め

エッジやノードのスタイルを定義する

エッジでもノードでも共通.

\tikzstyle{my node}=[draw, minimum width=2.0cm, minimum height=1.5cm]

tex.stackexchange.com

TikZで描いた図全体をテキストも含めてスケーリングする

scale=0.5だけだとテキストのサイズが変わらなくて変なことになる.

\begin{tikzpicture}[scale=0.5, every node/.style={scale=0.5}]
  ...
\end{tikzicture}

tex.stackexchange.com

座標間の内分点を計算する

\usetikzlibrary{calc}が必要.

\draw (x) -- ($(x)!0.75!(y)$) -- (y);

サンプル

これを応用すると 以下の図のように,少し位置をずらしつつノードから複数のエッジを伸ばす,ということもできる.

f:id:eqseqs:20200912173159p:plain

\begin{tikzpicture}
    \node[draw, minimum size=2cm] (F) at (0, 0) {$F$};
    \draw[-latex] (F.east) -- ++(2, 0);
    \draw[-latex] ($(F.east)!0.5!(F.north east)$) -- ++(2, 0);
    \draw[-latex] ($(F.east)!0.5!(F.south east)$) -- ++(2, 0);
\end{tikzpicture}

texwiki.texjp.org

エッジやノードのコーナーを丸くする

\draw [rounded corners=5pt] (x) -- (y);

tex.stackexchange.com

\drawコマンド中にノードや座標の定義をする

例では(2, 0)の位置にノードを作ってる. 1行目は名前なし,2行目は名前あり. 座標を作るときはnodecoordinateに変えればおk.

\draw (0, 0) -- (2, 0) node[draw];
\draw (0, 0) -- (2, 0) node[draw] (a);

tex.stackexchange.com

ノードのx座標(またはy座標)だけを参照する

(a -| b)で「水平座標がノードa,垂直座標がノードbの位置にある」という意味になる. 線を描くついでに座標やノードを作るときは2行目みたいな書き方をする.

\draw (a) -- (a -| b);
\draw (a) -- (a -| b) coordinate (c);

サンプル

f:id:eqseqs:20200912174002p:plain:w200

\begin{tikzpicture}
    \tikzstyle{my node}=[draw, circle, minimum size=1cm]
    \node[my node] (a) at (0, 0)   {$a$};
    \node[my node] (b) at (2, 2)   {$b$};
    \node[my node] (c) at (a -| b) {$c$};
    \node[my node] (d) at (a |- b) {$d$};
\end{tikzpicture}

tex.stackexchange.com

座標の単位を変更する(デフォルトは1cm)

TikZの図のある一部だけ別の単位で書いた方が可読性が良くなるケースがたまにある.

\begin{tikzpicture}
  \begin{scope}[x=4cm, y=4cm]
    ...
  \end{scope}
\end{tikzpicture}

tex.stackexchange.com