gpt4 book ai didi

caffe - 如何使用 pycaffe 编写带有内存数据层的网络?

转载 作者:行者123 更新时间:2023-12-01 07:38:55 25 4
gpt4 key购买 nike

可以在pycaffe 中使用以下行的hdf5 数据层编写caffe prototxt:

import caffe
from caffe import layers as L

def logreg(hdf5, batch_size):
n = caffe.NetSpec()
n.data, n.label = L.HDF5Data(batch_size = batch_size, source = hdf5, ntop = 2)
n.ip1 = L.InnerProduct(n.data, num_output = 2, weight_filler = dict(type='xavier'))
n.accuracy = L.Accuracy(n.ip1, n.label)
n.loss = L.SoftmaxWithLoss(n.ip1, n.label)
return n.to_proto()

with open('models/logreg_auto_train.prototxt', 'w') as f:
f.write(str(logreg('data/train.txt', chunck_size)))

是否可以使用类似的方法编写具有内存数据层的原型(prototype)文本?

最佳答案

尝试这样的事情:

import caffe
from caffe import layers as L

def logreg(height, width, channels, batch_size):
n = caffe.NetSpec()
n.data = L.MemoryData(batch_size = batch_size, height = height, width = width, channels = channels)
n.ip1 = L.InnerProduct(n.data, num_output = 2, weight_filler = dict(type='xavier'))
return n.to_proto()

with open('models/logreg_memdata.prototxt', 'w') as f:
f.write(str(logreg(128,128,3, chunck_size)))

关于caffe - 如何使用 pycaffe 编写带有内存数据层的网络?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35376302/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com