网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

python中语法定义的示例分析-创新互联

这篇文章给大家分享的是有关python中语法定义的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

成都创新互联公司服务项目包括东丽网站建设、东丽网站制作、东丽网页制作以及东丽网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,东丽网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到东丽省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

1. 括号与函数调用

def devided_3(x):
   return x/3.

print(a)    #不带括号调用的结果:
print(a(3)) #带括号调用的结果:1

不带括号时,调用的是函数在内存在的首地址; 带括号时,调用的是函数在内存区的代码块,输入参数后执行函数体。

2. 括号与类调用

class test():
  y = 'this is out of __init__()'
  def __init__(self):
    self.y = 'this is in the __init__()'
 
x = test  # x是类位置的首地址
print(x.y) # 输出类的内容:this is out of __init__()
x = test() # 类的实例化
print(x.y) # 输出类的属性:this is in the __init__() ;

3. function(#) (input)

def With_func_rtn(a):
  print("this is func with another func as return")
  print(a)
  def func(b):
    print("this is another function")
    print(b)
  return func
func(2018)(11)
>>> this is func with another func as return
  2018
  this is another function
  11

其实,这种情况最常用在卷积神经网络中:

def model(input_shape):
  # Define the input placeholder as a tensor with shape input_shape.
  X_input = Input(input_shape)
  # Zero-Padding: pads the border of X_input with zeroes
  X = ZeroPadding2D((3, 3))(X_input)
  # CONV -> BN -> RELU Block applied to X
  X = Conv2D(32, (7, 7), strides = (1, 1), name = 'conv0')(X)
  X = BatchNormalization(axis = 3, name = 'bn0')(X)
  X = Activation('relu')(X)
  # MAXPOOL
  X = MaxPooling2D((2, 2), name='max_pool')(X)
  # FLATTEN X (means convert it to a vector) + FULLYCONNECTED
  X = Flatten()(X)
  X = Dense(1, activation='sigmoid', name='fc')(X)
  # Create model. This creates your Keras model instance, you'll use this instance to train/test the model.
  model = Model(inputs = X_input, outputs = X, name='HappyModel')
  return model

感谢各位的阅读!关于“python中语法定义的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!


分享名称:python中语法定义的示例分析-创新互联
标题来源:http://bjjierui.cn/article/cegdoo.html

其他资讯