资源简介

使用DBN模型进行故障诊断,故障类型为4类,每类训练集为400个,测试20个。

资源截图

代码片段和文件信息

# -*- coding: utf-8 -*-
import tensorflow as tf
import numpy as np
import os
import matplotlib.pyplot as plt

class Batch(object):
    def __init__(self
                 images=None
                 labels=None
                 batch_size=None
                 shuffle=True):
        self.images = images
        if labels is None:
            self.exit_y = False
        else:
            self.exit_y = True
            self.labels = labels
        self.batch_size = batch_size
        self.shuffle = shuffle
        
        self._images = images
        self._labels = labels
        self._num_examples = images.shape[0]
        self._epochs_completed = 0
        self._index_in_epoch = 0
        
    def next_batch(self):
        “““Return the next ‘batch_size‘ examples from this data set.“““
        start = self._index_in_epoch
        # Shuffle for the first epoch
        if self._epochs_completed == 0 and start == 0 and self.shuffle:
            perm0 = np.arange(self._num_examples)
            np.random.shuffle(perm0)
            self._images = self.images[perm0]
            if self.exit_y: self._labels = self.labels[perm0]
        # Go to the next epoch
        if start + self.batch_size > self._num_examples:
            # Finished epoch
            self._epochs_completed += 1
            # Get the rest examples in this epoch
            rest_num_examples = self._num_examples - start
            images_rest_part = self._images[start:self._num_examples]
            if self.exit_y: labels_rest_part = self._labels[start:self._num_examples]
            # Shuffle the data
            if self.shuffle:
                perm = np.arange(self._num_examples)
                np.random.shuffle(perm)
                self._images = self.images[perm]
                if self.exit_y: self._labels = self.labels[perm]
            # Start next epoch
            start = 0
            self._index_in_epoch = self.batch_size - rest_num_examples
            end = self._index_in_epoch
            images_new_part = self._images[start:end]
            if self.exit_y:
                labels_new_part = self._labels[start:end]
                return np.concatenate((images_rest_part images_new_part) axis=0)  np.concatenate((labels_rest_part labels_new_part) axis=0)
            else:
                return np.concatenate((images_rest_part images_new_part) axis=0)
        else:
            self._index_in_epoch += self.batch_size
            end = self._index_in_epoch
            if self.exit_y:
                return self._images[start:end] self._labels[start:end]
            else:
                return self._images[start:end]

def act_func(func_name):
    if func_name==‘sigmoid‘:   # S(z) = 1/(1+exp(-z)) ∈ (01)
        return tf.nn.sigmoid
    elif func_name==‘softmax‘: # s(z) = S(z)/∑S(z) ∈ (01)
        return tf.nn.softmax
    elif func_name==‘relu‘:    # r(z) = max(0z) ∈ (0+inf)
        return tf.nn.relu
    elif func_name==‘tanh‘:    # r(z) = max(0z) ∈ (0+i

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-10-06 10:45  DBN\
     文件     1972722  2018-09-26 18:24  DBN\DBN代码说明(05.23版).pptx
     目录           0  2018-10-05 17:58  DBN\Tensorflow-Deep-Neural-Networks-master\
     文件        1616  2018-07-14 10:23  DBN\Tensorflow-Deep-Neural-Networks-master\README.md
     目录           0  2018-10-02 08:15  DBN\Tensorflow-Deep-Neural-Networks-master\base\
     文件         329  2018-07-14 10:23  DBN\Tensorflow-Deep-Neural-Networks-master\base\Version Information.txt
     目录           0  2018-10-02 08:21  DBN\Tensorflow-Deep-Neural-Networks-master\base\__pycache__\
     文件        9394  2018-10-02 08:21  DBN\Tensorflow-Deep-Neural-Networks-master\base\__pycache__\base_func.cpython-35.pyc
     文件        8492  2018-09-29 11:08  DBN\Tensorflow-Deep-Neural-Networks-master\base\__pycache__\base_func.cpython-36.pyc
     文件       10706  2018-09-29 11:08  DBN\Tensorflow-Deep-Neural-Networks-master\base\base_func.py
     目录           0  2018-10-02 08:15  DBN\Tensorflow-Deep-Neural-Networks-master\dataset\
     目录           0  2018-10-02 08:32  DBN\Tensorflow-Deep-Neural-Networks-master\dataset\MNIST_data\
     文件     1648877  2018-07-14 10:23  DBN\Tensorflow-Deep-Neural-Networks-master\dataset\MNIST_data\t10k-images-idx3-ubyte.gz
     文件        4542  2018-07-14 10:23  DBN\Tensorflow-Deep-Neural-Networks-master\dataset\MNIST_data\t10k-labels-idx1-ubyte.gz
     文件      564987  2018-09-30 09:45  DBN\Tensorflow-Deep-Neural-Networks-master\dataset\MNIST_data\test_data.mat
     文件         199  2018-10-01 16:27  DBN\Tensorflow-Deep-Neural-Networks-master\dataset\MNIST_data\test_label.mat
     文件     9912422  2018-07-14 10:23  DBN\Tensorflow-Deep-Neural-Networks-master\dataset\MNIST_data\train-images-idx3-ubyte.gz
     文件       28881  2018-07-14 10:23  DBN\Tensorflow-Deep-Neural-Networks-master\dataset\MNIST_data\train-labels-idx1-ubyte.gz
     文件     2821026  2018-09-30 09:44  DBN\Tensorflow-Deep-Neural-Networks-master\dataset\MNIST_data\train_data.mat
     文件         213  2018-10-01 15:58  DBN\Tensorflow-Deep-Neural-Networks-master\dataset\MNIST_data\train_label.mat
     目录           0  2018-10-02 08:15  DBN\Tensorflow-Deep-Neural-Networks-master\models\
     目录           0  2018-10-02 08:21  DBN\Tensorflow-Deep-Neural-Networks-master\models\__pycache__\
     文件        4217  2018-10-02 08:21  DBN\Tensorflow-Deep-Neural-Networks-master\models\__pycache__\cnn.cpython-35.pyc
     文件        3735  2018-09-19 09:46  DBN\Tensorflow-Deep-Neural-Networks-master\models\__pycache__\cnn.cpython-36.pyc
     文件        3684  2018-10-02 08:21  DBN\Tensorflow-Deep-Neural-Networks-master\models\__pycache__\dbn.cpython-35.pyc
     文件        3238  2018-09-29 11:05  DBN\Tensorflow-Deep-Neural-Networks-master\models\__pycache__\dbn.cpython-36.pyc
     文件        9539  2018-10-02 08:21  DBN\Tensorflow-Deep-Neural-Networks-master\models\__pycache__\model.cpython-35.pyc
     文件        8510  2018-09-19 09:44  DBN\Tensorflow-Deep-Neural-Networks-master\models\__pycache__\model.cpython-36.pyc
     文件        3661  2018-10-02 08:21  DBN\Tensorflow-Deep-Neural-Networks-master\models\__pycache__\rbm.cpython-35.pyc
     文件        3320  2018-09-19 09:44  DBN\Tensorflow-Deep-Neural-Networks-master\models\__pycache__\rbm.cpython-36.pyc
     文件        1632  2018-10-02 08:21  DBN\Tensorflow-Deep-Neural-Networks-master\models\__pycache__\rbms.cpython-35.pyc
............此处省略39个文件信息

评论

共有 条评论