Giter Site home page Giter Site logo

Comments (6)

ktaaaki avatar ktaaaki commented on August 14, 2024

それぞれの損失の一部でevalメソッドを呼び出せばできると思います.
例えばVAE(q, p, regularizer=kl, ...)で定義されたVAEでは,kl.eval(x_dict)-p.log_prob().expectation(q).eval(x_dict)またはStochasticReconstructionLoss(q, p).eval(x_dict)でKL divergenceと再構成誤差が評価できます.

ただしそれぞれの損失のevalでは別々の(確率的な)計算が実行されるため,これを一元化したい場合の実装は現状では困難です.中間結果を明示的にsampleevalメソッドで取り出せばできる場合もあります(中間の変数や損失がすでに定義されている場合など).

from pixyz.

tatsuhiko-inoue avatar tatsuhiko-inoue commented on August 14, 2024

回答ありがとうございます。

おっしゃる通り、実行してみたところ、実行した分、Encoder/Decoderも実行されました。
追加の計算なしでの取得は現状、非常に困難という理解でよいでしょうか?

from pixyz.

ktaaaki avatar ktaaaki commented on August 14, 2024

今回の件については,以下のようにhについての期待値計算を手続き的に実装すればできそうです.

class Decoder(Normal):
   ...

class EncoderBase(Determinisitic):
   def __init__(self):
      super().__init__(cond_var=['x'], var=['h'])
      ...
   ...

def train():
   ...
   p = Decoder()
   q1 = EncoderBase()
   q2 = Normal(var=['z'], cond_var=['h'], ...)
   prior = Normal(...)
   kl = KullbackLeibler(q2, prior)
   reconst = -p.log_prob().expectation(q2)
   ...
   h_dict = q1.sample(x_dict)
   kl_value = kl.eval(h_dict)
   reconst_value = reconst.eval(h_dict)

from pixyz.

tatsuhiko-inoue avatar tatsuhiko-inoue commented on August 14, 2024

回答ありがとうございました。

この方法を使ってみようと思います。

ただ、変なことを言うかもしれませんが、せっかくVAEというクラスを用意して頂いているのだから、もっと簡単にかけるとありがたいと考えています。
将来の機能として検討いただけますでしょうか?

from pixyz.

ktaaaki avatar ktaaaki commented on August 14, 2024

いつのバージョンから取り入れるかはまだ明言できませんが,検討中です.
pixyzの実用的な自由度を広げる上で,貴重なご意見ありがとうございます.

from pixyz.

tatsuhiko-inoue avatar tatsuhiko-inoue commented on August 14, 2024

検討いただき、ありがとうございます。
対応をお待ちしています。

from pixyz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.