我正在尝试学习TensorFlow,我从以下链接实现了MNIST示例:http://openmachin.es/blog/tensorflow-mnist 我希望能够实际查看训练/测试图像.所以我正在尝试添加代码,以显示第一批的第一张火车图片:
x_i = batch_xs[0]
image = tf.reshape(x_i,[28,28])
Run Code Online (Sandbox Code Playgroud)
现在,因为Data是float32类型(值在[0,1]范围内),我试图将它转换为uint16,然后将其编码为png以显示图像.我试过用tf.image.convert_image_dtype and tf.image.encode_png,但没有成功.你能帮我理解如何将原始数据转换为图像并显示图像?
当对float16 Numpy数字执行数学运算时,结果也是float16类型数.我的问题是如何计算结果?假设我乘以/添加两个float16数字,python是否在float32中生成结果然后将结果截断/舍入为float16?或者计算是否在"16位多路复用器/加法器硬件"中执行?
另一个问题 - 是否有float8类型?我找不到这个......如果没有,那么为什么?谢谢你们!
我最近阅读了一篇非常有趣的论文(http://arxiv.org/pdf/1602.02830v3.pdf),提出了一种训练 CNN 的方法,其权重和激活约束为 [-1,1]。从功率/速度的角度来看,这是非常有益的。
Torch 和 Theano 中该方法的实现在 github 中公开可用: https://github.com/MatthieuCourbariaux/BinaryNet (Theano) https://github.com/itayhubara/BinaryNet (Torch)
我想知道上面的方法是否可以在 TensorFlow 中实现?有没有人试过实现这个?
我设计了一个简单的指南针应用程序,第一步,我用一个视图(指南针视图)编写了该应用程序,并且运行良好。我创建了自定义罗盘视图的新实例,并使用了setcontent(mView)。
现在,我正在尝试使用布局,但我无法使其正常工作!每次尝试时,应用程序崩溃。
这是代码:
public class CustomDrawableView extends View {
public float azimut;
Paint paint = new Paint();
public CustomDrawableView(Context context) {
super(context);
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(2);
paint.setColor(Color.WHITE);
paint.setAntiAlias(true);
azimut=0;
};
public CustomDrawableView(Context context, float Azimut) {
super(context);
paint.setStyle(Style.STROKE);
paint.setStrokeWidth(2);
paint.setColor(Color.WHITE);
paint.setAntiAlias(true);
azimut=Azimut;
};
protected void onDraw(Canvas canvas) {
Bitmap bMap = BitmapFactory.decodeResource(getResources(),R.drawable.compassarrowbitmap);
int width = getWidth();
int height = getHeight();
int centerx = width/2;
int centery = height/2;
int imHeight=200;
int imWidth=200;
Bitmap arrow = Bitmap.createScaledBitmap(bMap,imHeight , imWidth, false);
canvas.save(Canvas.MATRIX_SAVE_FLAG); //Saving …Run Code Online (Sandbox Code Playgroud)