首页 文章

Keras mobilenet实施

提问于
浏览
0

我想使用具有depth_multiplier(或分辨率乘数)的不同值的mobilenet . 这两行代码给出了以下错误 . 知道这里出了什么问题吗?

from keras.applications.mobilenet import MobileNet
basic_model = MobileNet(alpha=0.25, depth_multiplier=0.25, weights=None)

错误:

回溯(最近一次调用最后一次):文件“C:/Users/Pedro/Desktop/Work/Smile/files/CVPR_2016_SMILES_DATA/test.py”,第2行,在basic_model = MobileNet(alpha = 0.25,depth_multiplier = 0.25,权重) =无)文件“C:\ Users \ Pedro \ Anaconda3 \ lib \ site-packages \ keras \ applications \ mobilenet.py”,第456行,在MobileNet中x = depthwise_conv_block(x,64,alpha,depth_multiplier,block_id = 1)文件“C:\ Users \ Pedro \ Anaconda3 \ lib \ site-packages \ keras \ applications \ mobilenet.py”,第654行,在_depthwise_conv_block name ='conv_dw%d'%block_id)(输入)文件“C:\ Users \ Pedro \ Anaconda3 \ lib \ site-packages \ keras \ engine \ topology.py“,第576行,调用self.build(input_shapes [0])文件”C:\ Users \ Pedro \ Anaconda3 \ lib \ site-packages \ keras \ applications \ mobilenet.py“,第228行,在build constraint = self.depthwise_constraint中)文件”C:\ Users \ Pedro \ Anaconda3 \ lib \ site-packages \ keras \ _ legacy \ interfaces.py“,第87行,在包装器返回func(* args,** kwargs)文件“C:\ Users \ Pedro \ Anaconda3 \ lib \ site-packages \ keras \ engine \ topology.py”中,行397,在add_weight weight = K.variable(initializer(shape),File“C:\ Users \ Pedro \ Anaconda3 \ lib \ site-packages \ keras \ initializers.py”,第212行,调用dtype = dtype,seed = self.seed)文件“C:\ Users \ Pedro \ Anaconda3 \ lib \ site-packages \ keras \ backend \ tensorflow_backend.py”,第3627行,in random_uniform dtype = dtype,seed = seed)文件“C:\ Users \ Pedro \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ ops \ random_ops.py“,第240行,in random_uniform形状,dtype,seed = seed1,seed2 = seed2)文件”C:\ Users \ Pedro \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ ops \ gen_random_ops.py“,第247行,_random_uniform seed = seed,seed2 = seed2,name = name)文件”C:\ Users \ Pedro \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ framework \ op_def_library.py“,第589行,在apply_op param_name = input_name中)文件”C:\ Users \ Pedro \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ framework \ op_def_library.py“,第60行,在_SatisfiesTypeConstraint“,” . join(dtypes.as_dtype(x).name for x in allowed_list)))TypeError:传递给参数的值'shape'的DataType float32不在允许值列表中:int32,int64

来自mobilent paper:"The second hyper-parameter to reduce the computational cost of a neural network is a resolution multiplier ρ. We apply this to the input image and the internal representation of every layer is subsequently reduced by the same multiplier. In practice, we implicitly set ρ by setting the input resolution. We can now express the computational cost for the core layers of our network as depthwise separable convolutions with width multiplier α and resolution multiplier ρ: DK · DK · αM · ρDF · ρDF + αM · αN · ρDF · ρDF (7) where ρ ∈ (0, 1] which is typically set implicitly so that the input resolution of the network is 224, 192, 160 or 128. ρ = 1 is the baseline MobileNet and ρ < 1 are reduced computation MobileNets. Resolution multiplier has the effect of reducing computational cost by ρ^2."

并且Keras声称depth_multiplier与herehere中的分辨率乘数相同:"depth_multiplier: depth multiplier for depthwise convolution (also called the resolution multiplier)"

2 回答

  • 0

    答案是在追溯调用的底部 .

    它期望一个整数,例如25(没有小数点的数字)而不是浮点数,例如0.25

    depth_multiplier:每个输入通道的深度卷积输出通道数 . 深度卷积输出通道的总数将等于filters_in * depth_multiplier .

    参考:https://github.com/fchollet/deep-learning-models/blob/master/mobilenet.py

  • 0

    它似乎只是错误的命名而且它们不一样 . 你可以阅读更多here

相关问题