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
# 読み込み | |
def read(filename): | |
img = tf.read_file(filename) | |
return tf.image.decode_png(img, channels=3) |
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
def write_jpg(data): | |
sample = tf.image.encode_jpeg(data, format='rgb', quality=100) | |
return 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
### File書き込み | |
#filepath="FILENAME.png" | |
filepath="FILENAME.jpg" | |
with open(filepath, 'wb') as fd: | |
fd.write(x) |
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
def write_png(data): | |
sample = tf.image.encode_png(data) | |
return 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 tensorflow as tf | |
import timeit | |
# See https://www.tensorflow.org/tutorials/using_gpu#allowing_gpu_memory_growth | |
config = tf.ConfigProto() | |
config.gpu_options.allow_growth = True | |
with tf.device('/cpu:0'): | |
random_image_cpu = tf.random_normal((100, 100, 100, 3)) | |
net_cpu = tf.layers.conv2d(random_image_cpu, 32, 7) |
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
Time (s) to convolve 32x7x7x3 filter over random 100x100x100x3 images (batch x height x width x channel). Sum of ten runs. | |
CPU (s): | |
8.547127412000009 | |
GPU (s): | |
0.8542735619998894 | |
GPU speedup over CPU: 10x |
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
BluetoothLEAdvertisementPublisher _publisher; | |
void SetupBluetoothAdvertisement() | |
{ | |
_publisher = new BluetoothLEAdvertisementPublisher(); | |
var manufacturerData = new BluetoothLEManufacturerData(); | |
manufacturerData.CompanyId = 0xFFFE; | |
var myIpAddress = GetMyIPAddress(); |
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
string GetMyIPAddress() | |
{ | |
var icp = NetworkInformation.GetInternetConnectionProfile(); | |
if(icp == null) | |
return string.Empty; | |
var adapter = icp.NetworkAdapter; | |
if(adapter == null) | |
return string.Empty; |
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
BluetoothLEAdvertisementWatcher _Watcher; | |
void SetupBluetoothWatcher() | |
{ | |
_watcher = new BluetoothLEAdvertisementWatcher(); | |
_watcher.Recieved += BluetoothWatcher_Connected; | |
var manufacturerData = new BluetoothLEManufacturerData(); | |
manufacturerData.CompanyId = 0xFFEE; | |
_watcher.AdvertisementFilter.Advertisement.ManufacturerData.Add(manufacturerData); | |
_watcher.Start(); |
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
void SetupDatagramServer() | |
{ | |
_serverSocket = new DatagramSocket(); | |
_serverSocket.MessageReceived += MessageRecieved; | |
var bindAwaiter = _serverSocket.BindServiceNameAsync("8000"); | |
var connectionComleteHandler = new AsyncActionCompletedHandler(OnConnectionCompletd); | |
bindAwaiter.Completed = connectionComleteHandler; | |
} |