大数据开发之keras代码框架应用
总体来讲keras这个深度学习框架真的很“简易”,它体现在可参考的文档写的比较详细,不像caffe,装完以后都得靠技术博客,keras有它自己的官方文档(不过是英文的),这给初学者提供了很大的学习空间。
在此做下代码框架应用笔记
class VGGNetwork:
def append_vgg_network(self, x_in, true_X_input):
return x #x is output of VGG
def load_vgg_weight(self, model):
return model
class DiscriminatorNetwork:
def append_gan_network(self, true_X_input):
return x
class GenerativeNetwork:
def create_sr_model(self, ip):
return x
def get_generator_output(self, input_img, srgan_model):
return self.output_func([input_img])
class SRGANNetwork:
def build_srgan_pretrain_model(self):
return self.srgan_model_
def build_discriminator_pretrain_model(self):
return self.discriminative_model_
def build_srgan_model(self):
return self.srgan_model_
def pre_train_srgan(self, image_dir, nb_images=50000, nb_epochs=1, use_small_srgan=False):
for i in range(nb_epochs):
for x in datagen.flow_from_directory
if iteration % 50 == 0 and iteration != 0
validation//print psnr
Train only generator + vgg network
if iteration % 1000 == 0 and iteration != 0
Saving model weights
def pre_train_discriminator(self, image_dir, nb_images=50000, nb_epochs=1, batch_size=128):
for i in range(nb_epochs):
for x in datagen.flow_from_directory
Train only discriminator
if iteration % 1000 == 0 and iteration != 0
Saving model weights
def train_full_model(self, image_dir, nb_images=50000, nb_epochs=10):
for i in range(nb_epochs):
for x in datagen.flow_from_directory
if iteration % 50 == 0 and iteration != 0
validation//print psnr
if iteration % 1000 == 0 and iteration != 0
Saving model weights
Train only discriminator, disable training of srgan
Train only generator, disable training of discriminator
if __name__ == "__main__":
from keras.utils.visualize_util import plot # Path to MS COCO dataset
coco_path = r"D:\Yue\Documents\Dataset\coco2014\train2014" '''
Base Network manager for the SRGAN model Width / Height = 32 to reduce the memory requirement for the discriminator. Batch size = 1 is slower, but uses the least amount of gpu memory, and also acts as
Instance Normalization (batch norm with 1 input image) which speeds up training slightly.
''' srgan_network = SRGANNetwork(img_width=32, img_height=32, batch_size=1)
srgan_network.build_srgan_model()
#plot(srgan_network.srgan_model_, 'SRGAN.png', show_shapes=True) # Pretrain the SRGAN network
#srgan_network.pre_train_srgan(coco_path, nb_images=80000, nb_epochs=1) # Pretrain the discriminator network
#srgan_network.pre_train_discriminator(coco_path, nb_images=40000, nb_epochs=1, batch_size=16) # Fully train the SRGAN with VGG loss and Discriminator loss
srgan_network.train_full_model(coco_path, nb_images=80000, nb_epochs=5)
大数据开发之keras代码框架应用的更多相关文章
- .NET Web开发之.NET MVC框架
摘要:MVC是一种架构设计模式,该模式主要应用于图形化用户界面(GUI)应用程序.那么什么是MVC?MVC由三部分组成:Model(模型).View(视图)及Controller(控制器). MVC概 ...
- Android开发之Drag&Drop框架实现拖放手势
Android3.0提供了drag/drop框架,利用此框架可以实现使用拖放手势将一个view拖放到当前布局中的另外一个view中.本文将介绍如何使用拖放框架. 一.实现拖放的步骤 首先,我们先了解一 ...
- 基于Python的大数据的分页模型代码
最近在写一个cmdb系统的分页,尽管Django本身有分页的模块儿,但是还是想实现一下自己心中想的分页的一种逻辑 因为,在我们工作当中,当我们的数据量超级大的时候,其实我们每次分页查询都不必将所有的数 ...
- iOS开发之HelloKit代码片段
完整代码托管:https://github.com/1042710553/HelloKit.git /************************/plist/****************** ...
- 大数据“重磅炸弹”——实时计算框架 Flink
Flink 学习 项目地址:https://github.com/zhisheng17/flink-learning/ 博客:http://www.54tianzhisheng.cn/tags/Fli ...
- Android开发之Volley网络通信框架
今天用了一下Volley网络通信框架,感觉挺好用的,写个博客记录一下用法.方便以后VC. Volley(Google提供的网络通信库,能使网络通信更快,更简单,更健壮.) 功能模块: 1. JSON, ...
- j2ee开发之Spring2.5框架学习笔记
Spring 2.5框架学习笔记 1.是一个开源的控制反转IOC和面向切面AOP的容器框架 2.IOC控制反转 public class PersonServiceBean { private Per ...
- 移动平台前端开发之WebApp代码技巧
1.首先我们来看看webkit内核中的一些私有的meta标签,这些meta标签在开发webapp时起到非常重要的作用 <meta content="width=device-width ...
- 大数据学习——hadoop的RPC框架
项目结构 服务端代码 test-hadoop-rpc pom.xml <?xml version="1.0" encoding="UTF-8"?> ...
随机推荐
- Vue父子组件相互传值及调用方法的方案
Vue父子组件相互传值及调用方法的方案 一.调用方法: 1.父组件调用子组件方法: 2.子组件调用父组件方法: 参考:https://www.cnblogs.com/jin-zhe/p/9523782 ...
- 【miscellaneous】【C/C++语言】UTF8与GBK字符编码之间的相互转换
UTF8与GBK字符编码之间的相互转换 C++ UTF8编码转换 CChineseCode 一 预备知识 1,字符:字符是抽象的最小文本单位.它没有固定的形状(可能是一个字形),而且没有值." ...
- 001 SringBoot基础知识及SpringBoot整合Mybatis
1.原有Spring优缺点分析 (1)优点 Spring是Java企业版(Java Enterprise Edition,JEE,也称J2EE)的轻量级代替品.无需开发重量级的Enterprise J ...
- C++工程师养成 每日一题(string使用)
题目: 题目来源牛客网:https://www.nowcoder.com/practice/f0db4c36573d459cae44ac90b90c6212?tpId 输入两个字符串,从第一字符串中删 ...
- status 和 typedef
- day08——文件操作
day08 文件操作: open() :打开 f (文件句柄)= open("文件的路径(文件放的位置)",mode="操作文件的模式",encoding=&q ...
- 2019-7-18 collections,time,random,os,sys,序列化模块(json和pickle)应用
一.collections模块 1.具名元组:namedtuple(生成可以使用名字来访问元素的tuple) 表示坐标点x为1 y为2的坐标 注意:第二个参数可以传可迭代对象,也可以传字符串,但是字 ...
- nodejs的交互式解释器模式常用命令
node - 进入交互器交互器解释模式 ctrl + c - 退出当前终端 ctrl + c 按下两次 - 退出 Node REPL ctrl + d - 退出 Node REPL 向上/向下 键 - ...
- js获取对象的属性个数
for (var i = 0; i < dt.length; i++) { if (Object.keys(dt[i]).length <= 1) { dt.splice(i, 1); i ...
- 2.NET Core设定数据库种子
1.使用以下代码在 Models 文件夹中创建一个名为 SeedData 的新类: using Microsoft.EntityFrameworkCore;using Microsoft.Extens ...