Giter VIP home page Giter VIP logo

Comments (4)

masa-su avatar masa-su commented on June 18, 2024

今のままでもReshapeを駆使して実装可能.
ただし,ミニバッチの場合データがずれるという問題がある.

x = lasagne.layers.InputLayer((None, dim_x))
q1 = lasagne.layers.ReshapeLayer(x, (-1, timesteps, dim_x))
q2 = lasagne.layers.GRULayer(q1,num_units=dim_z, grad_clipping=100)
q3 = lasagne.layers.SliceLayer(q2,indices=-1,axis=1)
mean = lasagne.layers.DenseLayer(q3,2,nonlinearity=lasagne.nonlinearities.linear)
var = lasagne.layers.DenseLayer(q3,2,nonlinearity=lasagne.nonlinearities.softplus)
q = Gaussian(mean,var,given=[x])

z = lasagne.layers.InputLayer((None, dim_z))
p1 = RepeatLayer(z, n=timesteps)
p2 = lasagne.layers.GRULayer(p1, num_units=dim_x, grad_clipping=100)
p3 = lasagne.layers.ReshapeLayer(p2, (-1, [2]))
mean = lasagne.layers.DenseLayer(p3, dim_x, nonlinearity=lasagne.nonlinearities.softmax)
p = Categorical(mean,given=[z])

model = VAE(q,p,batch_size*20,lasagne.updates.adam,random=1234)

from tars.

masa-su avatar masa-su commented on June 18, 2024

関連して,RepeatLayerをlayerに加える(上のコードでも使用).

from tars.

masa-su avatar masa-su commented on June 18, 2024

これでRNN-based VAEが実装可能.

x = lasagne.layers.InputLayer((None, timesteps, dim_x))
q1 = lasagne.layers.GRULayer(x, num_units=dim_z, grad_clipping=100)
q2 = lasagne.layers.SliceLayer(q1, indices=-1, axis=1)
mean = lasagne.layers.DenseLayer(q2,2,nonlinearity=lasagne.nonlinearities.linear)
var = lasagne.layers.DenseLayer(q2,2,nonlinearity=lasagne.nonlinearities.softplus)
q = Gaussian(mean,var,given=[x])

z = lasagne.layers.InputLayer((None, dim_z))
p1 = RepeatLayer(z, n=timesteps)
p2 = lasagne.layers.GRULayer(p1, num_units=dim_x, grad_clipping=100)
p3 = lasagne.layers.ReshapeLayer(p2, (-1, [2]))
p4 = lasagne.layers.DenseLayer(p3, dim_x, nonlinearity=lasagne.nonlinearities.softmax)
mean = lasagne.layers.ReshapeLayer(p4, (-1, timesteps, dim_x))
p = Categorical(mean,given=[z])

model = VAE(q,p,batch_size,adam,random=1234)

ただし,toy problemで何故かあまり再構成が良くない.

from tars.

masa-su avatar masa-su commented on June 18, 2024

とりあえず実装できるようになったので,閉じます.

from tars.

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.