end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

2023-02-05から1日間の記事一覧

pythonのdecoratorやcontextlibによる前後への処理追加

先程のentryに関連?として、以下のqiitaからの写経です。 https://qiita.com/chocomintkusoyaro/items/214f87a6300a88d15363 # cf. https://qiita.com/chocomintkusoyaro/items/214f87a6300a88d15363 import contextlib import sys def main(): msg = "this …

GoF Decorator for python

pythonにdecorator機能というものがあることを知りました。 pythonのdecorator機能とは、 「関数やクラスの前後に特定の処理を追加できる」ようですが、 GoFのデコレータパターンとは異なるようです。 で、pythonのdecorator機能を試す前に、 GoFデザインパ…

weakref for python を使用した弱参照化によるメモリリーク回避

「ゼロから作るディープラーニング 3 」の 「ステップ17 メモリ管理と循環参照」において、 weakrefによる弱参照化が紹介されていましたので、メモ weakref.ref() を使用する場合 参考url https://yumarublog.com/python/weakref/ import sys import weakref…

自動微分における順伝播と逆伝播(バックプロバゲーション)

自動微分における順伝播と逆伝播は、合成関数の微分によりますが、 十分には理解できていない気がしていますので、振り返り。 「ゼロから作るディープラーニング 3 」の写経です https://www.oreilly.co.jp/books/9784873119069/ https://github.com/oreilly…

svg marker による矢印

https://developer.mozilla.org/en-US/docs/Web/SVG/Element/marker 上記urlを参考にすると、以下 <svg xmlns="http://www.w3.org/2000/svg" width="400" height="100"> <defs> <style> circle,line, marker, path { stroke : #20285A; fill : none; stroke-width: 1; } line, path { marker-end : url(#arrow); …</defs></svg>

Pythonクラスの__call__で、インスタンスを関数のように呼び出しOK

class Test(): def __init__(self, test): self.test = test def __call__(self): print("called!!") t = Test('test') t()