# 会社メモ
## 10/1 turing techtalk
turing techtalk
動画リンク
https://www.youtube.com/live/qkIm3uW5Ats?si=jymdnyl1kcfRXUlN
世界モデル:Terra
世界モデルとは?→aiが周囲の環境を理解予測しそこから学習するための内部表現を構築するモデル(周囲の状況を内部的に抽象化して捉える、現在から将来や全体を予測)
世界モデルがてきると何が嬉しい?→プランニングできる、シミュレータとして使える(アクションで条件付けした動画を生成可能)
世界モデルは自動運転以外ではプランニングによく使われる(世界モデルの学習→プランニングの学習→行動の予測)←高い報酬が得られるような行動の予測ができるようになる!
自動運転では、動きが大きい、環境が複雑、高解像度が必要、などが難しい点
いい世界モデルを作ることがそもそも難しい→プランニングまで行うことは稀(やっててもほとんどシミュレータ)
点群やBEV、voxelで三次元表現を用いることもある
GAIA-1 Occworld panacea(3dbbを入力としてエージェントを生成可能、6視点)
vista(拡散モデルを利用した世界モデル、オープンソース)
Terraも自己回帰Transformer
lookup free quantization 画像とアクションを同時にトークンとしてTransformer に入力
事故映像が生成可能(学習データの分布外)
まだ活用の域にはない、おかしな映像、車が変な形、車が新幹線みたいになる、評価できる仕組みがまだない、人間が思う運転に対する評価を報酬として表現できるようにしないといけない
学習時にはテキスト、画像、アクションを交互に入力している
panacea はbev 上の任意の位置にエージェントを召喚できる
入力として与えた軌跡に沿った動画が生成できているかについては、まだ評価できていない
Terraは運転シーンの画像のみを学習に使用、事故に至りそうなデータは含まれている
opendvyoutube で学習(1000時間くらいに+100時間くらいのプライベートデータ
wayveの技術を多分に参考にしているとのこと
世界モデルがlongtailなシーンを生成できる可能性がある、その点で有用
学習データの分布は調査できていない、偏りはあると思う、データ量が膨大で調査するのは大変
## 診断書

- 
## 1/08(Mon)
```
;; <leaf-install-code>
(eval-and-compile
(when (or load-file-name byte-compile-current-file)
(setq user-emacs-directory
(expand-file-name
(file-name-directory (or load-file-name byte-compile-current-file))))))
(eval-and-compile
(customize-set-variable
'package-archives '(("org" . "https://orgmode.org/elpa/")
("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
(unless (package-installed-p 'leaf)
(package-refresh-contents)
(package-install 'leaf))
(leaf leaf-keywords
:ensure t
:init
;; optional packages if you want to use :hydra, :el-get, :blackout,,,
(leaf hydra :ensure t)
(leaf el-get :ensure t)
(leaf blackout :ensure t)
:config
;; initialize leaf-keywords.el
(leaf-keywords-init)))
;; </leaf-install-code>
(require 'package)
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")
("org" . "http://orgmode.org/elpa/")))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
(add-to-list 'load-path "~/.emacs.d/custom")
(require 'setup-general)
(require 'setup-cedet)
(require 'setup-editing)
(setq auto-save-default nil)
;; nerd icons
(require 'nerd-icons)
(use-package nerd-icons :ensure t)
(use-package nerd-icons-dired
:hook
(dired-mode . nerd-icons-dired-mode))
(use-package nerd-icons-ivy-rich
:ensure t
:init
(nerd-icons-ivy-rich-mode 1)
(ivy-rich-mode 1))
;; ファイルなら別バッファで、ディレクトリなら同じバッファで開く
(defun dired-open-in-accordance-with-situation ()
(interactive)
(let ((file (dired-get-filename)))
(if (file-directory-p file)
(dired-find-alternate-file)
(dired-find-file))))
;; dired-find-alternate-file の有効化
(put 'dired-find-alternate-file 'disabled nil)
;; RET 標準の dired-find-file では dired バッファが複数作られるので
;; dired-find-alternate-file を代わりに使う
(define-key dired-mode-map (kbd "RET") 'dired-open-in-accordance-with-situation)
(define-key dired-mode-map (kbd "a") 'dired-find-file)
;; スクリーンの最大化
(set-frame-parameter nil 'fullscreen 'maximized)
(setq show-paren-delay 0)
(show-paren-mode 1) ;; ;; C-qで移動
(defun match-paren (arg) "Go to the matching parenthesis if on
parenthesis." (interactive "p") (cond ((looking-at "\\s\(")
(forward-list 1) (backward-char 1)) ((looking-at "\\s\)")
(forward-char 1) (backward-list 1)) ) )
(global-set-key "\C-Q" 'match-paren)
;; font size change
(add-to-list 'default-frame-alist
'(font . "DejaVu Sans Mono-14"))
;; enable gtags
(setq load-path (cons "~/.emacs.d/gtags" load-path))
(require 'gtags)
(setq gtags-mode-hook
'(lambda ()
(local-set-key "\M-t" 'gtags-find-tag) ;関数へジャンプ
(local-set-key "\M-r" 'gtags-find-rtag) ;関数の参照元へジャンプ
(local-set-key "\M-s" 'gtags-find-symbol) ;変数の定義元/参照先へジャンプ
(local-set-key "\C-t" 'gtags-pop-stack) ;前のバッファに戻る
))
(add-hook 'c-mode-hook 'gtags-mode)
(add-hook 'c++-mode-hook 'gtags-mode)
(add-hook 'python-mode-hook 'gtags-mode)
;; use python3 in emacs shell
(setq python-shell-interpreter "python3")
(el-get-envpath-prepend "PYTHONPATH" "/home/naoki/Documents/min_pipenv")
(use-package eglot)
(add-to-list 'eglot-server-programs
'(python-mode "pylsp"))
(use-package python-mode
:ensure nil
:hook
(python-mode . eglot-ensure))
(require 'lsp-mode)
(add-hook 'python-mode-hook #'lsp)
;; autopep8
;; (require 'py-autopep8)
;; (add-hook 'python-mode-hook 'py-autopep8-enable-on-save)
;; settings for garbabe collection
(setq gc-cons-threshold 800000)
(setq garbage-collection-messages nil)
;; company
(require 'company)
(global-company-mode t)
(setq company-idle-delay nil)
(setq company-minimum-prefix-length 1)
(setq company-selection-wrap-around t)
(setq completion-ignore-case t)
(define-key company-active-map (kbd "C-n") 'company-select-next)
(define-key company-active-map (kbd "C-p") 'company-select-previous)
(define-key company-active-map (kbd "C-s") 'company-filter-candidates)
;; ivy
(when (require 'ivy nil t)
;; M-o を ivy-hydra-read-action に割り当てる.
(when (require 'ivy-hydra nil t)
(setq ivy-read-action-function #'ivy-hydra-read-action))
;; `ivy-switch-buffer' (C-x b) のリストに recent files と bookmark を含める.
(setq ivy-use-virtual-buffers t)
;; ミニバッファでコマンド発行を認める
(when (setq enable-recursive-minibuffers t)
(minibuffer-depth-indicate-mode 1)) ;; 何回層入ったかプロンプトに表示.
;; ESC連打でミニバッファを閉じる
(define-key ivy-minibuffer-map (kbd "<escape>") 'minibuffer-keyboard-quit)
;; プロンプトの表示が長い時に折り返す(選択候補も折り返される)
(setq ivy-truncate-lines nil)
;; リスト先頭で `C-p' するとき,リストの最後に移動する
(setq ivy-wrap t)
;; アクティベート
(ivy-mode 1))
;; counsel
(when (require 'counsel nil t)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "M-y") 'counsel-yank-pop)
(global-set-key (kbd "C-M-z") 'counsel-fzf)
(global-set-key (kbd "C-S-r") 'counsel-recentf)
(global-set-key (kbd "C-x C-b") 'counsel-ibuffer)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "C-M-f") 'counsel-ag)
;; activate
(counsel-mode 1))
;; swiper
(when (require 'swiper nil t)
(global-set-key (kbd "M-s M-s") 'swiper-thing-at-point)
(global-set-key (kbd "C-s") 'swiper))
(setq swiper-include-line-number-in-search t)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; ivy with dired
(when (require 'ivy-dired-history nil t)
(define-key dired-mode-map "," 'dired)
(with-eval-after-load "session"
(add-to-list 'session-globals-include 'ivy-dired-history-variable)))
;; ivy with magit
(with-eval-after-load "magit"
(setq magit-completing-read-function 'ivy-completing-read))
;; ivy with smex
(when (require 'smex nil t)
(setq smex-history-length 35)
(setq smex-completion-method 'ivy))
(setq ivy-initial-inputs-alist
'((org-agenda-refile . "^")
(org-capture-refile . "^")
;; (counsel-M-x . "^") ;; 削除.必要に応じて他のコマンドも除外する.
(counsel-describe-function . "^")
(counsel-describe-variable . "^")
(Man-completion-table . "^")
(woman . "^")))
(setf (alist-get 'counsel-M-x ivy-re-builders-alist) #'ivy--regex-ignore-order)
(setq ivy-re-builders-alist
'((swiper . ivy--regex-plus)
(t . ivy--regex-fuzzy)))
(defun ivy--sort-by-len (name candidates)
"Sort CANDIDATES based on similarity of their length with NAME."
(let ((name-len (length name))
(candidates-count (length candidates)))
(if (< 500 candidates-count)
candidates
(seq-sort-by #'length
(lambda (a b)
(< (abs (- name-len a))
(abs (- name-len b))))
candidates))))
(setf (alist-get 'counsel-M-x ivy-sort-matches-functions-alist)
#'ivy--sort-by-len)
;; counsel-ag
(defun ad:counsel-ag (f &optional initial-input initial-directory extra-ag-args ag-prompt caller)
(apply f (or initial-input (ivy-thing-at-point))
(unless current-prefix-arg
(or initial-directory default-directory))
extra-ag-args ag-prompt caller))
(advice-add 'counsel-ag :around #'ad:counsel-ag)
;; directory を指定して ag やり直し.クエリは再利用する
(defun my-counsel-ag-in-dir (_arg)
"Search again with new root directory."
(let ((current-prefix-arg '(4)))
(counsel-ag ivy-text nil ""))) ;; also disable extra-ag-args
(ivy-add-actions
'counsel-ag
'(("r" my-counsel-ag-in-dir "search in directory")))
(define-key counsel-ag-map (kbd "C-x C-d") 'counsel-cd)
;; counsel-recentf
(defun ad:counsel-recentf ()
"Find a file on `recentf-list'."
(interactive)
(require 'recentf)
(recentf-mode)
(ivy-read "Recentf: "
(progn
(mapcar #'substring-no-properties recentf-list) ;; no need?
(mapcar #'abbreviate-file-name recentf-list)) ;; ~/
:action (lambda (f)
(with-ivy-window
(find-file f)))
:require-match t
:caller 'counsel-recentf))
(advice-add 'counsel-recentf :override #'ad:counsel-recentf)
;; 以下の関数は,counsel-projectile-* と counsel-recentf にぶら下げる.
(defun my-counsel-fzf-in-default-dir (_arg)
"Search the current directory with fzf."
(counsel-fzf ivy-text default-directory))
;; add an action for counsel-recentf (M-o z)
(ivy-add-actions
'counsel-recentf
'(("z" my-counsel-fzf-in-default-dir "switch to fzf")))
(with-eval-after-load "ivy"
;; counsel-mark-ring のリストをソートさせない
(setf (alist-get 'counsel-mark-ring ivy-sort-functions-alist) nil))
;; counsel-mark-ring
(global-set-key (kbd "C-,") 'counsel-mark-ring)
(with-eval-after-load "flyspell"
(define-key flyspell-mode-map (kbd "C-,") 'counsel-mark-ring))
;; arrow visible
(defface my-ivy-arrow-visible
'((((class color) (background light)) :foreground "orange")
(((class color) (background dark)) :foreground "#EE6363"))
"Face used by Ivy for highlighting the arrow.")
(defface my-ivy-arrow-invisible
'((((class color) (background light)) :foreground "#FFFFFF")
(((class color) (background dark)) :foreground "#31343F"))
"Face used by Ivy for highlighting the invisible arrow.")
(if window-system
(when (require 'nerd-icons nil t)
(defun my-ivy-format-function-arrow (cands)
"Transform CANDS into a string for minibuffer."
(ivy--format-function-generic
(lambda (str)
(concat (nerd-icons-faicon "nf-fa-hand_o_right"
:v-adjust -0.2 :face 'my-ivy-arrow-visible)
" " (ivy--add-face str 'ivy-current-match)))
(lambda (str)
(concat (nerd-icons-faicon "nf-fa-hand_o_right" :face 'my-ivy-arrow-invisible) " " str))
cands
"\n"))
(setq ivy-format-functions-alist
'((t . my-ivy-format-function-arrow))))
(setq ivy-format-functions-alist '((t . ivy-format-function-arrow))))
;; Definitions for ivy-rich transformers.
;; See `ivy-rich-display-transformers-list' for details."
;;recentf
(require 'recentf)
(setq recentf-max-saved-items 200) ;; 200ファイルまで履歴保存する
(setq recentf-auto-cleanup 'never) ;; 存在しないファイルは消さない
(setq recentf-exclude '("/recentf" "COMMIT_EDITMSG" "/.?TAGS" "^/sudo:" "/\\.emacs\\.d/games/*-scores" "/\\.emacs\\.d/\\.cask/" "/\\.emacs\\.d/elpa/*" "^/tmp\\.*"))
(setq recentf-auto-save-timer (run-with-idle-timer 300 t 'recentf-save-list))
(recentf-mode 1)
(global-set-key "\M-g" 'goto-line)
;; (add-to-list 'auto-mode-alist '("\\.py$" . python-mode))
(global-display-line-numbers-mode)
(require 'cl-lib)
(require 'color)
(rainbow-delimiters-mode 1)
(setq rainbow-delimiters-outermost-only-face-count 1)
(set-face-foreground 'rainbow-delimiters-depth-1-face "#9a4040")
(set-face-foreground 'rainbow-delimiters-depth-2-face "#ff5e5e")
(set-face-foreground 'rainbow-delimiters-depth-3-face "#ffaa77")
(set-face-foreground 'rainbow-delimiters-depth-4-face "#dddd77")
(set-face-foreground 'rainbow-delimiters-depth-5-face "#80ee80")
(set-face-foreground 'rainbow-delimiters-depth-6-face "#66bbff")
(set-face-foreground 'rainbow-delimiters-depth-7-face "#da6bda")
(set-face-foreground 'rainbow-delimiters-depth-8-face "#afafaf")
(set-face-foreground 'rainbow-delimiters-depth-9-face "#f0f0f0")
(add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode)
(add-hook 'c-mode-hook 'rainbow-delimiters-mode)
(add-hook 'python-mode-hook 'rainbow-delimiters-mode)
;; doom theme
(use-package doom-themes
:ensure t
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-vibrant t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Enable custom neotree theme (all-the-icons must be installed!)
(doom-themes-neotree-config)
;; or for treemacs users
(setq doom-themes-treemacs-theme "doom-atom") ; use "doom-colors" for less minimal icon theme
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config))
(require 'doom-modeline)
(doom-modeline-mode 1)
(global-set-key (kbd "C-c <left>") 'windmove-left)
(global-set-key (kbd "C-c <down>") 'windmove-down)
(global-set-key (kbd "C-c <up>") 'windmove-up)
(global-set-key (kbd "C-c <right>") 'windmove-right)
;; c++ setting
(setq visible-bell t)
(require 'company)
(add-hook 'c-mode-hook 'company-mode)
(add-hook 'c++-mode-hook 'company-mode)
(setq company-clang-executable "/usr/bin/clang++-10")
(add-to-list 'company-backends 'company-c-headers)
(delete 'company-semantic company-backends)
(defadvice c-lineup-arglist (around my activate))
;; "Improve indentation of continued C++11 lambda function opened as argument."
;; C++ style
(add-hook 'c++-mode-hook
'(lambda()
(c-set-style "stroustrup")
(c-set-offset 'innamespace 0) ; namespace {}の中はインデントしない
(c-set-offset 'arglist-close 0) ; 関数の引数リストの閉じ括弧はインデントしない
(c-set-offset 'inlambda 0)
))
(with-eval-after-load 'company
(add-to-list 'company-backends 'company-irony))
(add-hook 'c++-mode-hook 'irony-mode)
(electric-pair-mode 1)
(require 'company-c-headers)
(add-to-list 'company-c-headers-path-system "/usr/include/c++/9/")
(when (locate-library "company")
(global-company-mode 1)
(global-set-key (kbd "C-M-i") 'company-complete)
(setq company-idle-delay nil) ; 自動補完をしない
(define-key company-active-map (kbd "C-n") 'company-select-next)
(define-key company-active-map (kbd "C-p") 'company-select-previous)
(define-key company-search-map (kbd "C-n") 'company-select-next)
(define-key company-search-map (kbd "C-p") 'company-select-previous)
(define-key company-active-map (kbd "<tab>") 'company-complete-selection))
;; xclip
(require 'xclip)
(xclip-mode 1)
;; magit
(use-package magit
:ensure t
:bind (("C-x g" . magit-status)
("C-x M-g" . magit-dispatch-popup)
)
)
;; nyan-mode
(nyan-mode t)
(nyan-start-animation)
(setq nyan-animate-nyancat t)
;; yas-mode
(require 'yasnippet)
(yas-global-mode 1)
;; shell setting
(setq sh-basic-offset 2)
(setq sh-indentation 2)
(setq sh-shell-file "/bin/sh")
;; rust setting
(add-to-list 'exec-path (expand-file-name "~/.local/bin/rust-analyzer"))
(add-to-list 'exec-path (expand-file-name "~/.cargo/bin/"))
(use-package rust-mode
:ensure t
:custom rust-format-on-save t)
(use-package cargo
:ensure t
:hook (rust-mode . cargo-minor-mode))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; #lsp
(use-package lsp-mode
:ensure t
:init (yas-global-mode)
:hook (rust-mode . lsp)
:bind ("C-c h" . lsp-describe-thing-at-point)
:custom (lsp-rust-server 'rust-analyzer))
(use-package lsp-ui
:ensure t)
;; blacken
(leaf blacken
:ensure t
:custom ((blacken-line-length . 80) ; 1行の長さを80文字まで許可
(blacken-skip-string-normalization . t))) ; 文字リテラルの「'」を「"」に変更しないように抑制
(leaf py-isort
:ensure t
:hook (before-save-hook . py-isort-before-save))
(require 'mozc)
(load-library "mozc")
(set-language-environment "Japanese")
(setq default-input-method "japanese-mozc")
(global-set-key [zenkaku-hankaku] 'toggle-input-method)
(global-set-key (kbd "C-M-i") 'company-complete)
(prefer-coding-system 'utf-8)
;; migemo setting
(require 'migemo)
;; cmigemo(default)
(setq migemo-command "cmigemo")
(setq migemo-options '("-q" "--emacs"))
;; Set your installed path
(setq migemo-dictionary "/usr/share/cmigemo/utf-8/migemo-dict")
(setq migemo-user-dictionary nil)
(setq migemo-regex-dictionary nil)
(setq migemo-coding-system 'utf-8-unix)
(migemo-init)
(require 'swiper-migemo)
(global-swiper-migemo-mode +1)
;; function-args
;; (require 'function-args)
;; (fa-config-default)
;; (define-key c-mode-map [(tab)] 'company-complete)
;; (define-key c++-mode-map [(tab)] 'company-complete)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(blacken-line-length 119)
'(blacken-skip-string-normalization t)
'(ispell-dictionary nil)
'(lsp-rust-server 'rust-analyzer)
'(lsp-ui-doc-enable t)
'(lsp-ui-doc-header t)
'(lsp-ui-doc-include-signature t)
'(lsp-ui-doc-max-height 30)
'(lsp-ui-doc-max-width 150)
'(lsp-ui-doc-position 'top)
'(lsp-ui-doc-use-childframe t)
'(lsp-ui-doc-use-webkit t)
'(lsp-ui-flycheck-enable nil t)
'(lsp-ui-imenu-enable nil)
'(lsp-ui-imenu-kind-position 'top)
'(lsp-ui-peek-enable t)
'(lsp-ui-peek-fontify 'on-demand)
'(lsp-ui-peek-list-width 50)
'(lsp-ui-peek-peek-height 20)
'(lsp-ui-sideline-enable nil)
'(lsp-ui-sideline-ignore-duplicate t)
'(lsp-ui-sideline-show-code-actions nil)
'(lsp-ui-sideline-show-diagnostics nil)
'(lsp-ui-sideline-show-hover t)
'(lsp-ui-sideline-show-symbol t)
'(package-archives
'(("org" . "https://orgmode.org/elpa/")
("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
'(package-selected-packages
'(ivy-migemo mozc py-isort cargo rust-mode vertico-posframe vertico nerd-icons-ivy-rich nerd-icons-ibuffer nerd-icons-completion nerd-icons-dired package-utils eglot python-mode exec-path-from-shell irony leaf-keywords leaf csharp-mode zygospore pipenv dash lsp-pyright lsp-ui lsp-mode fzf flx all-the-icons all-the-icons-dired all-the-icons-ivy-rich ivy-rich smex counsel nyan-mode doom-themes doom-modeline color-theme-modern py-autopep8 flycheck jedi jedi-core helm yasnippet ws-butler volatile-highlights use-package undo-tree iedit dtrt-indent counsel-projectile company clean-aindent-mode anzu))
'(python-indent-guess-indent-offset-verbose nil)
'(python-shell-prompt-detect-failure-warning nil)
'(rust-format-on-save t))
```
## 12/07(Thu)
### wavファイルの長さの合計を出力
```
import os
import wave
def get_wav_duration(file_path):
with wave.open(file_path, 'r') as wav_file:
frames = wav_file.getnframes()
rate = wav_file.getframerate()
duration = frames / float(rate)
return duration
def total_duration(directory):
total_dur = 0.0
for filename in os.listdir(directory):
if filename.endswith(".wav"):
file_path = os.path.join(directory, filename)
total_dur += get_wav_duration(file_path)
return total_dur
if __name__ == "__main__":
directory = input("Enter the directory path: ")
total = total_duration(directory)
print(f"The total duration of all WAV files is: {total} seconds")
```
## 10/23(Mon)
### GPU推論時間計測
```
import torch
import numpy as np
model = torch.hub.load('pytorch/vision:v0.9.0',
'resnet50', pretrained=True)
device = torch.device("cuda")
model.to(device)
input_batch_cpu = torch.randn(128, 3, 224, 224)
dummy_input = input_batch_cpu.clone().detach().to('cuda')
model.eval()
# INIT LOGGERS
print('start logger')
starter = torch.cuda.Event(enable_timing=True)
ender = torch.cuda.Event(enable_timing=True)
repetitions = 300
timings = np.zeros((repetitions, 1))
# GPU-WARM-UP
with torch.no_grad():
for _ in range(10):
dummy_warmup_output = model(dummy_input)
del dummy_warmup_output
torch.cuda.empty_cache()
# MEASURE PERFORMANCE
with torch.no_grad():
for rep in range(repetitions):
starter.record()
dummy_output = model(dummy_input)
ender.record()
# WAIT FOR GPU SYNC
torch.cuda.synchronize()
curr_time = starter.elapsed_time(ender)
timings[rep] = curr_time
del dummy_output
torch.cuda.empty_cache()
mean_syn = np.sum(timings) / repetitions
std_syn = np.std(timings)
print(mean_syn)
```
## 再生時間を取得
```
import librosa
import librosa
def get_duration(audio_file_path):
# librosaのload関数で音声ファイルを読み込む
y, sr = librosa.load(audio_file_path, sr=None)
# librosaのget_duration関数で再生時間を取得する
duration = librosa.get_duration(y=y, sr=sr)
return duration
if __name__ == '__main__':
# 音声ファイルのパスを入力として受け取る
file_path = input("Enter the path to the audio file: ")
duration = get_duration(file_path)
print(f"The duration of the audio file is: {duration:.2f} seconds")
```
## サンプリング周波数を取得
```
import librosa
def get_sampling_rate(audio_file_path):
# librosaのload関数を使用して音声ファイルを読み込む
# sr=None はオリジナルのサンプリングレートを保持するためのオプションです
_, sr = librosa.load(audio_file_path, sr=None)
return sr
if __name__ == '__main__':
# 音声ファイルのパスを入力として受け取る
file_path = input("Enter the path to the audio file: ")
sampling_rate = get_sampling_rate(file_path)
print(f"The sampling rate of the audio file is: {sampling_rate} Hz")
```
## 半分のファイルをランダムに抽出
```
import os
import random
import shutil
def copy_random_files(source_dir, target_dir):
# ソースディレクトリ内のファイルリストを取得
files = os.listdir(source_dir)
# ファイルをランダムにシャッフル
random.shuffle(files)
# 半分のファイル数を計算
half_count = len(files) // 2
# 半分のファイルをコピー
for file_name in files[:half_count]:
source_path = os.path.join(source_dir, file_name)
target_path = os.path.join(target_dir, file_name)
shutil.copy2(source_path, target_path) # ファイルをコピー
if __name__ == "__main__":
source_directory = '/path/to/source_directory' # ソースディレクトリのパスを指定
target_directory = '/path/to/target_directory' # ターゲットディレクトリのパスを指定
# ターゲットディレクトリが存在しない場合は作成
if not os.path.exists(target_directory):
os.makedirs(target_directory)
copy_random_files(source_directory, target_directory)
print("半分のファイルをコピーしました。")
```
## 音声を一定時間に分割(新規センサモデル学習で使用)
```
import librosa
import os
def split_audio(input_file, output_directory, duration=10):
# 音声ファイルを読み込む
y, sr = librosa.load(input_file, sr=None)
# 分割する時間間隔(秒)を指定
segment_duration = duration
# セグメント数を計算
num_segments = len(y) // (sr * segment_duration)
# 出力ディレクトリが存在しない場合は作成
if not os.path.exists(output_directory):
os.makedirs(output_directory)
# 音声ファイルをセグメントに分割
for segment_index in range(num_segments):
start_sample = segment_index * sr * segment_duration
end_sample = (segment_index + 1) * sr * segment_duration
segment = y[start_sample:end_sample]
# セグメントをファイルとして保存
output_file = os.path.join(output_directory, f"segment_{segment_index + 1}.wav")
librosa.output.write_wav(output_file, segment, sr)
if __name__ == "__main__":
input_file = 'path/to/your/input_audio.wav' # 入力音声ファイルのパス
output_directory = 'path/to/your/output_directory' # 分割したセグメントを保存するディレクトリのパス
segment_duration = 10 # 分割する時間間隔(秒)
split_audio(input_file, output_directory, segment_duration)
```
```
import numpy as np
import scipy.io.wavfile as wav
def compute_fft(signal, fs):
n = len(signal)
spectrum = np.fft.fft(signal)
frequencies = np.fft.fftfreq(n, d=1/fs)
return frequencies, abs(spectrum)
def compute_sn_ratio(signal, noise_threshold=1e-4):
signal_power = np.sum(signal[abs(signal) > noise_threshold] ** 2)
noise_power = np.sum(signal[abs(signal) <= noise_threshold] ** 2)
if noise_power == 0:
return float('inf')
return 10 * np.log10(signal_power / noise_power)
def main():
filename = "path_to_your_audio_file.wav"
fs, data = wav.read(filename)
# ステレオの場合、2列のデータが存在する
if len(data.shape) == 2 and data.shape[1] == 2:
left_channel = data[:, 0]
right_channel = data[:, 1]
else:
print("This is not a stereo file!")
return
# 左チャンネル
frequencies_left, spectrum_left = compute_fft(left_channel, fs)
sn_ratio_left = compute_sn_ratio(left_channel)
# 右チャンネル
frequencies_right, spectrum_right = compute_fft(right_channel, fs)
sn_ratio_right = compute_sn_ratio(right_channel)
print(f"S/N Ratio (Left): {sn_ratio_left} dB")
print(f"S/N Ratio (Right): {sn_ratio_right} dB")
# 周波数特性をプロット
import matplotlib.pyplot as plt
plt.figure(figsize=(12, 6))
plt.subplot(1, 2, 1)
plt.plot(frequencies_left, spectrum_left)
plt.title('Frequency Spectrum (Left Channel)')
plt.xlabel('Frequency (Hz)')
plt.ylabel('Magnitude')
plt.subplot(1, 2, 2)
plt.plot(frequencies_right, spectrum_right)
plt.title('Frequency Spectrum (Right Channel)')
plt.xlabel('Frequency (Hz)')
plt.ylabel('Magnitude')
plt.tight_layout()
plt.show()
if __name__ == "__main__":
main()
```
## init.el
```
; <leaf-install-code>
(eval-and-compile
(when (or load-file-name byte-compile-current-file)
(setq user-emacs-directory
(expand-file-name
(file-name-directory (or load-file-name byte-compile-current-file))))))
(eval-and-compile
(customize-set-variable
'package-archives '(("org" . "https://orgmode.org/elpa/")
("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
(package-initialize)
(unless (package-installed-p 'leaf)
(package-refresh-contents)
(package-install 'leaf))
(leaf leaf-keywords
:ensure t
:init
;; optional packages if you want to use :hydra, :el-get, :blackout,,,
(leaf hydra :ensure t)
(leaf el-get :ensure t)
(leaf blackout :ensure t)
:config
;; initialize leaf-keywords.el
(leaf-keywords-init)))
;; </leaf-install-code>
(require 'package)
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")
("org" . "http://orgmode.org/elpa/")))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
(add-to-list 'load-path "~/.emacs.d/custom")
(require 'setup-general)
(require 'setup-cedet)
(require 'setup-editing)
(setq auto-save-default nil)
;; ファイルなら別バッファで、ディレクトリなら同じバッファで開く
(defun dired-open-in-accordance-with-situation ()
(interactive)
(let ((file (dired-get-filename)))
(if (file-directory-p file)
(dired-find-alternate-file)
(dired-find-file))))
;; dired-find-alternate-file の有効化
(put 'dired-find-alternate-file 'disabled nil)
;; RET 標準の dired-find-file では dired バッファが複数作られるので
;; dired-find-alternate-file を代わりに使う
(define-key dired-mode-map (kbd "RET") 'dired-open-in-accordance-with-situation)
(define-key dired-mode-map (kbd "a") 'dired-find-file)
;; スクリーンの最大化
(set-frame-parameter nil 'fullscreen 'maximized)
(setq show-paren-delay 0)
(show-paren-mode 1) ;; ;; C-qで移動
(defun match-paren (arg) "Go to the matching parenthesis if on
parenthesis." (interactive "p") (cond ((looking-at "\\s\(")
(forward-list 1) (backward-char 1)) ((looking-at "\\s\)")
(forward-char 1) (backward-list 1)) ) )
(global-set-key "\C-Q" 'match-paren)
;; font size change
(add-to-list 'default-frame-alist
'(font . "DejaVu Sans Mono-14"))
;; enable gtags
(setq load-path (cons "~/.emacs.d/gtags" load-path))
(require 'gtags)
(setq gtags-mode-hook
'(lambda ()
(local-set-key "\M-t" 'gtags-find-tag) ;関数へジャンプ
(local-set-key "\M-r" 'gtags-find-rtag) ;関数の参照元へジャンプ
(local-set-key "\M-s" 'gtags-find-symbol) ;変数の定義元/参照先へジャンプ
(local-set-key "\C-t" 'gtags-pop-stack) ;前のバッファに戻る
))
(add-hook 'c-mode-hook 'gtags-mode)
(add-hook 'c++-mode-hook 'gtags-mode)
(add-hook 'python-mode-hook 'gtags-mode)
;; use python3 in emacs shell
(setq python-shell-interpreter "python3")
(setq python-shell-interpreter-args "-m IPython --simple-prompt -i")
(el-get-envpath-prepend "PYTHONPATH" "/home/naoki/Documents/min_pipenv")
;; python setting(elpy+EIN)
(leaf python
:custom (python-indent-guess-indent-offset-verbose . nil)
:config
(leaf elpy
:ensure t
:defvar elpy-modules python-shell-completion-native-disabled-interpreters
:defun elpy-enable
:after python
:custom
;; (python-shell-interpreter . "jupyter")
;; (python-shell-interpreter-args . "console --simple-prompt")
(python-shell-prompt-detect-failure-warning . nil)
:init (elpy-enable)
:hook (elpy-mode-hook . (lambda () (add-hook 'before-save-hook 'elpy-format-code nil t)))
:config
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
(setq elpy-rpc-python-command "python3")
(setq python-shell-prompt-detect-failure-warning nil)
(setq elpy-rpc-virtualenv-path 'current)
(add-to-list 'python-shell-completion-native-disabled-interpreters
"jupyter")
)
)
;; autopep8
(require 'py-autopep8)
(add-hook 'python-mode-hook 'py-autopep8-mode)
;; pipenv
(use-package pipenv
:hook (python-mode . pipenv-mode)
:init
(setq
pipenv-projectile-after-switch-function
#'pipenv-projectile-after-switch-extended))
(setq gc-cons-threshold 800000)
(setq garbage-collection-messages nil)
;; lsp-mode
;; (require 'lsp-mode)
;; (setq read-process-output-max (* 1024 1024))
;; (setq lsp-completion-provider :capf)
;; (setq lsp-idle-delay 0.500)
;; lsp-ui
;; (use-package lsp-ui
;; :custom
;; ;; lsp-ui-doc
;; (lsp-ui-doc-enable t)
;; (lsp-ui-doc-header t)
;; (lsp-ui-doc-include-signature t)
;; (lsp-ui-doc-position 'top) ;; top, bottom, or at-point
;; (lsp-ui-doc-max-width 150)
;; (lsp-ui-doc-max-height 30)
;; (lsp-ui-doc-use-childframe t)
;; (lsp-ui-doc-use-webkit t)
;; ;; lsp-ui-flycheck
;; (lsp-ui-flycheck-enable nil)
;; ;; lsp-ui-sideline
;; (lsp-ui-sideline-enable nil)
;; (lsp-ui-sideline-ignore-duplicate t)
;; (lsp-ui-sideline-show-symbol t)
;; (lsp-ui-sideline-show-hover t)
;; (lsp-ui-sideline-show-diagnostics nil)
;; (lsp-ui-sideline-show-code-actions nil)
;; ;; lsp-ui-imenu
;; (lsp-ui-imenu-enable nil)
;; (lsp-ui-imenu-kind-position 'top)
;; ;; lsp-ui-peek
;; (lsp-ui-peek-enable t)
;; (lsp-ui-peek-peek-height 20)
;; (lsp-ui-peek-list-width 50)
;; (lsp-ui-peek-fontify 'on-demand) ;; never, on-demand, or always
;; :preface
;; (defun ladicle/toggle-lsp-ui-doc ()
;; (interactive)
;; (if lsp-ui-doc-mode
;; (progn
;; (lsp-ui-doc-mode -1)
;; (lsp-ui-doc--hide-frame))
;; (lsp-ui-doc-mode 1)))
;; :bind
;; (:map lsp-mode-map
;; ("C-c C-r" . lsp-ui-peek-find-references)
;; ("C-c C-j" . lsp-ui-peek-find-definitions)
;; ("C-c i" . lsp-ui-peek-find-implementation)
;; ("C-c m" . lsp-ui-imenu)
;; ("C-c s" . lsp-ui-sideline-mode)
;; ("C-c d" . ladicle/toggle-lsp-ui-doc))
;; :hook
;; (lsp-mode . lsp-ui-mode))
;; python -> lsp
;; (use-package python-mode
;; :config
;; (add-hook 'python-mode-hook #'lsp))
;; company
(require 'company)
(global-company-mode t)
(setq company-idle-delay nil)
(setq company-minimum-prefix-length 1)
(setq company-selection-wrap-around t)
(setq completion-ignore-case t)
(define-key company-active-map (kbd "C-n") 'company-select-next)
(define-key company-active-map (kbd "C-p") 'company-select-previous)
(define-key company-active-map (kbd "C-s") 'company-filter-candidates)
;; ivy
(when (require 'ivy nil t)
;; M-o を ivy-hydra-read-action に割り当てる.
(when (require 'ivy-hydra nil t)
(setq ivy-read-action-function #'ivy-hydra-read-action))
;; `ivy-switch-buffer' (C-x b) のリストに recent files と bookmark を含める.
(setq ivy-use-virtual-buffers t)
;; ミニバッファでコマンド発行を認める
(when (setq enable-recursive-minibuffers t)
(minibuffer-depth-indicate-mode 1)) ;; 何回層入ったかプロンプトに表示.
;; ESC連打でミニバッファを閉じる
(define-key ivy-minibuffer-map (kbd "<escape>") 'minibuffer-keyboard-quit)
;; プロンプトの表示が長い時に折り返す(選択候補も折り返される)
(setq ivy-truncate-lines nil)
;; リスト先頭で `C-p' するとき,リストの最後に移動する
(setq ivy-wrap t)
;; アクティベート
(ivy-mode 1))
;; counsel
(when (require 'counsel nil t)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "M-y") 'counsel-yank-pop)
(global-set-key (kbd "C-M-z") 'counsel-fzf)
(global-set-key (kbd "C-S-r") 'counsel-recentf)
(global-set-key (kbd "C-x C-b") 'counsel-ibuffer)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "C-M-f") 'counsel-ag)
;; activate
(counsel-mode 1))
;; swiper
(when (require 'swiper nil t)
(global-set-key (kbd "M-s M-s") 'swiper-thing-at-point)
(global-set-key (kbd "C-s") 'swiper))
(setq swiper-include-line-number-in-search t)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; ivy with dired
(when (require 'ivy-dired-history nil t)
(define-key dired-mode-map "," 'dired)
(with-eval-after-load "session"
(add-to-list 'session-globals-include 'ivy-dired-history-variable)))
;; ivy with magit
(with-eval-after-load "magit"
(setq magit-completing-read-function 'ivy-completing-read))
;; ivy with smex
(when (require 'smex nil t)
(setq smex-history-length 35)
(setq smex-completion-method 'ivy))
(setq ivy-initial-inputs-alist
'((org-agenda-refile . "^")
(org-capture-refile . "^")
;; (counsel-M-x . "^") ;; 削除.必要に応じて他のコマンドも除外する.
(counsel-describe-function . "^")
(counsel-describe-variable . "^")
(Man-completion-table . "^")
(woman . "^")))
(setf (alist-get 'counsel-M-x ivy-re-builders-alist) #'ivy--regex-ignore-order)
(setq ivy-re-builders-alist
'((swiper . ivy--regex-plus)
(t . ivy--regex-fuzzy)))
(defun ivy--sort-by-len (name candidates)
"Sort CANDIDATES based on similarity of their length with NAME."
(let ((name-len (length name))
(candidates-count (length candidates)))
(if (< 500 candidates-count)
candidates
(seq-sort-by #'length
(lambda (a b)
(< (abs (- name-len a))
(abs (- name-len b))))
candidates))))
(setf (alist-get 'counsel-M-x ivy-sort-matches-functions-alist)
#'ivy--sort-by-len)
;; counsel-ag
(defun ad:counsel-ag (f &optional initial-input initial-directory extra-ag-args ag-prompt caller)
(apply f (or initial-input (ivy-thing-at-point))
(unless current-prefix-arg
(or initial-directory default-directory))
extra-ag-args ag-prompt caller))
(advice-add 'counsel-ag :around #'ad:counsel-ag)
;; directory を指定して ag やり直し.クエリは再利用する
(defun my-counsel-ag-in-dir (_arg)
"Search again with new root directory."
(let ((current-prefix-arg '(4)))
(counsel-ag ivy-text nil ""))) ;; also disable extra-ag-args
(ivy-add-actions
'counsel-ag
'(("r" my-counsel-ag-in-dir "search in directory")))
(define-key counsel-ag-map (kbd "C-x C-d") 'counsel-cd)
;; counsel-recentf
(defun ad:counsel-recentf ()
"Find a file on `recentf-list'."
(interactive)
(require 'recentf)
(recentf-mode)
(ivy-read "Recentf: "
(progn
(mapcar #'substring-no-properties recentf-list) ;; no need?
(mapcar #'abbreviate-file-name recentf-list)) ;; ~/
:action (lambda (f)
(with-ivy-window
(find-file f)))
:require-match t
:caller 'counsel-recentf))
(advice-add 'counsel-recentf :override #'ad:counsel-recentf)
;; 以下の関数は,counsel-projectile-* と counsel-recentf にぶら下げる.
(defun my-counsel-fzf-in-default-dir (_arg)
"Search the current directory with fzf."
(counsel-fzf ivy-text default-directory))
;; add an action for counsel-recentf (M-o z)
(ivy-add-actions
'counsel-recentf
'(("z" my-counsel-fzf-in-default-dir "switch to fzf")))
(with-eval-after-load "ivy"
;; counsel-mark-ring のリストをソートさせない
(setf (alist-get 'counsel-mark-ring ivy-sort-functions-alist) nil))
;; counsel-mark-ring
(global-set-key (kbd "C-,") 'counsel-mark-ring)
(with-eval-after-load "flyspell"
(define-key flyspell-mode-map (kbd "C-,") 'counsel-mark-ring))
;; arrow visible
(defface my-ivy-arrow-visible
'((((class color) (background light)) :foreground "orange")
(((class color) (background dark)) :foreground "#EE6363"))
"Face used by Ivy for highlighting the arrow.")
(defface my-ivy-arrow-invisible
'((((class color) (background light)) :foreground "#FFFFFF")
(((class color) (background dark)) :foreground "#31343F"))
"Face used by Ivy for highlighting the invisible arrow.")
(if window-system
(when (require 'all-the-icons nil t)
(defun my-ivy-format-function-arrow (cands)
"Transform CANDS into a string for minibuffer."
(ivy--format-function-generic
(lambda (str)
(concat (all-the-icons-faicon
"hand-o-right"
:v-adjust -0.2 :face 'my-ivy-arrow-visible)
" " (ivy--add-face str 'ivy-current-match)))
(lambda (str)
(concat (all-the-icons-faicon
"hand-o-right" :face 'my-ivy-arrow-invisible) " " str))
cands
"\n"))
(setq ivy-format-functions-alist
'((t . my-ivy-format-function-arrow))))
(setq ivy-format-functions-alist '((t . ivy-format-function-arrow))))
;; ivy-rich
(all-the-icons-ivy-rich-mode 1)
(ivy-rich-mode 1)
;; Whether display the icons
(setq all-the-icons-ivy-rich-icon t)
;; Whether display the colorful icons.
;; It respects `all-the-icons-color-icons'.
(setq all-the-icons-ivy-rich-color-icon t)
;; The icon size
(setq all-the-icons-ivy-rich-icon-size 1.0)
;; Whether support project root
(setq all-the-icons-ivy-rich-project t)
;; Definitions for ivy-rich transformers.
;; See `ivy-rich-display-transformers-list' for details."
;;recentf
(require 'recentf)
(setq recentf-max-saved-items 200) ;; 200ファイルまで履歴保存する
(setq recentf-auto-cleanup 'never) ;; 存在しないファイルは消さない
(setq recentf-exclude '("/recentf" "COMMIT_EDITMSG" "/.?TAGS" "^/sudo:" "/\\.emacs\\.d/games/*-scores" "/\\.emacs\\.d/\\.cask/" "/\\.emacs\\.d/elpa/*" "^/tmp\\.*"))
(setq recentf-auto-save-timer (run-with-idle-timer 300 t 'recentf-save-list))
(recentf-mode 1)
(global-set-key "\M-g" 'goto-line)
(add-to-list 'auto-mode-alist '("\\.py$" . python-mode))
(global-display-line-numbers-mode)
(require 'cl-lib)
(require 'color)
(rainbow-delimiters-mode 1)
(setq rainbow-delimiters-outermost-only-face-count 1)
(set-face-foreground 'rainbow-delimiters-depth-1-face "#9a4040")
(set-face-foreground 'rainbow-delimiters-depth-2-face "#ff5e5e")
(set-face-foreground 'rainbow-delimiters-depth-3-face "#ffaa77")
(set-face-foreground 'rainbow-delimiters-depth-4-face "#dddd77")
(set-face-foreground 'rainbow-delimiters-depth-5-face "#80ee80")
(set-face-foreground 'rainbow-delimiters-depth-6-face "#66bbff")
(set-face-foreground 'rainbow-delimiters-depth-7-face "#da6bda")
(set-face-foreground 'rainbow-delimiters-depth-8-face "#afafaf")
(set-face-foreground 'rainbow-delimiters-depth-9-face "#f0f0f0")
(add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode)
(add-hook 'c-mode-hook 'rainbow-delimiters-mode)
(add-hook 'python-mode-hook 'rainbow-delimiters-mode)
;; doom theme
(require 'all-the-icons)
(use-package doom-themes
:ensure t
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-vibrant t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Enable custom neotree theme (all-the-icons must be installed!)
(doom-themes-neotree-config)
;; or for treemacs users
(setq doom-themes-treemacs-theme "doom-atom") ; use "doom-colors" for less minimal icon theme
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config))
(require 'doom-modeline)
(doom-modeline-mode 1)
(global-set-key (kbd "C-c <left>") 'windmove-left) (global-set-key
(kbd "C-c <down>") 'windmove-down) (global-set-key (kbd "C-c <up>")
'windmove-up) (global-set-key (kbd "C-c <right>") 'windmove-right)
;; c++ setting
(setq visible-bell t)
(require 'company)
(add-hook 'c-mode-hook 'company-mode)
(add-hook 'c++-mode-hook 'company-mode)
(setq company-clang-executable "/usr/bin/clang++-10")
(add-to-list 'company-backends 'company-c-headers)
(delete 'company-semantic company-backends)
(defadvice c-lineup-arglist (around my activate))
;; "Improve indentation of continued C++11 lambda function opened as argument."
;; C++ style
(add-hook 'c++-mode-hook
'(lambda()
(c-set-style "stroustrup")
(c-set-offset 'innamespace 0) ; namespace {}の中はインデントしない
(c-set-offset 'arglist-close 0) ; 関数の引数リストの閉じ括弧はインデントしない
(c-set-offset 'inlambda 0)
))
(with-eval-after-load 'company
(add-to-list 'company-backends 'company-irony))
(add-hook 'c++-mode-hook 'irony-mode)
(electric-pair-mode 1)
(require 'xclip)
(xclip-mode 1)
(require 'company-c-headers)
(add-to-list 'company-c-headers-path-system "/usr/include/c++/9/")
(when (locate-library "company")
(global-company-mode 1)
(global-set-key (kbd "C-M-i") 'company-complete)
(setq company-idle-delay nil) ; 自動補完をしない
(define-key company-active-map (kbd "C-n") 'company-select-next)
(define-key company-active-map (kbd "C-p") 'company-select-previous)
(define-key company-search-map (kbd "C-n") 'company-select-next)
(define-key company-search-map (kbd "C-p") 'company-select-previous)
(define-key company-active-map (kbd "<tab>") 'company-complete-selection))
;; (require 'ein) (setq ein:worksheet-enable-undo t)
;; (setq ein:complete-on-dot nil)
;; (setq ein:completion-backend'ein:use-company-backend)
;; (add-hook 'ein:notebook-mode-hook 'undo-tree-mode)
;; (add-hook 'ein:notebook-mode-hook 'python-mode)
;; (add-hook 'ein:notebook-mode-hook 'elpy-mode)
(add-to-list 'company-backends 'company-jedi)
;; magit
(use-package magit
:ensure t
:bind (("C-x g" . magit-status)
("C-x M-g" . magit-dispatch-popup)
)
)
;; nyan-mode
(nyan-mode t)
(nyan-start-animation)
(setq nyan-animate-nyancat t)
;; yas-mode
(require 'yasnippet)
(yas-global-mode 1)
;; shell setting
(setq sh-basic-offset 2)
(setq sh-indentation 2)
(setq sh-shell-file "/bin/sh")
;; shellの文字化けを回避
(add-hook 'shell-mode-hook
(lambda ()
(set-buffer-process-coding-system 'utf-8-unix 'utf-8-unix)
))
;; function-args
;; (require 'function-args)
;; (fa-config-default)
;; (define-key c-mode-map [(tab)] 'company-complete)
;; (define-key c++-mode-map [(tab)] 'company-complete)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(lsp-ui-doc-enable t)
'(lsp-ui-doc-header t)
'(lsp-ui-doc-include-signature t)
'(lsp-ui-doc-max-height 30)
'(lsp-ui-doc-max-width 150)
'(lsp-ui-doc-position (quote top))
'(lsp-ui-doc-use-childframe t)
'(lsp-ui-doc-use-webkit t)
'(lsp-ui-flycheck-enable nil t)
'(lsp-ui-imenu-enable nil)
'(lsp-ui-imenu-kind-position (quote top))
'(lsp-ui-peek-enable t)
'(lsp-ui-peek-fontify (quote on-demand))
'(lsp-ui-peek-list-width 50)
'(lsp-ui-peek-peek-height 20)
'(lsp-ui-sideline-enable nil)
'(lsp-ui-sideline-ignore-duplicate t)
'(lsp-ui-sideline-show-code-actions nil)
'(lsp-ui-sideline-show-diagnostics nil)
'(lsp-ui-sideline-show-hover t)
'(lsp-ui-sideline-show-symbol t)
'(package-archives
(quote
(("org" . "https://orgmode.org/elpa/")
("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/"))))
'(package-selected-packages
(quote
(package-utils irony leaf-keywords leaf csharp-mode zygospore pipenv dash elpy lsp-pyright lsp-ui lsp-mode fzf flx all-the-icons all-the-icons-dired all-the-icons-ivy-rich ivy-rich smex counsel nyan-mode doom-themes doom-modeline color-theme-modern py-autopep8 flycheck jedi jedi-core helm yasnippet ws-butler volatile-highlights use-package undo-tree iedit dtrt-indent counsel-projectile company clean-aindent-mode anzu)))
'(python-indent-guess-indent-offset-verbose nil)
'(python-shell-prompt-detect-failure-warning nil))
;; Keep underscores within a word boundary
;; (add-hook 'python-mode-hook
;; (lambda () ((modify-syntax-entry ?_ "_" python-mode-syntax-table))))
```
## マテリアル探し
### 2050年のデンソーの主力事業は何になっているか
- 1. 日本において、新車販売台数、保有台数は減少(人口減、都市部に人口集中、ライドシェアの発展など)→現在のビジネスモデル(新車に搭載するハード・ソフトの開発)ではジリ貧
- 2. 無人タクシーの市場規模が急速に拡大する予測→そっちに舵を切っていくべき、国内OEMの動きは遅いため海外OEM、ベンチャーとも積極的に協業して利益を確保していくべき
- 3. 食料枯渇→自国で生産する必要あり、労働力不足が懸念されるが自社ロボットや自動運転の分野のノウハウなどを用いて省人化を達成することでカバー、都市部への人口集中により田舎の土地が余る→土地を買い占めて大規模な農場を作る
- [新車販売台数、保有台数ともに減少傾向](https://www.tax.metro.tokyo.lg.jp/report/material/pdf/r0303/car/02.pdf)
- 2050 年の乗用車市場(保有台数、新車販売台数)の予測は、想定される社会の変化に応じて 3 パターンの推定を行った。
- ① 人口分布・所得の変化による推定:乗用車の保有・販売に影響を及ぼすと考えられる変数(人口・所得・世帯数など)の将来的な予測値に基づき行った予測。2050 年時点での保有台数は 55,538 千台、販売台数は 3,016 千台と予測。
- ② シェアリング普及による影響を考慮した推定(ベースシナリオ):上記①に、シェアリングサービスが普及した場合の乗用車保有台数への影響を考慮して行った予測。2050 年時点でカーシェアの普及によって潜在的に代替される可能性のある乗用車保有台数を推計し、それらが 2050 年にかけてカーシェアに移行するという前提の元、予測を行った。2050 年時点での保有台数は 49,898 千台、販売台数は 2,831 千台と予測。
- ③ シェアリング普及が想定よりも進展すると仮定した場合の推定:上記②にくわえ、低速自動運転の普及によるシェアリング・サービスの向上等により、シェアリングの普及がより進展すると想定した場合の推定。低速の自動運転による配車サービスが実現されることで、カーシェアサービスにアクセス可能な利用者が増加するとともに、シェアリングを利用する意向のない消費者の割合が減少するという前提の元、予測を行った。2050 年時点での保有台数は 45,162 千台、販売台数は2,691 千台と予測。
- [都市部への人口集中](https://www.soumu.go.jp/johotsusintokei/whitepaper/ja/r02/html/nd121120.html)
- 国連の調査によると、世界の都市圏の人口割合は年々増加傾向にあり、都市人口は2015年の約40億人から2030年に50億人を超え、2040年には60億人まで増加すると推定されている(図表2-1-1-2)。中でも東京の都市人口は2025年まで世界第1位の予測となっており、埼玉、千葉、神奈川を含む東京圏には日本の総人口の約3割が居住するなど、我が国の都市への人口集中の度合いは世界の中でも特に高くなっているといえる。
- 都市部への人口集中は、都市における過密化等による感染症リスクや自然災害リスクの増加や交通混雑等を引き起こす一方で、地方においては都市部への人口流出による地域経済・産業の担い手不足やコミュニティ維持の困難も引き起こす要因となる。
- [ライドシェアの需要増大](https://monoist.itmedia.co.jp/mn/articles/1902/26/news048.html)
- 富士経済は2019年2月22日、日本国内の自動車関連シェアサービスの市場予測を発表した。2030年には、相乗り型のライドシェアの市場規模が2017年比187.1倍の131億円に拡大する見通しだ。駐車場シェアリングは利便性が評価されて浸透し、同68.4倍の1094億円に市場拡大すると見込む。この他、カーシェアリングの2030年の市場は同9倍の260億円に成長するとしている。
- 相乗り型ライドシェアの市場は、ドライバーと利用者をマッチングさせる仲介手数料を対象としている。シェアリングエコノミーの1つとして認知が進んでおり、ライドシェア事業者がイベント会社や地方自治体との提携を進めたことから、2018年の市場規模は1億円となる見通し。今後は、ライドシェア事業者による行政への働きかけ強化や、タクシードライバーの高齢化と人材不足への対策により、2025年ごろから市場が活性化するとしている。
- [食料が枯渇する](https://www.maff.go.jp/j/zyukyu/jki/j_zyukyu_mitosi/attach/pdf/index-12.pdf)
- 人口増加と経済発展により2050年の世界の食料需要量は2010年比1.7倍となる。特に、低所得国の伸びが大きい。
- 食料需要の増加に対応して、穀物の生産量は2010年比1.7倍、油糧種子は1.6倍に増加する。農地の制約から各作物の収穫面積の伸びは小さく、生産量の増加は主に単収の増加により達成される。
- 我が国の主要農作物の輸入先である北米、中南米、オセアニア、並びに欧州では、経済発展に伴う農業投資の増加により生産量、純輸出量が更に増加する。
- 一方、アフリカ、中東では、経済発展に伴う農業投資の増大により主要作物の生産量は増加するものの、人口増加等により需要量の増加が生産量の増加を上回り、純輸入量が大幅に増加する。アジアでは米の生産量、輸出量は増加するが、食生活の多様化等に伴い小麦、大豆の需要量が増大し輸入量が増加する。
- 多くの農産物を輸入する我が国としては、国内生産の増大を図りつつ、日頃から世界の農作物の需給状況や見通し等の情報を幅広く収集する必要がある。また、アフリカなど食料輸入の増加が見通される開発途上の国々に対して、生産性向上に向けた技術支援を継続的に行い、世界の食料安全保障に貢献することが重要である。
## ChatGPT
- 色々な質問に対していい感じに答えてくれるチャットボット(Siriのすごい版?)
- 答えてくれる質問の種類
- 調べもの
- [感想文](https://ai-popularizer.tech/chatgpt-impressionofreading/)
- [プログラミング](https://cpoint-lab.co.jp/article/202212/23601/)
- etc
- [ネット検索に代わりうる](https://atmarkit.itmedia.co.jp/ait/articles/2302/17/news030.html)
- [企業で使われることも検討されている](https://www.businessinsider.jp/post-265674)
- [デタラメを言うこともしばしば](https://www3.nhk.or.jp/news/html/20221209/k10013917101000.html)
- [コンビニの店員さんやタクシーの運転手よりも先に学校の先生の方がいらなくなる?](https://www.kmw.ac.jp/contents/kaigo/lost-to-ai)
- [教育現場で問題になっている](https://www3.nhk.or.jp/news/special/international_news_navi/articles/feature/2023/02/15/29349.html)
- ソフト(AI)の発展は日進月歩
- ハード(ロボット)の進化のスピードはそこまででもない
- [工場で働くロボット](https://www.therobotreport.com/agility-robotics-digit-bring-in-150m/)
- [Atlas](https://www.youtube.com/watch?v=tF4DML7FIWk)
- インフラを整えるのが大変(人件費<導入コスト)
- ソフトで完結するものは取って代わられるのが早そう(ライター、イラストレーター等)
## 自己紹介メモ
- [hackmd](https://hackmd.io/?nav=overview)
- markdown形式でオンライン上にメモを残せるサービス
- 複数人で共有・閲覧できる
- vim, emacs, sublimeの中からエディターを選べる
- [お絵描きAI](https://github.com/CompVis/stable-diffusion)
- 描いてほしいものを言葉で入力として与えると、その画像が出力される(text-to-image)。
- a photograph of an astronaut riding a horse
(馬に乗っている宇宙飛行士の画像)
<img src=https://i.imgur.com/baMWjbb.png width=320>
<img src=https://i.imgur.com/WYYwjn3.png width=320>
- [競技プログラミング(勉強中)](https://atcoder.jp/contests/abc280)
- コンピュータサイエンスや数学に関する問題を、制限時間内にどれだけ解けるかを競う
- コード作成→オンライン上でジャッジ
- [経県値](https://uub.jp/j.cgi/)
- 四国と日本海側が行けていない
<img src=https://i.imgur.com/XrIECbR.png width=320>