《Efficient Deep Learning Book》[EDL] Chapter 3 - Learning Techniquesworkflow of such a device. The model continuously classifies audio signals into one of the four classes, three of which are the keywords that the device will accept: hello, weather and time. The fourth of a dog (30%) and a hamster (70%). The label assigned to this image is a composite of the two classes in the same proportion. Thus, the model would be expected to predict a ‘dog’ with a probability of tensorflow.keras import layers, optimizers, metrics DROPOUT_RATE = 0.2 LEARNING_RATE = 0.0002 NUM_CLASSES = 102 def create_model(): # Initialize the core model core_args = dict(input_shape=(IMG_SIZE,0 码力 | 56 页 | 18.93 MB | 1 年前3
Keras: 基于 Python 的深度学习库只需一行代码就能评估模型性能: loss_and_metrics = model.evaluate(x_test, y_test, batch_size=128) 或者对新的数据生成预测: classes = model.predict(x_test, batch_size=128) 构建一个问答系统,一个图像分类模型,一个神经图灵机,或者其他的任何模型,就是这么 的快。深度学习背后的思想很 size=(1000, 1)) # 将标签转换为分类的 one-hot 编码 one_hot_labels = keras.utils.to_categorical(labels, num_classes=10) # 训练模型,以 32 个样本为一个 batch 进行迭代 model.fit(data, one_hot_labels, epochs=10, batch_size=32) 3 randint(10, size=(1000, 1)), num_classes=10) x_test = np.random.random((100, 20)) y_test = keras.utils.to_categorical(np.random.randint(10, size=(100, 1)), num_classes=10) model = Sequential() # Dense(64)0 码力 | 257 页 | 1.19 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 4 - Efficient ArchitecturesThis is a binary classification problem in which our model classifies an input into one of the two classes: ‘Suitable’ and ‘Not Suitable’. Since in this scenario we have only a few examples it is easy to is possible to linearly separate3 the data points belonging to the two classes using a line. The line separating the two classes is called a decision boundary, and this is only one possible decision boundary decision boundary to separate the two classes of animals (suitable and not suitable for the petting zoo). In this case, we could manually separate the two classes (Suitable / Not Suitable), since there0 码力 | 53 页 | 3.92 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 6 - Advanced Learning Techniques - Technical Reviewour task. def get_bert_model( encoder_size, learning_rate=2e-5, keep_tfhub_weights=True, num_classes=4): """Create a BERT classifier.""" with tpu_strategy.scope(): # Prepare the inputs. bert_inputs output = tf.keras.layers.Dense(50, activation='relu')(output) output = tf.keras.layers.Dense(num_classes, activation=None)(output) output = tf.keras.layers.Activation('softmax')(output) bert_classifier over-confidently. Consider the case where we have a model and solving a multi-class classification problem with classes. The ground-truth labels will either be the index of the correct class for that given example, or0 码力 | 31 页 | 4.03 MB | 1 年前3
keras tutorialadd(Dropout(0.2)) model.add(Dense(512, activation='relu')) model.add(Dropout(0.2)) model.add(Dense(num_classes, activation='softmax')) Where, Keras 19 Line 1 imports Sequential model chapter. Keras 20 As we learned earlier, Keras modules contains pre-defined classes, functions and variables which are useful for deep learning algorithm. Let us learn the modules (include_top=True, weights='imagenet', input_tensor=None, input_shape=None, pooling=None, classes=1000) Here, include_top refers the fully-connected layer at the top of the network. weights0 码力 | 98 页 | 1.57 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 7 - Automationcreating a random classification dataset with 20 samples, each one assigned to one of the five target classes. import random import tensorflow as tf import numpy as np from tensorflow.keras import layers, losses chosen values for the learning_rate and dropout_rate. DROPOUT_RATE = 0.2 LEARNING_RATE = 0.0002 NUM_CLASSES = 102 def build_hp_model(hp): if hp: learning_rate = hp.Float( "learning_rate", min_value=1e-4 resnet.preprocess_input(x)), core, layers.Flatten(), layers.Dropout(dropout_rate), layers.Dense(NUM_CLASSES, activation='softmax') ]) adam = optimizers.Adam(learning_rate=learning_rate) model.compile(0 码力 | 33 页 | 2.48 MB | 1 年前3
动手学深度学习 v2.02016)中的ResNet‐18。因为输入的图像很小,所以稍微修改了一下。与 7.6节的区别在于,我们在开始时 使用了更小的卷积核、步长和填充,而且删除了最大汇聚层。 #@save def resnet18(num_classes, in_channels=1): """稍加修改的ResNet-18模型""" def resnet_block(in_channels, out_channels, num_residuals AdaptiveAvgPool2d((1,1))) net.add_module("fc", nn.Sequential(nn.Flatten(), nn.Linear(512, num_classes))) return net 12.6.2 网络初始化 我们将在训练回路中初始化网络。请参见 4.8节复习初始化方法。 net = resnet18(10) # 获取GPU列表 devices """使用非极大值抑制来预测边界框""" device, batch_size = cls_probs.device, cls_probs.shape[0] anchors = anchors.squeeze(0) num_classes, num_anchors = cls_probs.shape[1], cls_probs.shape[2] out = [] for i in range(batch_size): (continues0 码力 | 797 页 | 29.45 MB | 1 年前3
Lecture 3: Logistic Regression.. What’s the underlying decision rule in logistic regression? At the decision boundary, both classes are equiprobable; thus, we have Pr(Y = 1 | X = x; θ) = Pr(Y = 0 | X = x; θ) ⇒ 1 1 + exp(−θTx) multinomial) classification is the problem of classifying instances into one of the more than two classes The existing multiclass classification techniques can be categorized into Transformation to binary0 码力 | 29 页 | 660.51 KB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 1 - Introductionaspect. It has more than 1 million labeled images, where each image belongs to 1 out of 1000 possible classes. This helped with creating a testbed for researchers to experiment with. Along with techniques like a ‘0’ to the incorrect class, the soft labels consist of probabilities for each of the possible classes according to the teacher model. Figure 1-10: Distillation of a smaller student model from a larger0 码力 | 21 页 | 3.17 MB | 1 年前3
《Efficient Deep Learning Book》[EDL] Chapter 2 - Compression Techniquesfollows right after. The final layer is a dense (fully-connected) layer of size 10 because we have 10 classes to identify. Note that the first dimension is None, since it refers to the batch dimension which SparseCategoricalCrossEntropy loss function as it is best suited to classify multi-class (In this case, classes are 0, 1, 2 and so on until 9) inputs. We use the sparse variant of the categorical cross entropy0 码力 | 33 页 | 1.96 MB | 1 年前3
共 16 条
- 1
- 2













