• 大小: 319KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-13
  • 语言: 其他
  • 标签: Alexnet  

资源简介

TensorFlow实现训练Alexnet网络,训练mnist数据集合cfar数据集。mnist数据集测试准确度0.986.不需要下载权重,因为输出大小不一样。

资源截图

代码片段和文件信息


import tensorflow as tf
import numpy as np
import os

os.environ[‘TF_CPP_MIN_LOG_LEVEL‘] = ‘2‘  


class AlexNet(object):
    “““Implementation of the AlexNet.“““

    def __init__(self x keep_prob num_classes):
        “““Create the graph of the AlexNet model.

        Args:
            x: Placeholder for the input tensor.
            keep_prob: Dropout probability.
            num_classes: Number of classes in the dataset.
            skip_layer: List of names of the layer that get trained from
                scratch
            weights_path: Complete path to the pretrained weight file if it
                isn‘t in the same folder as this code
        “““
        # Parse input arguments into class variables
        self.X = x
        self.NUM_CLASSES = num_classes
        self.KEEP_PROB = keep_prob
        # self.SKIP_layer = skip_layer
       # self.WEIGHTS_PATH = weights_path

        # Call the create function to build the computational graph of AlexNet
        self.create()

    def create(self):
        “““Create the network graph.“““
        # 1st layer: Conv (w ReLu) -> Lrn -> Pool
        conv1 = conv(self.X [11396] [1111] padding=‘VALID‘ name=‘conv1‘)
        norm1 = lrn(conv1 2 1e-05 0.75 name=‘norm1‘)
        pool1 = max_pool(norm1 1 1 1 1 padding=‘VALID‘ name=‘pool1‘)

        # 2nd layer: Conv (w ReLu)  -> Lrn -> Pool with 2 groups
        conv2 = conv(pool1 [3 396256] [1 111] padding=‘VALID‘name=‘conv2‘)
        norm2 = lrn(conv2 2 1e-05 0.75 name=‘norm2‘)
        pool2 = max_pool(norm2 2 2 2 2 padding=‘VALID‘ name=‘pool2‘)

        # 3rd layer: Conv (w ReLu)
        conv3 = conv(pool2 [3 3256 384] [1111] name=‘conv3‘)

        # 4th layer: Conv (w ReLu) splitted into two groups
        conv4 = conv(conv3 [3 3 384 384] [1 1 1 1]  name=‘conv4‘)

        # 5th layer: Conv (w ReLu) -> Pool splitted into two groups
        conv5 = conv(conv4 [3 3384 256] [1 111] name=‘conv5‘)
        pool5 = max_pool(conv5 3 3 2 2 padding=‘VALID‘ name=‘pool5‘)

        # 6th layer: Flatten -> FC (w ReLu) -> Dropout
        flattened = tf.reshape(pool5 [-1 6 * 6 * 256])
        fc6 = fc(flattened 6 * 6 * 256 4096 name=‘fc6‘)
        dropout6 = dropout(fc6 self.KEEP_PROB)

        # 7th layer: FC (w ReLu) -> Dropout
        fc7 = fc(dropout6 4096 4096 name=‘fc7‘)
        dropout7 = dropout(fc7 self.KEEP_PROB)

        # 8th layer: FC and return unscaled activations
        self.fc8 = fc(dropout7 4096 self.NUM_CLASSES relu = Falsename=‘fc8‘)


def conv(input_tensorfilterstridesnamepadding = “SAME“):
    with tf.variable_scope(name):
        weights = tf.get_variable(‘weights‘filterinitializer=tf.truncated_normal_initializer(stddev=0.1))
        biases = tf.get_variable(‘biases‘filter[3]initializer=tf.constant_initializer(0.0))
        conv1 = tf.nn.conv2d(input_tensorweightsstride

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

     文件       4615  2018-04-29 16:44  Alexnet\Alexnet.py

     文件        104  2018-04-24 21:23  Alexnet\classes.py

     文件       9075  2018-03-16 09:29  Alexnet\eval.py

     文件       6838  2018-04-27 10:52  Alexnet\small_test.py

     文件     130839  2018-04-24 22:27  Alexnet\tensorboard\events.out.tfevents.1524580059.OS-201709090818

     文件     130839  2018-04-24 22:37  Alexnet\tensorboard\events.out.tfevents.1524580658.OS-201709090818

     文件     130839  2018-04-24 22:40  Alexnet\tensorboard\events.out.tfevents.1524580850.OS-201709090818

     文件     130839  2018-04-24 22:41  Alexnet\tensorboard\events.out.tfevents.1524580871.OS-201709090818

     文件     130839  2018-04-24 22:46  Alexnet\tensorboard\events.out.tfevents.1524581172.OS-201709090818

     文件     130839  2018-04-24 22:47  Alexnet\tensorboard\events.out.tfevents.1524581219.OS-201709090818

     文件     130839  2018-04-24 22:51  Alexnet\tensorboard\events.out.tfevents.1524581483.OS-201709090818

     文件     130839  2018-04-24 22:52  Alexnet\tensorboard\events.out.tfevents.1524581526.OS-201709090818

     文件     130839  2018-04-26 11:12  Alexnet\tensorboard\events.out.tfevents.1524712338.OS-201709090818

     文件     130839  2018-04-26 11:19  Alexnet\tensorboard\events.out.tfevents.1524712745.OS-201709090818

     文件     130839  2018-04-26 11:19  Alexnet\tensorboard\events.out.tfevents.1524712778.OS-201709090818

     文件     130839  2018-04-26 11:28  Alexnet\tensorboard\events.out.tfevents.1524713316.OS-201709090818

     文件     130839  2018-04-26 11:29  Alexnet\tensorboard\events.out.tfevents.1524713344.OS-201709090818

     文件     130839  2018-04-26 11:31  Alexnet\tensorboard\events.out.tfevents.1524713501.OS-201709090818

     文件     130839  2018-04-26 11:33  Alexnet\tensorboard\events.out.tfevents.1524713583.OS-201709090818

     文件     130839  2018-04-26 11:36  Alexnet\tensorboard\events.out.tfevents.1524713761.OS-201709090818

     文件     130839  2018-04-26 11:36  Alexnet\tensorboard\events.out.tfevents.1524713778.OS-201709090818

     文件     130839  2018-04-26 11:43  Alexnet\tensorboard\events.out.tfevents.1524714234.OS-201709090818

     文件     130839  2018-04-26 11:45  Alexnet\tensorboard\events.out.tfevents.1524714319.OS-201709090818

     文件     130839  2018-04-26 11:49  Alexnet\tensorboard\events.out.tfevents.1524714549.OS-201709090818

     文件     130839  2018-04-26 11:49  Alexnet\tensorboard\events.out.tfevents.1524714594.OS-201709090818

     文件     130839  2018-04-26 11:51  Alexnet\tensorboard\events.out.tfevents.1524714670.OS-201709090818

     文件     130839  2018-04-26 11:53  Alexnet\tensorboard\events.out.tfevents.1524714818.OS-201709090818

     文件     130839  2018-04-26 11:55  Alexnet\tensorboard\events.out.tfevents.1524714922.OS-201709090818

     文件     130839  2018-04-26 11:56  Alexnet\tensorboard\events.out.tfevents.1524714965.OS-201709090818

     文件     130839  2018-04-26 11:56  Alexnet\tensorboard\events.out.tfevents.1524715016.OS-201709090818

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

评论

共有 条评论