Invalid JSON:Unexpected non-whitespace character after JSONat line 2, column 1
| {"QuestionId": 36550131, "AnswerCount": 2, "Tags": "<machine-learning><computer-vision><deep-learning><caffe><lmdb>", "CreationDate": "2016-04-11T13:28:14.220", "AcceptedAnswerId": "36554793", "Title": "Check failed: mdb_status == 0 (2 vs. 0) No such file or directory", "Body": "<p>I received the following error while I was training the data. I have tried all the solutions given on the internet and nothing seems to work for me. I have checked paths and size of the lmdb files are non-zero. But the problem still exists. I have no idea how to solve this issue.</p>\n\n<pre><code>pooling_\nI0411 12:42:53.114141 21769 layer_factory.hpp:77] Creating layer data\nI0411 12:42:53.114586 21769 net.cpp:91] Creating Layer data\nI0411 12:42:53.114604 21769 net.cpp:399] data -> data\nI0411 12:42:53.114645 21769 net.cpp:399] data -> label\nF0411 12:42:53.114650 21772 db_lmdb.hpp:14] Check failed: mdb_status == 0 (2 \nvs. 0) No such file or directory\n*** Check failure stack trace: ***\nI0411 12:42:53.114673 21769 data_transformer.cpp:25] Loading mean file from: \n/home/Documents/Test/Images300/train_image_mean.binaryproto\n@ 0x7fa9436a3daa (unknown)\n@ 0x7fa9436a3ce4 (unknown)\n@ 0x7fa9436a36e6 (unknown)\n@ 0x7fa9436a6687 (unknown)\n@ 0x7fa943b0472e caffe::db::LMDB::Open()\n@ 0x7fa943afc644 caffe::DataReader::Body::InternalThreadEntry()\n@ 0x7fa940e46a4a (unknown)\n@ 0x7fa9406fe182 start_thread\n@ 0x7fa942a8a47d (unknown)\n@ (nil) (unknown)\nAborted (core dumped)\n</code></pre>\n\n<p>Below is my file settings:</p>\n\n<pre><code>name: \"GoogleNet\"\nlayer {\n name: \"data\"\n type: \"Data\"\n top: \"data\"\n top: \"label\"\n include {\n phase: TRAIN\n }\n transform_param {\n mirror: true\n crop_size: 224\n mean_file: \"/home/Documents/Test/Images300/train_image_mean.binaryproto\"\n }\n data_param {\n source: \"/home/caffe/examples/zImageDetection/ImageDetection_train_lmdb\"\n batch_size: 32\n backend: LMDB\n }\n}\nlayer {\n name: \"data\"\n type: \"Data\"\n top: \"data\"\n top: \"label\"\n include {\n phase: TEST\n }\n transform_param {\n mirror: false\n crop_size: 224\n mean_file: \"/home/Documents/Test/Image300/test_image_mean.binaryproto\"\n }\n data_param {\n source: \"/home/caffe/examples/zImageDetection/ImageDetection_val_lmdb\"\n batch_size: 50\n backend: LMDB\n }\n}\n</code></pre>\n", "Lable": "D"} | |
| {"QuestionId": 36585880, "AnswerCount": 4, "Tags": "<javascript><node.js>", "CreationDate": "2016-04-12T23:28:40.367", "AcceptedAnswerId": "36585909", "Title": "Is there a way to synchronously execute multiple JavaScript files in node?", "Body": "<p>So in Node I can execute a JavaScript file using a command like:</p>\n\n<pre><code>$ node src/someFile.js\n</code></pre>\n\n<p>But is there a way to execute <em>all</em> of the JavaScript files in a given directory synchronously (one file executes, then after it has finished the next one executes, etc)? Basically, is there a single command that would have the effect of something like</p>\n\n<pre><code>$ node src/firstFile.js\n$ node src/secondFile.js\n$ node src/thirdFile.js\n...\n</code></pre>\n\n<p>I've tried commands like</p>\n\n<pre><code>$ node src/*.js\n</code></pre>\n\n<p>but with no success.</p>\n\n<p>If there exists no such command, what's the best way to go about doing something like this?</p>\n", "Lable": "No"} | |
| {"QuestionId": 36746860, "AnswerCount": 2, "Tags": "<python><tensorflow><caffe>", "CreationDate": "2016-04-20T14:24:01.620", "AcceptedAnswerId": "37283787", "Title": "FCN in TensorFlow missing crop layer", "Body": "<p>I am currently trying to implement <a href=\"http://www.cs.berkeley.edu/~jonlong/long_shelhamer_fcn.pdf\" rel=\"nofollow\">FCN for semantic segmentation</a> in TensorFlow as it was previously done in Caffe <a href=\"https://github.com/shelhamer/fcn.berkeleyvision.org\" rel=\"nofollow\">here</a>.</p>\n\n<p>Unfortunately I'm struggling with following 3 things:</p>\n\n<p>1) How to map \"Deconvolution\" layer from Caffe to TensorFlow? Is it correctly <code>tf.nn.conv2d_transpose</code>?</p>\n\n<p>2) How to map \"Crop\" layer from Caffe to TensorFlow? Unfortunately I can't see any alternative in TensorFlow. Is there equivalent for this in TensorFlow?</p>\n\n<p>3) Does Caffe <code>SoftmaxWithLoss</code> correspond to TensorFlow softmax_cross_entropy_with_logits?</p>\n\n<p>Thank you in advance for any advices, hints and help.</p>\n\n<p><strong>EDIT 9th May 2016:</strong></p>\n\n<p>1) I have found out that <code>tf.nn.conv2_transpose</code> really corresponds to deconvolution layer.</p>\n\n<p>2) Crop layer for now seems to be really a problem. I have found out that there actually exists <a href=\"https://www.tensorflow.org/versions/r0.8/api_docs/python/image.html#resize_image_with_crop_or_pad\" rel=\"nofollow\"><code>tf.image.resize_image_with_crop_or_pad</code></a>, but this seems to be impossible to use for this purposes, because it can't work with dynamically created tensors nor with 4D tensors that you need to use after <code>tf.nn.conv2_transpose</code> layer.</p>\n\n<p>Some more information might be on: <a href=\"https://github.com/tensorflow/tensorflow/issues/2049\" rel=\"nofollow\">https://github.com/tensorflow/tensorflow/issues/2049</a></p>\n\n<p><strong>EDIT 17th May 2016:</strong></p>\n\n<p>I have followed @24hours advice and build FCN in tensorflow, though I was not able to make it train on data of the arbitrary size.</p>\n\n<p>2) Crop layer is really not needed.</p>\n\n<p>3) I have used <code>tf.nn.sparse_softmax_cross_entropy_with_logits</code> at the end and it worked for me.</p>\n", "Lable": "D"} | |
| {"QuestionId": 36758114, "AnswerCount": 1, "Tags": "<python><arrays><numpy><tensorflow>", "CreationDate": "2016-04-21T01:42:15.617", "AcceptedAnswerId": "36759716", "Title": "ValueError: setting an array element with a sequence when using feed_dict in TensorFlow", "Body": "<p>I am trying to feed a Tensor containing the correct labels when I perform training.</p>\n\n<p>The correct labels for the entire training dataset are contained in one tensor which has been converted from a numpy array:</p>\n\n<pre><code>numpy_label = np.zeros((614,5),dtype=np.float32)\n\nfor i in range(614):\n numpy_label[i,label_numbers[i]-1] = 1\n\n# Convert to tensor\ny_label_all = tf.convert_to_tensor(numpy_label,dtype=tf.float32)\n</code></pre>\n\n<p>I have a placeholder for the correct labels for each batch:</p>\n\n<pre><code>images_per_batch = 5\ny_label = tf.placeholder(tf.float32,shape=[images_per_batch,5])\n</code></pre>\n\n<p>During each training step, I slice the corresponding portion of <code>y_label_all</code> as <code>y_</code> and want to feed it as <code>y_label</code>:</p>\n\n<pre><code>for step in range(100):\n\n # Slice correct labels for current batch\n y_ = tf.slice(y_label_all,[step,0],[images_per_batch,5])\n\n # Train\n _, loss_value = sess.run([train_step,loss],feed_dict={y_label:y_})\n</code></pre>\n\n<p><strong>This generates the error:</strong></p>\n\n<pre><code>_, loss_value = sess.run([train_step,loss],feed_dict={y_label:y_})\n File \"/usr/local/lib/python2.7/dist- packages/tensorflow/python/client/session.py\", line 357, in run\nnp_val = np.array(subfeed_val, dtype=subfeed_t.dtype.as_numpy_dtype)\nValueError: setting an array element with a sequence.\n</code></pre>\n\n<p><strong>Shape of variables <code>y_</code> and <code>y_label</code>:</strong></p>\n\n<pre class=\"lang-py prettyprint-override\"><code>#y_: \nTensor(\"Slice:0\", shape=TensorShape([Dimension(5), Dimension(5)]), dtype=float32)\n\n#y_label: \nTensor(\"Placeholder:0\", shape=TensorShape([Dimension(5), Dimension(5)]), dtype=float32)\n</code></pre>\n\n<p>I don't understand what is going wrong? Apparently it is something to do with the numpy - but now that I have converted the numpy array to a tensor, does that affect anything?</p>\n\n<p>Help and insight are much appreciated. Thank you!</p>\n", "Lable": "D"} | |
| {"QuestionId": 36762468, "AnswerCount": 2, "Tags": "<angularjs><eslint>", "CreationDate": "2016-04-21T07:20:51.433", "AcceptedAnswerId": "36762825", "Title": "How do I setup a folder with a different rule and another folder with a different rule", "Body": "<p>My folder structure is as follows: </p>\n\n<pre><code>-client // Contains the front end and AngularJS code \n-server // Contains backend code \n-models // Contains backedn code \n</code></pre>\n\n<p>Now, I wish to use <a href=\"https://github.com/Gillespie59/eslint-plugin-angular\" rel=\"nofollow\">eslint angular</a> only for the client folder whereas I wish to use <a href=\"https://www.npmjs.com/package/eslint-config-airbnb-base\" rel=\"nofollow\">airbnb base</a> for the other folders that are not inside the client folder.</p>\n\n<p>I have two <code>.eslintrc.json</code> files - one in the client folder and one in the ROOT folder.</p>\n\n<p>Client folder configuration looks like: </p>\n\n<pre><code>{\n \"extends\": \"angular\"\n}\n</code></pre>\n\n<p>whereas the one in the root folder looks like:</p>\n\n<pre><code>{\n \"extends\": \"airbnb-base\",\n \"root\": true\n}\n</code></pre>\n\n<p>Now, in the root folder, when I run <code>eslint .</code>, while the backend folders are being linted correctly, the front end doesn't seem to be using the angularjs eslint at all - I am getting errors about ES6 which I am not using the client folder. I don't also get errors about not following John Papa's style guide in the client folder (which the angular plugin should).</p>\n\n<p>However, if I go inside the client folder and run the esling command inside it, it seems to use the correct configuration.</p>\n\n<p>How do I configure it so that only client folder uses the angular eslint whereas the other folders use the airbnb one?</p>\n", "Lable": "No"} | |
| {"QuestionId": 36811786, "AnswerCount": 2, "Tags": "<c++><c++14>", "CreationDate": "2016-04-23T14:02:49.977", "AcceptedAnswerId": "36811848", "Title": "What does the standard say implementations should do upon finding unknown attributes?", "Body": "<p>C++11 brought support for so-called \"generalized attributes\", along with two standard ones, <code>noreturn</code> and <code>carries_dependency</code>. C++14 added <code>deprecated</code> to the table. However, I cannot find anything clear on <strong>what are implementations mandated to do by the standard upon finding an attribute that's unknown to them</strong>. Perhaps it's just that the standard doesn't say anything on the matter. Nevertheless, I would like to know.</p>\n\n<p>In practice, both gcc and clang have warnings regarding this situation that may be disabled. In particular, gcc gives the warning <code>'some_attribute' attribute directive ignored</code> (<code>-Wattributes</code>), while clang complains with <code>unknown attribute 'some_attribute' ignored</code> (<code>-Wunknown-attributes</code>). I haven't been able to find documentation for those options, though; the <a href=\"https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html\" rel=\"nofollow\">Warning Options</a> page for GCC merely mentions <code>-Wattributes</code>, while there doesn't even seem to be a similar list for Clang.</p>\n\n<p><strong>Why do I ask this?</strong> Well, some implementation-specific attributes are interesting. Take, for example, GCC's <a href=\"https://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html\" rel=\"nofollow\"><code>nonnull</code></a> attribute. We could happily annotate some functions with it:</p>\n\n<pre><code>[[gnu::nonnull]] void my_function ( char * a , int * b );\n</code></pre>\n\n<p>If the implementation knows about the attribute, everything's fine. But what can we expect if it doesn't?</p>\n\n<ul>\n<li><p><strong>It ignores it and this behavior is backed by the standard.</strong> We can go on and add every interesting attribute we find in online docs. In particular, this would allow mixing <code>visibility</code> and <code>dllexport</code> without as many <code>#if</code>s ~yay!</p>\n\n<pre><code>#if BUILDING_DLL\n#define DLLEXIMPORT dllexport\n#else\n#define DLLEXIMPORT dllimport\n#endif\n\n// even if MSVC doesn't support specifying dllexport this way, Clang does, and it can\n// compile MSVC-compatible objects\n[[gnu::visibility(\"default\"),DLLEXIMPORT]] void api_function ();\n</code></pre></li>\n<li><p><strong>It complains about it and this behavior is backed by the standard.</strong> D'oh! We'll have to roll some ugly machinery to keep unknown attributes from the hands of those pesky implementations.</p>\n\n<p>With just one attribute, it's easy, as empty attribute lists are allowed by the standard:</p>\n\n<pre><code>#if SOMETHING\n#define ATTRIBUTE_GNU_NONNULL gnu::nonnull\n#else\n#define ATTRIBUTE_GNU_NONNULL\n#endif\n\n// if ATTRIBUTE_GNU_NONNULL is defined to nothing, all that happens is that we get\n// an empty attribute list, which is 'standardly valid'\n[[ATTRIBUTE_GNU_NONNULL]] void my_function ( char * a , int * b );\n</code></pre>\n\n<p>However, with more than one attribute, things become more tricky:</p>\n\n<pre><code>#if SOMETHING\n#define ATTRIBUTE_GNU_NONNULL gnu::nonnull\n#else\n#define ATTRIBUTE_GNU_NONNULL\n#endif\n\n#if SOMETHING\n#define ATTRIBUTE_GNU_VISIBILITY( visibility_type ) gnu::visibility(#visibility_type)\n#else\n#define ATTRIBUTE_GNU_VISIBILITY( visibility_type )\n#endif\n\n// if any of the two macros is defined to nothing, it expands to [[,blah_blah]]\n// or [[blah_blah,]] - both of which are invalid\n[[ATTRIBUTE_GNU_NONNULL,ATTRIBUTE_GNU_VISIBILITY(default)]] void my_function\n( char * a , int * b );\n</code></pre>\n\n<p>The even-uglier solution that comes to mind is to have macros that combine attributes, like this:</p>\n\n<pre><code>#if SOMETHING\n#define ATTRIBUTES_GNU_NONNULL_AND_GNU_VISIBILITY( visibility_type ) \\\n gnu::nonnull,gnu::visibility(#visibility_type)\n#else\n#define ATTRIBUTES_GNU_NONNULL_AND_GNU_VISIBILITY( visibility_type )\n#endif\n\n[[ATTRIBUTES_GNU_NONNULL_AND_GNU_VISIBILITY(default)]] void my_function\n( char * a , int * b );\n</code></pre>\n\n<p>But I would be shot in the head for this <code>:)</code>.</p></li>\n</ul>\n\n<p>Thus, if the standard mandated that implementations ignore unknown attributes, I could pick every relevant attribute I found in online docs without fear and without ugly solutions \u2014 hence my interest.</p>\n", "Lable": "No"} | |
| {"QuestionId": 36849445, "AnswerCount": 0, "Tags": "<android><sqlite>", "CreationDate": "2016-04-25T19:29:37.553", "AcceptedAnswerId": null, "Title": "SQLite, why cant android find the column?", "Body": "<p>I'm reading a book.. and now I get the problem :\n\"(1) no such column: FAVORITE\"</p>\n\n<p>I tried so many things.. it always says : no such column..</p>\n\n<p>I really dunno where the problem is.. cant find it. </p>\n\n<ul>\n<li>Could you guys take a look ?</li>\n</ul>\n\n<p>Thanks a lot.</p>\n\n<pre><code>package com.hfed.starbuzz;\n\nimport android.content.ContentValues;\nimport android.content.Context;\nimport android.database.sqlite.SQLiteDatabase;\nimport android.database.sqlite.SQLiteOpenHelper;\nimport android.util.Log;\n\npublic class StarbuzzDatabaseHelper extends SQLiteOpenHelper {\n\n private static final String DB_NAME = \"starbuzz\";\n private static final int DB_VERSION = 2;\n\n StarbuzzDatabaseHelper(Context context){\n super(context, DB_NAME, null, DB_VERSION);\n }\n\n @Override\n public void onCreate(SQLiteDatabase db){\n updateMyDatabase(db, 0, DB_VERSION);\n }\n\n @Override\n public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){\n updateMyDatabase(db, oldVersion, newVersion);\n }\n\n private void updateMyDatabase(SQLiteDatabase db, int oldVersion, int newVersion) {\n if (oldVersion < 1){\n db.execSQL(\"CREATE TABLE DRINK (_id INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, \"\n + \"DESCRIPTION TEXT, IMAGE_RESOURCE_ID INTEGER);\");\n insertDrink(db, \"Latte\", \"Espresso and steamed milk\", R.drawable.latte);\n insertDrink(db, \"Cappuccino\", \"Espresso, hot milk and steamed-milk foam\", R.drawable.cappuccino);\n insertDrink(db, \"Filter\", \"Our best drip coffee\", R.drawable.filter);\n }\n if(oldVersion < 2){\n db.execSQL(\"ALTER TABLE DRINK ADD COLUMN FAVORITE NUMERIC;\");\n }\n }\n\n private static void insertDrink(SQLiteDatabase db, String name, String description, int resourceID)\n {\n ContentValues drinkValues = new ContentValues();\n drinkValues.put(\"NAME\", name);\n drinkValues.put(\"DESCRIPTION\", description);\n drinkValues.put(\"IMAGE_RESOURCE_ID\", resourceID);\n db.insert(\"DRINK\", null, drinkValues);\n }\n}\n</code></pre>\n\n<p>The MainActivity.:::::</p>\n\n<pre><code>package com.hfed.starbuzz;\n\nimport android.app.Activity;\nimport android.database.Cursor;\nimport android.database.sqlite.SQLiteDatabase;\nimport android.database.sqlite.SQLiteException;\nimport android.database.sqlite.SQLiteOpenHelper;\nimport android.os.Bundle;\nimport android.content.Intent;\nimport android.view.View;\nimport android.widget.AdapterView;\nimport android.widget.CursorAdapter;\nimport android.widget.ListView;\nimport android.widget.SimpleCursorAdapter;\nimport android.widget.Toast;\n\npublic class TopLevelActivity extends Activity {\n private SQLiteDatabase db;\n private Cursor favoritesCursor;\n\n @Override\n protected void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_top_level);\n\n AdapterView.OnItemClickListener itemClickListener = new AdapterView.OnItemClickListener(){\n public void onItemClick(AdapterView<?> listView, View v, int position, long id) {\n if(position == 0)\n {\n Intent intent = new Intent(TopLevelActivity.this, DrinkCategoryActivity.class);\n startActivity(intent);\n }\n }\n };\n\n ListView listView = (ListView) findViewById(R.id.list_options);\n listView.setOnItemClickListener(itemClickListener);\n\n ListView listFavorites = (ListView)findViewById(R.id.list_favorites);\n try{\n SQLiteOpenHelper starbuzzDatabaseHelper = new StarbuzzDatabaseHelper(this);\n db =starbuzzDatabaseHelper.getReadableDatabase();\n favoritesCursor = db.query(\"DRINK\", new String[]{\"_id\", \"NAME\"}, \"FAVORITE = 1\", null, null, null, null);\n\n CursorAdapter favoriteAdapter = new SimpleCursorAdapter(TopLevelActivity.this,\n android.R.layout.simple_list_item_1, favoritesCursor, new String[]{\"NAME\"},\n new int[]{android.R.id.text1}, 0);\n listFavorites.setAdapter(favoriteAdapter);\n }catch (SQLiteException e){\n Toast.makeText(this, \"Database unavailable\", Toast.LENGTH_SHORT).show();\n }\n\n listFavorites.setOnItemClickListener(new AdapterView.OnItemClickListener(){\n @Override\n public void onItemClick(AdapterView<?> listView, View v, int position, long id){\n Intent intent = new Intent(TopLevelActivity.this, DrinkActivity.class);\n intent.putExtra(DrinkActivity.EXTRA_DRINKNO, (int) id);\n startActivity(intent);\n }\n });\n }\n\n @Override\n public void onDestroy(){\n super.onDestroy();\n favoritesCursor.close();\n db.close();\n }\n}\n</code></pre>\n", "Lable": "No"} | |
| {"QuestionId": 36886711, "AnswerCount": 11, "Tags": "<python><graphviz><theano><keras><pydot>", "CreationDate": "2016-04-27T10:08:21.043", "AcceptedAnswerId": "36890526", "Title": "Keras: \"RuntimeError: Failed to import pydot.\" after installing graphviz and pydot", "Body": "<p>I'm using Anaconda Python 2.7 on windows 10</p>\n\n<p>I was planning on doing Keras visualization so (whilst spyder was open) I opened the Anaconda command prompt and pip installed graphviz and pydot. Now when I try run the following:</p>\n\n<pre><code>from keras.models import Sequential\n</code></pre>\n\n<p>or any sort of \"from keras.\" , I get the error:</p>\n\n<pre><code>ImportError: cannot import name gof\n</code></pre>\n\n<p>I have uninstalled and reinstalled Keras, Graphviz and pydot. i am using the development version of theano. I cannot find a fix. </p>\n\n<p><strong>P.S</strong></p>\n\n<p>If I uninstall graphviz and pydot, keras works again</p>\n\n<p><strong>EDIT</strong></p>\n\n<p>After uninstalling anaconda and reinstalling it including theano, keras, <strong>graphviz and pydot</strong> I now get the following error:</p>\n\n<pre><code>from keras.utils.visualize_util import plot\n\nUsing Theano backend.\nUsing gpu device 0: GeForce GTX 970M (CNMeM is disabled, cuDNN not available)\nTraceback (most recent call last):\n\n File \"<ipython-input-1-65016ddab3cd>\", line 1, in <module>\n from keras.utils.visualize_util import plot\n\n File \"C:\\Anaconda2\\lib\\site-packages\\keras\\utils\\visualize_util.py\", line 8, in <module>\n raise RuntimeError('Failed to import pydot. You must install pydot'\n\nRuntimeError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.\n</code></pre>\n\n<p>I used <code>pip install graphviz</code> and <code>pip install git+https://github.com/nlhepler/pydot.git</code></p>\n", "Lable": "D"} | |
| {"QuestionId": 36891804, "AnswerCount": 1, "Tags": "<typescript><angular><asp.net-mvc-5>", "CreationDate": "2016-04-27T13:49:31.610", "AcceptedAnswerId": null, "Title": "Can I pass an object from Angular2 to an MVC5 Post?", "Body": "<p>I am trying to pass my object from Angular2 through a post to an MVC Controller. I was hoping I could pass the actual object in, but all of my properties are appearing as null when it gets into my controller. Is it possible to pass the entire object in? I also tried with \"UrlSearchParameters\" but it didnt work either.</p>\n\n<p>Here's my controller post function:</p>\n\n<pre><code>[HttpPost]\n public JsonResult AddClient(Models.Client client)\n { \n var cli = new Models.Client();\n cli.name = client.name;\n cli.npi = client.npi;\n cli.dateAdded = DateTime.Now.ToShortDateString();\n return Json(cli);\n }\n</code></pre>\n\n<p>Here's my client type:</p>\n\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\">\r\n<div class=\"snippet-code\">\r\n<pre class=\"snippet-code-html lang-html prettyprint-override\"><code>export interface Client {\r\n name: string;\r\n npi: number;\r\n dateAdded?: string;\r\n id?: number\r\n}</code></pre>\r\n</div>\r\n</div>\r\n</p>\n\n<p>Here's my Angular2 service:</p>\n\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\">\r\n<div class=\"snippet-code\">\r\n<pre class=\"snippet-code-html lang-html prettyprint-override\"><code>import {Injectable} from 'angular2/core';\r\nimport {Client} from './client';\r\nimport {RequestOptions, Http, Response, Headers, URLSearchParams} from 'angular2/http';\r\nimport {Observable} from 'rxjs/Observable';\r\n\r\n\r\n@Injectable()\r\nexport class ClientService {\r\n constructor(private http: Http) { }\r\n\r\n\r\n getClients(): Observable<Client[]> {\r\n return this.http.get('/Client/GetClients')\r\n .map(this.extractData);\r\n }\r\n\r\n addClient(client: Client): Observable<Client> {\r\n let clientUrl = '/Client/AddClient';\r\n let body = JSON.stringify({ client });\r\n let header = new Headers({ 'Content-Type': 'application/json' });\r\n let options = new RequestOptions({ headers: header });\r\n\r\n return this.http.post(clientUrl, body, options)\r\n .map(this.extractData)\r\n .catch(this.handleError);\r\n }\r\n\r\n private extractData(res: Response) {\r\n if (res.status < 200 || res.status >= 300) {\r\n throw new Error('Bad response status: ' + res.status);\r\n }\r\n let body = res.json();\r\n return body || {};\r\n }\r\n private handleError(error: any) {\r\n // In a real world app, we might send the error to remote logging infrastructure\r\n let errMsg = error.message || 'Server error';\r\n console.error(errMsg); // log to console instead\r\n return Observable.throw(errMsg);\r\n }\r\n}</code></pre>\r\n</div>\r\n</div>\r\n</p>\n\n<p>Thanks for any help!</p>\n", "Lable": "No"} | |
| {"QuestionId": 36916690, "AnswerCount": 6, "Tags": "<tensorflow><google-cloud-platform><google-compute-engine><google-cloud-ml><gcp-ai-platform-notebook>", "CreationDate": "2016-04-28T13:49:12.197", "AcceptedAnswerId": "36927672", "Title": "Which Google Cloud Platform service is the easiest for running Tensorflow?", "Body": "<p>While working on Udacity Deep Learning assignments, I encountered memory problem. I need to switch to a cloud platform. I worked with AWS EC2 before but now I would like to try Google Cloud Platform (GCP). I will need at least 8GB memory. I know how to use docker locally but never tried it on the cloud.</p>\n\n<ol>\n<li>Is there any ready-made solution for running Tensorflow on GCP?</li>\n<li>If not, which service (Compute Engine or Container Engine) would make it easier to get started?</li>\n<li>Any other tip is also appreciated!</li>\n</ol>\n", "Lable": "D"} | |
| {"QuestionId": 36929675, "AnswerCount": 1, "Tags": "<c++><caffe><hdf5>", "CreationDate": "2016-04-29T04:39:34.273", "AcceptedAnswerId": null, "Title": "Error import hdf5 file to train hdf5_classification in caffe", "Body": "<p>This is my log</p>\n\n<pre><code>Log file created at: 2016/04/29 14:01:52\n Running on machine: DELL\n Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg\n F0429 14:01:52.191473 14832 upgrade_proto.cpp:79] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: examples/hdf5_classification/nonlinear_auto_train.prototxt\n</code></pre>\n\n<p>This is my bat</p>\n\n<pre><code>.\\bin\\caffe.exe train --solver=D:\\caffe-windows-master\\examples\\hdf5_classification\\nonlinear_solver.prototxt\npause\n</code></pre>\n\n<p>This is my nonlinear_solver.prototxt</p>\n\n<pre><code>train_net: \"examples/hdf5_classification/nonlinear_auto_train.prototxt\"\n#test_net: \"examples/hdf5_classification/nonlinear_auto_test.prototxt\"\n#test_iter: 250\n#test_interval: 1000\nbase_lr: 0.01\nlr_policy: \"step\"\ngamma: 0.1\nstepsize: 5000\ndisplay: 1000\nmax_iter: 10000\nmomentum: 0.9\nweight_decay: 0.0005\nsnapshot: 10000\nsnapshot_prefix: \"examples/hdf5_classification/data/train\"\nsolver_mode: GPU\n</code></pre>\n\n<p>This is my nonlinear_auto_train.prototxt</p>\n\n<pre><code>layer {\n name: \"data\"\n type: \"HDF5Data\"\n top: \"data\"\n top: \"label\"\n hdf5_data_param {\n source: \"D:\\caffe-windows-master\\examples/hdf5_classification/data/list.txt\"\n batch_size: 10\n }\n}\nlayer {\n name: \"ip1\"\n type: \"InnerProduct\"\n bottom: \"data\"\n top: \"ip1\"\n inner_product_param {\n num_output: 40\n weight_filler {\n type: \"xavier\"\n }\n }\n}\nlayer {\n name: \"relu1\"\n type: \"ReLU\"\n bottom: \"ip1\"\n top: \"ip1\"\n}\nlayer {\n name: \"ip2\"\n type: \"InnerProduct\"\n bottom: \"ip1\"\n top: \"ip2\"\n inner_product_param {\n num_output: 2\n weight_filler {\n type: \"xavier\"\n }\n }\n}\nlayer {\n name: \"accuracy\"\n type: \"Accuracy\"\n bottom: \"ip2\"\n bottom: \"label\"\n top: \"accuracy\"\n}\nlayer {\n name: \"loss\"\n type: \"SoftmaxWithLoss\"\n bottom: \"ip2\"\n bottom: \"label\"\n top: \"loss\"\n}\n</code></pre>\n\n<p>the code runs on the windows</p>\n\n<blockquote>\n <p>Firstly, I can't find the D:\\ThirdPartyLibrary;</p>\n \n <p>Secondly, the h5 file has been saved in proper folder;</p>\n \n <p>Thirdly, I use the absolute path for every file</p>\n</blockquote>\n\n<p>I don't know why the code doesn't run well</p>\n", "Lable": "D"} | |
| {"QuestionId": 36994890, "AnswerCount": 0, "Tags": "<image><numpy><tensorflow>", "CreationDate": "2016-05-03T03:01:40.630", "AcceptedAnswerId": null, "Title": "Shape Error in Tensorflow", "Body": "<p>So I have some 32x32 images with 3 color channels so I flattened them out and made their shape 3072. I loaded the images and reshaped them to be a (1, 3072) numpy matrix but when the network is running it will give the following error:</p>\n\n<pre><code>Traceback (most recent call last):\n File \"/Users/Me/project/lib/python3.4/site-packages/tensorflow/python/client/session.py\", line 428, in _do_run\ntarget_list)\ntensorflow.python.pywrap_tensorflow.StatusNotOK: Invalid argument: Incompatible shapes: [300] vs. [100] \n[[Node: Equal_1 = Equal[T=DT_INT64, _device=\"/job:localhost/replica:0/task:0/cpu:0\"](ArgMax_2, ArgMax_3)]]\n</code></pre>\n\n<p>This is the code that loads the images:</p>\n\n<pre><code>name = QtGui.QFileDialog.getOpenFileNames(self, 'Open File')\nfname = [str(each) for each in name]\nflist = []\ndlist = []\nfor n, val in enumerate(name):\n flist.append(val)\n img = Image.open(flist[n])\n img.load()\n data = np.asarray(img, dtype = \"int32\")\n print(data.shape)\n data.shape = (1, 3072)\n quack = np.asmatrix(data)\n print(quack)\n dlist.append(quack)\nprint(dlist)\nfor n in range(len(dlist)):\n if n==0:\n self.inlist = dlist[n]\n if n>0:\n self.inlist = np.vstack((self.inlist, dlist[n]))\n</code></pre>\n\n<p>I am doing it in batches of 100.\nThe error seems to be coming from the following lines:</p>\n\n<pre><code>for i in range(2000):\n if i%100 == 0:\n train_accuracy = accuracy.eval(feed_dict={\n x:self.inlist, y_: self.outListm, keep_prob: 1.0})\n print (\"step %d, training accuracy %g\"%(i, train_accuracy))\n self.progress.setValue(i/199.99)\n train_step.run(feed_dict={x: self.inlist, y_: self.outListm, keep_prob: 0.5}) \n</code></pre>\n\n<p>This is the code of the network that I got from the Tensorflow website and changed a little.</p>\n\n<pre><code>W_conv1 = weight_variable([1, 2, 1, 32])\nb_conv1 = bias_variable([32])\n\nx_image = tf.reshape(x, [-1,32,32,1])\n\nh_conv1 = tf.nn.relu(conv2d(x_image, W_conv1) + b_conv1)\nh_pool1 = max_pool_2x2(h_conv1)\n\nW_conv2 = weight_variable([1, 2, 32, 64])\nb_conv2 = bias_variable([64])\n\nh_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2) + b_conv2)\nh_pool2 = max_pool_2x2(h_conv2)\n\nW_fc1 = weight_variable([8 * 8 * 64, 1024])\nb_fc1 = bias_variable([1024])\n\nh_pool2_flat = tf.reshape(h_pool2, [-1, 8*8*64])\n\nkeep_prob = tf.placeholder(\"float\")\nh_fc1_drop = tf.nn.dropout(h_fc1, keep_prob)\n\nW_fc2 = weight_variable([1024, 512])\nb_fc2 = bias_variable([512])\n\ny_conv=tf.nn.softmax(tf.matmul(h_fc1_drop, W_fc2) + b_fc2)\n\ncross_entropy = -tf.reduce_sum(y_*tf.log(y_conv))\ntrain_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)\ncorrect_prediction = tf.equal(tf.argmax(y_conv,1), tf.argmax(y_,1))\naccuracy = tf.reduce_mean(tf.cast(correct_prediction, \"float\"))\nsess.run(tf.initialize_all_variables())\nfor i in range(2000):\n if i%100 == 0:\n train_accuracy = accuracy.eval(feed_dict={x: self.inlist, y_: self.outListm, keep_prob: 1.0})\n print (\"step %d, training accuracy %g\"%(i, train_accuracy))\n self.progress.setValue(i/199.99)\n train_step.run(feed_dict={x: self.inlist, y_: self.outListm, keep_prob: 0.5})\n</code></pre>\n", "Lable": "D"} | |
| {"QuestionId": 37007495, "AnswerCount": 3, "Tags": "<python><deep-learning><caffe>", "CreationDate": "2016-05-03T14:53:38.517", "AcceptedAnswerId": null, "Title": "Caffe didn't see hdf5.h when compiling", "Body": "<p>I am having trouble when installing Caffe Deep Learning Framework on Python:</p>\n\n<p>When I run <code>make</code> command at caffe directory, it says </p>\n\n<blockquote>\n <p>hdf5.h:no such directory</p>\n</blockquote>\n\n<p>The steps I have done:</p>\n\n<ul>\n<li><p>Update and upgrade my Ubuntu Server</p></li>\n<li><p>Install Python 2.7</p></li>\n<li><p>Having all of the dependencies base on <a href=\"http://caffe.berkeleyvision.org/install_apt.html\" rel=\"noreferrer\">http://caffe.berkeleyvision.org/install_apt.html</a></p></li>\n<li><p>Run cp cp Makefile.config.example Makefile.config</p></li>\n<li><p>Uncomment cpu_only = 1 in Makefile.config</p></li>\n</ul>\n\n<p>I will be grateful if someone can help me.</p>\n\n<p>Error message: </p>\n\n<pre><code>CXX src/caffe/util/hdf5.cpp\nin file include from src/caffe/util/hdf5.cpp:1:0:\n./include/caffe/util/hdf5.hpp:6:18: fatal error: hdf5.h: No such file or directory\ncompilation terminated \n\nMakefile:572 recipe for target '.build_release/src/caffe/util/hdf5.o' \nfailed Make:*** [.build_release/src/caffe/util/hdf5.o] Error 1\n</code></pre>\n", "Lable": "D"} | |
| {"QuestionId": 37109166, "AnswerCount": 1, "Tags": "<tensorflow>", "CreationDate": "2016-05-09T06:35:27.563", "AcceptedAnswerId": "37113360", "Title": "Tensorflow convert_to_tensor TypeError: List of Tensors when single Tensor expected", "Body": "<p>I am getting the following error when executing the code below. rnn.rnn() returns a list of tensors. Error is on the convert_to_tensor line.</p>\n\n<blockquote>\n <p>TypeError: List of Tensors when single Tensor expected</p>\n</blockquote>\n\n<pre><code>outputs, _states = rnn.rnn(lstm, X_split, initial_state=init_state)\noutput_tensor = tf.convert_to_tensor(outputs)\n</code></pre>\n\n<p>When I also initialized the dtype argument to tf.float32</p>\n\n<pre><code>output_tensor = tf.convert_to_tensor(outputs, dtype=tf.float32)\n</code></pre>\n\n<p>I got the following error on the same line:</p>\n\n<blockquote>\n <p>TypeError: Expected float32, got list containing Tensors of type '_Message' instead.</p>\n</blockquote>\n\n<p>What is the cause of these errors? I want my final output to be a tensor containing tensors.</p>\n\n<p>EDIT: I checked the DType of the individual tensors of the list. All of them are of type float32. What could be the cause of this error now?</p>\n", "Lable": "D"} | |
| {"QuestionId": 37244708, "AnswerCount": 1, "Tags": "<tensorflow><word-embedding>", "CreationDate": "2016-05-15T23:21:22.090", "AcceptedAnswerId": "37248181", "Title": "How to use word embeddings for prediction in Tensorflow", "Body": "<p>I'm trying to work through the Tensorflow tutorials and have gotten stuck trying to enhance the <a href=\"https://www.tensorflow.org/versions/r0.8/tutorials/recurrent/index.html\" rel=\"nofollow\">RNN/language model tutorial</a> so that I can predict the next word in a sentence. The tutorial uses word embeddings as the representation for the words.</p>\n\n<p>Since the model learns on the word embeddings, I'm assuming that any sort of prediction I add will output the same embeddings. What I can't figure out is how to convert from those embeddings back to the word ids from the dataset. The only example I have seen kept an in memory data structure with the reverse of the mapping of wordid -> embedding and used that for lookups. This obviously won't work for all problems. Is there a better way?</p>\n", "Lable": "D"} | |