Skip to content

Instantly share code, notes, and snippets.

View marty1885's full-sized avatar
πŸ‘¨β€πŸ’»
Writing code

Martin Chang marty1885

πŸ‘¨β€πŸ’»
Writing code
View GitHub Profile
#include <random>
#include <iomanip>
#include <array>
#include <exception>
#define NDEBUG
#include <tvm/tvm.h>
#include <tvm/build_module.h>
#include <topi/broadcast.h>
#undef NDEBUG
@marty1885
marty1885 / Etherium\IOTA Phone Recovery.md
Last active May 31, 2018 05:11
Etherium/IOTA Phone Recovery

Etherium/IOTA Phone Recovery

So, this is a stupid project I came up with that might work. It attempts to solve the problem that phone manuf actors can abuse there phone recovery service to track you by offloading the task of activating the tracking daemon on the phone from the service provider to the user and the Etherium network.

This should also work on IOTA. But I'll focus on Etherium for now. (I started designing it for Etherium, but IOTA seems to be a better way to go. Really, just replace Etheriun to IOTA int the later sessions)

How it works

This secession describes the basic principle how how it workds. This is only a draft and things are subject to change.

Let's assume an app called EPR (Etherium Phone Recovery) is installed on someones phone. And there exists two PGP keys. Key A and B (Ka and Kb for short). And two Ethetium address. Ea and Eb. Where Ea is the user's Etherium address, Ka is the PGP key that the user used to retrieve data. While Eb is the app's Etherium address, Kb is the PGP k

//tiny-dnn headers
#define CNN_USE_AVX
#include <tiny_dnn/tiny_dnn.h>
using namespace tiny_dnn;
using namespace tiny_dnn::activation;
using namespace tiny_dnn::layers;
//tiny-dnn comes with xtensor, use it
#include <tiny_dnn/xtensor/xnpy.hpp>
#include <tiny_dnn/xtensor/xview.hpp>
net.test(x, y).print_detail(std::cout);
net.save("model.net");
auto onEnumerateEpoch = [&]()
{
std::cout << std::endl;
std::cout << "Epoch " << epoch << "/" << NUM_BATCHES << " finished. "
<< t.elapsed() << "s elapsed." << std::endl;
++epoch;
//net.test(x, y).print_detail(std::cout);
disp.restart(numData);
@marty1885
marty1885 / includes.cpp
Last active May 30, 2018 00:45
tinydnn-tut
//tiny-dnn headers
#define CNN_USE_AVX
#include <tiny_dnn/tiny_dnn.h>
using namespace tiny_dnn;
using namespace tiny_dnn::activation;
using namespace tiny_dnn::layers;
//tiny-dnn comes with xtensor, use it
#include <tiny_dnn/xtensor/xnpy.hpp>
#include <tiny_dnn/xtensor/xview.hpp>
decltype(auto) convertDataset(const xt::xarray<float>& X, const xt::xarray<float>& Y)
{
size_t numData = X.shape()[0];
std::vector<vec_t> x(numData);
std::vector<label_t> y(numData);
for(size_t i=0;i<numData;i++)
{
auto xb = xt::view(X, i, xt::all());
x[i] = vec_t(xb.begin(), xb.end());
#include <Athena/Athena.hpp>
#include <Athena/Backend/XtensorBackend.hpp>
#include <Athena/Backend/NNPACKBackend.hpp>
#include "mnist_reader.hpp"
#include <iostream>
#include <chrono>
using namespace std::chrono;
network<sequential> net;
net << conv(64, 64, 5, 1, 6) << leaky_relu() // in: 64x64x1, out 6 chanels, kernel size: 5
<< max_pool(60, 60, 6, 2) // in: 60x60x6, 2x2 pooling
<< conv(30, 30, 5, 6, 9) << leaky_relu() // in: 30x30x6, out 9 channels, kernel size: 5
<< max_pool(26, 26, 9, 2) // in:26x26x9, 2x2 pooling
<< conv(13, 13, 6, 9, 12) << leaky_relu()// in: 13x13x9, out 12 channels, kernel size: 6
<< fc(8*8*12, 10)
<< softmax();
adam optimizer;
net.train<mse>(optimizer, x, y, BATCH_SIZE, NUM_BATCHES
xt::xarray<float> X = xt::load_npy<float>("X.npy");
xt::xarray<float> Y = xt::cast<float>((xt::xarray<float>)xt::load_npy<double>("Y.npy"));