我用头文件TinyGPSPlus在Arduino uno中编写了以下代码,并使用了GPS SKG 13BL(GPS模块).
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
This program sketch obtain and print the lati,logi,speed,date and time
It requires the use of SoftwareSerial, and assumes that you have a
9600-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
void setup()
{
Serial.begin(9600);
ss.begin(GPSBaud); …Run Code Online (Sandbox Code Playgroud) 实际上,我们不能在if语句中使用tf.var作为布尔值,而不是使用tf.cond。我为规范化的输入数据编写此代码,并得到令人困惑的错误,我在哪里做错了?
def global_contrast_normalize(X, scale=1., subtract_mean=True,use_std=False,
sqrt_bias=0., min_divisor=1e-8):
mean=tf.reduce_mean(X,axis=1)
if subtract_mean:
X = X - mean[:, numpy.newaxis] # Makes a copy.
else:
X = tf.copy.copy(X)
if X.get_shape()[1]==1:
#ddof = 0
mean, var = tf.nn.moments(X, axes=[1])
normalizers = tf.sqrt(sqrt_bias + var) / scale
else:
normalizers = tf.sqrt(sqrt_bias + tf.reduce_sum((X ** 2),axis=1)) / scale
Normalizers= tf.Variable(normalizers,'float32')
M=tf.Variable(min_divisor,'float32')
tf.cond( tf.less_equal(Normalizers,M),lambda:tf.assign(Normalizers, [1]),lambda:tf.assign(Normalizers,normalizers))
X /= Normalizers[:, tf.newaxis] # Does not make a copy.
return X
Run Code Online (Sandbox Code Playgroud)
错误:
在_call_cpp_shape_fn_impl中引发ValueError(err.message)
ValueError:形状必须为等级0,但对于输入形状为[1],[1]的“ cond_11 / Switch”(op:“ Switch”),等级为1。