1

ここにあるTheanoを使用してGPUでSDEを解決する例を試しています

GpuDimShuffle エラーで立ち往生していますが、どのディムも一致していません...

import theano
import theano.tensor as T
from theano.tensor.shared_randomstreams import RandomStreams
import numpy as np
import matplotlib.pyplot as plt
import time

#define the ode function
#dc/dt  = f(c, lambda)
#c is a vector with n components
def evolve(c, n, k, l):
    return T.pow(c, n)/(T.pow(c, n)+T.pow(k,n)) - l*c

def euler(c, n, k, l, dt):
    return T.cast(c + dt*evolve(c, n, k, l) + T.sqrt(dt)*c*rv_n, 'float32')

def rk4(c, n, k, l, dt):
    '''
    Adapted from
    http://people.sc.fsu.edu/~jburkardt/c_src/stochastic_rk/stochastic_rk.html
    '''
    a21 =   2.71644396264860
    a31 = - 6.95653259006152
    a32 =   0.78313689457981
    a41 =   0.0
    a42 =   0.48257353309214
    a43 =   0.26171080165848
    a51 =   0.47012396888046
    a52 =   0.36597075368373
    a53 =   0.08906615686702
    a54 =   0.07483912056879

    q1 =   2.12709852335625
    q2 =   2.73245878238737
    q3 =  11.22760917474960
    q4 =  13.36199560336697

    x1 = c
    k1 = dt * evolve(x1, n, k, l) + T.sqrt(dt) * c * rv_n

    x2 = x1 + a21 * k1
    k2 = dt * evolve(x2, n, k, l) + T.sqrt(dt) * c * rv_n

    x3 = x1 + a31 * k1 + a32 * k2
    k3 = dt * evolve(x3, n, k, l) + T.sqrt(dt) * c * rv_n

    x4 = x1 + a41 * k1 + a42 * k2
    k4 = dt * evolve(x4, n, k, l) + T.sqrt(dt) * c * rv_n

    return T.cast(x1 + a51 * k1 + a52 * k2 + a53 * k3 + a54 * k4, 'float32')

#random
srng = RandomStreams(seed=31415)

#define symbolic variables
dt = T.fscalar("dt")
k = T.fscalar("k")
l = T.fscalar("l")
n = T.fscalar("n")
c = T.fvector("c")

#define numeric variables
num_samples = 50000
c0 = theano.shared(0.5*np.ones(num_samples, dtype='float32'))
n0 = 6
k0 = 0.5
l0 = 1/(1+np.power(k0, n0))
dt0 = 0.1
total_time = 8
total_steps = int(total_time/dt0)
rv_n = srng.normal(c.shape, std=0.05) #is a shared variable

#create loop
#first symbolic loop with everything
(cout, updates) = theano.scan(fn=rk4,
                                outputs_info=[c], #output shape
                                non_sequences=[n, k, l, dt], #fixed parameters
                                n_steps=total_steps)
#compile it
sim = theano.function(inputs=[n, k, l, dt],givens={c:c0}, outputs=cout,updates=updates,allow_input_downcast=True)

収量:

TypeError: ('ノードのコンパイル中に次のエラーが発生しました', Rebroadcast{0(GpuDimShuffle{x,0}.0), '\n', 'super(type, obj): obj は型のインスタンスまたはサブタイプでなければなりません')

私は Theano 0.6.0 を使用しています

4

1 に答える 1

1

開発版に更新すると、うまくいきます:

http://www.deeplearning.net/software/theano/install.html#bleeding-edge-install-instructions

私たちは開発バージョンを非常に安定した状態に保つように努めており、前回のリリース以降の多くの修正が含まれているため、すべての人に使用することをお勧めします.

それでも解決しない場合、エラーはお使いの OS または Python のバージョンに固有のものです。それについてもっと情報が必要です。また、常に完全なエラー メッセージをトレースバックと共に提供してください。これにより、より多くのデバッグ情報が提供されます。

于 2014-06-25T13:33:15.273 に答える