python
python
PoemK
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
PyTorch 模型参数和optimizer
网络参数 ( parameters()和named_parameters())model为网络,打印层结构:ret=[*model.modules()]for layer in ret: #print(type(layer)) print(layer.__class__)大概会输出这样的一个效果:<class ‘main.ResNet’>...原创 2019-04-11 15:49:08 · 4969 阅读 · 0 评论 -
Tensorflow 教程笔记---Custom layers
import tensorflow as tftf.enable_eager_execution()Layers: common sets of useful operations# In the tf.keras.layers package, layers are objects. To construct a layer,# simply construct the object...原创 2019-02-09 21:42:06 · 2281 阅读 · 0 评论 -
Tensorflow官方教程笔记--Eager execution basics
import tensorflow as tfprint(tf.add(1, 2))print(tf.add([1, 2], [3, 4]))print(tf.square(5))print(tf.reduce_sum([1, 2, 3]))print(tf.encode_base64("hello world"))print(tf.square(2) + tf.square(3))...原创 2019-02-07 21:05:21 · 2329 阅读 · 0 评论 -
Tensorflow reduce_sum()
tf.reduce_sum(arg1,arg2)对arg1进行求和,消去维度arg2。arg1:待处理数据arg2:如果为空,那么对数据中所有元素求和;否则,代表消去的维度。print(tf.reduce_sum( [[1, 2, 3],[1, 2, 3]] ) )print(tf.reduce_sum( [[1, 2, 3],[1, 2, 3]],0 ) ) #消去第0维,即对...原创 2019-02-07 20:04:56 · 365 阅读 · 0 评论 -
python、PyTorch图像读取与numpy转换
Tensor转为numpynp.array(Tensor)numpy转换为Tensortorch.Tensor(numpy.darray)PIL.Image.Image转换成numpynp.array(PIL.Image.Image)numpy 转换成PIL.Image.ImageImage.fromarray(numpy.ndarray)首先需要保证n...原创 2018-06-15 16:27:18 · 19079 阅读 · 4 评论 -
python等号
a=[1,23,4,6,7]b=a[2]b=3a[1, 23, 4, 6, 7]解释:b指向了一个新的变量3,a不会改变def fun2(a): a=5fun2(a[0])a[1, 23, 4, 6, 7]解释:函数内的参数a指向了一个新的变量5,但是对于列表a中的元素,a[0]并没有发生变化。class Node: def __ini...原创 2018-06-15 16:28:32 · 6474 阅读 · 0 评论 -
PyTorch数据读取
torch.utils.data.DataLoadertorch.utils.data.DataLoader(torch.utils.data.dataset,batch_size,shuffle,num_workers,pin_memory)关键是这两个类: torch.utils.data.DataLoader torch.utils.data.datasetimport to...原创 2018-06-12 19:19:57 · 3141 阅读 · 0 评论 -
python 以及C++目录操作
C++目录操作 类别 头文件 代码 windows判断目录是否存在 #include&amp;amp;amp;lt;io.h&amp;amp;amp;gt; _access() windows创建目录 #include&amp;amp;amp;lt;direct.h&amp;amp;amp;gt; mkdir() linux判断目录是否存在 #include&am原创 2018-06-12 14:36:42 · 250 阅读 · 0 评论 -
python 接受命令行参数
定义一个参数解析类#option.pyimport argparseclass Option(): def __init__(self): self.parser = argparse.ArgumentParser(description='PyTorch Light CNN Training') self.parser.add_argument...原创 2018-06-12 16:53:48 · 2631 阅读 · 0 评论 -
python函数形参星号
形参前面加一个星号,传入的参数转换成元组def print_everything(*args): for count, thing in enumerate(args): print('{0}.{1}'.format(count,thing))print_everything('apple','banana','cabbage')#参数传入元组0.apple1...原创 2018-06-14 11:24:04 · 1852 阅读 · 0 评论