This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Leetcode https://leetcode.com/problems/min-stack | |
// What's a min stack? A min stack is a stack (first in, last out) that also tracks the minimum value at any given point of time. | |
// push, pop, top and min element need to be constant time. | |
class StackNode{ | |
public: | |
int val; | |
int minval; | |
StackNode(int x, int min): val(x), minval(min) {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From https://github.com/gameplay3d/GamePlay/blob/master/gameplay/src/PlatformAndroid.cpp | |
// Line 1373 | |
{ | |
// Prepare to monitor accelerometer. | |
__sensorManager = ASensorManager_getInstance(); | |
__accelerometerSensor = ASensorManager_getDefaultSensor(__sensorManager, ASENSOR_TYPE_ACCELEROMETER); | |
__gyroscopeSensor = ASensorManager_getDefaultSensor(__sensorManager, ASENSOR_TYPE_GYROSCOPE); | |
__sensorEventQueue = ASensorManager_createEventQueue(__sensorManager, __state->looper, LOOPER_ID_USER, NULL, NULL); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code to use a frozen pb model and run inferences in C using libtensorflow | |
// Adapted from https://github.com/PatWie/tensorflow-cmake/blob/master/inference/c/inference_c.c | |
#include "pch.h" | |
#include <stdlib.h> | |
#include <iostream> | |
#include <c_api.h> | |
/* Functions to help read pb file */ | |
void free_buffer(void* data, size_t length) { free(data); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Add appropriate headers here */ | |
// #include<iostream.h> | |
// #include<stdio.h> | |
#include <c_api.h> | |
int main() | |
{ | |
printf("Hello from TensorFlow C library version %s\n", TF_Version()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo EXPORTS > D:\libtensorflow\tensorflow.def | |
for /f "usebackq tokens=4,* delims=_ " %i in (`dumpbin /exports "D:\libtensorflow\tensorflow.dll"`) do if %i==TF echo %i_%j >> D:\libtensorflow\tensorflow.def | |
lib /def:"D:\libtensorflow\tensorflow.def" /out:"D:\libtensorflow\tensorflow.lib" /machine:x64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tensorflow.python.platform import gfile | |
with tf.Session() as sess: | |
with gfile.FastGFile('slopemodel/slopemodel.pb', 'rb') as f: | |
graph_def = tf.GraphDef() | |
graph_def.ParseFromString(f.read()) | |
sess.graph.as_default() | |
g_in = tf.import_graph_def(graph_def) | |
tensor_output = sess.graph.get_tensor_by_name('import/dense_2/Sigmoid:0') | |
tensor_input = sess.graph.get_tensor_by_name('import/dense_1_input:0') | |
predictions = sess.run(tensor_output, {tensor_input:sample}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import/dense_1_input | |
import/dense_1/kernel | |
import/dense_1/kernel/read | |
import/dense_1/bias | |
import/dense_1/bias/read | |
import/dense_1/MatMul | |
import/dense_1/BiasAdd | |
import/dense_1/Relu | |
import/dense_2/kernel | |
import/dense_2/kernel/read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tensorflow.python.platform import gfile | |
with tf.Session() as sess: | |
with gfile.FastGFile('slopemodel/slopemodel.pb', 'rb') as f: | |
graph_def = tf.GraphDef() | |
graph_def.ParseFromString(f.read()) | |
sess.graph.as_default() | |
g_in = tf.import_graph_def(graph_def) | |
for op in tf.get_default_graph().get_operations(): | |
print(str(op.name)) | |
for n in tf.get_default_graph().as_graph_def().node: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sample = normdata[1].reshape((1,21)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 603 596 578 548 539 532 533 513 494 497 505 483 461 463 445 443 431 426 406 390 397 | |
1 552 557 554 575 592 608 611 617 623 634 637 660 694 687 703 717 723 710 732 744 746 | |
1 746 770 804 794 818 824 831 831 849 858 864 875 877 897 892 896 907 907 919 924 950 | |
0 432 433 424 416 411 396 381 376 377 361 361 361 349 331 325 300 309 297 297 275 275 | |
0 363 354 341 328 319 302 289 279 256 245 228 226 211 204 197 188 161 160 146 139 118 | |
1 425 429 439 460 456 443 471 476 499 489 507 519 523 540 545 545 555 563 558 554 569 | |
1 463 461 462 479 494 501 518 513 526 543 576 592 593 599 603 607 616 625 623 644 663 | |
0 374 383 372 383 368 354 335 324 316 310 313 299 259 262 248 239 234 223 205 197 191 | |
1 553 572 590 581 577 592 603 608 639 642 669 670 681 685 702 702 713 712 722 750 754 | |
0 403 388 392 389 371 363 339 324 302 281 271 264 240 251 246 234 219 220 198 179 176 |
NewerOlder