我在 Tensorflow 中使用 LSTM 单元。
lstm_cell = tf.contrib.rnn.BasicLSTMCell(lstm_units)
Run Code Online (Sandbox Code Playgroud)
我想知道如何初始化权重和状态,或者更确切地说,Tensorflow 中 LSTM 单元(状态和权重)的默认初始化器是什么?
有没有一种简单的方法来手动设置初始化程序?
注意:tf.get_variable()
据我从文档中了解到,使用了 glorot_uniform_initializer 。
谁能解释一下“ self_( this, []( ... ) {} )
”是如何工作的?
struct Parent {
std::shared_ptr<Parent> self_;
Parent() : self_( this, []( ... ) {} ) {}
operator std::shared_ptr<Parent>() const { return self_; }
}
Run Code Online (Sandbox Code Playgroud) 上面的错误信息显示在我的代码中。请参阅以下内容:
class BottomNaviBar extends StatefulWidget {
static const String id = 'bottom_navi_bar';
@override
_BottomNaviBarState createState() => _BottomNaviBarState();
}
class _BottomNaviBarState extends State<BottomNaviBar> {
int selectedIndex = 0;
bool showRecipeNotificationBadge = false;
bool showProfileNotificationBadge = false;
final _auth = FirebaseAuth.instance;
FirebaseUser loggedInUser;
String userEmail;
@override
void initState() {
super.initState();
getCurrentUser();
}
void getCurrentUser() async {
try {
final user = await _auth.currentUser();
if (user != null) {
loggedInUser = user;
userEmail = user.email;
}
} catch (e) {
print(e);
}
} …
Run Code Online (Sandbox Code Playgroud) 像这样声明和初始化类实例有什么区别:
MyClass var(param1, param2);
Run Code Online (Sandbox Code Playgroud)
...和这个?
MyClass var = MyClass(param1, param2);
Run Code Online (Sandbox Code Playgroud)
我隐约记得听说它们在某些时候是等效的,但现在我想知道后一种情况是否也可能调用类的赋值运算符、移动构造函数或复制构造函数,而不仅仅是显式使用的特定构造函数。
我创建了一个不同的init方法,并希望它是指定的初始化程序而不是标准-init
.如何防止客户端代码使用实例化类-init
?
例如
/* everyone must call this */
- (id)initWithInfo:(NSDictionary *)info {
self = [super init];
if (self) {
_info = info;
}
return self;
}
/* Don't want anyone to be able to create this using init */
Run Code Online (Sandbox Code Playgroud) x1和x2的初始化有什么不同吗?
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
var x1 = new C { };
var x2 = new C ();
}
}
public class C
{
public int A;
}
}
Run Code Online (Sandbox Code Playgroud) initializer ×6
c++ ×2
c# ×1
constructor ×1
dart ×1
flutter ×1
instance ×1
lambda ×1
lstm ×1
objective-c ×1
python ×1
tensorflow ×1
this ×1