这篇教程Python layers.InputLayer方法代码示例写得很实用,希望能帮到您。
本文整理汇总了Python中keras.layers.InputLayer方法的典型用法代码示例。如果您正苦于以下问题:Python layers.InputLayer方法的具体用法?Python layers.InputLayer怎么用?Python layers.InputLayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块keras.layers 的用法示例。 在下文中一共展示了layers.InputLayer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。 示例1: build_model# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import InputLayer [as 别名]def build_model(): model = Sequential() model.add(InputLayer(input_shape=(None, None, 1))) model.add(Conv2D(8, (3, 3), activation='relu', padding='same', strides=2)) model.add(Conv2D(8, (3, 3), activation='relu', padding='same')) model.add(Conv2D(16, (3, 3), activation='relu', padding='same')) model.add(Conv2D(16, (3, 3), activation='relu', padding='same', strides=2)) model.add(Conv2D(32, (3, 3), activation='relu', padding='same')) model.add(Conv2D(32, (3, 3), activation='relu', padding='same', strides=2)) model.add(UpSampling2D((2, 2))) model.add(Conv2D(32, (3, 3), activation='relu', padding='same')) model.add(UpSampling2D((2, 2))) model.add(Conv2D(16, (3, 3), activation='relu', padding='same')) model.add(UpSampling2D((2, 2))) model.add(Conv2D(2, (3, 3), activation='tanh', padding='same')) # model.compile(optimizer='rmsprop', loss='mse') model.compile(optimizer='adam', loss='mse') return model#训练数据
示例2: fsrcnn# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import InputLayer [as 别名]def fsrcnn(x, d=56, s=12, m=4, scale=3): """Build an FSRCNN model. See https://arxiv.org/abs/1608.00367 """ model = Sequential() model.add(InputLayer(input_shape=x.shape[-3:])) c = x.shape[-1] f = [5, 1] + [3] * m + [1] n = [d, s] + [s] * m + [d] for ni, fi in zip(n, f): model.add(Conv2D(ni, fi, padding='same', kernel_initializer='he_normal', activation='relu')) model.add(Conv2DTranspose(c, 9, strides=scale, padding='same', kernel_initializer='he_normal')) return model
开发者ID:qobilidop,项目名称:srcnn,代码行数:18,代码来源:models.py
示例3: nsfsrcnn# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import InputLayer [as 别名]def nsfsrcnn(x, d=56, s=12, m=4, scale=3, pos=1): """Build an FSRCNN model, but change deconv position. See https://arxiv.org/abs/1608.00367 """ model = Sequential() model.add(InputLayer(input_shape=x.shape[-3:])) c = x.shape[-1] f1 = [5, 1] + [3] * pos n1 = [d, s] + [s] * pos f2 = [3] * (m - pos - 1) + [1] n2 = [s] * (m - pos - 1) + [d] f3 = 9 n3 = c for ni, fi in zip(n1, f1): model.add(Conv2D(ni, fi, padding='same', kernel_initializer='he_normal', activation='relu')) model.add(Conv2DTranspose(s, 3, strides=scale, padding='same', kernel_initializer='he_normal')) for ni, fi in zip(n2, f2): model.add(Conv2D(ni, fi, padding='same', kernel_initializer='he_normal', activation='relu')) model.add(Conv2D(n3, f3, padding='same', kernel_initializer='he_normal')) return model
开发者ID:qobilidop,项目名称:srcnn,代码行数:27,代码来源:models.py
示例4: espcn# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import InputLayer [as 别名]def espcn(x, f=[5, 3, 3], n=[64, 32], scale=3): """Build an ESPCN model. See https://arxiv.org/abs/1609.05158 """ assert len(f) == len(n) + 1 model = Sequential() model.add(InputLayer(input_shape=x.shape[1:])) c = x.shape[-1] for ni, fi in zip(n, f): model.add(Conv2D(ni, fi, padding='same', kernel_initializer='he_normal', activation='tanh')) model.add(Conv2D(c * scale ** 2, f[-1], padding='same', kernel_initializer='he_normal')) model.add(Conv2DSubPixel(scale)) return model
开发者ID:qobilidop,项目名称:srcnn,代码行数:18,代码来源:models.py
示例5: make_model_small# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import InputLayer [as 别名]def make_model_small(train_input, num_classes, weights_file=None): '''Return Cifar10 DL model with small number layers.''' model = Sequential() # model.add(KL.InputLayer(input_shape=inshape[1:])) if isinstance(train_input, tf.Tensor): model.add(KL.InputLayer(input_tensor=train_input)) else: model.add(KL.InputLayer(input_shape=train_input)) # if standardize: # model.add(KL.Lambda(stand_img)) model.add(KL.Conv2D(32, (3, 3), padding='same')) model.add(KL.Activation('relu')) model.add(KL.Flatten()) # model.add(Dropout(0.5)) model.add(KL.Dense(num_classes)) model.add(KL.Activation('softmax')) if weights_file is not None and os.path.exists(weights_file): model.load_weights(weights_file) return model
示例6: compute_output_shape# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import InputLayer [as 别名]def compute_output_shape(self, input_shape): return input_shape# class LocalParam(InputLayer):# def __init__(self, shape, mult=1, my_initializer='RandomNormal', **kwargs):# super(LocalParam, self).__init__(input_shape=shape, **kwargs) # # Create a trainable weight variable for this layer.# self.kernel = self.add_weight(name='kernel', # shape=tuple(shape),# initializer=my_initializer,# trainable=True) # outputs = self._inbound_nodes[0].output_tensors# z = Input(tensor=K.expand_dims(self.kernel, 0)*mult)# if len(outputs) == 1:# self._inbound_nodes[0].output_tensors[0] = z# else:# self._inbound_nodes[0].output_tensors = z # def get_output(self): # call() would force inputs# outputs = self._inbound_nodes[0].output_tensors# if len(outputs) == 1:# return outputs[0]# else:# return outputs
开发者ID:voxelmorph,项目名称:voxelmorph,代码行数:30,代码来源:layers.py
示例7: bicubic# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import InputLayer [as 别名]def bicubic(x, scale=3): model = Sequential() model.add(InputLayer(input_shape=x.shape[-3:])) model.add(ImageRescale(scale, method=tf.image.ResizeMethod.BICUBIC)) return model
开发者ID:qobilidop,项目名称:srcnn,代码行数:7,代码来源:models.py
示例8: make_model# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import InputLayer [as 别名]def make_model(inshape, num_classes, weights_file=None): model = Sequential() model.add(KL.InputLayer(input_shape=inshape[1:])) # model.add(KL.Conv2D(32, (3, 3), padding='same', input_shape=inshape[1:])) model.add(KL.Conv2D(32, (3, 3), padding='same')) model.add(KL.Activation('relu')) model.add(KL.Conv2D(32, (3, 3))) model.add(KL.Activation('relu')) model.add(KL.MaxPooling2D(pool_size=(2, 2))) model.add(KL.Dropout(0.25)) model.add(KL.Conv2D(64, (3, 3), padding='same')) model.add(KL.Activation('relu')) model.add(KL.Conv2D(64, (3, 3))) model.add(KL.Activation('relu')) model.add(KL.MaxPooling2D(pool_size=(2, 2))) model.add(KL.Dropout(0.25)) model.add(KL.Flatten()) model.add(KL.Dense(512)) model.add(KL.Activation('relu')) model.add(KL.Dropout(0.5)) model.add(KL.Dense(num_classes)) model.add(KL.Activation('softmax')) if weights_file is not None and os.path.exists(weights_file): model.load_weights(weights_file) return model
示例9: make_model# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import InputLayer [as 别名]def make_model(x_train_input, nclasses): '''Non-functional model definition.''' model = Sequential() model.add(KL.InputLayer(input_tensor=x_train_input)) ll = cnn_layers_list(nclasses) for il in ll: model.add(il) return model
示例10: make_model_full# 需要导入模块: from keras import layers [as 别名]# 或者: from keras.layers import InputLayer [as 别名]def make_model_full(train_input, num_classes, weights_file=None): '''Return Cifar10 DL model with many layers. :param train_input: Either a tf.Tensor input placeholder/pipeline, or a tuple input shape. ''' model = Sequential() # model.add(KL.InputLayer(input_shape=inshape[1:])) if isinstance(train_input, tf.Tensor): model.add(KL.InputLayer(input_tensor=train_input)) else: model.add(KL.InputLayer(input_shape=train_input)) # if standardize: # model.add(KL.Lambda(stand_img)) model.add(KL.Conv2D(32, (3, 3), padding='same')) model.add(KL.Activation('relu')) model.add(KL.Conv2D(32, (3, 3))) model.add(KL.Activation('relu')) model.add(KL.MaxPooling2D(pool_size=(2, 2))) model.add(KL.Dropout(0.25)) model.add(KL.Conv2D(64, (3, 3), padding='same')) model.add(KL.Activation('relu')) model.add(KL.Conv2D(64, (3, 3))) model.add(KL.Activation('relu')) model.add(KL.MaxPooling2D(pool_size=(2, 2))) model.add(KL.Dropout(0.25)) model.add(KL.Flatten()) model.add(KL.Dense(512)) model.add(KL.Activation('relu')) model.add(KL.Dropout(0.5)) model.add(KL.Dense(num_classes)) model.add(KL.Activation('softmax')) if weights_file is not None and os.path.exists(weights_file): model.load_weights(weights_file) return model
|