资源简介
为大家贡献个复数版的Caffe,个人肥了很大劲才下载到的。里面有复数卷积层,复数全连接层,复数池化层,复数sigmoid层,复数幅度层,复数反卷积层。亲测可用。
代码片段和文件信息
//
// This script converts the CIFAR dataset to the leveldb format used
// by caffe to perform classification.
// Usage:
// convert_cifar_data input_folder output_db_file
// The CIFAR dataset could be downloaded at
// http://www.cs.toronto.edu/~kriz/cifar.html
#include // NOLINT(readability/streams)
#include
#include “boost/scoped_ptr.hpp“
#include “glog/logging.h“
#include “google/protobuf/text_format.h“
#include “stdint.h“
#include “caffe/proto/caffe.pb.h“
#include “caffe/util/db.hpp“
#include “caffe/util/format.hpp“
using caffe::Datum;
using boost::scoped_ptr;
using std::string;
namespace db = caffe::db;
const int kCIFARSize = 32;
const int kCIFARImageNBytes = 3072;
const int kCIFARBatchSize = 10000;
const int kCIFARTrainBatches = 5;
void read_image(std::ifstream* file int* label char* buffer) {
char label_char;
file->read(&label_char 1);
*label = label_char;
file->read(buffer kCIFARImageNBytes);
return;
}
void convert_dataset(const string& input_folder const string& output_folder
const string& db_type) {
scoped_ptr train_db(db::GetDB(db_type));
train_db->Open(output_folder + “/cifar10_train_“ + db_type db::NEW);
scoped_ptr txn(train_db->NewTransaction());
// Data buffer
int label;
char str_buffer[kCIFARImageNBytes];
Datum datum;
datum.set_channels(3);
datum.set_height(kCIFARSize);
datum.set_width(kCIFARSize);
LOG(INFO) << “Writing Training data“;
for (int fileid = 0; fileid < kCIFARTrainBatches; ++fileid) {
// Open files
LOG(INFO) << “Training Batch “ << fileid + 1;
string batchFileName = input_folder + “/data_batch_“
+ caffe::format_int(fileid+1) + “.bin“;
std::ifstream data_file(batchFileName.c_str()
std::ios::in | std::ios::binary);
CHECK(data_file) << “Unable to open train file #“ << fileid + 1;
for (int itemid = 0; itemid < kCIFARBatchSize; ++itemid) {
read_image(&data_file &label str_buffer);
datum.set_label(label);
datum.set_data(str_buffer kCIFARImageNBytes);
string out;
CHECK(datum.SerializeToString(&out));
txn->Put(caffe::format_int(fileid * kCIFARBatchSize + itemid 5) out);
}
}
txn->Commit();
train_db->Close();
LOG(INFO) << “Writing Testing data“;
scoped_ptr test_db(db::GetDB(db_type));
test_db->Open(output_folder + “/cifar10_test_“ + db_type db::NEW);
txn.reset(test_db->NewTransaction());
// Open files
std::ifstream data_file((input_folder + “/test_batch.bin“).c_str()
std::ios::in | std::ios::binary);
CHECK(data_file) << “Unable to open test file.“;
for (int itemid = 0; itemid < kCIFARBatchSize; ++itemid) {
read_image(&data_file &label str_buffer);
datum.set_label(label);
datum.set_data(str_buffer kCIFARImageNBytes);
string out;
CHECK(datum.SerializeToString(&out));
txn->Put(caffe::format_int(itemid 5) out);
}
txn->Commit();
test_db->Close();
}
int main(int argc char** ar
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 101863 2017-08-06 14:51 caffe-complex\.Doxyfile
文件 936 2017-08-06 14:51 caffe-complex\.github\ISSUE_TEMPLATE.md
文件 1207 2017-08-06 14:51 caffe-complex\.gitignore
文件 1938 2017-08-06 14:51 caffe-complex\.travis.yml
文件 1180 2017-08-06 14:51 caffe-complex\caffe.cloc
文件 2169 2017-08-06 14:51 caffe-complex\cmake\ConfigGen.cmake
文件 11469 2017-08-06 14:51 caffe-complex\cmake\Cuda.cmake
文件 7141 2017-08-06 14:51 caffe-complex\cmake\Dependencies.cmake
文件 1939 2017-08-06 14:51 caffe-complex\cmake\External\gflags.cmake
文件 1777 2017-08-06 14:51 caffe-complex\cmake\External\glog.cmake
文件 1505 2017-08-06 14:51 caffe-complex\cmake\lint.cmake
文件 1764 2017-08-06 14:51 caffe-complex\cmake\Misc.cmake
文件 1724 2017-08-06 14:51 caffe-complex\cmake\Modules\FindAtlas.cmake
文件 1545 2017-08-06 14:51 caffe-complex\cmake\Modules\FindGFlags.cmake
文件 1451 2017-08-06 14:51 caffe-complex\cmake\Modules\FindGlog.cmake
文件 6723 2017-08-06 14:51 caffe-complex\cmake\Modules\FindLAPACK.cmake
文件 1728 2017-08-06 14:51 caffe-complex\cmake\Modules\FindLevelDB.cmake
文件 1119 2017-08-06 14:51 caffe-complex\cmake\Modules\FindLMDB.cmake
文件 1749 2017-08-06 14:51 caffe-complex\cmake\Modules\FindMatlabMex.cmake
文件 3360 2017-08-06 14:51 caffe-complex\cmake\Modules\FindMKL.cmake
文件 654 2017-08-06 14:51 caffe-complex\cmake\Modules\FindNCCL.cmake
文件 2333 2017-08-06 14:51 caffe-complex\cmake\Modules\FindNumPy.cmake
文件 1593 2017-08-06 14:51 caffe-complex\cmake\Modules\FindOpenBLAS.cmake
文件 1071 2017-08-06 14:51 caffe-complex\cmake\Modules\FindSnappy.cmake
文件 1398 2017-08-06 14:51 caffe-complex\cmake\Modules\FindvecLib.cmake
文件 3744 2017-08-06 14:51 caffe-complex\cmake\ProtoBuf.cmake
文件 7651 2017-08-06 14:51 caffe-complex\cmake\Summary.cmake
文件 7191 2017-08-06 14:51 caffe-complex\cmake\Targets.cmake
文件 1769 2017-08-06 14:51 caffe-complex\cmake\Templates\CaffeConfig.cmake.in
文件 377 2017-08-06 14:51 caffe-complex\cmake\Templates\CaffeConfigVersion.cmake.in
............此处省略788个文件信息
- 上一篇:雷达成像国际会议PPT
- 下一篇:Thinkpad X220 BIOS白名单
评论
共有 条评论