

初心者です．Githubにアップされているチュートリアル通りにやっています．  
<https://github.com/Microsoft/CNTK/blob/master/Tutorials/CNTK_205_Artistic_Style_Transfer.ipynb>

6セル目を実行すると以下のようなエラーが出力されます．解決方法を教えて頂きたいです．

[code]

    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-7-5c5a134b2d0e> in <module>()
         42 else:
         43     x0 = content
    ---> 44 xstar = optimize(loss, x0, inner, outer)
         45 plt.imshow(np.asarray(np.transpose(xstar+SHIFT, (1, 2, 0)), dtype=np.uint8))
    
    <ipython-input-7-5c5a134b2d0e> in optimize(loss, x0, inner, outer)
         30     for i in range(outer):
         31         s = opt.minimize(objfun, img2vec(x0), args=(loss,), method='L-BFGS-B', 
    ---> 32                          bounds=bounds, options={'maxiter': inner}, jac=True)
         33         print('objective : %s' % s.fun[0])
         34         x0 = vec2img(s.x)
    
    C:\Users\owner\Anaconda3\lib\site-packages\scipy\optimize\_minimize.py in minimize(fun, x0, args, method, jac, hess, hessp, bounds, constraints, tol, callback, options)
        448     elif meth == 'l-bfgs-b':
        449         return _minimize_lbfgsb(fun, x0, args, jac, bounds,
    --> 450                                 callback=callback, **options)
        451     elif meth == 'tnc':
        452         return _minimize_tnc(fun, x0, args, jac, bounds, callback=callback,
    
    C:\Users\owner\Anaconda3\lib\site-packages\scipy\optimize\lbfgsb.py in _minimize_lbfgsb(fun, x0, args, jac, bounds, disp, maxcor, ftol, gtol, eps, maxfun, maxiter, iprint, callback, maxls, **unknown_options)
        326             # until the completion of the current minimization iteration.
        327             # Overwrite f and g:
    --> 328             f, g = func_and_grad(x)
        329         elif task_str.startswith(b'NEW_X'):
        330             # new iteration
    
    C:\Users\owner\Anaconda3\lib\site-packages\scipy\optimize\lbfgsb.py in func_and_grad(x)
        276     else:
        277         def func_and_grad(x):
    --> 278             f = fun(x, *args)
        279             g = jac(x, *args)
        280             return f, g
    
    C:\Users\owner\Anaconda3\lib\site-packages\scipy\optimize\optimize.py in function_wrapper(*wrapper_args)
        290     def function_wrapper(*wrapper_args):
        291         ncalls[0] += 1
    --> 292         return function(*(wrapper_args + args))
        293 
        294     return ncalls, function_wrapper
    
    C:\Users\owner\Anaconda3\lib\site-packages\scipy\optimize\optimize.py in __call__(self, x, *args)
         61     def __call__(self, x, *args):
         62         self.x = numpy.asarray(x).copy()
    ---> 63         fg = self.fun(x, *args)
         64         self.jac = fg[1]
         65         return fg[0]
    
    <ipython-input-7-5c5a134b2d0e> in objfun(x, loss)
         22     v, g = value_and_grads(loss, {loss.arguments[0]: [[y]]})
         23     v = np.reshape(v, (1,))
    ---> 24     g = img2vec(list(g.values())[0])
         25     return v, g
         26 
    
    <ipython-input-7-5c5a134b2d0e> in img2vec(img)
          6 # utility to convert an image to a vector
          7 def img2vec(img):
    ----> 8     return img.flatten().astype(np.float64)
          9 
         10 # utility to compute the value and the gradient of f at a particular place defined by binding
    
    AttributeError: 'list' object has no attribute 'flatten'
    
[/code]


CC BY-SA 3.0
2017-06-27T10:04:14.113
35917
2017-06-27T22:05:03.247
2017-06-27T22:05:03.247
19110
23647
question
python
CNTKにおける画風変換でのエラー