Programming 【Python】TensorflowでCNNモデルを定義して学習する【Cifar10】 tensorflowを用いてCNNモデルを自分で定義して学習する実装をまとめる。データセットにはCifar10を使う。 まずはCifar10のデータセットを以下のように実装して読み込む。 import matplotl... 2023.07.30 ProgrammingPython
Programming 【Python】遺伝的アルゴリズムGAを実装して文章を生成する 遺伝的アルゴリズムGAの基本的な実装を行って文章を生成する。"Hello, where are you?"を作るようにする。 全体のコードは以下になる。突然変異mutateで作りたい文章を求めている。 import r... 2023.07.30 ProgrammingPython
Programming 【Tensorflow】データセットからモデルを転移学習する【Python, Cifar10】 tensorflowで学習済みモデルを使って転移学習をする実装をまとめておく。以下のようなコードになる。これはDenseNet121の学習済みモデルを使う場合。 from tensorflow.keras import da... 2023.07.26 ProgrammingPython
Programming 【Jupyter Lab】nbconvert failedのエラーを解決する方法【PDF出力】 Jupyter Labで使っているNotebookをPDFに出力しようとしたところ、別のタブが開かれて以下のようなエラーが出てきた。 nbconvert failed: xelatex not found on PATH, ... 2023.06.16 ProgrammingPythonUbuntu
Programming ScannerError: mapping values are not allowed here yaml spaceを解決する方法 ScannerError: mapping values are not allowed here yaml spaceを解決する方法 Pythonでyamlファイルを読み込んでグラフを描こうとしたときに以下のようなエラーが... 2022.12.15 ProgrammingPython
Programming 【map】配列の要素で多数決を行う方法【Python】 【map】配列の要素で多数決を行う方法【Python】 分類モデルを学習する時にクロスバリデーション、アンサンブルなどで予測結果の多数決を取りたい場合がある。 この時に便利な方法があるのでまとめておく。 以下のよ... 2022.06.02 ProgrammingPython
Programming 【torch.text】module ‘torchtext.data’ has no attribute ‘Field’を解決する 【torch.text】module 'torchtext.data' has no attribute 'Field'を解決する Pytorchのプログラムを実行した際に、以下の部分でエラーが出てきた。 from t... 2022.05.31 ProgrammingPython
Programming 【Protobuf】”TypeError: Descriptors cannot not be created directly.”を解決する【solved】 【Protobuf】"TypeError: Descriptors cannot not be created directly."を解決する【solved】 Pythonでtensorflowをインポートしようとしたときに... 2022.05.29 ProgrammingPython
Programming 【Pytorch】No module named ‘torchtext.legacy’を解決する方法【Solved】 【Pytorch】No module named 'torchtext.legacy'を解決する方法【Solved】 以下を実行しようとするとエラーが出た。 from torchtext.legacy import d... 2022.05.27 ProgrammingPython
Programming 【Pytorch】mnistを用いたクラス分類モデルをCNNで学習するコード 【Pytorch】mnistを用いたクラス分類モデルをCNNで学習するコード CNNでmnistの画像データをクラス分類するためのコードをまとめておく。 CNNの実装で必要な層(レイヤー)の定義は↓のページでまとめてい... 2022.05.25 ProgrammingPython