teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

コード追記

2017/09/08 02:30

投稿

8524ba23
8524ba23

スコア38352

answer CHANGED
@@ -1,2 +1,17 @@
1
1
  `links`は 要素`('conv1', L.Convolution2D(3, 16, 3, 1, 0, w))`を1個持つ[リスト](https://docs.python.jp/3/library/stdtypes.html?highlight=%E3%83%AA%E3%82%B9%E3%83%88#list)です。
2
- その要素`('conv1', L.Convolution2D(3, 16, 3, 1, 0, w))` は、`'conv1'`という文字列と、`L.Convolution2D(3, 16, 3, 1, 0, w)`の戻り値の、2個の要素を持つ[タプル](https://docs.python.jp/3/library/stdtypes.html?highlight=%E3%83%AA%E3%82%B9%E3%83%88#tuple)です。
2
+ その要素`('conv1', L.Convolution2D(3, 16, 3, 1, 0, w))` は、`'conv1'`という文字列と、`L.Convolution2D(3, 16, 3, 1, 0, w)`の戻り値の、2個の要素を持つ[タプル](https://docs.python.jp/3/library/stdtypes.html?highlight=%E3%83%AA%E3%82%B9%E3%83%88#tuple)です。
3
+
4
+ ```Python
5
+ def Convolution2D(a,b,c,d,e,f): # ダミー関数
6
+ return 123
7
+
8
+ w = 1
9
+ links = [('conv1', Convolution2D(3, 16, 3, 1, 0, w))]
10
+
11
+ print(type(links)) # <class 'list'>
12
+ print( links[0]) # ('conv1', 123)
13
+
14
+ print(type(links[0])) # <class 'tuple'>
15
+ print( links[0][0]) # conv1
16
+ print( links[0][1]) # 123
17
+ ```