{"action":"created","issue":{"url":"https://api.github.com/repos/BVLC/caffe/issues/1698","labels_url":"https://api.github.com/repos/BVLC/caffe/issues/1698/labels{/name}","comments_url":"https://api.github.com/repos/BVLC/caffe/issues/1698/comments","events_url":"https://api.github.com/repos/BVLC/caffe/issues/1698/events","html_url":"https://github.com/BVLC/caffe/issues/1698","id":53768814,"number":1698,"title":"Make a matrix output and ground truth example (segmentation, sliding window detection, etc.)","user":{"login":"shelhamer","id":311113,"avatar_url":"https://avatars.githubusercontent.com/u/311113?v=3","gravatar_id":"","url":"https://api.github.com/users/shelhamer","html_url":"https://github.com/shelhamer","followers_url":"https://api.github.com/users/shelhamer/followers","following_url":"https://api.github.com/users/shelhamer/following{/other_user}","gists_url":"https://api.github.com/users/shelhamer/gists{/gist_id}","starred_url":"https://api.github.com/users/shelhamer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shelhamer/subscriptions","organizations_url":"https://api.github.com/users/shelhamer/orgs","repos_url":"https://api.github.com/users/shelhamer/repos","events_url":"https://api.github.com/users/shelhamer/events{/privacy}","received_events_url":"https://api.github.com/users/shelhamer/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/BVLC/caffe/labels/documentation","name":"documentation","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-01-08T16:21:35Z","updated_at":"2015-11-29T08:33:32Z","closed_at":null,"body":"Caffe is perfectly happy with models that make matrix outputs and learn from matrix ground truths for problems where the output and truth have spatial dimensions e.g. reconstruction / de-noising, pixelwise semantic segmentation, sliding window detection, and so forth. The forward and backward passes for these models follow directly from the definitions and Caffe has always been capable of computing these.\r\n\r\nHowever, there isn't yet a bundled example and exactly how to accomplish this is confusing to many new users.\r\n\r\n#189 is already solved technically by on-the-fly reshaping #594, instance-wise losses like SOFTMAX_LOSS, EUCLIDEAN_LOSS, SIGMOID_CROSS_ENTROPY_LOSS and so on, and proper data preparation. At the same time, this isn't immediately obvious from the documentation and examples so a walkthrough would do a lot of good.\r\n\r\n#308 is technically redundant and does not mesh with the Caffe code but it was put to use in a standalone way and it's good that the code was made available to accompany the tech report."},"comment":{"url":"https://api.github.com/repos/BVLC/caffe/issues/comments/160391447","html_url":"https://github.com/BVLC/caffe/issues/1698#issuecomment-160391447","issue_url":"https://api.github.com/repos/BVLC/caffe/issues/1698","id":160391447,"user":{"login":"liyangliu","id":5159489,"avatar_url":"https://avatars.githubusercontent.com/u/5159489?v=3","gravatar_id":"","url":"https://api.github.com/users/liyangliu","html_url":"https://github.com/liyangliu","followers_url":"https://api.github.com/users/liyangliu/followers","following_url":"https://api.github.com/users/liyangliu/following{/other_user}","gists_url":"https://api.github.com/users/liyangliu/gists{/gist_id}","starred_url":"https://api.github.com/users/liyangliu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liyangliu/subscriptions","organizations_url":"https://api.github.com/users/liyangliu/orgs","repos_url":"https://api.github.com/users/liyangliu/repos","events_url":"https://api.github.com/users/liyangliu/events{/privacy}","received_events_url":"https://api.github.com/users/liyangliu/received_events","type":"User","site_admin":false},"created_at":"2015-11-29T08:33:32Z","updated_at":"2015-11-29T08:33:32Z","body":"Hello, @shelhamer\r\n\r\nsorry to bother you, I am trying to fine-tune your fcn_alexnet to my own dataset, but when i use gpu, i encounter a problem as follows:\r\n\r\nI1128 22:55:19.044678   358 parallel.cpp:395] GPUs pairs 0:1, 2:3, 0:2\r\nI1128 22:55:19.319453   358 data_layer.cpp:44] output data size: 20,3,451,451\r\nI1128 22:55:19.419453   358 data_layer.cpp:44] output data size: 20,1,451,451\r\nI1128 22:55:22.330047   358 data_layer.cpp:44] output data size: 20,3,451,451\r\nI1128 22:55:22.433482   358 data_layer.cpp:44] output data size: 20,1,451,451\r\nI1128 22:55:25.011587   358 parallel.cpp:238] GPU 2 does not have p2p access to GPU 0\r\nI1128 22:55:25.315258   358 data_layer.cpp:44] output data size: 20,3,451,451\r\nI1128 22:55:25.440186   358 data_layer.cpp:44] output data size: 20,1,451,451\r\nI1128 22:55:28.140528   358 parallel.cpp:423] Starting Optimization\r\nI1128 22:55:28.141278   358 solver.cpp:293] Solving FCN-AlexNet-FD\r\nI1128 22:55:28.141311   358 solver.cpp:294] Learning Rate Policy: fixed\r\nI1128 22:55:28.141938   358 solver.cpp:346] Iteration 0, Testing net (#0)\r\nF1128 22:55:28.424314   358 math_functions.cu:123] Check failed: status == CUBLAS_STATUS_SUCCESS (11 vs. 0)  CUBLAS_STATUS_MAPPING_ERROR\r\n*** Check failure stack trace: ***\r\n    @     0x7fa222b9212d  google::LogMessage::Fail()\r\n    @     0x7fa222b93fcd  google::LogMessage::SendToLog()\r\n    @     0x7fa222b91d48  google::LogMessage::Flush()\r\n    @     0x7fa222b9482e  google::LogMessageFatal::~LogMessageFatal()\r\n    @     0x7fa2232c211a  caffe::caffe_gpu_asum<>()\r\n    @     0x7fa2232c4172  caffe::SoftmaxWithLossLayer<>::Forward_gpu()\r\n    @     0x7fa2231d6db2  caffe::Net<>::ForwardFromTo()\r\n    @     0x7fa2231d6ed7  caffe::Net<>::ForwardPrefilled()\r\n    @     0x7fa2231c1ba6  caffe::Solver<>::Test()\r\n    @     0x7fa2231c23be  caffe::Solver<>::TestAll()\r\n    @     0x7fa2231c250d  caffe::Solver<>::Step()\r\n    @     0x7fa2231c2f15  caffe::Solver<>::Solve()\r\n    @     0x7fa2231ce35e  caffe::P2PSync<>::run()\r\n    @           0x40906e  train()\r\n    @           0x40671b  main\r\n    @     0x7fa222096a40  (unknown)\r\n    @           0x406eb9  _start\r\n\r\n\r\n\r\ni have transform my data to lmdb by your python code at github and use it as the source.\r\n\r\nprint(\"Creating Training Data LMDB File ..... \")\r\nin_db = lmdb.open('../data/FDDB/8_2/TrainFDDB_Data_lmdb',map_size=map_size)\r\nwith in_db.begin(write=True) as in_txn:\r\n    for in_idx, in_ in enumerate(inputs_data_train):\r\n        print in_idx\r\n        im = np.array(Image.open(in_)) # or load whatever ndarray you need\r\n        Dtype = im.dtype\r\n        if len(im.shape) == 2:\r\n            (row, col) = im.shape\r\n            im3 = np.zeros([row, col, 3], Dtype)\r\n            for i in range(3):\r\n                im3[:, :, i] = im\r\n            im = im3\r\n        im = im[:,:,::-1]\r\n        im = Image.fromarray(im)\r\n        im = im.resize([Rheight, Rwidth], Image.ANTIALIAS)\r\n        im = np.array(im,Dtype)\r\n        im = im.transpose((2,0,1))\r\n        im_dat = caffe.io.array_to_datum(im)\r\n        in_txn.put('{:0>10d}'.format(in_idx),im_dat.SerializeToString())\r\nin_db.close()\r\n\r\nprint(\"Creating Training Label LMDB File ..... \")\r\nin_db = lmdb.open('../data/FDDB/8_2/TrainFDDB_Label_lmdb',map_size=map_size)\r\nwith in_db.begin(write=True) as in_txn:\r\n    for in_idx, in_ in enumerate(inputs_label_train):\r\n        print in_idx\r\n        # in_label = in_[:-40]+'SegmentationClass/'+in_[-15:-3]+'png'\r\n\tDtype = 'uint8'\r\n\tL = np.array(Image.open(in_), Dtype) # or load whatever ndarray you need\r\n        Limg = Image.fromarray(L)\r\n        Limg = Limg.resize([LabelHeight, LabelWidth],Image.NEAREST) # To resize the Label file to the required size \r\n        L = np.array(Limg,Dtype)\r\n\t# L2 = np.zeros([LabelHeight, LabelWidth, 2], Dtype)\r\n\t# L2[:, :, 0] = L\r\n\t# L2[:, :, 1] = 1 - L\r\n        L = L.reshape(L.shape[0],L.shape[1],1)\r\n        L = L.transpose((2,0,1))\r\n        L_dat = caffe.io.array_to_datum(L)\r\n        in_txn.put('{:0>10d}'.format(in_idx),L_dat.SerializeToString())\r\nin_db.close()\r\n\r\nlayer {\r\n  name: \"data\"\r\n  type: \"Data\"\r\n  top: \"data\"\r\n  include {\r\n    phase: TRAIN\r\n  }\r\n  transform_param {\r\n    mean_value: 104.00699\r\n    mean_value: 116.66877\r\n    mean_value: 122.67892\r\n  }\r\n  data_param {\r\n    source: \"data/Train_Data_lmdb\"\r\n    batch_size: 20\r\n    backend: LMDB\r\n  }\r\n}\r\nlayer {\r\n  name: \"label\"\r\n  type: \"Data\"\r\n  top: \"label\"\r\n  include {\r\n    phase: TRAIN\r\n  }\r\n  data_param {\r\n    source: \"data/Train_Label_lmdb\"\r\n    batch_size: 20\r\n    backend: LMDB\r\n  }\r\n}\r\n\r\nthe same with test phase\r\n\r\ni created 4 lmdbs for train data, test data, train label, test label respectively\r\nmy label is a matrix(each element is 0 or 1(uint8) as yes or not), and saved as png pictures\r\nand the last convolution layer and deconvolution layer of my net has num_output = 2 \r\n\r\nwhen I use cpu mode, it is ok, but it's too slow\r\ncould you please be so kind as to help me a little?\r\nthanks very much.\r\n\r\ni have looking for the answer for so long and can't figure it out.\r\ni really don't want to bother you, but i have no idea how to leave a message for you at github, sorry.\r\n\r\nthank you."}}