• 大小: 11MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-01
  • 语言: 其他
  • 标签: AI  

资源简介

深度学习(花书)代码和笔记:一份深度学习的笔记(英文),以及相关的代码

资源截图

代码片段和文件信息

# coding: UTF-8
‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘
    file name: main.py
    create time: 2017年09月01日 星期五 13时48分54秒
    author: Jipeng Huang
    e-mail: huangjipengnju@gmail.com
    github: https://github.com/hjptriplebee
‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘
# based on tensorflow/example/tutorials deepdream
import os
import argparse
import tensorflow as tf
import numpy as np
import cv2

# parameter
model_name = “tensorflow_inception_graph.pb“
imagenet_mean = 117.0
layer = ‘mixed4c‘
iter_num = 50
octave_num = 4
octave_scale = 1.4
learning_rate = 1.5
tile_size = 512
noise = np.random.uniform(size=(224 224 3)) + 100.0


def define_args():
    “““define args“““
    parser = argparse.ArgumentParser(description=“deep_dream“)
    parser.add_argument(“-i“ “--input“ help=“input path“ default=“none“)
    parser.add_argument(“-o“ “--output“ help=“output path“ default=“output/output.jpg“)
    return parser.parse_args()


def get_model():
    “““download model“““
    model = os.path.join(“model“ model_name)
    if not os.path.exists(model):
        print(“Down model...“)
        os.system(“wget https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip -P model“)
        os.system(“unzip model/inception5h.zip -d model“)
        os.system(“rm model/inception5h.zip“)
        os.system(“rm model/imagenet_comp_graph_label_strings.txt“)
    return model


def deep_dream(model output_path input_image=noise):
    “““implement of deep dream“““
    # define graph
    graph = tf.Graph()
    sess = tf.InteractiveSession(graph=graph)

    # load model
    with tf.gfile.FastGFile(model “rb“) as f:
        graph_def = tf.GraphDef()
        graph_def.ParseFromString(f.read())

    # define input
    X = tf.placeholder(tf.float32 name=“input“)
    X2 = tf.expand_dims(X - imagenet_mean 0)
    tf.import_graph_def(graph_def {“input“: X2})

    # L2 and gradient
    loss = tf.reduce_mean(tf.square(graph.get_tensor_by_name(“import/%s:0“ % layer)))
    gradient = tf.gradients(loss X)[0]

    image = input_image
    octaves = []

    # tranforming TF function
    def tffunc(*argtypes):
        placeholders = list(map(tf.placeholder argtypes))

        def wrap(f):
            out = f(*placeholders)

            def wrapper(*args **kw):
                return out.eval(dict(zip(placeholders args)) session=kw.get(‘session‘))

            return wrapper

        return wrap

    def resize(image size):
        “““resize image in nparray“““
        image = tf.expand_dims(image 0)
        return tf.image.resize_bilinear(image size)[0 : : :]

    resize = tffunc(np.float32 np.int32)(resize)

    for i in range(octave_num - 1):
        size = np.shape(image)[:2]
        narrow_size = np.int32(np.float32(size) / octave_scale)
        # down sampling and up sampling equal to smooth diff can save significance
        down = resize(image narrow_size)
        diff = image - resize(down size)
        image = do

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        306  2019-04-12 20:32  深度学习(花书)代码和笔记\simplified-deeplearning-master\.gitignore

     文件     149739  2019-04-12 20:34  深度学习(花书)代码和笔记\simplified-deeplearning-master\bak\function-approximation\figures\long.png

     文件      18630  2019-04-12 20:34  深度学习(花书)代码和笔记\simplified-deeplearning-master\bak\function-approximation\figures\model.png

     文件          0  2019-04-12 20:34  深度学习(花书)代码和笔记\simplified-deeplearning-master\bak\function-approximation\README.md

     文件       2395  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\bak\README.md

     文件       4601  2019-04-12 20:34  深度学习(花书)代码和笔记\simplified-deeplearning-master\pending\CNN_deepdream\DeepDream.py

     文件       2810  2019-04-12 20:34  深度学习(花书)代码和笔记\simplified-deeplearning-master\pending\CNN_deepdream\README.md

     文件        431  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\pending\README.md

     文件       8606  2019-04-12 20:32  深度学习(花书)代码和笔记\simplified-deeplearning-master\README.md

     文件      20424  2019-04-12 20:34  深度学习(花书)代码和笔记\simplified-deeplearning-master\卷积网络\img\network-structure.png

     文件      10413  2019-04-12 20:34  深度学习(花书)代码和笔记\simplified-deeplearning-master\卷积网络\img\share-weight.png

     文件      35705  2019-04-12 20:34  深度学习(花书)代码和笔记\simplified-deeplearning-master\卷积网络\img\sparse-representation.png

     文件       1587  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\卷积网络\README.md

     文件       6707  2019-04-12 20:34  深度学习(花书)代码和笔记\simplified-deeplearning-master\卷积网络\src\simple-mnist-CNN.ipynb

     文件       5519  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\卷积网络\简单卷积网络.md

     文件         23  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\实践调参\README.md

     文件        137  2019-04-12 20:32  深度学习(花书)代码和笔记\simplified-deeplearning-master\循环递归网络\CharRNN.md

     文件      44701  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\循环递归网络\img\sinx.png

     文件      51756  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\循环递归网络\img\sinxx.png

     文件        327  2019-04-12 20:32  深度学习(花书)代码和笔记\simplified-deeplearning-master\循环递归网络\LSTM.md

     文件        518  2019-04-12 20:32  深度学习(花书)代码和笔记\simplified-deeplearning-master\循环递归网络\RNN.md

     文件     189589  2019-04-12 20:32  深度学习(花书)代码和笔记\simplified-deeplearning-master\循环递归网络\rnn_func_approx.ipynb

     文件        565  2019-04-12 20:32  深度学习(花书)代码和笔记\simplified-deeplearning-master\循环递归网络\Sequence.md

     文件       8556  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\数学基础\img\gradient_descent_loss.png

     文件      14309  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\数学基础\img\graph_model.png

     文件      20007  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\数学基础\img\laplace_dist.png

     文件      13163  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\数学基础\img\local_min.png

     文件       9739  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\数学基础\img\logistic_curve.png

     文件      11770  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\数学基础\img\logistic_feature.png

     文件      17068  2019-04-12 20:33  深度学习(花书)代码和笔记\simplified-deeplearning-master\数学基础\img\max_min_saddle_point.png

............此处省略124个文件信息

评论

共有 条评论