Example #1
0
#        sg.theta = theta.reshape(sh).copy()
#        res = sg.interpolate(grid2, with_derivative=False)
#        return res
#

    from dolo.numeric.serial_operations import numdiff1, numdiff2

    #    x0 = sg.theta.flatten()
    x0 = values.flatten()
    print(x0.shape)

    test = fun(x0)
    print('image')
    print(test.shape)
    #    dtest = numdiff1(grid[1] fun, values)
    dtest = numdiff2(fun, x0, dv=1e-5)

    #    print(values.shape)
    #    print(test.shape)
    #    print(dtest)

    print('numerical derivative')
    print(dtest.shape)

    #    dtest = dtest.swapaxes(1,2)

    #    print(test.shape)
    #    print(test)
    #    [res1, res2, res3] = sg.interpolate(grid2, with_theta_deriv=True)
    #
    print('symbolic derivative')
Example #2
0
#        sg.theta = theta.reshape(sh).copy()
#        res = sg.interpolate(grid2, with_derivative=False)
#        return res
#

    from dolo.numeric.serial_operations import numdiff1, numdiff2

#    x0 = sg.theta.flatten()
    x0 = values.flatten()
    print(x0.shape)

    test = fun(x0)
    print('image')
    print( test.shape)
#    dtest = numdiff1(grid[1] fun, values)
    dtest = numdiff2( fun, x0, dv=1e-5)

#    print(values.shape)
#    print(test.shape)
#    print(dtest)

    print('numerical derivative')
    print(dtest.shape)

#    dtest = dtest.swapaxes(1,2)

#    print(test.shape)
#    print(test)
#    [res1, res2, res3] = sg.interpolate(grid2, with_theta_deriv=True)
#
    print('symbolic derivative')
Example #3
0
    #    print ddval
    #    print(dval0)


    def fobj(values):
        sg2.fit_values(values.reshape((2, 5)))
        return sg2.interpolate(sg2.grid, with_derivative=False)

    print('derivatives w.r.t. parameters')
    [val, dval] = sg2.interpolate(sg2.grid,
                                  with_theta_deriv=True,
                                  with_derivative=False)

    vals = vals.reshape((1, 10))
    #    [val0,dval0] = numdiff1(fobj,vals)
    [val1, dval1] = numdiff2(fobj, vals)

    print vals.shape
    print fobj(vals).shape
    print dval.shape
    print dval.shape
    #    print dval0.shape
    print(dval1.shape)

    exit()
    ddval = numdiff1(sg2.interpolate, sg2.real_grid)
    print ddval

    print dval.shape
    print ddval.shape
Example #4
0
    #    print('dval - dval0')
    #    print(ddval -dval)
    #    print(ddval -dval0)
    #    print ddval
    #    print(dval0)

    def fobj(values):
        sg2.fit_values(values.reshape((2, 5)))
        return sg2.interpolate(sg2.grid, with_derivative=False)

    print ("derivatives w.r.t. parameters")
    [val, dval] = sg2.interpolate(sg2.grid, with_theta_deriv=True, with_derivative=False)

    vals = vals.reshape((1, 10))
    #    [val0,dval0] = numdiff1(fobj,vals)
    [val1, dval1] = numdiff2(fobj, vals)

    print vals.shape
    print fobj(vals).shape
    print dval.shape
    print dval.shape
    #    print dval0.shape
    print (dval1.shape)

    exit()
    ddval = numdiff1(sg2.interpolate, sg2.real_grid)
    print ddval

    print dval.shape
    print ddval.shape