分类 人工智能笔记 下的文章

指数加权平均(polyak averaging):$\tau$是加权平均系数,它相当于一个超学习率,非常敏感,增大0.01就有可能会使训练发散。一般要保证$(1-\tau)^{n}$大约在10%左右,n是一个epoch的episodes数。总之要让Actor的Loss在100个epoch内爆炸到$(1-\gamma^T)/(1-\gamma)$的大小,其中$\gamma$是discount,...

展开阅读

最优化问题:$$ \begin{align*} &\max_a & & \sum_{i=1}^m a_i - \frac{1}{2} \sum_{i=1}^m\sum_{j=1}^m a_i a_j y_i y_j x_i^\top x_j \label{softsvmd}\tag{$\mathrm{SVM_{soft} dual}$}\\ &...

展开阅读

import tensorflow as tf import numpy as np import operator as op from functools import reduce class svm_model: def __init__(self,n_class, dimension, learning_rate=1e-2, regularization=1): ...

展开阅读

conda install tensorflow-gpu以上命令安装好tensorflow-gpu后,我遇到了这样的问题:CUDA driver version is insufficient for CUDA runtime version经过分析,我发现使用anaconda自动分析依赖安装的cudatoolkit的版本是CUDA 10.0 (10.0.130),而ubuntu装机自带的N...

展开阅读

使用Tensorflow进行计算机视觉研究时,常常会遇到磁盘读写瓶颈,具体表现为CPU和磁盘使用率极高,而GPU使用率很低。对于这种IO瓶颈,可以使用NVIDIA开源的DALI库进行数据读写加速,以下是安装和使用教程。安装(需要TensorFlow 版本1.7或更高,CUDA9.0或更高)CUDA9.0:pip install --extra-index-url https://develo...

展开阅读

以下是SVM代码:import torch import numpy as np from random import shuffle from sklearn.utils import shuffle as shuffle_ds def rbf(sigma=1): def rbf_kernel(x1,x2,sigma): X12norm = torch.sum(x1...

展开阅读

首先,为了方便划分不同的网络模块(子网络)、分别导入权重、指定是否需要训练、指定是否需要复用,需要使用如下语句为网络权重设定scope;使用collection将隐含层输出保存为字典;在with xxx:语句内部定义的网络层也要定义scopeimport tensorflow as tf import tensorflow.contrib.slim as slim # 需要Reuse时,设...

展开阅读

通用的Debug方案:使用Tensorflow/Keras中在不同的网络层之间传递的tensor对象的eval()方法进行调试,在一个Tensorflow Session中,使用tf.global_variables_initializer()以初始化之前定义的tensor对象。之后就可以对之前定义的全局变量进行更改,以对网络的输入进行自定义,并使用eval()方法观察层之间的输出值了。in...

展开阅读

import os import tensorflow as tf import numpy as np def mkdir(result_dir): if not os.path.isdir(result_dir): os.makedirs(result_dir) return def load_ckpt_initialize(checkpoint_d...

展开阅读

RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same在初始化后的model后添加代码model.cuda()即可RuntimeError: cuda runtime error (59) : device-side assert trig...

展开阅读