TypeError :(' Shape必须是整数',TensorConstant {[1. 8. 1. 1.]},' float64')

时间:2017-02-10 00:46:34

标签: python-3.x theano keras

我在使用theano和keras的Python 3.5中遇到以下错误。我在keras运行CNN模型。

    TypeError                                 Traceback (most recent calllast)
   <ipython-input-5-8f63b9541c7f> in <module>()
    ----> 1 model = get_unet(Adam(lr=1e-5))

 <ipython-input-1-1aa31b714bd1> in get_unet_inception_2head(optimizer)
121 
122     inputs = Input((1, IMG_ROWS, IMG_COLS), name='main_input')
--> 123     conv1 = inception_block(inputs, 32, batch_mode=2, splitted=splitted, activation=act)
124     #conv1 = inception_block(conv1, 32, batch_mode=2, splitted=splitted, activation=act)
125 <ipython-input-1-1aa31b714bd1> in inception_block(inputs, depth, batch_mode, splitted, activation)
 27     actv = activation == 'relu' and (lambda: LeakyReLU(0.0)) or activation == 'elu' and (lambda: ELU(1.0)) or None
 28 ---> 29     c1_1 = Convolution2D(depth/4, 1, 1, init='he_normal', border_mode='same')(inputs)
 30 
 31     c2_1 = Convolution2D(depth/8*3, 1, 1, init='he_normal',border_mode='same')(inputs)
       .
       .
       .
       .
       .
       .
/opt/anaconda3/lib/python3.5/site-packages/theano/tensor/basic.py in      make_node(self, x, shp)
   4361             # except when shp is constant and empty
  4362             # (in this case, shp.dtype does not matter anymore).
  -> 4363             raise TypeError("Shape must be integers", shp, shp.dtype)
 4364         assert shp.ndim == 1
  4365         if isinstance(shp, TensorConstant):

  TypeError: ('Shape must be integers', TensorConstant{[ 1.  8.  1.  1.]}, 'float64')

我也收到以下警告:

 /opt/anaconda3/lib/python3.5/site-packages/keras/backend/theano_backend.py:145: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
return variable(np.random.normal(loc=0.0, scale=scale, size=shape),
 /opt/anaconda3/lib/python3.5/site-packages/keras/backend/theano_backend.py:116: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future return variable(np.zeros(shape), dtype, name)

我认为这个警告引起了问题。我试过像铸造到int等所有东西。 请帮我解决这个问题。

代码链接:http://ideone.com/Y02erf

0 个答案:

没有答案
相关问题